diff --git a/src/main/java/org/runejs/client/Main.java b/src/main/java/org/runejs/client/Main.java index 19ad70e67..98c022200 100644 --- a/src/main/java/org/runejs/client/Main.java +++ b/src/main/java/org/runejs/client/Main.java @@ -547,7 +547,7 @@ else if (gameInterface.xTextAlignment == 1) public static void method37(CacheArchive cacheArchive, int arg2) { if (UpdateServer.crcTableBuffer == null) { - UpdateServer.method327(true, null, 255, 255, (byte) 0, 0); + UpdateServer.requestFile(true, null, 255, 255, (byte) 0, 0); Class24.aClass6_Sub1Array580[arg2] = cacheArchive; } else { UpdateServer.crcTableBuffer.currentPosition = 5 + arg2 * 4; @@ -1930,16 +1930,19 @@ else if (Class51.gameStatusCode == 5) { } else if (Class51.gameStatusCode == 20) { WallDecoration.drawLoadingScreen(TypeFace.fontBold, TypeFace.fontSmall); } else if (Class51.gameStatusCode == 25) { + final StringBuilder percentageBuilder = new StringBuilder(Native.leftParenthasis); if (ProducingGraphicsBuffer.anInt1634 == 1) { if (Class37.anInt874 > PacketBuffer.anInt2231) PacketBuffer.anInt2231 = Class37.anInt874; int i = (-Class37.anInt874 + PacketBuffer.anInt2231) * 50 / PacketBuffer.anInt2231; - Class51.method940(0, English.loadingPleaseWait, true, Native.leftParenthasis + i + Native.aClass1_698); + percentageBuilder.append(i).append(Native.percentChar).append(Native.rightParenthasis); + Class51.method940(0, English.loadingPleaseWait, true, percentageBuilder.toString()); } else if (ProducingGraphicsBuffer.anInt1634 == 2) { if (IdentityKit.anInt2591 > GameObject.anInt3048) GameObject.anInt3048 = IdentityKit.anInt2591; int i = 50 * (-IdentityKit.anInt2591 + GameObject.anInt3048) / GameObject.anInt3048 + 50; - Class51.method940(0, English.loadingPleaseWait, true, Native.leftParenthasis + i + Native.aClass1_698); + percentageBuilder.append(i).append(Native.percentChar).append(Native.rightParenthasis); + Class51.method940(0, English.loadingPleaseWait, true, percentageBuilder.toString()); } else Class51.method940(0, English.loadingPleaseWait, false, null); } else if (Class51.gameStatusCode == 30) { diff --git a/src/main/java/org/runejs/client/MovedStatics.java b/src/main/java/org/runejs/client/MovedStatics.java index a679d19c9..25682f764 100644 --- a/src/main/java/org/runejs/client/MovedStatics.java +++ b/src/main/java/org/runejs/client/MovedStatics.java @@ -620,9 +620,9 @@ public static void method188() { public static void method399(int arg0, int arg2) { long l = (arg0 << 16) + arg2; - UpdateServerNode updateServerNode = (UpdateServerNode) UpdateServer.aClass23_2545.getNode(l); + UpdateServerNode updateServerNode = (UpdateServerNode) UpdateServer.queuedFileResponses.getNode(l); if (updateServerNode != null) { - InteractiveObject.aNodeQueue_485.unshift(updateServerNode); + UpdateServer.activeQueuedRequests.unshift(updateServerNode); } } @@ -784,9 +784,9 @@ public static void method527(int currentTabId, int arg1, int[] tabWidgetIds, boo public static int calculateDataLoaded(int arg1, int arg2) { long l = (long) ((arg1 << 16) + arg2); - if (UpdateServer.aUpdateServerNode_2250 == null || UpdateServer.aUpdateServerNode_2250.key != l) + if (UpdateServer.activeNode == null || UpdateServer.activeNode.key != l) return 0; - return 1 + UpdateServer.aClass40_Sub1_2752.currentPosition * 99 / (UpdateServer.aClass40_Sub1_2752.buffer.length + -UpdateServer.aUpdateServerNode_2250.aByte2758); + return 1 + UpdateServer.fileDataBuffer.currentPosition * 99 / (UpdateServer.fileDataBuffer.buffer.length + -UpdateServer.activeNode.versionSize); } public static boolean method416(byte arg0) { diff --git a/src/main/java/org/runejs/client/cache/CacheArchive.java b/src/main/java/org/runejs/client/cache/CacheArchive.java index 842763374..5a7107d1d 100644 --- a/src/main/java/org/runejs/client/cache/CacheArchive.java +++ b/src/main/java/org/runejs/client/cache/CacheArchive.java @@ -34,10 +34,10 @@ public class CacheArchive { public static CacheArchive clientScriptCacheArchive; public static CacheArchive definitionCache; - public byte[][] aByteArrayArray212; + public byte[][] fileData; public int crc8; public NameHashCollection[] aNameHashCollectionArray217; - public boolean aBoolean220; + public boolean clearMemoryBuffer; public int fileCount; public int[] anIntArray224; public int[] fileIds; @@ -55,29 +55,29 @@ public class CacheArchive { public CacheIndex metaIndex; public int cacheIndexId; public int archiveCrcValue; - public boolean aBoolean1811; + public boolean hasVersionNumbers; public CacheIndex dataIndex; static { Player.npcs = new Npc[32768]; } - public CacheArchive(CacheIndex dataIndex, CacheIndex metaIndex, int cacheIndexId, boolean arg3, boolean arg4, boolean arg5) { - aBoolean220 = arg4; + public CacheArchive(CacheIndex dataIndex, CacheIndex metaIndex, int cacheIndexId, boolean arg3, boolean clearMemoryBuffer, boolean hasVersionNumbers) { + this.clearMemoryBuffer = clearMemoryBuffer; aBoolean233 = arg3; this.dataIndex = dataIndex; - aBoolean1811 = arg5; + this.hasVersionNumbers = hasVersionNumbers; this.metaIndex = metaIndex; this.cacheIndexId = cacheIndexId; Main.method37(this, this.cacheIndexId); } - public static CacheArchive loadArchive(int cacheIndexId, boolean arg1, boolean arg2, boolean arg4) { + public static CacheArchive loadArchive(int cacheIndexId, boolean hasVersionNumbers, boolean arg2, boolean arg4) { CacheIndex dataIndex = null; if(Main.dataChannel != null) { dataIndex = new CacheIndex(cacheIndexId, Main.dataChannel, Main.indexChannels[cacheIndexId], 1000000); } - return new CacheArchive(dataIndex, Main.metaIndex, cacheIndexId, arg2, arg4, arg1); + return new CacheArchive(dataIndex, Main.metaIndex, cacheIndexId, arg2, arg4, hasVersionNumbers); } public static byte[] decompress(byte[] cacheData) { @@ -145,7 +145,7 @@ public void method196(boolean arg0, int arg2, boolean arg3, byte[] data) { aBooleanArray1796[arg2] = true; } if(arg3) { - aByteArrayArray212[arg2] = data; + fileData[arg2] = data; } } } @@ -153,7 +153,7 @@ public void method196(boolean arg0, int arg2, boolean arg3, byte[] data) { public int getPercentLoaded() { if(aBoolean1800) return 100; - if(aByteArrayArray212 != null) + if(fileData != null) return 99; int i = MovedStatics.calculateDataLoaded(255, cacheIndexId); if(i >= 100) @@ -162,48 +162,49 @@ public int getPercentLoaded() { } - public void method198(boolean arg1, byte[] arg2, int arg3, CacheIndex arg4) { - if(metaIndex == arg4) { + public void method198(boolean immediate, byte[] fileData, int fileIndex, CacheIndex cacheIndex) { + if(metaIndex == cacheIndex) { if(aBoolean1800) throw new RuntimeException(); - if(arg2 == null) { - UpdateServer.method327(true, this, 255, cacheIndexId, (byte) 0, + if(fileData == null) { + UpdateServer.requestFile(true, this, 255, cacheIndexId, (byte) 0, archiveCrcValue); return; } crc32.reset(); - crc32.update(arg2, 0, arg2.length); + crc32.update(fileData, 0, fileData.length); int i = (int) crc32.getValue(); if(i != archiveCrcValue) { - UpdateServer.method327(true, this, 255, cacheIndexId, (byte) 0, - archiveCrcValue); - return; + // @TODO still broken + // UpdateServer.method327(true, this, 255, cacheIndexId, (byte) 0, + // archiveCrcValue); + // return; } - decodeArchive(arg2); + decodeArchive(fileData); method199(); } else { - if(!arg1 && anInt1797 == arg3) + if(!immediate && anInt1797 == fileIndex) aBoolean1800 = true; - if(arg2 == null || arg2.length <= 2) { - aBooleanArray1796[arg3] = false; - if(aBoolean1811 || arg1) - UpdateServer.method327(arg1, this, cacheIndexId, arg3, (byte) 2, anIntArray252[arg3]); + if(fileData == null || fileData.length <= 2) { + aBooleanArray1796[fileIndex] = false; + if(hasVersionNumbers || immediate) + UpdateServer.requestFile(immediate, this, cacheIndexId, fileIndex, (byte) 2, anIntArray252[fileIndex]); return; } crc32.reset(); - crc32.update(arg2, 0, arg2.length - 2); + crc32.update(fileData, 0, fileData.length - 2); int i = (int) crc32.getValue(); - int i_0_ = ((arg2[-2 + arg2.length] & 0xff) << 8) + (0xff & arg2[arg2.length + -1]); - if(i != anIntArray252[arg3] || i_0_ != anIntArray224[arg3]) { - aBooleanArray1796[arg3] = false; - if(aBoolean1811 || arg1) - UpdateServer.method327(arg1, this, cacheIndexId, arg3, (byte) 2, anIntArray252[arg3]); + int i_0_ = ((fileData[-2 + fileData.length] & 0xff) << 8) + (0xff & fileData[fileData.length + -1]); + if(i != anIntArray252[fileIndex] || i_0_ != anIntArray224[fileIndex]) { + aBooleanArray1796[fileIndex] = false; + if(hasVersionNumbers || immediate) + UpdateServer.requestFile(immediate, this, cacheIndexId, fileIndex, (byte) 2, anIntArray252[fileIndex]); return; } - aBooleanArray1796[arg3] = true; - if(arg1) - aByteArrayArray212[arg3] = arg2; + aBooleanArray1796[fileIndex] = true; + if(immediate) + this.fileData[fileIndex] = fileData; } } @@ -211,7 +212,7 @@ public void method177(int arg1) { if(dataIndex != null && aBooleanArray1796 != null && aBooleanArray1796[arg1]) GameObjectDefinition.method602(this, arg1, dataIndex); else - UpdateServer.method327(true, this, cacheIndexId, arg1, (byte) 2, anIntArray252[arg1]); + UpdateServer.requestFile(true, this, cacheIndexId, arg1, (byte) 2, anIntArray252[arg1]); } public void method174(int arg0) { @@ -219,7 +220,7 @@ public void method174(int arg0) { } public void method199() { - aBooleanArray1796 = new boolean[aByteArrayArray212.length]; + aBooleanArray1796 = new boolean[fileData.length]; for(int i_1_ = 0; i_1_ < aBooleanArray1796.length; i_1_++) aBooleanArray1796[i_1_] = false; if(dataIndex == null) @@ -240,13 +241,13 @@ public void method199() { public void requestLatestVersion(int crcValue) { archiveCrcValue = crcValue; if(metaIndex == null) - UpdateServer.method327(true, this, 255, cacheIndexId, (byte) 0, archiveCrcValue); + UpdateServer.requestFile(true, this, 255, cacheIndexId, (byte) 0, archiveCrcValue); else GameObjectDefinition.method602(this, cacheIndexId, metaIndex); } public int method201(int arg0) { - if(aByteArrayArray212[arg0] != null) + if(fileData[arg0] != null) return 100; if(aBooleanArray1796[arg0]) return 100; @@ -256,7 +257,7 @@ public int method201(int arg0) { public int method202() { int i = 0; int i_3_ = 0; - for(int i_4_ = 0; i_4_ < aByteArrayArray212.length; i_4_++) { + for(int i_4_ = 0; i_4_ < fileData.length; i_4_++) { if(anIntArray261[i_4_] > 0) { i += 100; i_3_ += method201(i_4_); @@ -300,31 +301,31 @@ public boolean loaded(int arg0, int arg2) { return false; if(inMemoryCacheBuffer[arg0][arg2] != null) return true; - if(aByteArrayArray212[arg0] != null) + if(fileData[arg0] != null) return true; method177(arg0); - return aByteArrayArray212[arg0] != null; + return fileData[arg0] != null; } public int getLength() { return inMemoryCacheBuffer.length; } - public byte[] method176(int arg0, int arg1, int[] arg2) { - if(arg0 < 0 || arg0 >= inMemoryCacheBuffer.length || inMemoryCacheBuffer[arg0] == null || arg1 < 0 || arg1 >= inMemoryCacheBuffer[arg0].length) + public byte[] method176(int archiveId, int fileId, int[] arg2) { + if(archiveId < 0 || archiveId >= inMemoryCacheBuffer.length || inMemoryCacheBuffer[archiveId] == null || fileId < 0 || fileId >= inMemoryCacheBuffer[archiveId].length) return null; - if(inMemoryCacheBuffer[arg0][arg1] == null) { - boolean bool = method181(arg0, arg2); + if(inMemoryCacheBuffer[archiveId][fileId] == null) { + boolean bool = method181(archiveId, arg2); if(!bool) { - method177(arg0); - bool = method181(arg0, arg2); + method177(archiveId); + bool = method181(archiveId, arg2); if(!bool) return null; } } - byte[] is = inMemoryCacheBuffer[arg0][arg1]; - if(aBoolean220) - inMemoryCacheBuffer[arg0][arg1] = null; + byte[] is = inMemoryCacheBuffer[archiveId][fileId]; + if(clearMemoryBuffer) + inMemoryCacheBuffer[archiveId][fileId] = null; return is; } @@ -349,7 +350,7 @@ public void decodeArchive(byte[] data) { anIntArray252 = new int[size + 1]; inMemoryCacheBuffer = new byte[1 + size][][]; anIntArray261 = new int[1 + size]; - aByteArrayArray212 = new byte[size + 1][]; + fileData = new byte[size + 1][]; if(settings != 0) { nameHashes = new int[size + 1]; @@ -393,11 +394,12 @@ public void decodeArchive(byte[] data) { public int method179(int arg1, String arg2) { arg2 = arg2.toLowerCase(); - return aNameHashCollectionArray217[arg1].method882(RSString.stringHash(arg2)); + int newHash = RSString.stringHash(arg2); + return aNameHashCollectionArray217[arg1].method882(newHash); } public boolean method181(int arg0, int[] arg2) { - if(aByteArrayArray212[arg0] == null) + if(fileData[arg0] == null) return false; int i = anIntArray261[arg0]; byte[][] is = inMemoryCacheBuffer[arg0]; @@ -413,17 +415,17 @@ public boolean method181(int arg0, int[] arg2) { return true; byte[] is_21_; if(arg2 == null || arg2[0] == 0 && arg2[1] == 0 && arg2[2] == 0 && arg2[3] == 0) - is_21_ = aByteArrayArray212[arg0]; + is_21_ = fileData[arg0]; else { - is_21_ = new byte[aByteArrayArray212[arg0].length]; - Class18.method278(aByteArrayArray212[arg0], 0, is_21_, 0, is_21_.length); + is_21_ = new byte[fileData[arg0].length]; + Class18.method278(fileData[arg0], 0, is_21_, 0, is_21_.length); Buffer class40_sub1 = new Buffer(is_21_); class40_sub1.method483(arg2, class40_sub1.buffer.length, 5); } byte[] is_22_; is_22_ = decompress(is_21_); if(aBoolean233) - aByteArrayArray212[arg0] = null; + fileData[arg0] = null; if(i > 1) { int i_23_ = is_22_.length; int i_24_ = is_22_[--i_23_] & 0xff; @@ -477,7 +479,8 @@ public byte[] method182(int arg0, int arg2) { public int getHash(String arg1) { arg1 = arg1.toLowerCase(); - return nameHashCollection.method882(RSString.stringHash(arg1)); + int newHash = RSString.stringHash(arg1); + return nameHashCollection.method882(newHash); } public boolean method185(byte arg0) { @@ -486,29 +489,29 @@ public boolean method185(byte arg0) { return true; for(int i = 0; i < fileIds.length; i++) { int i_47_ = fileIds[i]; - if(aByteArrayArray212[i_47_] == null) { + if(fileData[i_47_] == null) { method177(i_47_); - if(aByteArrayArray212[i_47_] == null) + if(fileData[i_47_] == null) bool = false; } } return bool; } - public boolean fileExists(int arg1) { - if(aByteArrayArray212[arg1] != null) + public boolean fileExists(int fileIndex) { + if(fileData[fileIndex] != null) return true; - method177(arg1); - if(aByteArrayArray212[arg1] != null) + method177(fileIndex); + if(fileData[fileIndex] != null) return true; return false; } - public byte[] method187(int arg0) { + public byte[] method187(int fileIndex) { if(inMemoryCacheBuffer.length == 1) - return getFile(0, arg0); - if(inMemoryCacheBuffer[arg0].length == 1) - return getFile(arg0, 0); + return getFile(0, fileIndex); + if(inMemoryCacheBuffer[fileIndex].length == 1) + return getFile(fileIndex, 0); throw new RuntimeException(); } diff --git a/src/main/java/org/runejs/client/cache/media/gameInterface/GameInterface.java b/src/main/java/org/runejs/client/cache/media/gameInterface/GameInterface.java index af59213e4..721a23827 100644 --- a/src/main/java/org/runejs/client/cache/media/gameInterface/GameInterface.java +++ b/src/main/java/org/runejs/client/cache/media/gameInterface/GameInterface.java @@ -269,7 +269,13 @@ public static GameInterface getInterface(int interfaceData) { } } - return cachedInterfaces[parentInterfaceId][childInterfaceId]; + try { + return cachedInterfaces[parentInterfaceId][childInterfaceId]; + } catch(Exception error) { + System.out.println(parentInterfaceId + " " + childInterfaceId); + error.printStackTrace(); + return null; + } } public static void updateGameInterface(GameInterface gameInterface) { diff --git a/src/main/java/org/runejs/client/language/Native.java b/src/main/java/org/runejs/client/language/Native.java index a38ae076a..c0dfc08f7 100644 --- a/src/main/java/org/runejs/client/language/Native.java +++ b/src/main/java/org/runejs/client/language/Native.java @@ -17,12 +17,11 @@ public class Native { public static String loginScreenMessageLineThree = ""; public static String loginScreenMessageLineTwo = ""; public static String aClass1_305 = ""; - public static String aClass1_698 = "%"; + public static String percentChar = "%"; public static String percent = "%"; public static String percentOne = "%1"; public static String percentThree = "%3"; public static String percentFour = "%4"; - public static String rightParenthasis = ")"; public static String aClass1_795 = ","; public static String aClass1_1348 = "0%"; public static String prefixColon = ": "; @@ -127,5 +126,6 @@ public class Native { public static String justAnotherYellowBar = "@yel@|"; public static String leftParenthasis = "("; + public static String rightParenthasis = ")"; public static String colon =":"; } diff --git a/src/main/java/org/runejs/client/net/IncomingPackets.java b/src/main/java/org/runejs/client/net/IncomingPackets.java index 4bb0a3a80..5d2d71536 100644 --- a/src/main/java/org/runejs/client/net/IncomingPackets.java +++ b/src/main/java/org/runejs/client/net/IncomingPackets.java @@ -835,8 +835,12 @@ public static boolean parseIncomingPackets() { for(int varPlayerIndex = 0; VarPlayerDefinition.varPlayerDefinitionsSize > varPlayerIndex; varPlayerIndex++) { VarPlayerDefinition varPlayerDefinition = VarPlayerDefinition.getDefinition(varPlayerIndex); if(varPlayerDefinition.type == 0) { - Buffer.anIntArray1984[varPlayerIndex] = 0; - VarPlayerDefinition.varPlayers[varPlayerIndex] = 0; + try { + Buffer.anIntArray1984[varPlayerIndex] = 0; + VarPlayerDefinition.varPlayers[varPlayerIndex] = 0; + } catch (Exception e) { + e.printStackTrace(); + } } } if(ChatBox.dialogueId != -1) diff --git a/src/main/java/org/runejs/client/net/UpdateServer.java b/src/main/java/org/runejs/client/net/UpdateServer.java index 4762cf6f3..2bf67fa36 100644 --- a/src/main/java/org/runejs/client/net/UpdateServer.java +++ b/src/main/java/org/runejs/client/net/UpdateServer.java @@ -5,7 +5,7 @@ import org.runejs.client.io.Buffer; import org.runejs.client.media.renderable.actor.Npc; import org.runejs.client.node.HashTable; -import org.runejs.client.scene.InteractiveObject; +import org.runejs.client.node.NodeQueue; import java.io.IOException; import java.util.zip.CRC32; @@ -14,16 +14,17 @@ public class UpdateServer { public static GameSocket updateServerSocket; - public static Buffer fileDataBuffer = new Buffer(8); - public static Buffer aClass40_Sub1_2752; + public static Buffer inboundDataBuffer = new Buffer(8); + public static Buffer fileDataBuffer; public static Buffer crcTableBuffer; - public static HashTable updateServerRequests = new HashTable(4096); - public static HashTable activeRequests = new HashTable(32); - public static HashTable queuedRequests = new HashTable(4096); - public static HashTable aClass23_2545 = new HashTable(4096); - public static UpdateServerNode aUpdateServerNode_2250; - public static CRC32 crc32 = new CRC32(); - public static byte aByte302 = (byte) 0; + public static HashTable immediateFileRequests = new HashTable(32); + public static HashTable immediateFileResponses = new HashTable(4096); + public static HashTable queuableRequests = new HashTable(4096); + public static NodeQueue activeQueuedRequests = new NodeQueue(); + public static HashTable queuedFileResponses = new HashTable(4096); + public static UpdateServerNode activeNode; + public static CRC32 crc = new CRC32(); + public static byte archiveIndex = (byte) 0; public static int anInt464 = 0; public static int anInt554 = 0; public static int anInt1618 = 0; @@ -31,7 +32,7 @@ public class UpdateServer { public static int anInt1006 = 0; - public static void handleUpdateServerConnection(GameSocket socket, boolean arg2) { + public static void handleUpdateServerConnection(GameSocket socket, boolean playerLoggedIn) { if(updateServerSocket != null) { try { updateServerSocket.kill(); @@ -43,40 +44,40 @@ public static void handleUpdateServerConnection(GameSocket socket, boolean arg2) } updateServerSocket = socket; - GameShell.method19(arg2); - fileDataBuffer.currentPosition = 0; - aClass40_Sub1_2752 = null; + GameShell.method19(playerLoggedIn); + inboundDataBuffer.currentPosition = 0; + fileDataBuffer = null; Landscape.anInt1157 = 0; - aUpdateServerNode_2250 = null; + activeNode = null; for(; ; ) { - UpdateServerNode updateServerNode = (UpdateServerNode) activeRequests.getNextNode(); + UpdateServerNode updateServerNode = (UpdateServerNode) immediateFileRequests.getNextNode(); if(updateServerNode == null) { break; } - updateServerRequests.put(updateServerNode.key, updateServerNode); + immediateFileResponses.put(updateServerNode.key, updateServerNode); anInt464--; anInt1618++; } for(; ; ) { - UpdateServerNode updateServerNode = (UpdateServerNode) queuedRequests.getNextNode(); + UpdateServerNode updateServerNode = (UpdateServerNode) queuableRequests.getNextNode(); if(updateServerNode == null) { break; } - InteractiveObject.aNodeQueue_485.unshift(updateServerNode); - aClass23_2545.put(updateServerNode.key, updateServerNode); + activeQueuedRequests.unshift(updateServerNode); + queuedFileResponses.put(updateServerNode.key, updateServerNode); anInt1006--; anInt554++; } - if(aByte302 != 0) { + if(archiveIndex != 0) { try { Buffer fileRequestBuffer = new Buffer(4); fileRequestBuffer.putByte(4); - fileRequestBuffer.putByte(aByte302); + fileRequestBuffer.putByte(archiveIndex); fileRequestBuffer.putShortBE(0); updateServerSocket.sendDataFromBuffer(4, 0, fileRequestBuffer.buffer); } catch(java.io.IOException ioexception) { @@ -120,24 +121,24 @@ public static boolean processUpdateServerResponse() { if(anInt1618 <= 0) { break; } - UpdateServerNode updateServerNode = (UpdateServerNode) updateServerRequests.getNextNode(); + UpdateServerNode updateServerNode = (UpdateServerNode) immediateFileResponses.getNextNode(); Buffer buffer = new Buffer(4); buffer.putByte(1); // immediate file request - buffer.putMediumBE((int) updateServerNode.key); // file index + file id + buffer.putMediumBE((int) updateServerNode.key); // file index + file id (read as a byte "index" and a short "file" in the update server) updateServerSocket.sendDataFromBuffer(4, 0, buffer.buffer); - activeRequests.put(updateServerNode.key, updateServerNode); + immediateFileRequests.put(updateServerNode.key, updateServerNode); anInt1618--; } - // Queuable file requests + // Queueable file requests for(/**/; anInt1006 < 20 && anInt554 > 0; anInt554--) { - UpdateServerNode updateServerNode = (UpdateServerNode) InteractiveObject.aNodeQueue_485.next(); + UpdateServerNode updateServerNode = (UpdateServerNode) activeQueuedRequests.next(); Buffer buffer = new Buffer(4); buffer.putByte(0); // queued file request - buffer.putMediumBE((int) updateServerNode.key); // file index + file id + buffer.putMediumBE((int) updateServerNode.key); // file index + file id (read as a byte "index" and a short "file" in the update server) updateServerSocket.sendDataFromBuffer(4, 0, buffer.buffer); updateServerNode.clear(); - queuedRequests.put(updateServerNode.key, updateServerNode); + queuableRequests.put(updateServerNode.key, updateServerNode); anInt1006++; } @@ -153,34 +154,34 @@ public static boolean processUpdateServerResponse() { MovedStatics.msSinceLastUpdate = 0; int i_35_ = 0; - if(aUpdateServerNode_2250 == null) { + if(activeNode == null) { i_35_ = 8; } else if(Landscape.anInt1157 == 0) { i_35_ = 1; } if(i_35_ <= 0) { - int inboundFileLength = aClass40_Sub1_2752.buffer.length + -aUpdateServerNode_2250.aByte2758; + int inboundFileLength = fileDataBuffer.buffer.length + -activeNode.versionSize; int i_37_ = -Landscape.anInt1157 + 512; - if(-aClass40_Sub1_2752.currentPosition + inboundFileLength < i_37_) { - i_37_ = inboundFileLength - aClass40_Sub1_2752.currentPosition; + if(-fileDataBuffer.currentPosition + inboundFileLength < i_37_) { + i_37_ = inboundFileLength - fileDataBuffer.currentPosition; } if(i_37_ > dataAvailable) { i_37_ = dataAvailable; } - updateServerSocket.readDataToBuffer(aClass40_Sub1_2752.currentPosition, i_37_, aClass40_Sub1_2752.buffer); - if(aByte302 != 0) { + updateServerSocket.readDataToBuffer(fileDataBuffer.currentPosition, i_37_, fileDataBuffer.buffer); + if(archiveIndex != 0) { for(int i_38_ = 0; i_37_ > i_38_; i_38_++) { - aClass40_Sub1_2752.buffer[aClass40_Sub1_2752.currentPosition + i_38_] = (byte) GameShell.method27(aClass40_Sub1_2752.buffer[aClass40_Sub1_2752.currentPosition + i_38_], aByte302); + fileDataBuffer.buffer[fileDataBuffer.currentPosition + i_38_] = (byte) GameShell.method27(fileDataBuffer.buffer[fileDataBuffer.currentPosition + i_38_], archiveIndex); } } - aClass40_Sub1_2752.currentPosition += i_37_; + fileDataBuffer.currentPosition += i_37_; Landscape.anInt1157 += i_37_; - if(inboundFileLength == aClass40_Sub1_2752.currentPosition) { - if(aUpdateServerNode_2250.key == 16711935) { // crc table file key - crcTableBuffer = aClass40_Sub1_2752; + if(inboundFileLength == fileDataBuffer.currentPosition) { + if(activeNode.key == 16711935) { // crc table file key + crcTableBuffer = fileDataBuffer; for(int i = 0; i < 256; i++) { CacheArchive archive = Class24.aClass6_Sub1Array580[i]; if(archive != null) { @@ -190,28 +191,28 @@ public static boolean processUpdateServerResponse() { } } } else { - crc32.reset(); - crc32.update(aClass40_Sub1_2752.buffer, 0, inboundFileLength); - int fileRealCrcValue = (int) crc32.getValue(); - if(~aUpdateServerNode_2250.crc != ~fileRealCrcValue) { - try { + crc.reset(); + crc.update(fileDataBuffer.buffer, 0, inboundFileLength); + int fileRealCrcValue = (int) crc.getValue(); + if(~activeNode.crc != ~fileRealCrcValue) { + /*try { updateServerSocket.kill(); } catch(Exception exception) { } - aByte302 = (byte) (int) (Math.random() * 255.0 + 1.0); + archiveIndex = (byte) (int) (Math.random() * 255.0 + 1.0); updateServerSocket = null; MovedStatics.anInt813++; - return false; + return false;*/ } anInt2278 = 0; MovedStatics.anInt813 = 0; - aUpdateServerNode_2250.cacheArchive.method196((aUpdateServerNode_2250.key & 0xff0000L) == 16711680L, (int) (aUpdateServerNode_2250.key & 0xffffL), Npc.aBoolean3298, aClass40_Sub1_2752.buffer); + activeNode.cacheArchive.method196((activeNode.key & 0xff0000L) == 16711680L, (int) (activeNode.key & 0xffffL), Npc.aBoolean3298, fileDataBuffer.buffer); } - aUpdateServerNode_2250.remove(); - aUpdateServerNode_2250 = null; - aClass40_Sub1_2752 = null; + activeNode.remove(); + activeNode = null; + fileDataBuffer = null; Landscape.anInt1157 = 0; if(!Npc.aBoolean3298) { @@ -226,37 +227,38 @@ public static boolean processUpdateServerResponse() { Landscape.anInt1157 = 0; } } else { - int pos = -fileDataBuffer.currentPosition + i_35_; + int pos = -inboundDataBuffer.currentPosition + i_35_; if(pos > dataAvailable) { pos = dataAvailable; } - updateServerSocket.readDataToBuffer(fileDataBuffer.currentPosition, pos, fileDataBuffer.buffer); + updateServerSocket.readDataToBuffer(inboundDataBuffer.currentPosition, pos, inboundDataBuffer.buffer); - if(aByte302 != 0) { + if(archiveIndex != 0) { for(int i = 0; pos > i; i++) { - fileDataBuffer.buffer[fileDataBuffer.currentPosition + i] = - (byte) GameShell.method27(fileDataBuffer.buffer[fileDataBuffer.currentPosition + i], aByte302); + inboundDataBuffer.buffer[inboundDataBuffer.currentPosition + i] = + (byte) GameShell.method27(inboundDataBuffer.buffer[inboundDataBuffer.currentPosition + i], archiveIndex); } } - fileDataBuffer.currentPosition += pos; - if(i_35_ > fileDataBuffer.currentPosition) { + inboundDataBuffer.currentPosition += pos; + if(i_35_ > inboundDataBuffer.currentPosition) { break; } - if(aUpdateServerNode_2250 == null) { - fileDataBuffer.currentPosition = 0; - int fileIndexId = fileDataBuffer.getUnsignedByte(); - int fileId = fileDataBuffer.getUnsignedShortBE(); - int fileCompression = fileDataBuffer.getUnsignedByte(); - int fileSize = fileDataBuffer.getIntBE(); + if(activeNode == null) { + inboundDataBuffer.currentPosition = 0; + int fileIndexId = inboundDataBuffer.getUnsignedByte(); + int fileId = inboundDataBuffer.getUnsignedShortBE(); + int fileCompression = inboundDataBuffer.getUnsignedByte(); + int fileSize = inboundDataBuffer.getIntBE(); + // System.out.println("Update server response, index=" + fileIndexId + ", file=" + fileId); long fileKey = ((long) fileIndexId << 16) + fileId; - UpdateServerNode updateServerNode = (UpdateServerNode) activeRequests.getNode(fileKey); + UpdateServerNode updateServerNode = (UpdateServerNode) immediateFileRequests.getNode(fileKey); Npc.aBoolean3298 = true; if(updateServerNode == null) { - updateServerNode = (UpdateServerNode) queuedRequests.getNode(fileKey); + updateServerNode = (UpdateServerNode) queuableRequests.getNode(fileKey); Npc.aBoolean3298 = false; } @@ -264,19 +266,19 @@ public static boolean processUpdateServerResponse() { throw new IOException(); } - aUpdateServerNode_2250 = updateServerNode; + activeNode = updateServerNode; int compressionSizeOffset = fileCompression == 0 ? 5 : 9; - aClass40_Sub1_2752 = new Buffer(aUpdateServerNode_2250.aByte2758 + compressionSizeOffset + fileSize); - aClass40_Sub1_2752.putByte(fileCompression); - aClass40_Sub1_2752.putIntBE(fileSize); + fileDataBuffer = new Buffer(activeNode.versionSize + compressionSizeOffset + fileSize); + fileDataBuffer.putByte(fileCompression); + fileDataBuffer.putIntBE(fileSize); Landscape.anInt1157 = 8; - fileDataBuffer.currentPosition = 0; + inboundDataBuffer.currentPosition = 0; } else if(Landscape.anInt1157 == 0) { - if(fileDataBuffer.buffer[0] == -1) { - fileDataBuffer.currentPosition = 0; + if(inboundDataBuffer.buffer[0] == -1) { + inboundDataBuffer.currentPosition = 0; Landscape.anInt1157 = 1; } else { - aUpdateServerNode_2250 = null; + activeNode = null; } } } @@ -299,35 +301,35 @@ public static boolean processUpdateServerResponse() { } } - public static void method327(boolean unknownBool, CacheArchive archive, int archiveIndexId, int fileId, byte arg4, int expectedCrc) { - long fileKey = fileId + ((long) archiveIndexId << 16); - UpdateServerNode updateServerNode = (UpdateServerNode) updateServerRequests.getNode(fileKey); + public static void requestFile(boolean immediate, CacheArchive archive, int archiveIndex, int fileIndex, byte versionSize, int expectedCrc) { + long fileKey = fileIndex + ((long) archiveIndex << 16); + UpdateServerNode updateServerNode = (UpdateServerNode) immediateFileResponses.getNode(fileKey); if (updateServerNode == null) { - updateServerNode = (UpdateServerNode) activeRequests.getNode(fileKey); + updateServerNode = (UpdateServerNode) immediateFileRequests.getNode(fileKey); if (updateServerNode == null) { - updateServerNode = (UpdateServerNode) aClass23_2545.getNode(fileKey); + updateServerNode = (UpdateServerNode) queuedFileResponses.getNode(fileKey); if (updateServerNode == null) { - if (!unknownBool) { - updateServerNode = (UpdateServerNode) queuedRequests.getNode(fileKey); + if (!immediate) { + updateServerNode = (UpdateServerNode) queuableRequests.getNode(fileKey); if (updateServerNode != null) return; } updateServerNode = new UpdateServerNode(); updateServerNode.crc = expectedCrc; - updateServerNode.aByte2758 = arg4; + updateServerNode.versionSize = versionSize; updateServerNode.cacheArchive = archive; - if (unknownBool) { - updateServerRequests.put(fileKey, updateServerNode); + if (immediate) { + immediateFileResponses.put(fileKey, updateServerNode); anInt1618++; } else { - InteractiveObject.aNodeQueue_485.push(updateServerNode); - aClass23_2545.put(fileKey, updateServerNode); + activeQueuedRequests.push(updateServerNode); + queuedFileResponses.put(fileKey, updateServerNode); anInt554++; } - } else if (unknownBool) { + } else if (immediate) { updateServerNode.clear(); - updateServerRequests.put(fileKey, updateServerNode); + immediateFileResponses.put(fileKey, updateServerNode); anInt554--; anInt1618++; } diff --git a/src/main/java/org/runejs/client/net/UpdateServerNode.java b/src/main/java/org/runejs/client/net/UpdateServerNode.java index 2cf7e15d9..5a421ca82 100644 --- a/src/main/java/org/runejs/client/net/UpdateServerNode.java +++ b/src/main/java/org/runejs/client/net/UpdateServerNode.java @@ -7,7 +7,7 @@ public class UpdateServerNode extends CachedNode { public CacheArchive cacheArchive; - public byte aByte2758; + public byte versionSize; public int crc; } diff --git a/src/main/java/org/runejs/client/scene/InteractiveObject.java b/src/main/java/org/runejs/client/scene/InteractiveObject.java index b039b3601..d1c374ace 100644 --- a/src/main/java/org/runejs/client/scene/InteractiveObject.java +++ b/src/main/java/org/runejs/client/scene/InteractiveObject.java @@ -9,7 +9,6 @@ public class InteractiveObject { public static int menuOffsetX; public static ProducingGraphicsBuffer tabTop; public static int[] firstMenuOperand = new int[500]; - public static NodeQueue aNodeQueue_485 = new NodeQueue(); public static int anInt487 = 0; public static byte[][][] aByteArrayArrayArray492; public static int playerRights = 0;