Replaced LRUCache with org.apache.commons.collections4.map.LRUMap
This commit is contained in:
1 parent
0400cb9ff9
commit
077a25091e
10 files changed
+123
-140
No files matched your search
@@ -2,80 +2,18 @@
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3)
|
||||
|
||||
import org.apache.commons.collections4.map.LRUMap;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Component {
|
||||
|
||||
public static final LRUMap<Long, Model> modelCache = new LRUMap<>(30);
|
||||
public static LRUMap<Long, Image24> imageCache;
|
||||
public static Component[] instances;
|
||||
public static LRUCache aCache_238;
|
||||
public static final LRUCache A_CACHE___264 = new LRUCache(30);
|
||||
public Image24 aImage_207;
|
||||
public int anInt208;
|
||||
public Image24[] aImageArray209;
|
||||
public int unusedInt;
|
||||
public int[] anIntArray212;
|
||||
public int anInt214;
|
||||
public int[] anIntArray215;
|
||||
public int anInt216;
|
||||
public int anInt217;
|
||||
public String aString218;
|
||||
public int anInt219;
|
||||
public int anInt220;
|
||||
public String aString221;
|
||||
public String aString222;
|
||||
public boolean aBoolean223;
|
||||
public int anInt224;
|
||||
public String[] aStringArray225;
|
||||
public int[][] anIntArrayArray226;
|
||||
public boolean aBoolean227;
|
||||
public String aString228;
|
||||
public int anInt230;
|
||||
public int anInt231;
|
||||
public int anInt232;
|
||||
public int anInt233;
|
||||
public int anInt234;
|
||||
public boolean aBoolean235;
|
||||
public int anInt236;
|
||||
public int anInt237;
|
||||
public int anInt239;
|
||||
public int[] anIntArray240;
|
||||
public int[] anIntArray241;
|
||||
public boolean aBoolean242;
|
||||
public BitmapFont aFont_243;
|
||||
public int anInt244;
|
||||
public int[] anIntArray245;
|
||||
public int anInt246;
|
||||
public int[] anIntArray247;
|
||||
public String aString248;
|
||||
public boolean aBoolean249;
|
||||
public int anInt250;
|
||||
public boolean unusedBool;
|
||||
public int[] anIntArray252;
|
||||
public int[] anIntArray253;
|
||||
public byte aByte254;
|
||||
public int anInt255;
|
||||
public int anInt256;
|
||||
public int anInt257;
|
||||
public int anInt258;
|
||||
public boolean aBoolean259;
|
||||
public Image24 aImage_260;
|
||||
public int anInt261;
|
||||
public int anInt262;
|
||||
public int anInt263;
|
||||
public int anInt265;
|
||||
public boolean aBoolean266;
|
||||
public int anInt267;
|
||||
public boolean aBoolean268;
|
||||
public int anInt269;
|
||||
public int anInt270;
|
||||
public int anInt271;
|
||||
public int[] anIntArray272;
|
||||
|
||||
public Component() {
|
||||
}
|
||||
|
||||
public static void unpack(FileArchive archive, BitmapFont[] aclass30_sub2_sub1_sub4, FileArchive archive_1) throws IOException {
|
||||
aCache_238 = new LRUCache(50000);
|
||||
imageCache = new LRUMap<>(500);
|
||||
Buffer buffer = new Buffer(archive.read("data"));
|
||||
int i = -1;
|
||||
int j = buffer.get2U();
|
||||
@@ -276,18 +214,18 @@ public class Component {
|
||||
}
|
||||
}
|
||||
}
|
||||
aCache_238 = null;
|
||||
imageCache = null;
|
||||
}
|
||||
|
||||
public static Image24 method207(int i, FileArchive archive, String s) {
|
||||
long l = (StringUtil.hashCode(s) << 8) + (long) i;
|
||||
Image24 image = (Image24) aCache_238.get(l);
|
||||
Image24 image = imageCache.get(l);
|
||||
if (image != null) {
|
||||
return image;
|
||||
}
|
||||
try {
|
||||
image = new Image24(archive, s, i);
|
||||
aCache_238.put(l, image);
|
||||
imageCache.put(l, image);
|
||||
} catch (Exception _ex) {
|
||||
return null;
|
||||
}
|
||||
@@ -295,12 +233,77 @@ public class Component {
|
||||
}
|
||||
|
||||
public static void method208(int i, int j, Model model) {
|
||||
A_CACHE___264.clear();
|
||||
modelCache.clear();
|
||||
if ((model != null) && (j != 4)) {
|
||||
A_CACHE___264.put(((long) j << 16) + i, model);
|
||||
modelCache.put(((long) j << 16) + i, model);
|
||||
}
|
||||
}
|
||||
|
||||
public Image24 aImage_207;
|
||||
public int anInt208;
|
||||
public Image24[] aImageArray209;
|
||||
public int unusedInt;
|
||||
public int[] anIntArray212;
|
||||
public int anInt214;
|
||||
public int[] anIntArray215;
|
||||
public int anInt216;
|
||||
public int anInt217;
|
||||
public String aString218;
|
||||
public int anInt219;
|
||||
public int anInt220;
|
||||
public String aString221;
|
||||
public String aString222;
|
||||
public boolean aBoolean223;
|
||||
public int anInt224;
|
||||
public String[] aStringArray225;
|
||||
public int[][] anIntArrayArray226;
|
||||
public boolean aBoolean227;
|
||||
public String aString228;
|
||||
public int anInt230;
|
||||
public int anInt231;
|
||||
public int anInt232;
|
||||
public int anInt233;
|
||||
public int anInt234;
|
||||
public boolean aBoolean235;
|
||||
public int anInt236;
|
||||
public int anInt237;
|
||||
public int anInt239;
|
||||
public int[] anIntArray240;
|
||||
public int[] anIntArray241;
|
||||
public boolean aBoolean242;
|
||||
public BitmapFont aFont_243;
|
||||
public int anInt244;
|
||||
public int[] anIntArray245;
|
||||
public int anInt246;
|
||||
public int[] anIntArray247;
|
||||
public String aString248;
|
||||
public boolean aBoolean249;
|
||||
public int anInt250;
|
||||
public boolean unusedBool;
|
||||
public int[] anIntArray252;
|
||||
public int[] anIntArray253;
|
||||
public byte aByte254;
|
||||
public int anInt255;
|
||||
public int anInt256;
|
||||
public int anInt257;
|
||||
public int anInt258;
|
||||
public boolean aBoolean259;
|
||||
public Image24 aImage_260;
|
||||
public int anInt261;
|
||||
public int anInt262;
|
||||
public int anInt263;
|
||||
public int anInt265;
|
||||
public boolean aBoolean266;
|
||||
public int anInt267;
|
||||
public boolean aBoolean268;
|
||||
public int anInt269;
|
||||
public int anInt270;
|
||||
public int anInt271;
|
||||
public int[] anIntArray272;
|
||||
|
||||
public Component() {
|
||||
}
|
||||
|
||||
public void method204(int i, int j) {
|
||||
int k = anIntArray253[i];
|
||||
anIntArray253[i] = anIntArray253[j];
|
||||
@@ -311,7 +314,7 @@ public class Component {
|
||||
}
|
||||
|
||||
public Model method206(int i, int j) {
|
||||
Model model = (Model) A_CACHE___264.get(((long) i << 16) + j);
|
||||
Model model = modelCache.get(((long) i << 16) + j);
|
||||
if (model != null) {
|
||||
return model;
|
||||
}
|
||||
@@ -331,7 +334,7 @@ public class Component {
|
||||
model = null;
|
||||
}
|
||||
if (model != null) {
|
||||
A_CACHE___264.put((i << 16) + j, model);
|
||||
modelCache.put((long) ((i << 16) + j), model);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
@@ -1776,9 +1776,9 @@ public class Game extends GameShell {
|
||||
public void method23() {
|
||||
LocType.aCache_785.clear();
|
||||
LocType.aCache_780.clear();
|
||||
NPCType.aCache_95.clear();
|
||||
ObjType.aCache_159.clear();
|
||||
ObjType.aCache_158.clear();
|
||||
NPCType.modelCache.clear();
|
||||
ObjType.modelCache.clear();
|
||||
ObjType.iconCache.clear();
|
||||
PlayerEntity.modelCache.clear();
|
||||
SpotAnimType.modelCache.clear();
|
||||
}
|
||||
@@ -2248,7 +2248,7 @@ public class Game extends GameShell {
|
||||
if (k == 4) {
|
||||
Draw3D.setBrightness(0.59999999999999998D);
|
||||
}
|
||||
ObjType.aCache_158.clear();
|
||||
ObjType.iconCache.clear();
|
||||
aBoolean1255 = true;
|
||||
}
|
||||
if (j == 3) {
|
||||
|
||||
@@ -99,7 +99,7 @@ public abstract class GameShell extends Applet implements Runnable, MouseListene
|
||||
ratio = lastRatio;
|
||||
delta = lastDelta;
|
||||
} else if (ntime > otim[opos]) {
|
||||
ratio = (int) ((long) (2560L * deltime) / (ntime - otim[opos]));
|
||||
ratio = (int) ((2560L * deltime) / (ntime - otim[opos]));
|
||||
}
|
||||
|
||||
if (ratio < 25) {
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class LRUCache<T> {
|
||||
|
||||
private final int capacity;
|
||||
private final LinkedHashMap<Long, T> map;
|
||||
|
||||
public LRUCache(int capacity) {
|
||||
this.capacity = capacity;
|
||||
this.map = new LinkedHashMap<>(capacity);
|
||||
}
|
||||
|
||||
public T get(long key) {
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
public void put(long key, T value) {
|
||||
if (map.containsKey(key) && map.size() == capacity) {
|
||||
Iterator<Long> iter = map.keySet().iterator();
|
||||
iter.next();
|
||||
iter.remove();
|
||||
}
|
||||
map.put(key, value);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
map.clear();
|
||||
}
|
||||
|
||||
}
|
||||
+12
-10
@@ -2,6 +2,8 @@
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3)
|
||||
|
||||
import org.apache.commons.collections4.map.LRUMap;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class LocType {
|
||||
@@ -13,9 +15,9 @@ public class LocType {
|
||||
public static int anInt756;
|
||||
public static Game aGame765;
|
||||
public static int anInt771;
|
||||
public static LRUCache aCache_780 = new LRUCache(30);
|
||||
public static LRUMap<Long, Model> aCache_780 = new LRUMap(30);
|
||||
public static LocType[] aTypeArray782;
|
||||
public static LRUCache aCache_785 = new LRUCache(500);
|
||||
public static LRUMap<Long,Model> aCache_785 = new LRUMap(500);
|
||||
|
||||
public boolean aBoolean736;
|
||||
public byte aByte737;
|
||||
@@ -227,8 +229,8 @@ public class LocType {
|
||||
if (j != 10) {
|
||||
return null;
|
||||
}
|
||||
l1 = (long) (((long) anInt754 << 6) + l) + ((long) (k + 1) << 32);
|
||||
Model model_1 = (Model) aCache_780.get(l1);
|
||||
l1 = ((long) anInt754 << 6) + l + ((long) (k + 1) << 32);
|
||||
Model model_1 = aCache_780.get(l1);
|
||||
if (model_1 != null) {
|
||||
return model_1;
|
||||
}
|
||||
@@ -242,7 +244,7 @@ public class LocType {
|
||||
if (flag1) {
|
||||
l2 += 0x10000;
|
||||
}
|
||||
model = (Model) aCache_785.get(l2);
|
||||
model = aCache_785.get(l2);
|
||||
if (model == null) {
|
||||
model = Model.tryGet(l2 & 0xffff);
|
||||
if (model == null) {
|
||||
@@ -251,7 +253,7 @@ public class LocType {
|
||||
if (flag1) {
|
||||
model.rotateY180();
|
||||
}
|
||||
aCache_785.put(l2, model);
|
||||
aCache_785.put((long)l2, model);
|
||||
}
|
||||
if (k1 > 1) {
|
||||
A_MODEL_ARRAY_741[i2] = model;
|
||||
@@ -272,8 +274,8 @@ public class LocType {
|
||||
if (i1 == -1) {
|
||||
return null;
|
||||
}
|
||||
l1 = (long) (((long) anInt754 << 6) + ((long) i1 << 3) + l) + ((long) (k + 1) << 32);
|
||||
Model class30_sub2_sub4_sub6_2 = (Model) aCache_780.get(l1);
|
||||
l1 = ((long) anInt754 << 6) + ((long) i1 << 3) + l + ((long) (k + 1) << 32);
|
||||
Model class30_sub2_sub4_sub6_2 = aCache_780.get(l1);
|
||||
if (class30_sub2_sub4_sub6_2 != null) {
|
||||
return class30_sub2_sub4_sub6_2;
|
||||
}
|
||||
@@ -282,7 +284,7 @@ public class LocType {
|
||||
if (flag3) {
|
||||
j2 += 0x10000;
|
||||
}
|
||||
model = (Model) aCache_785.get(j2);
|
||||
model = aCache_785.get(j2);
|
||||
if (model == null) {
|
||||
model = Model.tryGet(j2 & 0xffff);
|
||||
if (model == null) {
|
||||
@@ -291,7 +293,7 @@ public class LocType {
|
||||
if (flag3) {
|
||||
model.rotateY180();
|
||||
}
|
||||
aCache_785.put(j2, model);
|
||||
aCache_785.put((long)j2, model);
|
||||
}
|
||||
}
|
||||
boolean flag;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3)
|
||||
|
||||
import org.apache.commons.collections4.map.LRUMap;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class NPCType {
|
||||
@@ -12,7 +14,7 @@ public class NPCType {
|
||||
public static int[] anIntArray72;
|
||||
public static NPCType[] aTypeArray80;
|
||||
public static Game aGame82;
|
||||
public static LRUCache aCache_95 = new LRUCache(30);
|
||||
public static LRUMap<Long, Model> modelCache = new LRUMap<>(30);
|
||||
|
||||
public static NPCType method159(int i) {
|
||||
if (i > aTypeArray80.length) {
|
||||
@@ -49,11 +51,12 @@ public class NPCType {
|
||||
}
|
||||
|
||||
public static void unload() {
|
||||
aCache_95 = null;
|
||||
modelCache = null;
|
||||
anIntArray72 = null;
|
||||
aTypeArray80 = null;
|
||||
aBuffer_60 = null;
|
||||
}
|
||||
|
||||
public int anInt55 = -1;
|
||||
public int anInt57 = -1;
|
||||
public int anInt58 = -1;
|
||||
@@ -155,7 +158,7 @@ public class NPCType {
|
||||
return type.method164(j, k, ai);
|
||||
}
|
||||
}
|
||||
Model model = (Model) aCache_95.get(aLong78);
|
||||
Model model = modelCache.get(aLong78);
|
||||
if (model == null) {
|
||||
boolean flag = false;
|
||||
for (int value : anIntArray94) {
|
||||
@@ -182,7 +185,7 @@ public class NPCType {
|
||||
}
|
||||
model.createLabelReferences();
|
||||
model.calculateNormals(64 + anInt85, 850 + anInt92, -30, -50, -30, true);
|
||||
aCache_95.put(aLong78, model);
|
||||
modelCache.put(aLong78, model);
|
||||
}
|
||||
Model model_1 = Model.EMPTY;
|
||||
model_1.set(model, SeqFrame.isNull(k) & SeqFrame.isNull(j));
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3)
|
||||
|
||||
import org.apache.commons.collections4.map.LRUMap;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ObjType {
|
||||
|
||||
public static LRUCache aCache_158 = new LRUCache(100);
|
||||
public static LRUCache aCache_159 = new LRUCache(50);
|
||||
public static LRUMap<Integer, Image24> iconCache = new LRUMap<>(100);
|
||||
public static LRUMap<Integer, Model> modelCache = new LRUMap<>(50);
|
||||
public static ObjType[] aTypeArray172;
|
||||
public static int anInt180;
|
||||
public static boolean aBoolean182 = true;
|
||||
@@ -59,8 +61,8 @@ public class ObjType {
|
||||
}
|
||||
|
||||
public static void unload() {
|
||||
aCache_159 = null;
|
||||
aCache_158 = null;
|
||||
modelCache = null;
|
||||
iconCache = null;
|
||||
anIntArray195 = null;
|
||||
aTypeArray172 = null;
|
||||
aBuffer_183 = null;
|
||||
@@ -109,7 +111,7 @@ public class ObjType {
|
||||
|
||||
public static Image24 method200(int i, int j, int k) {
|
||||
if (k == 0) {
|
||||
Image24 image = (Image24) aCache_158.get(i);
|
||||
Image24 image = iconCache.get(i);
|
||||
if ((image != null) && (image.anInt1445 != j) && (image.anInt1445 != -1)) {
|
||||
image.unlink();
|
||||
image = null;
|
||||
@@ -219,7 +221,7 @@ public class ObjType {
|
||||
class30_sub2_sub1_sub1_2.anInt1445 = j6;
|
||||
}
|
||||
if (k == 0) {
|
||||
aCache_158.put(i, class30_sub2_sub1_sub1_1);
|
||||
iconCache.put(i, class30_sub2_sub1_sub1_1);
|
||||
}
|
||||
Draw2D.bind(ai1, i2, j2);
|
||||
Draw2D.setBounds(j3, k2, l2, i3);
|
||||
@@ -422,7 +424,7 @@ public class ObjType {
|
||||
return method198(j).method201(1);
|
||||
}
|
||||
}
|
||||
Model model = (Model) aCache_159.get(anInt157);
|
||||
Model model = modelCache.get(anInt157);
|
||||
if (model != null) {
|
||||
return model;
|
||||
}
|
||||
@@ -440,7 +442,7 @@ public class ObjType {
|
||||
}
|
||||
model.calculateNormals(64 + anInt196, 768 + anInt184, -50, -10, -50, true);
|
||||
model.pickBounds = true;
|
||||
aCache_159.put(anInt157, model);
|
||||
modelCache.put(anInt157, model);
|
||||
return model;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3)
|
||||
|
||||
import org.apache.commons.collections4.map.LRUMap;
|
||||
|
||||
public class PlayerEntity extends PathingEntity {
|
||||
|
||||
public static LRUCache modelCache = new LRUCache(260);
|
||||
public static LRUMap<Long, Model> modelCache = new LRUMap<>(260);
|
||||
public long aLong1697 = -1L;
|
||||
public NPCType aType_1698;
|
||||
public boolean aBoolean1699 = false;
|
||||
@@ -218,7 +220,7 @@ public class PlayerEntity extends PathingEntity {
|
||||
} else if (super.anInt1517 >= 0) {
|
||||
k = SeqType.instances[super.anInt1517].anIntArray353[super.anInt1518];
|
||||
}
|
||||
Model model_1 = (Model) modelCache.get(l);
|
||||
Model model_1 = modelCache.get(l);
|
||||
if (model_1 == null) {
|
||||
boolean flag = false;
|
||||
for (int i2 = 0; i2 < 12; i2++) {
|
||||
@@ -238,7 +240,7 @@ public class PlayerEntity extends PathingEntity {
|
||||
}
|
||||
if (flag) {
|
||||
if (aLong1697 != -1L) {
|
||||
model_1 = (Model) modelCache.get(aLong1697);
|
||||
model_1 = modelCache.get(aLong1697);
|
||||
}
|
||||
if (model_1 == null) {
|
||||
return null;
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
// Jad home page: http://www.kpdus.com/jad.html
|
||||
// Decompiler options: packimports(3)
|
||||
|
||||
import org.apache.commons.collections4.map.LRUMap;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class SpotAnimType {
|
||||
|
||||
public static int anInt402;
|
||||
public static SpotAnimType[] instances;
|
||||
public static LRUCache modelCache = new LRUCache(30);
|
||||
public static LRUMap<Integer, Model> modelCache = new LRUMap<>(30);
|
||||
public int anInt404;
|
||||
public int anInt405;
|
||||
public int anInt406 = -1;
|
||||
@@ -73,7 +75,7 @@ public class SpotAnimType {
|
||||
}
|
||||
|
||||
public Model method266() {
|
||||
Model model = (Model) modelCache.get(anInt404);
|
||||
Model model = modelCache.get(anInt404);
|
||||
if (model != null) {
|
||||
return model;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user