417 lines
9.2 KiB
Java
417 lines
9.2 KiB
Java
import java.io.EOFException;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.OutputStream;
|
|
import java.net.Socket;
|
|
import net.runelite.mapping.Export;
|
|
import net.runelite.mapping.Implements;
|
|
import net.runelite.mapping.ObfuscatedGetter;
|
|
import net.runelite.mapping.ObfuscatedName;
|
|
import net.runelite.mapping.ObfuscatedSignature;
|
|
|
|
@ObfuscatedName("fh")
|
|
@Implements("NetSocket")
|
|
public final class NetSocket extends AbstractSocket implements Runnable {
|
|
@ObfuscatedName("st")
|
|
@ObfuscatedSignature(
|
|
signature = "Lcz;"
|
|
)
|
|
@Export("clientPreferences")
|
|
static ClientPreferences clientPreferences;
|
|
@ObfuscatedName("m")
|
|
@Export("inputStream")
|
|
InputStream inputStream;
|
|
@ObfuscatedName("o")
|
|
@Export("socket")
|
|
Socket socket;
|
|
@ObfuscatedName("q")
|
|
@Export("outputStream")
|
|
OutputStream outputStream;
|
|
@ObfuscatedName("j")
|
|
@Export("isClosed")
|
|
boolean isClosed;
|
|
@ObfuscatedName("p")
|
|
@ObfuscatedSignature(
|
|
signature = "Lfm;"
|
|
)
|
|
@Export("taskHandler")
|
|
TaskHandler taskHandler;
|
|
@ObfuscatedName("g")
|
|
@ObfuscatedSignature(
|
|
signature = "Lfa;"
|
|
)
|
|
@Export("task")
|
|
Task task;
|
|
@ObfuscatedName("n")
|
|
@Export("outBuffer")
|
|
byte[] outBuffer;
|
|
@ObfuscatedName("u")
|
|
@ObfuscatedGetter(
|
|
intValue = -1562381729
|
|
)
|
|
@Export("outLength")
|
|
int outLength;
|
|
@ObfuscatedName("a")
|
|
@ObfuscatedGetter(
|
|
intValue = -171573129
|
|
)
|
|
@Export("outOffset")
|
|
int outOffset;
|
|
@ObfuscatedName("z")
|
|
@Export("exceptionWriting")
|
|
boolean exceptionWriting;
|
|
@ObfuscatedName("w")
|
|
@ObfuscatedGetter(
|
|
intValue = -881465833
|
|
)
|
|
@Export("bufferLength")
|
|
final int bufferLength;
|
|
@ObfuscatedName("y")
|
|
@ObfuscatedGetter(
|
|
intValue = -1622692111
|
|
)
|
|
@Export("maxPacketLength")
|
|
final int maxPacketLength;
|
|
|
|
@ObfuscatedSignature(
|
|
signature = "(Ljava/net/Socket;Lfm;I)V"
|
|
)
|
|
public NetSocket(Socket var1, TaskHandler var2, int var3) throws IOException {
|
|
this.isClosed = false;
|
|
this.outLength = 0;
|
|
this.outOffset = 0;
|
|
this.exceptionWriting = false;
|
|
this.taskHandler = var2;
|
|
this.socket = var1;
|
|
this.bufferLength = var3;
|
|
this.maxPacketLength = var3 - 100;
|
|
this.socket.setSoTimeout(30000);
|
|
this.socket.setTcpNoDelay(true);
|
|
this.socket.setReceiveBufferSize(65536);
|
|
this.socket.setSendBufferSize(65536);
|
|
this.inputStream = this.socket.getInputStream();
|
|
this.outputStream = this.socket.getOutputStream();
|
|
}
|
|
|
|
@ObfuscatedName("m")
|
|
@ObfuscatedSignature(
|
|
signature = "(I)V",
|
|
garbageValue = "-768493590"
|
|
)
|
|
@Export("close")
|
|
public void close() {
|
|
if (!this.isClosed) {
|
|
synchronized(this) {
|
|
this.isClosed = true;
|
|
this.notifyAll();
|
|
}
|
|
|
|
if (this.task != null) {
|
|
while (this.task.status == 0) {
|
|
SpriteMask.sleepExact(1L);
|
|
}
|
|
|
|
if (this.task.status == 1) {
|
|
try {
|
|
((Thread)this.task.result).join();
|
|
} catch (InterruptedException var3) {
|
|
}
|
|
}
|
|
}
|
|
|
|
this.task = null;
|
|
}
|
|
}
|
|
|
|
@ObfuscatedName("o")
|
|
@ObfuscatedSignature(
|
|
signature = "(B)I",
|
|
garbageValue = "-8"
|
|
)
|
|
@Export("readUnsignedByte")
|
|
public int readUnsignedByte() throws IOException {
|
|
return this.isClosed ? 0 : this.inputStream.read();
|
|
}
|
|
|
|
@ObfuscatedName("q")
|
|
@ObfuscatedSignature(
|
|
signature = "(I)I",
|
|
garbageValue = "-1942767880"
|
|
)
|
|
@Export("available")
|
|
public int available() throws IOException {
|
|
return this.isClosed ? 0 : this.inputStream.available();
|
|
}
|
|
|
|
@ObfuscatedName("j")
|
|
@ObfuscatedSignature(
|
|
signature = "(II)Z",
|
|
garbageValue = "1355091335"
|
|
)
|
|
@Export("isAvailable")
|
|
public boolean isAvailable(int var1) throws IOException {
|
|
if (this.isClosed) {
|
|
return false;
|
|
} else {
|
|
return this.inputStream.available() >= var1;
|
|
}
|
|
}
|
|
|
|
@ObfuscatedName("p")
|
|
@ObfuscatedSignature(
|
|
signature = "([BIIB)I",
|
|
garbageValue = "37"
|
|
)
|
|
@Export("read")
|
|
public int read(byte[] var1, int var2, int var3) throws IOException {
|
|
if (this.isClosed) {
|
|
return 0;
|
|
} else {
|
|
int var4;
|
|
int var5;
|
|
for (var4 = var3; var3 > 0; var3 -= var5) {
|
|
var5 = this.inputStream.read(var1, var2, var3);
|
|
if (var5 <= 0) {
|
|
throw new EOFException();
|
|
}
|
|
|
|
var2 += var5;
|
|
}
|
|
|
|
return var4;
|
|
}
|
|
}
|
|
|
|
@ObfuscatedName("g")
|
|
@ObfuscatedSignature(
|
|
signature = "([BIII)V",
|
|
garbageValue = "-950578253"
|
|
)
|
|
@Export("write0")
|
|
void write0(byte[] var1, int var2, int var3) throws IOException {
|
|
if (!this.isClosed) {
|
|
if (this.exceptionWriting) {
|
|
this.exceptionWriting = false;
|
|
throw new IOException();
|
|
} else {
|
|
if (this.outBuffer == null) {
|
|
this.outBuffer = new byte[this.bufferLength];
|
|
}
|
|
|
|
synchronized(this) {
|
|
for (int var5 = 0; var5 < var3; ++var5) {
|
|
this.outBuffer[this.outOffset] = var1[var5 + var2];
|
|
this.outOffset = (this.outOffset + 1) % this.bufferLength;
|
|
if ((this.maxPacketLength + this.outLength) % this.bufferLength == this.outOffset) {
|
|
throw new IOException();
|
|
}
|
|
}
|
|
|
|
if (this.task == null) {
|
|
this.task = this.taskHandler.newThreadTask(this, 3);
|
|
}
|
|
|
|
this.notifyAll();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@ObfuscatedName("n")
|
|
@ObfuscatedSignature(
|
|
signature = "([BIIB)V",
|
|
garbageValue = "-105"
|
|
)
|
|
@Export("write")
|
|
public void write(byte[] var1, int var2, int var3) throws IOException {
|
|
this.write0(var1, var2, var3);
|
|
}
|
|
|
|
protected void finalize() {
|
|
this.close();
|
|
}
|
|
|
|
public void run() {
|
|
try {
|
|
while (true) {
|
|
label84: {
|
|
int var1;
|
|
int var2;
|
|
synchronized(this) {
|
|
if (this.outLength == this.outOffset) {
|
|
if (this.isClosed) {
|
|
break label84;
|
|
}
|
|
|
|
try {
|
|
this.wait();
|
|
} catch (InterruptedException var10) {
|
|
}
|
|
}
|
|
|
|
var2 = this.outLength;
|
|
if (this.outOffset >= this.outLength) {
|
|
var1 = this.outOffset - this.outLength;
|
|
} else {
|
|
var1 = this.bufferLength - this.outLength;
|
|
}
|
|
}
|
|
|
|
if (var1 <= 0) {
|
|
continue;
|
|
}
|
|
|
|
try {
|
|
this.outputStream.write(this.outBuffer, var2, var1);
|
|
} catch (IOException var9) {
|
|
this.exceptionWriting = true;
|
|
}
|
|
|
|
this.outLength = (var1 + this.outLength) % this.bufferLength;
|
|
|
|
try {
|
|
if (this.outLength == this.outOffset) {
|
|
this.outputStream.flush();
|
|
}
|
|
} catch (IOException var8) {
|
|
this.exceptionWriting = true;
|
|
}
|
|
continue;
|
|
}
|
|
|
|
try {
|
|
if (this.inputStream != null) {
|
|
this.inputStream.close();
|
|
}
|
|
|
|
if (this.outputStream != null) {
|
|
this.outputStream.close();
|
|
}
|
|
|
|
if (this.socket != null) {
|
|
this.socket.close();
|
|
}
|
|
} catch (IOException var7) {
|
|
}
|
|
|
|
this.outBuffer = null;
|
|
break;
|
|
}
|
|
} catch (Exception var12) {
|
|
class197.RunException_sendStackTrace((String)null, var12);
|
|
}
|
|
|
|
}
|
|
|
|
@ObfuscatedName("m")
|
|
@ObfuscatedSignature(
|
|
signature = "(IB)Ljm;",
|
|
garbageValue = "67"
|
|
)
|
|
@Export("SequenceDefinition_get")
|
|
public static SequenceDefinition SequenceDefinition_get(int var0) {
|
|
SequenceDefinition var1 = (SequenceDefinition)SequenceDefinition.SequenceDefinition_cached.get((long)var0);
|
|
if (var1 != null) {
|
|
return var1;
|
|
} else {
|
|
byte[] var2 = SequenceDefinition.SequenceDefinition_archive.takeFile(12, var0);
|
|
var1 = new SequenceDefinition();
|
|
if (var2 != null) {
|
|
var1.decode(new Buffer(var2));
|
|
}
|
|
|
|
var1.postDecode();
|
|
SequenceDefinition.SequenceDefinition_cached.put(var1, (long)var0);
|
|
return var1;
|
|
}
|
|
}
|
|
|
|
@ObfuscatedName("u")
|
|
@ObfuscatedSignature(
|
|
signature = "(Lkn;J)V"
|
|
)
|
|
static void method3677(Buffer var0, long var1) {
|
|
var1 /= 10L;
|
|
if (var1 < 0L) {
|
|
var1 = 0L;
|
|
} else if (var1 > 65535L) {
|
|
var1 = 65535L;
|
|
}
|
|
|
|
var0.writeShort((int)var1);
|
|
}
|
|
|
|
@ObfuscatedName("z")
|
|
@ObfuscatedSignature(
|
|
signature = "(II)Leg;",
|
|
garbageValue = "-1650164099"
|
|
)
|
|
@Export("getFrames")
|
|
static Frames getFrames(int var0) {
|
|
Frames var1 = (Frames)SequenceDefinition.SequenceDefinition_cachedFrames.get((long)var0);
|
|
if (var1 != null) {
|
|
return var1;
|
|
} else {
|
|
AbstractArchive var3 = SequenceDefinition.SequenceDefinition_animationsArchive;
|
|
AbstractArchive var4 = SequenceDefinition.SequenceDefinition_skeletonsArchive;
|
|
boolean var5 = true;
|
|
int[] var6 = var3.getGroupFileIds(var0);
|
|
|
|
for (int var7 = 0; var7 < var6.length; ++var7) {
|
|
byte[] var8 = var3.getFile(var0, var6[var7]);
|
|
if (var8 == null) {
|
|
var5 = false;
|
|
} else {
|
|
int var9 = (var8[0] & 255) << 8 | var8[1] & 255;
|
|
byte[] var10 = var4.getFile(var9, 0);
|
|
if (var10 == null) {
|
|
var5 = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
Frames var2;
|
|
if (!var5) {
|
|
var2 = null;
|
|
} else {
|
|
try {
|
|
var2 = new Frames(var3, var4, var0, false);
|
|
} catch (Exception var12) {
|
|
var2 = null;
|
|
}
|
|
}
|
|
|
|
if (var2 != null) {
|
|
SequenceDefinition.SequenceDefinition_cachedFrames.put(var2, (long)var0);
|
|
}
|
|
|
|
return var2;
|
|
}
|
|
}
|
|
|
|
@ObfuscatedName("ko")
|
|
@ObfuscatedSignature(
|
|
signature = "(I)V",
|
|
garbageValue = "2085444453"
|
|
)
|
|
static void method3674() {
|
|
if (Client.field756 && class60.localPlayer != null) {
|
|
int var0 = class60.localPlayer.pathX[0];
|
|
int var1 = class60.localPlayer.pathY[0];
|
|
if (var0 < 0 || var1 < 0 || var0 >= 104 || var1 >= 104) {
|
|
return;
|
|
}
|
|
|
|
class225.oculusOrbFocalPointX = class60.localPlayer.x;
|
|
int var2 = Language.getTileHeight(class60.localPlayer.x, class60.localPlayer.y, TileItemPile.Client_plane) - Client.camFollowHeight;
|
|
if (var2 < WorldMapDecoration.field234) {
|
|
WorldMapDecoration.field234 = var2;
|
|
}
|
|
|
|
HealthBarDefinition.oculusOrbFocalPointY = class60.localPlayer.y;
|
|
Client.field756 = false;
|
|
}
|
|
|
|
}
|
|
}
|