Skip to content

Commit 03c3070

Browse files
committed
refactor: more cache renaming/moving
1 parent 89f3c72 commit 03c3070

12 files changed

+78
-82
lines changed

src/main/java/org/runejs/client/ClientScriptRunner.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.runejs.client;
22

3-
import org.runejs.client.cache.CacheArchive;
43
import org.runejs.client.cache.cs.InvokedScript;
54
import org.runejs.client.cache.cs.ClientScript;
65
import org.runejs.client.net.OutgoingPackets;
@@ -35,7 +34,6 @@
3534
public class ClientScriptRunner extends Node {
3635
public static String[] scriptStringValues = new String[1000];
3736
public static int runEnergy = 0;
38-
public static CacheArchive aCacheArchive_2162;
3937
public static String[] localStrings;
4038
public static int[] localInts;
4139
public static int[] scriptIntValues = new int[1000];

src/main/java/org/runejs/client/Game.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -866,13 +866,6 @@ public static Camera getActiveCamera() {
866866
return Player.cutsceneActive ? Game.cutsceneCamera : Game.playerCamera;
867867
}
868868

869-
public static void method357(CacheArchive arg0, CacheArchive arg2) {
870-
GroundItemTile.aCacheArchive_1375 = arg2;
871-
ActorDefinition.count = GroundItemTile.aCacheArchive_1375.fileLength(9);
872-
873-
MovedStatics.aCacheArchive_1577 = arg0;
874-
}
875-
876869
public static IndexedImage method359(String arg0, String arg1, CacheArchive arg2) {
877870
int i = arg2.getHash(arg0);
878871
int i_23_ = arg2.method179(i, arg1);

src/main/java/org/runejs/client/MovedStatics.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public class MovedStatics {
5959
public static int chatEffectsDisabled = 0;
6060
public static int anInt321 = 5063219;
6161
public static boolean redrawChatbox = false;
62-
public static CacheArchive aCacheArchive_654;
6362
public static int[] anIntArray666 = new int[]{1, 0, -1, 0};
6463
public static int pulseCycle = 0;
6564
public static int anInt938 = 500;
@@ -88,7 +87,6 @@ public class MovedStatics {
8887
public static int[] chatboxLineOffsets;
8988
public static int anInt199 = 0;
9089
public static volatile boolean aBoolean1575 = false;
91-
public static CacheArchive aCacheArchive_1577;
9290
public static int anInt1586 = -1;
9391
public static boolean reportMutePlayer = false;
9492
public static int anInt1607 = 10;
@@ -136,15 +134,13 @@ public class MovedStatics {
136134
* Bit masks for packet buffer
137135
*/
138136
public static int[] anIntArray2361 = new int[]{0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455, 536870911, 1073741823, 2147483647, -1};
139-
public static CacheArchive aCacheArchive_2364;
140137
public static int destinationX = 0;
141138
public static int anInt1511 = -1;
142139
/**
143140
* The hint (arrow) icon sprites.
144141
*/
145142
public static ImageRGB[] hintIconSprites;
146143
public static int anInt2581;
147-
public static CacheArchive aCacheArchive_2582;
148144
public static ImageRGB minimapEdge;
149145
/**
150146
* Images for scenery on the minimap (e.g. trees, ladders, etc)
@@ -351,7 +347,6 @@ public class MovedStatics {
351347
* Relates to minimap
352348
*/
353349
public static int[] anIntArray66;
354-
public static CacheArchive aCacheArchive_1705;
355350
public static int[] keyCodes = new int[128];
356351
public static int tooltipDelay = 50;
357352
public static int anInt2231 = 1;
@@ -485,12 +480,6 @@ public static int getCutsceneCameraPlane() {
485480
return 3;
486481
}
487482

488-
public static void initializeAnimationCaches(CacheArchive skinArchive, CacheArchive definitionArchive, CacheArchive skeletonArchive) {
489-
ClientScriptRunner.aCacheArchive_2162 = skinArchive;
490-
aCacheArchive_2364 = skeletonArchive;
491-
AnimationSequence.aCacheArchive_2484 = definitionArchive;
492-
}
493-
494483
public static boolean method459(int arg0, int arg1) {
495484
if (arg0 == 11)
496485
arg0 = 10;
@@ -998,13 +987,6 @@ public static int randomNoise(int x, int y) {
998987
}
999988

1000989

1001-
public static void initializeItemDefinitionCache(CacheArchive definitionCache, boolean arg1, CacheArchive arg2) {
1002-
membersServer = arg1;
1003-
MovedStatics.aCacheArchive_284 = arg2;
1004-
ItemDefinition.itemDefinitionCache = definitionCache;
1005-
ItemDefinition.count = ItemDefinition.itemDefinitionCache.fileLength(10);
1006-
}
1007-
1008990
public static int method888(int x, int y) {
1009991
int vertexHeight = -128 + perlinNoise(x + 45365, 91923 + y, 4) - (-(perlinNoise(x + 10294, 37821 + y, 2) - 128 >> 1) + -(-128 + perlinNoise(x, y, 1) >> 2));
1010992
vertexHeight = 35 + (int) (0.3 * (double) vertexHeight);
@@ -1307,8 +1289,7 @@ public static void animateNpcs() {
13071289
*/
13081290
public static ImageRGB[] mapFunctionIcons;
13091291
public static FontMetrics fontMetrics;
1310-
public static CacheArchive aCacheArchive_284;
1311-
public static Calendar aCalendar279 = Calendar.getInstance();
1292+
public static Calendar aCalendar279 = Calendar.getInstance();
13121293
public static int connectionStage = 0;
13131294
public static int anInt292 = 0;
13141295

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public class CacheArchive {
2929
public static CacheArchive huffmanCacheArchive;
3030
public static CacheArchive jingleCacheArchive;
3131
public static CacheArchive clientScriptCacheArchive;
32-
public static CacheArchive definitionCache;
3332
public static int anInt1195 = 0;
3433

3534
public byte[][] aByteArrayArray212;

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

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

33
import org.runejs.client.*;
4+
import org.runejs.client.cache.CacheArchive;
45
import org.runejs.client.cache.media.AnimationSequence;
56
import org.runejs.client.cache.media.ImageRGB;
67
import org.runejs.client.frame.Minimap;
@@ -23,6 +24,8 @@ public class ActorDefinition extends CachedNode implements EntityDefinition {
2324
public static int count;
2425
public static NodeCache actorDefinitionNodeCache = new NodeCache(64);
2526
public static NodeCache actorChildModelCache = new NodeCache(50);
27+
public static CacheArchive aCacheArchive_1375;
28+
public static CacheArchive aCacheArchive_1577;
2629

2730
public boolean isClickable = true;
2831
public int boundaryDimension = 1;
@@ -121,7 +124,7 @@ public static ActorDefinition getDefinition(int id) {
121124
ActorDefinition definition = (ActorDefinition) actorDefinitionNodeCache.get(id);
122125
if(definition != null)
123126
return definition;
124-
byte[] data = GroundItemTile.aCacheArchive_1375.getFile(9, id);
127+
byte[] data = aCacheArchive_1375.getFile(9, id);
125128
definition = new ActorDefinition();
126129
definition.id = id;
127130
if(data != null)
@@ -135,6 +138,13 @@ public static void clearActorCache() {
135138
actorChildModelCache.clear();
136139
}
137140

141+
public static void initializeActorCache(CacheArchive arg0, CacheArchive arg2) {
142+
aCacheArchive_1375 = arg2;
143+
count = aCacheArchive_1375.fileLength(9);
144+
145+
aCacheArchive_1577 = arg0;
146+
}
147+
138148
public Model getChildModel(AnimationSequence animation1, AnimationSequence animation2, int arg3, int arg4) {
139149
if(childIds != null) {
140150
ActorDefinition actorDefinition = getChildDefinition();
@@ -147,7 +157,7 @@ public Model getChildModel(AnimationSequence animation1, AnimationSequence anima
147157
if(model1 == null) {
148158
boolean bool = false;
149159
for(int model : models) {
150-
if(!MovedStatics.aCacheArchive_1577.loaded(model, 0)) {
160+
if(!aCacheArchive_1577.loaded(model, 0)) {
151161
bool = true;
152162
}
153163
}
@@ -156,7 +166,7 @@ public Model getChildModel(AnimationSequence animation1, AnimationSequence anima
156166
}
157167
Model[] class40_sub5_sub17_sub5s = new Model[models.length];
158168
for(int i = 0; models.length > i; i++) {
159-
class40_sub5_sub17_sub5s[i] = Model.getModel(MovedStatics.aCacheArchive_1577, models[i]);
169+
class40_sub5_sub17_sub5s[i] = Model.getModel(aCacheArchive_1577, models[i]);
160170
}
161171
if(class40_sub5_sub17_sub5s.length == 1) {
162172
model1 = class40_sub5_sub17_sub5s[0];
@@ -310,7 +320,7 @@ public Model getHeadModel() {
310320
}
311321
boolean cached = false;
312322
for(int headModelIndex : headModelIndexes) {
313-
if(!MovedStatics.aCacheArchive_1577.loaded(headModelIndex, 0)) {
323+
if(!aCacheArchive_1577.loaded(headModelIndex, 0)) {
314324
cached = true;
315325
}
316326
}
@@ -319,7 +329,7 @@ public Model getHeadModel() {
319329
}
320330
Model[] models = new Model[headModelIndexes.length];
321331
for(int i = 0; i < headModelIndexes.length; i++) {
322-
models[i] = Model.getModel(MovedStatics.aCacheArchive_1577, headModelIndexes[i]);
332+
models[i] = Model.getModel(aCacheArchive_1577, headModelIndexes[i]);
323333
}
324334
Model headModel;
325335
if(models.length == 1) {

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public class GameObjectDefinition extends CachedNode implements EntityDefinition
2020
public static int count;
2121
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};
2222
public static boolean lowMemory = false;
23+
public static CacheArchive definitionCache;
24+
public static CacheArchive aCacheArchive_1705;
2325
private static NodeCache objectDefinitionCache = new NodeCache(64);
2426
public static NodeCache objectModelCache = new NodeCache(500);
2527
private static Model[] objectModelHolder = new Model[4];
@@ -152,7 +154,7 @@ public static GameObjectDefinition getDefinition(int objectId) {
152154
if(gameObjectDefinition != null) {
153155
return gameObjectDefinition;
154156
}
155-
byte[] is = CacheArchive.definitionCache.getFile(6, objectId);
157+
byte[] is = definitionCache.getFile(6, objectId);
156158
gameObjectDefinition = new GameObjectDefinition();
157159
gameObjectDefinition.id = objectId;
158160
if(is == null) {
@@ -184,6 +186,13 @@ public static void clearGameObjectModelCache() {
184186
animatedObjectModelCache.clear();
185187
}
186188

189+
public static void initializeGameObjectDefinitionCache(CacheArchive arg1, boolean lowMemory, CacheArchive definitionCache) {
190+
GameObjectDefinition.definitionCache = definitionCache;
191+
count = GameObjectDefinition.definitionCache.fileLength(6);
192+
GameObjectDefinition.lowMemory = lowMemory;
193+
aCacheArchive_1705 = arg1;
194+
}
195+
187196
public Model createTerrainObjectModel(int arg0, int arg1, int arg2, int arg3, int arg4, int arg6) {
188197
long l;
189198
if(objectTypes == null) {
@@ -277,7 +286,7 @@ public Model createObjectModel(boolean shaded, boolean hasBones, int orientation
277286
}
278287
model = (Model) objectModelCache.get(modelId);
279288
if(model == null) {
280-
model = Model.getModel(MovedStatics.aCacheArchive_1705, modelId & 0xffff);
289+
model = Model.getModel(aCacheArchive_1705, modelId & 0xffff);
281290
if(model == null) {
282291
return null;
283292
}
@@ -311,7 +320,7 @@ public Model createObjectModel(boolean shaded, boolean hasBones, int orientation
311320
}
312321
model = (Model) objectModelCache.get(modelId);
313322
if(model == null) {
314-
model = Model.getModel(MovedStatics.aCacheArchive_1705, 0xffff & modelId);
323+
model = Model.getModel(aCacheArchive_1705, 0xffff & modelId);
315324
if(model == null) {
316325
return null;
317326
}
@@ -524,7 +533,7 @@ public boolean method610(int arg0) {
524533
if(objectTypes != null) {
525534
for(int i = 0; objectTypes.length > i; i++) {
526535
if(objectTypes[i] == arg0) {
527-
return MovedStatics.aCacheArchive_1705.loaded(objectModels[i] & 0xffff, 0);
536+
return aCacheArchive_1705.loaded(objectModels[i] & 0xffff, 0);
528537
}
529538
}
530539
return true;
@@ -537,7 +546,7 @@ public boolean method610(int arg0) {
537546
}
538547
boolean bool = true;
539548
for(int i = 0; objectModels.length > i; i++) {
540-
bool &= MovedStatics.aCacheArchive_1705.loaded(0xffff & objectModels[i], 0);
549+
bool &= aCacheArchive_1705.loaded(0xffff & objectModels[i], 0);
541550
}
542551
return bool;
543552
}
@@ -564,7 +573,7 @@ public boolean method612() {
564573
}
565574
boolean bool = true;
566575
for(int i = 0; objectModels.length > i; i++) {
567-
bool &= MovedStatics.aCacheArchive_1705.loaded(0xffff & objectModels[i], 0);
576+
bool &= aCacheArchive_1705.loaded(0xffff & objectModels[i], 0);
568577
}
569578
return bool;
570579
}

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

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

3-
import org.runejs.client.*;
43
import org.runejs.client.cache.CacheArchive;
54
import org.runejs.client.io.Buffer;
65
import org.runejs.client.media.renderable.Model;
@@ -11,6 +10,7 @@ public class IdentityKit extends CachedNode {
1110
public static CacheArchive identityKitCache;
1211
public static NodeCache identityKitNodeCache = new NodeCache(64);
1312
public static int identityKitLength;
13+
public static CacheArchive aCacheArchive_654;
1414
public int[] recolorToFind = new int[6];
1515
public int[] recolorToReplace;
1616
public int bodyPartId = -1;
@@ -41,6 +41,12 @@ public static void clearIdentityKitCache() {
4141
identityKitNodeCache.clear();
4242
}
4343

44+
public static void initializeIdentityKitDefinitionCache(CacheArchive definitionCache, CacheArchive arg2) {
45+
aCacheArchive_654 = arg2;
46+
identityKitCache = definitionCache;
47+
identityKitLength = identityKitCache.fileLength(3);
48+
}
49+
4450
public void readValues(Buffer buffer) {
4551
while(true) {
4652
int opcode = buffer.getUnsignedByte();
@@ -57,7 +63,7 @@ public boolean isBodyModelCached() {
5763
}
5864
boolean isCached = true;
5965
for(int i = 0; modelId.length > i; i++) {
60-
if(!MovedStatics.aCacheArchive_654.loaded(modelId[i], 0)) {
66+
if(!aCacheArchive_654.loaded(modelId[i], 0)) {
6167
isCached = false;
6268
}
6369
}
@@ -68,7 +74,7 @@ public boolean method624() {
6874
boolean bool = true;
6975
int i = 0;
7076
for(/**/; i < 5; i++) {
71-
if(models[i] != -1 && !MovedStatics.aCacheArchive_654.loaded(models[i], 0)) {
77+
if(models[i] != -1 && !aCacheArchive_654.loaded(models[i], 0)) {
7278
bool = false;
7379
}
7480
}
@@ -100,7 +106,7 @@ public Model method629() {
100106
int i = 0;
101107
for(int i_7_ = 0; i_7_ < 5; i_7_++) {
102108
if(models[i_7_] != -1) {
103-
class40_sub5_sub17_sub5s[i++] = Model.getModel(MovedStatics.aCacheArchive_654, models[i_7_]);
109+
class40_sub5_sub17_sub5s[i++] = Model.getModel(aCacheArchive_654, models[i_7_]);
104110
}
105111
}
106112
Model class40_sub5_sub17_sub5 = new Model(class40_sub5_sub17_sub5s, i);
@@ -119,7 +125,7 @@ public Model getBodyModel() {
119125
}
120126
Model[] models = new Model[modelId.length];
121127
for(int i = 0; i < modelId.length; i++) {
122-
models[i] = Model.getModel(MovedStatics.aCacheArchive_654, modelId[i]);
128+
models[i] = Model.getModel(aCacheArchive_654, modelId[i]);
123129
}
124130
Model model;
125131
if(models.length == 1) {

0 commit comments

Comments
 (0)