Skip to content

Commit 5d5fcdd

Browse files
committed
refactor: move statics off GameObjectDefinition
1 parent 54cee35 commit 5d5fcdd

File tree

4 files changed

+37
-40
lines changed

4 files changed

+37
-40
lines changed

src/main/java/org/runejs/client/cache/CacheArchive.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.runejs.client.*;
44
import org.runejs.client.cache.bzip.BZip;
5-
import org.runejs.client.cache.def.GameObjectDefinition;
65
import org.runejs.client.io.Buffer;
76
import org.runejs.client.net.UpdateServer;
87
import org.runejs.client.node.Class40_Sub6;
@@ -119,6 +118,24 @@ public static int calculateFullCrc8(byte[] data, int size) {
119118
return MovedStatics.calculateCrc8(0, size, data);
120119
}
121120

121+
private static void method602(CacheArchive arg0, int arg1, CacheIndex arg2) {
122+
byte[] is = null;
123+
synchronized(MovedStatics.aLinkedList_53) {
124+
for(Class40_Sub6 class40_sub6 = (Class40_Sub6) MovedStatics.aLinkedList_53.peekFirst(); class40_sub6 != null; class40_sub6 = (Class40_Sub6) MovedStatics.aLinkedList_53.pollFirst()) {
125+
if((long) arg1 == class40_sub6.key && arg2 == class40_sub6.cacheIndex && class40_sub6.anInt2112 == 0) {
126+
is = class40_sub6.aByteArray2102;
127+
break;
128+
}
129+
}
130+
}
131+
if(is == null) {
132+
byte[] is_6_ = arg2.get(arg1);
133+
arg0.method198(true, is_6_, arg1, arg2);
134+
} else {
135+
arg0.method198(true, is, arg1, arg2);
136+
}
137+
}
138+
122139
public void method196(boolean arg0, int arg2, boolean arg3, byte[] data) {
123140
if(arg0) {
124141
if(aBoolean1800) {
@@ -201,7 +218,7 @@ public void method198(boolean arg1, byte[] arg2, int arg3, CacheIndex arg4) {
201218

202219
public void method177(int arg1) {
203220
if(dataIndex != null && aBooleanArray1796 != null && aBooleanArray1796[arg1])
204-
GameObjectDefinition.method602(this, arg1, dataIndex);
221+
method602(this, arg1, dataIndex);
205222
else
206223
UpdateServer.method327(true, this, cacheIndexId, arg1, (byte) 2, anIntArray252[arg1]);
207224
}
@@ -234,7 +251,7 @@ public void requestLatestVersion(int crcValue) {
234251
if(metaIndex == null)
235252
UpdateServer.method327(true, this, 255, cacheIndexId, (byte) 0, archiveCrcValue);
236253
else
237-
GameObjectDefinition.method602(this, cacheIndexId, metaIndex);
254+
method602(this, cacheIndexId, metaIndex);
238255
}
239256

240257
public int method201(int arg0) {

src/main/java/org/runejs/client/cache/def/GameObjectDefinition.java

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package org.runejs.client.cache.def;
22

33
import org.runejs.client.*;
4-
import org.runejs.client.cache.CacheIndex;
54
import org.runejs.client.cache.CacheArchive;
6-
import org.runejs.client.node.Class40_Sub6;
75
import org.runejs.client.node.NodeCache;
86
import org.runejs.client.cache.media.AnimationSequence;
97
import org.runejs.client.io.Buffer;
@@ -16,10 +14,9 @@
1614
import java.io.IOException;
1715

1816
public class GameObjectDefinition extends CachedNode implements EntityDefinition {
19-
public static int anInt2543 = 0;
2017
public static int count;
2118
public static int[] OBJECT_TYPES = new int[]{0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3};
22-
public static boolean lowMemory = false;
19+
private static boolean lowMemory = false;
2320
private static CacheArchive definitionArchive;
2421
private static CacheArchive modelArchive;
2522
private static NodeCache definitionCache = new NodeCache(64);
@@ -106,24 +103,6 @@ public GameObjectDefinition() {
106103
modelSizeY = 128;
107104
}
108105

109-
public static void method602(CacheArchive arg0, int arg1, CacheIndex arg2) {
110-
byte[] is = null;
111-
synchronized(MovedStatics.aLinkedList_53) {
112-
for(Class40_Sub6 class40_sub6 = (Class40_Sub6) MovedStatics.aLinkedList_53.peekFirst(); class40_sub6 != null; class40_sub6 = (Class40_Sub6) MovedStatics.aLinkedList_53.pollFirst()) {
113-
if((long) arg1 == class40_sub6.key && arg2 == class40_sub6.cacheIndex && class40_sub6.anInt2112 == 0) {
114-
is = class40_sub6.aByteArray2102;
115-
break;
116-
}
117-
}
118-
}
119-
if(is == null) {
120-
byte[] is_6_ = arg2.get(arg1);
121-
arg0.method198(true, is_6_, arg1, arg2);
122-
} else {
123-
arg0.method198(true, is, arg1, arg2);
124-
}
125-
}
126-
127106

128107
public static void addTemporaryObject(int objectId, int x, int orientation, int duration, int plane, int y, int typeKey, int type, int delay) {
129108
InteractiveObjectTemporary obj = null;

src/main/java/org/runejs/client/cache/media/gameInterface/GameInterface.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.runejs.client.chat.ChatShapeEffect;
1212
import org.runejs.client.frame.ChatBox;
1313
import org.runejs.client.frame.console.Console;
14+
import org.runejs.client.input.KeyFocusListener;
1415
import org.runejs.client.input.MouseHandler;
1516
import org.runejs.client.io.Buffer;
1617
import org.runejs.client.language.English;
@@ -278,13 +279,13 @@ public GameInterface() {
278279
public static void method639() {
279280
synchronized(Game.keyFocusListener) {
280281
MovedStatics.anInt1389 = MovedStatics.anInt1214;
281-
if(GameObjectDefinition.anInt2543 < 0) {
282+
if(KeyFocusListener.anInt2543 < 0) {
282283
for(int i = 0; i < 112; i++) {
283284
MovedStatics.obfuscatedKeyStatus[i] = false;
284285
}
285-
GameObjectDefinition.anInt2543 = MovedStatics.anInt2183;
286+
KeyFocusListener.anInt2543 = MovedStatics.anInt2183;
286287
} else {
287-
while(GameObjectDefinition.anInt2543 != MovedStatics.anInt2183) {
288+
while(KeyFocusListener.anInt2543 != MovedStatics.anInt2183) {
288289
int i = MovedStatics.keyCodes[MovedStatics.anInt2183];
289290
MovedStatics.anInt2183 = 0x7f & MovedStatics.anInt2183 + 1;
290291
if(i < 0) {

src/main/java/org/runejs/client/input/KeyFocusListener.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.runejs.client.frame.console.Console;
44
import org.runejs.client.*;
5-
import org.runejs.client.cache.def.GameObjectDefinition;
65
import org.runejs.client.util.Signlink;
76

87
import java.awt.*;
@@ -15,6 +14,7 @@
1514
public class KeyFocusListener implements KeyListener, FocusListener {
1615
public static volatile int framesSinceKeyboardInput = 0;
1716
public static int[] anIntArray1564 = new int[]{-1, -1, -1, -1, -1, -1, -1, -1, 85, 80, 84, -1, 91, -1, -1, -1, 81, 82, 86, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, 83, 104, 105, 103, 102, 96, 98, 97, 99, -1, -1, -1, -1, -1, -1, -1, 25, 16, 17, 18, 19, 20, 21, 22, 23, 24, -1, -1, -1, -1, -1, -1, -1, 48, 68, 66, 50, 34, 51, 52, 53, 39, 54, 55, 56, 70, 69, 40, 41, 32, 35, 49, 36, 38, 67, 33, 65, 37, 64, -1, -1, -1, -1, -1, 228, 231, 227, 233, 224, 219, 225, 230, 226, 232, 89, 87, -1, 88, 229, 90, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, -1, -1, -1, 101, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 100, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
17+
public static int anInt2543 = 0;
1818

1919
static {
2020
for (int divident = 0; divident < 256; divident++) {
@@ -105,7 +105,7 @@ public void focusGained(FocusEvent arg0) {
105105

106106
public synchronized void focusLost(FocusEvent arg0) {
107107
if (Game.keyFocusListener != null) {
108-
GameObjectDefinition.anInt2543 = -1;
108+
anInt2543 = -1;
109109
}
110110
}
111111

@@ -135,11 +135,11 @@ public synchronized void keyPressed(KeyEvent keyEvent) {
135135
if (eventKeyCode == 192 || eventKeyCode == 129) {
136136
Console.console.consoleOpen = !Console.console.consoleOpen;
137137
}
138-
if (GameObjectDefinition.anInt2543 >= 0 && obfuscatedKeyCode >= 0) {
139-
MovedStatics.keyCodes[GameObjectDefinition.anInt2543] = obfuscatedKeyCode;
140-
GameObjectDefinition.anInt2543 = 0x7f & GameObjectDefinition.anInt2543 + 1;
141-
if (GameObjectDefinition.anInt2543 == MovedStatics.anInt2183) {
142-
GameObjectDefinition.anInt2543 = -1;
138+
if (anInt2543 >= 0 && obfuscatedKeyCode >= 0) {
139+
MovedStatics.keyCodes[anInt2543] = obfuscatedKeyCode;
140+
anInt2543 = 0x7f & anInt2543 + 1;
141+
if (anInt2543 == MovedStatics.anInt2183) {
142+
anInt2543 = -1;
143143
}
144144
}
145145
if (obfuscatedKeyCode >= 0 || keyChar >= 0) {
@@ -164,11 +164,11 @@ public synchronized void keyReleased(KeyEvent arg0) {
164164
} else {
165165
i = ~0x80 & anIntArray1564[i];
166166
}
167-
if (GameObjectDefinition.anInt2543 >= 0 && i >= 0) {
168-
MovedStatics.keyCodes[GameObjectDefinition.anInt2543] = i ^ 0xffffffff;
169-
GameObjectDefinition.anInt2543 = 0x7f & 1 + GameObjectDefinition.anInt2543;
170-
if (MovedStatics.anInt2183 == GameObjectDefinition.anInt2543) {
171-
GameObjectDefinition.anInt2543 = -1;
167+
if (anInt2543 >= 0 && i >= 0) {
168+
MovedStatics.keyCodes[anInt2543] = i ^ 0xffffffff;
169+
anInt2543 = 0x7f & 1 + anInt2543;
170+
if (MovedStatics.anInt2183 == anInt2543) {
171+
anInt2543 = -1;
172172
}
173173
}
174174
}

0 commit comments

Comments
 (0)