Skip to content

Commit 1751986

Browse files
authored
Merge pull request #178 from runejs/more-renames
refactor: fully rename caches, make private
2 parents 13715a2 + dd8f450 commit 1751986

15 files changed

+154
-146
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1985,7 +1985,7 @@ public static void clearCaches() {
19851985
PlayerAppearance.clearPlayerModelCache();
19861986
GameInterface.clearInterfaceCaches();
19871987
((Class35) Rasterizer3D.interface3).clearTextures();
1988-
ClientScript.clientScriptCache.clear();
1988+
ClientScript.clearClientScriptCache();
19891989
CacheArchive.skeletonCacheArchive.clearCache();
19901990
CacheArchive.skinDefinitionCacheArchive.clearCache();
19911991
CacheArchive.gameInterfaceCacheArchive.clearCache();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public static void loadRegion() {
221221
MovedStatics.spawnGroundItem(y, x);
222222
}
223223
clearTemporaryObjects();
224-
GameObjectDefinition.objectModelCache.clear();
224+
GameObjectDefinition.clearStaticModelCache();
225225
if(GameShell.clientFrame != null) {
226226
OutgoingPackets.buffer.putPacket(121);
227227
OutgoingPackets.buffer.putIntBE(1057001181);

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ public static void handleVarPlayers(int varPlayerIndex) {
12531253
Rasterizer3D.createPalette(0.6);
12541254
((Class35) Rasterizer3D.interface3).setBrightness(0.6);
12551255
}
1256-
clearImageCache();
1256+
ItemDefinition.clearImageCache();
12571257
clearScreen = true;
12581258
}
12591259
if(varPlayerType == 3) {
@@ -3098,10 +3098,6 @@ public static void drawLoadingText(int percent, Color color, String desc) {
30983098
}
30993099
}
31003100

3101-
public static void clearImageCache() {
3102-
ItemDefinition.itemImageCache.clear();
3103-
}
3104-
31053101
public static void method778(HuffmanEncoding arg1) {
31063102
aHuffmanEncoding_2590 = arg1;
31073103
}

src/main/java/org/runejs/client/audio/Instrument.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,25 @@ public int evaluateWave(int phase, int amplitude, int table) {
128128
return 0;
129129
}
130130

131-
public static void method776(int[] arg0, int arg1, int arg2) {
132-
arg2 = arg1 + arg2 - 7;
133-
while(arg1 < arg2) {
134-
arg0[arg1++] = 0;
135-
arg0[arg1++] = 0;
136-
arg0[arg1++] = 0;
137-
arg0[arg1++] = 0;
138-
arg0[arg1++] = 0;
139-
arg0[arg1++] = 0;
140-
arg0[arg1++] = 0;
141-
arg0[arg1++] = 0;
131+
private static void resetOutput(int[] dest, int counter, int length) {
132+
length = counter + length - 7;
133+
while(counter < length) {
134+
dest[counter++] = 0;
135+
dest[counter++] = 0;
136+
dest[counter++] = 0;
137+
dest[counter++] = 0;
138+
dest[counter++] = 0;
139+
dest[counter++] = 0;
140+
dest[counter++] = 0;
141+
dest[counter++] = 0;
142142
}
143-
arg2 += 7;
144-
while(arg1 < arg2)
145-
arg0[arg1++] = 0;
143+
length += 7;
144+
while(counter < length)
145+
dest[counter++] = 0;
146146
}
147147

148148
public int[] synthesize(int n_s, int dt) {
149-
method776(output, 0, n_s);
149+
resetOutput(output, 0, n_s);
150150
if(dt < 10) {
151151
return output;
152152
}

src/main/java/org/runejs/client/cache/cs/ClientScript.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
public class ClientScript extends CachedNode {
1616

17-
public static NodeCache clientScriptCache = new NodeCache(128);
17+
private static NodeCache clientScriptCache = new NodeCache(128);
1818

1919
public int[] intOperands;
2020
public int intStackCount;
@@ -24,6 +24,10 @@ public class ClientScript extends CachedNode {
2424
public int localIntCount;
2525
public int[] opcodes;
2626

27+
public static void clearClientScriptCache() {
28+
clientScriptCache.clear();
29+
}
30+
2731

2832
public static void clientScriptDebugger() {
2933
int len = CacheArchive.clientScriptCacheArchive.getLength();

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
public class ActorDefinition extends CachedNode implements EntityDefinition {
2222

2323
public static int count;
24-
public static NodeCache actorDefinitionNodeCache = new NodeCache(64);
25-
public static NodeCache actorChildModelCache = new NodeCache(50);
26-
public static CacheArchive aCacheArchive_1375;
27-
public static CacheArchive aCacheArchive_1577;
24+
private static NodeCache actorDefinitionCache = new NodeCache(64);
25+
private static NodeCache actorModelCache = new NodeCache(50);
26+
private static CacheArchive actorDefinitionArchive;
27+
private static CacheArchive actorModelArchive;
2828

2929
public boolean isClickable = true;
3030
public int boundaryDimension = 1;
@@ -116,28 +116,28 @@ public static ImageRGB method578() {
116116
}
117117

118118
public static ActorDefinition getDefinition(int id) {
119-
ActorDefinition definition = (ActorDefinition) actorDefinitionNodeCache.get(id);
119+
ActorDefinition definition = (ActorDefinition) actorDefinitionCache.get(id);
120120
if(definition != null)
121121
return definition;
122-
byte[] data = aCacheArchive_1375.getFile(9, id);
122+
byte[] data = actorDefinitionArchive.getFile(9, id);
123123
definition = new ActorDefinition();
124124
definition.id = id;
125125
if(data != null)
126126
definition.readValues(new Buffer(data));
127-
actorDefinitionNodeCache.put(id, definition);
127+
actorDefinitionCache.put(id, definition);
128128
return definition;
129129
}
130130

131131
public static void clearActorCache() {
132-
actorDefinitionNodeCache.clear();
133-
actorChildModelCache.clear();
132+
actorDefinitionCache.clear();
133+
actorModelCache.clear();
134134
}
135135

136-
public static void initializeActorCache(CacheArchive arg0, CacheArchive arg2) {
137-
aCacheArchive_1375 = arg2;
138-
count = aCacheArchive_1375.fileLength(9);
136+
public static void initializeActorCache(CacheArchive models, CacheArchive definitions) {
137+
actorDefinitionArchive = definitions;
138+
count = actorDefinitionArchive.fileLength(9);
139139

140-
aCacheArchive_1577 = arg0;
140+
actorModelArchive = models;
141141
}
142142

143143
public Model getChildModel(AnimationSequence animation1, AnimationSequence animation2, int arg3, int arg4) {
@@ -148,11 +148,11 @@ public Model getChildModel(AnimationSequence animation1, AnimationSequence anima
148148
}
149149
return actorDefinition.getChildModel(animation1, animation2, arg3, arg4);
150150
}
151-
Model model1 = (Model) actorChildModelCache.get(id);
151+
Model model1 = (Model) actorModelCache.get(id);
152152
if(model1 == null) {
153153
boolean bool = false;
154154
for(int model : models) {
155-
if(!aCacheArchive_1577.loaded(model, 0)) {
155+
if(!actorModelArchive.loaded(model, 0)) {
156156
bool = true;
157157
}
158158
}
@@ -161,7 +161,7 @@ public Model getChildModel(AnimationSequence animation1, AnimationSequence anima
161161
}
162162
Model[] class40_sub5_sub17_sub5s = new Model[models.length];
163163
for(int i = 0; models.length > i; i++) {
164-
class40_sub5_sub17_sub5s[i] = Model.getModel(aCacheArchive_1577, models[i]);
164+
class40_sub5_sub17_sub5s[i] = Model.getModel(actorModelArchive, models[i]);
165165
}
166166
if(class40_sub5_sub17_sub5s.length == 1) {
167167
model1 = class40_sub5_sub17_sub5s[0];
@@ -177,7 +177,7 @@ public Model getChildModel(AnimationSequence animation1, AnimationSequence anima
177177
assert model1 != null;
178178
model1.createBones();
179179
model1.applyLighting(ambient + 64, 850 + contrast, -30, -50, -30, true);
180-
actorChildModelCache.put(id, model1);
180+
actorModelCache.put(id, model1);
181181
}
182182
Model class40_sub5_sub17_sub5_0_;
183183
if(animation1 != null && animation2 != null) {
@@ -315,7 +315,7 @@ public Model getHeadModel() {
315315
}
316316
boolean cached = false;
317317
for(int headModelIndex : headModelIndexes) {
318-
if(!aCacheArchive_1577.loaded(headModelIndex, 0)) {
318+
if(!actorModelArchive.loaded(headModelIndex, 0)) {
319319
cached = true;
320320
}
321321
}
@@ -324,7 +324,7 @@ public Model getHeadModel() {
324324
}
325325
Model[] models = new Model[headModelIndexes.length];
326326
for(int i = 0; i < headModelIndexes.length; i++) {
327-
models[i] = Model.getModel(aCacheArchive_1577, headModelIndexes[i]);
327+
models[i] = Model.getModel(actorModelArchive, headModelIndexes[i]);
328328
}
329329
Model headModel;
330330
if(models.length == 1) {

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

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ 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 modelCache;
25-
private static NodeCache objectDefinitionCache = new NodeCache(64);
26-
public static NodeCache objectModelCache = new NodeCache(500);
23+
private static CacheArchive definitionArchive;
24+
private static CacheArchive modelArchive;
25+
private static NodeCache definitionCache = new NodeCache(64);
26+
private static NodeCache modelCacheStatic = new NodeCache(500);
2727
private static Model[] objectModelHolder = new Model[4];
28-
private static NodeCache terrainObjectModelCache = new NodeCache(10);
28+
private static NodeCache modelCacheDynamic = new NodeCache(10);
2929
private static NodeCache animatedObjectModelCache = new NodeCache(30);
3030

3131
public int unkn1;
@@ -150,11 +150,11 @@ public static void addTemporaryObject(int objectId, int x, int orientation, int
150150
}
151151

152152
public static GameObjectDefinition getDefinition(int objectId) {
153-
GameObjectDefinition gameObjectDefinition = (GameObjectDefinition) objectDefinitionCache.get(objectId);
153+
GameObjectDefinition gameObjectDefinition = (GameObjectDefinition) definitionCache.get(objectId);
154154
if(gameObjectDefinition != null) {
155155
return gameObjectDefinition;
156156
}
157-
byte[] is = definitionCache.getFile(6, objectId);
157+
byte[] is = definitionArchive.getFile(6, objectId);
158158
gameObjectDefinition = new GameObjectDefinition();
159159
gameObjectDefinition.id = objectId;
160160
if(is == null) {
@@ -175,22 +175,26 @@ public static GameObjectDefinition getDefinition(int objectId) {
175175
gameObjectDefinition.solid = false;
176176
gameObjectDefinition.walkable = false;
177177
}
178-
objectDefinitionCache.put(objectId, gameObjectDefinition);
178+
definitionCache.put(objectId, gameObjectDefinition);
179179
return gameObjectDefinition;
180180
}
181181

182182
public static void clearGameObjectModelCache() {
183-
objectDefinitionCache.clear();
184-
objectModelCache.clear();
185-
terrainObjectModelCache.clear();
183+
definitionCache.clear();
184+
modelCacheStatic.clear();
185+
modelCacheDynamic.clear();
186186
animatedObjectModelCache.clear();
187187
}
188188

189+
public static void clearStaticModelCache() {
190+
modelCacheStatic.clear();
191+
}
192+
189193
public static void initializeGameObjectDefinitionCache(CacheArchive modelCache, boolean lowMemory, CacheArchive definitionCache) {
190-
GameObjectDefinition.definitionCache = definitionCache;
191-
count = GameObjectDefinition.definitionCache.fileLength(6);
194+
GameObjectDefinition.definitionArchive = definitionCache;
195+
count = GameObjectDefinition.definitionArchive.fileLength(6);
192196
GameObjectDefinition.lowMemory = lowMemory;
193-
GameObjectDefinition.modelCache = modelCache;
197+
GameObjectDefinition.modelArchive = modelCache;
194198
}
195199

196200
public static boolean isObjectLoaded(int type, int id) {
@@ -209,13 +213,13 @@ public Model createTerrainObjectModel(int arg0, int arg1, int arg2, int arg3, in
209213
} else {
210214
l = arg2 + (id << 10) + (arg4 << 3);
211215
}
212-
Model model = (Model) terrainObjectModelCache.get(l);
216+
Model model = (Model) modelCacheDynamic.get(l);
213217
if(model == null) {
214218
model = createObjectModel(!nonFlatShading, false, arg2, arg4);
215219
if(model == null) {
216220
return null;
217221
}
218-
terrainObjectModelCache.put(l, model);
222+
modelCacheDynamic.put(l, model);
219223
}
220224
if(adjustToTerrain || nonFlatShading) {
221225
model = new Model(adjustToTerrain, nonFlatShading, model);
@@ -293,16 +297,16 @@ public Model createObjectModel(boolean shaded, boolean hasBones, int orientation
293297
if(bool) {
294298
modelId += 65536;
295299
}
296-
model = (Model) objectModelCache.get(modelId);
300+
model = (Model) modelCacheStatic.get(modelId);
297301
if(model == null) {
298-
model = Model.getModel(modelCache, modelId & 0xffff);
302+
model = Model.getModel(modelArchive, modelId & 0xffff);
299303
if(model == null) {
300304
return null;
301305
}
302306
if(bool) {
303307
model.method818();
304308
}
305-
objectModelCache.put(modelId, model);
309+
modelCacheStatic.put(modelId, model);
306310
}
307311
if(modelCount > 1) {
308312
objectModelHolder[modelIndex] = model;
@@ -327,16 +331,16 @@ public Model createObjectModel(boolean shaded, boolean hasBones, int orientation
327331
if(bool) {
328332
modelId += 65536;
329333
}
330-
model = (Model) objectModelCache.get(modelId);
334+
model = (Model) modelCacheStatic.get(modelId);
331335
if(model == null) {
332-
model = Model.getModel(modelCache, 0xffff & modelId);
336+
model = Model.getModel(modelArchive, 0xffff & modelId);
333337
if(model == null) {
334338
return null;
335339
}
336340
if(bool) {
337341
model.method818();
338342
}
339-
objectModelCache.put(modelId, model);
343+
modelCacheStatic.put(modelId, model);
340344
}
341345
}
342346
boolean bool;
@@ -542,7 +546,7 @@ public boolean isTypeModelLoaded(int type) {
542546
if(objectTypes != null) {
543547
for(int i = 0; objectTypes.length > i; i++) {
544548
if(objectTypes[i] == type) {
545-
return modelCache.loaded(objectModels[i] & 0xffff, 0);
549+
return modelArchive.loaded(objectModels[i] & 0xffff, 0);
546550
}
547551
}
548552
return true;
@@ -555,7 +559,7 @@ public boolean isTypeModelLoaded(int type) {
555559
}
556560
boolean bool = true;
557561
for(int i = 0; objectModels.length > i; i++) {
558-
bool &= modelCache.loaded(0xffff & objectModels[i], 0);
562+
bool &= modelArchive.loaded(0xffff & objectModels[i], 0);
559563
}
560564
return bool;
561565
}
@@ -582,7 +586,7 @@ public boolean method612() {
582586
}
583587
boolean bool = true;
584588
for(int i = 0; objectModels.length > i; i++) {
585-
bool &= modelCache.loaded(0xffff & objectModels[i], 0);
589+
bool &= modelArchive.loaded(0xffff & objectModels[i], 0);
586590
}
587591
return bool;
588592
}

0 commit comments

Comments
 (0)