Skip to content

Commit d39212c

Browse files
committed
refactor: rename ItemDefinition caches
1 parent ab0da76 commit d39212c

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

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/cache/def/ItemDefinition.java

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
public class ItemDefinition extends CachedNode implements EntityDefinition {
1515
public static int count;
16-
public static CacheArchive itemDefinitionCache;
17-
public static NodeCache itemDefinitionNodeCache = new NodeCache(64);
18-
public static NodeCache groundItemModelNodeCache = new NodeCache(50);
19-
public static NodeCache itemImageCache = new NodeCache(100);
20-
public static CacheArchive aCacheArchive_284;
16+
public static CacheArchive definitionArchive;
17+
public static NodeCache definitionCache = new NodeCache(64);
18+
public static NodeCache modelCache = new NodeCache(50);
19+
public static NodeCache imageCache = new NodeCache(100);
20+
public static CacheArchive modelArchive;
2121

2222
public int stackable;
2323
public String name;
@@ -94,11 +94,11 @@ public ItemDefinition() {
9494

9595

9696
public static ItemDefinition forId(int id, int arg1) {
97-
ItemDefinition definition = (ItemDefinition) itemDefinitionNodeCache.get(id);
97+
ItemDefinition definition = (ItemDefinition) definitionCache.get(id);
9898
if(definition != null) {
9999
return definition;
100100
}
101-
byte[] is = itemDefinitionCache.getFile(arg1, id);
101+
byte[] is = definitionArchive.getFile(arg1, id);
102102
definition = new ItemDefinition();
103103
definition.id = id;
104104
if(is != null) {
@@ -113,13 +113,13 @@ public static ItemDefinition forId(int id, int arg1) {
113113
definition.groundOptions = null;
114114
definition.name = English.membersObject;
115115
}
116-
itemDefinitionNodeCache.put(id, definition);
116+
definitionCache.put(id, definition);
117117
return definition;
118118
}
119119

120120
public static ImageRGB sprite(int stackSize, int id, int backColour) {
121121
if(backColour == 0) {
122-
ImageRGB sprite = (ImageRGB) itemImageCache.get((long) id);
122+
ImageRGB sprite = (ImageRGB) imageCache.get((long) id);
123123
if(sprite != null && sprite.maxHeight != stackSize && sprite.maxHeight != -1) {
124124
sprite.unlink();
125125
sprite = null;
@@ -221,7 +221,7 @@ else if(i_13_ <= 0 || rendered.pixels[i_15_ + (i_13_ + -1) * 32] != 1) {
221221
notedSprite.maxHeight = i_17_;
222222
}
223223
if(backColour == 0)
224-
itemImageCache.put((long) id, rendered);
224+
imageCache.put((long) id, rendered);
225225
Rasterizer.prepare(pixels, i_1_, i);
226226
Rasterizer.setBounds(i_2_, i_5_, i_4_, i_6_);
227227
Rasterizer3D.setLineOffsets(lineOffsets);
@@ -239,16 +239,20 @@ else if(i_13_ <= 0 || rendered.pixels[i_15_ + (i_13_ + -1) * 32] != 1) {
239239
}
240240

241241
public static void clearItemCache() {
242-
itemDefinitionNodeCache.clear();
243-
groundItemModelNodeCache.clear();
244-
itemImageCache.clear();
242+
definitionCache.clear();
243+
modelCache.clear();
244+
imageCache.clear();
245245
}
246246

247247
public static void initializeItemDefinitionCache(CacheArchive definitionCache, boolean arg1, CacheArchive arg2) {
248248
MovedStatics.membersServer = arg1;
249-
aCacheArchive_284 = arg2;
250-
itemDefinitionCache = definitionCache;
251-
count = itemDefinitionCache.fileLength(10);
249+
modelArchive = arg2;
250+
definitionArchive = definitionCache;
251+
count = definitionArchive.fileLength(10);
252+
}
253+
254+
public static void clearImageCache() {
255+
imageCache.clear();
252256
}
253257

254258
public boolean headPieceReady(boolean female) {
@@ -262,10 +266,10 @@ public boolean headPieceReady(boolean female) {
262266
return true;
263267
}
264268
boolean ready = true;
265-
if(!aCacheArchive_284.loaded(primaryId, 0)) {
269+
if(!modelArchive.loaded(primaryId, 0)) {
266270
ready = false;
267271
}
268-
if(secondaryId != -1 && !aCacheArchive_284.loaded(secondaryId, 0)) {
272+
if(secondaryId != -1 && !modelArchive.loaded(secondaryId, 0)) {
269273
ready = false;
270274
}
271275
return ready;
@@ -284,13 +288,13 @@ public boolean equipmentReady(boolean arg0) {
284288
return true;
285289
}
286290
boolean bool = true;
287-
if(!aCacheArchive_284.loaded(i, 0)) {
291+
if(!modelArchive.loaded(i, 0)) {
288292
bool = false;
289293
}
290-
if(i_1_ != -1 && !aCacheArchive_284.loaded(i_1_, 0)) {
294+
if(i_1_ != -1 && !modelArchive.loaded(i_1_, 0)) {
291295
bool = false;
292296
}
293-
if(i_2_ != -1 && !aCacheArchive_284.loaded(i_2_, 0)) {
297+
if(i_2_ != -1 && !modelArchive.loaded(i_2_, 0)) {
294298
bool = false;
295299
}
296300
return bool;
@@ -308,14 +312,14 @@ public Model asEquipment(boolean isFemale) {
308312
if(primaryId == -1) {
309313
return null;
310314
}
311-
Model primary = Model.getModel(aCacheArchive_284, primaryId);
315+
Model primary = Model.getModel(modelArchive, primaryId);
312316
if(secondaryId != -1) {
313-
Model secondary = Model.getModel(aCacheArchive_284, secondaryId);
317+
Model secondary = Model.getModel(modelArchive, secondaryId);
314318
if(tertiaryId == -1) {
315319
Model[] tertiary = {primary, secondary};
316320
primary = new Model(tertiary, 2);
317321
} else {
318-
Model model3 = Model.getModel(aCacheArchive_284, tertiaryId);
322+
Model model3 = Model.getModel(modelArchive, tertiaryId);
319323
Model[] models = {primary, secondary, model3};
320324
primary = new Model(models, 3);
321325
}
@@ -362,9 +366,9 @@ public Model asHeadPiece(boolean female) {
362366
if(primaryId == -1) {
363367
return null;
364368
}
365-
Model primary = Model.getModel(aCacheArchive_284, primaryId);
369+
Model primary = Model.getModel(modelArchive, primaryId);
366370
if(secondaryId != -1) {
367-
Model secondary = Model.getModel(aCacheArchive_284, secondaryId);
371+
Model secondary = Model.getModel(modelArchive, secondaryId);
368372
Model[] models = {primary, secondary};
369373
primary = new Model(models, 2);
370374
}
@@ -509,11 +513,11 @@ public Model asGroundStack(boolean arg0, int amount) {
509513
return forId(id, 10).asGroundStack(arg0, 1);
510514
}
511515
}
512-
Model model = (Model) groundItemModelNodeCache.get(id);
516+
Model model = (Model) modelCache.get(id);
513517
if(model != null) {
514518
return model;
515519
}
516-
model = Model.getModel(aCacheArchive_284, inventoryModelId);
520+
model = Model.getModel(modelArchive, inventoryModelId);
517521
if(model == null) {
518522
return null;
519523
}
@@ -528,7 +532,7 @@ public Model asGroundStack(boolean arg0, int amount) {
528532
if(arg0) {
529533
model.applyLighting(ambient + 64, 768 + contrast, -50, -10, -50, true);
530534
model.singleTile = true;
531-
groundItemModelNodeCache.put(id, model);
535+
modelCache.put(id, model);
532536
}
533537
return model;
534538

0 commit comments

Comments
 (0)