From 1e7146f20884d9b3aacc979a3c8fc7a736ec954d Mon Sep 17 00:00:00 2001 From: thedaneeffect Date: Tue, 16 Mar 2021 01:07:29 -0400 Subject: [PATCH] Reduced redundant linked list implementation --- .idea/.gitignore | 3 + .idea/.name | 1 + .idea/compiler.xml | 16 +++ .idea/jarRepositories.xml | 20 ++++ .idea/misc.xml | 11 +++ .idea/modules.xml | 8 ++ .idea/uiDesigner.xml | 124 ++++++++++++++++++++++++ .idea/vcs.xml | 6 ++ src/main/java/Buffer.java | 14 +-- src/main/java/Component.java | 12 +-- src/main/java/DoublyLinkedList.java | 118 +++++++++++++++------- src/main/java/DoublyLinkedListNode.java | 22 ----- src/main/java/Draw2D.java | 2 +- src/main/java/Entity.java | 2 +- src/main/java/Game.java | 110 ++++++++++----------- src/main/java/Hashtable.java | 42 -------- src/main/java/LRUCache.java | 70 ++++--------- src/main/java/LinkedList.java | 102 ------------------- src/main/java/LinkedListNode.java | 23 ----- src/main/java/LocType.java | 14 +-- src/main/java/NPCType.java | 4 +- src/main/java/ObjType.java | 10 +- src/main/java/OnDemand.java | 75 +++++++------- src/main/java/OnDemandRequest.java | 2 +- src/main/java/PlayerEntity.java | 6 +- src/main/java/Scene.java | 28 +++--- src/main/java/SceneLocTemporary.java | 2 +- src/main/java/SceneTile.java | 2 +- src/main/java/SoundTrack.java | 14 +-- src/main/java/SpotAnimType.java | 4 +- 30 files changed, 444 insertions(+), 423 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/.name create mode 100644 .idea/compiler.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml delete mode 100644 src/main/java/DoublyLinkedListNode.java delete mode 100644 src/main/java/Hashtable.java delete mode 100644 src/main/java/LinkedList.java delete mode 100644 src/main/java/LinkedListNode.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..059361f --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +317 \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..363ec27 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..4361200 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..814348e --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/java/Buffer.java b/src/main/java/Buffer.java index 8129036..ab8f613 100644 --- a/src/main/java/Buffer.java +++ b/src/main/java/Buffer.java @@ -24,11 +24,11 @@ import java.nio.charset.StandardCharsets; * C — put(-v) — get returns (-v)
* S — put(128 - v) — get returns (128 - v)
*/ -public class Buffer extends DoublyLinkedListNode { +public class Buffer extends DoublyLinkedList.Node { - public static final LinkedList pool0 = new LinkedList(); - public static final LinkedList pool1 = new LinkedList(); - public static final LinkedList pool2 = new LinkedList(); + public static final DoublyLinkedList pool0 = new DoublyLinkedList(); + public static final DoublyLinkedList pool1 = new DoublyLinkedList(); + public static final DoublyLinkedList pool2 = new DoublyLinkedList(); private static final int[] BITMASK = {0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 0x1ffff, 0x3ffff, 0x7ffff, 0xfffff, 0x1fffff, 0x3fffff, 0x7fffff, 0xffffff, 0x1ffffff, 0x3ffffff, 0x7ffffff, 0xfffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, -1}; public static int poolSize0; public static int poolSize1; @@ -40,13 +40,13 @@ public class Buffer extends DoublyLinkedListNode { if ((sizeType == 0) && (poolSize0 > 0)) { poolSize0--; - buffer = (Buffer) pool0.method251(); + buffer = (Buffer) pool0.pollFront(); } else if ((sizeType == 1) && (poolSize1 > 0)) { poolSize1--; - buffer = (Buffer) pool1.method251(); + buffer = (Buffer) pool1.pollFront(); } else if ((sizeType == 2) && (poolSize2 > 0)) { poolSize2--; - buffer = (Buffer) pool2.method251(); + buffer = (Buffer) pool2.pollFront(); } if (buffer != null) { diff --git a/src/main/java/Component.java b/src/main/java/Component.java index edbb805..cb6c805 100644 --- a/src/main/java/Component.java +++ b/src/main/java/Component.java @@ -279,13 +279,13 @@ public class Component { public static Image24 method207(int i, FileArchive archive, String s) { long l = (StringUtil.hashCode(s) << 8) + (long) i; - Image24 image = (Image24) aCache_238.method222(l); + Image24 image = (Image24) aCache_238.get(l); if (image != null) { return image; } try { image = new Image24(archive, s, i); - aCache_238.method223(image, l); + aCache_238.put(l, image); } catch (Exception _ex) { return null; } @@ -293,9 +293,9 @@ public class Component { } public static void method208(int i, int j, Model model) { - A_CACHE___264.method224(); + A_CACHE___264.clear(); if ((model != null) && (j != 4)) { - A_CACHE___264.method223(model, ((long) j << 16) + i); + A_CACHE___264.put(((long) j << 16) + i, model); } } @@ -309,7 +309,7 @@ public class Component { } public Model method206(int i, int j) { - Model model = (Model) A_CACHE___264.method222(((long) i << 16) + j); + Model model = (Model) A_CACHE___264.get(((long) i << 16) + j); if (model != null) { return model; } @@ -329,7 +329,7 @@ public class Component { model = null; } if (model != null) { - A_CACHE___264.method223(model, (i << 16) + j); + A_CACHE___264.put((i << 16) + j, model); } return model; } diff --git a/src/main/java/DoublyLinkedList.java b/src/main/java/DoublyLinkedList.java index f397a2c..6df4e96 100644 --- a/src/main/java/DoublyLinkedList.java +++ b/src/main/java/DoublyLinkedList.java @@ -1,66 +1,114 @@ -// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) - public class DoublyLinkedList { - public final DoublyLinkedListNode aNode_43; - public DoublyLinkedListNode aNode_44; + public static class Node { + + public Node prev; + public Node next; + + public void unlink() { + if (next != null) { + next.prev = prev; + prev.next = next; + prev = null; + next = null; + } + } + + } + + public final Node head; + public Node peeked; public DoublyLinkedList() { - aNode_43 = new DoublyLinkedListNode(); - aNode_43.aNode_1303 = aNode_43; - aNode_43.aNode_1304 = aNode_43; + head = new Node(); + head.prev = head; + head.next = head; } - public void method150(DoublyLinkedListNode node) { - if (node.aNode_1304 != null) { - node.method330(); + public void pushBack(Node node) { + if (node.next != null) { + node.unlink(); } - node.aNode_1304 = aNode_43.aNode_1304; - node.aNode_1303 = aNode_43; - node.aNode_1304.aNode_1303 = node; - node.aNode_1303.aNode_1304 = node; + node.next = head.next; + node.prev = head; + node.next.prev = node; + node.prev.next = node; } - public DoublyLinkedListNode method151() { - DoublyLinkedListNode node = aNode_43.aNode_1303; - if (node == aNode_43) { + public void pushFront(Node node) { + if (node.next != null) { + node.unlink(); + } + node.next = head; + node.prev = head.prev; + node.next.prev = node; + node.prev.next = node; + } + + public Node pollFront() { + Node node = head.prev; + if (node == head) { return null; } else { - node.method330(); + node.unlink(); return node; } } - public DoublyLinkedListNode method152() { - DoublyLinkedListNode node = aNode_43.aNode_1303; - if (node == aNode_43) { - aNode_44 = null; + public Node peekFront() { + Node node = head.prev; + if (node == head) { + peeked = null; return null; } else { - aNode_44 = node.aNode_1303; + peeked = node.prev; return node; } } - public DoublyLinkedListNode method153() { - DoublyLinkedListNode node = aNode_44; - if (node == aNode_43) { - aNode_44 = null; + public Node peekBack() { + Node node = head.next; + if (node == head) { + peeked = null; return null; } else { - aNode_44 = node.aNode_1303; + peeked = node.next; return node; } } - public int method154() { - int i = 0; - for (DoublyLinkedListNode node = aNode_43.aNode_1303; node != aNode_43; node = node.aNode_1303) { - i++; + public Node prev() { + Node node = peeked; + if (node == head) { + peeked = null; + return null; + } else { + peeked = node.prev; + return node; } - return i; + } + + public Node next() { + Node node = peeked; + if (node == head) { + peeked = null; + return null; + } + peeked = node.next; + return node; + } + + public void clear() { + if (head.prev == head) { + return; + } + do { + Node node = head.prev; + if (node == head) { + return; + } + node.unlink(); + } while (true); } } diff --git a/src/main/java/DoublyLinkedListNode.java b/src/main/java/DoublyLinkedListNode.java deleted file mode 100644 index cb03274..0000000 --- a/src/main/java/DoublyLinkedListNode.java +++ /dev/null @@ -1,22 +0,0 @@ -// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) - -public class DoublyLinkedListNode extends LinkedListNode { - - public DoublyLinkedListNode aNode_1303; - public DoublyLinkedListNode aNode_1304; - - public DoublyLinkedListNode() { - } - - public void method330() { - if (aNode_1304 != null) { - aNode_1304.aNode_1303 = aNode_1303; - aNode_1303.aNode_1304 = aNode_1304; - aNode_1303 = null; - aNode_1304 = null; - } - } - -} diff --git a/src/main/java/Draw2D.java b/src/main/java/Draw2D.java index 394207e..61424fc 100644 --- a/src/main/java/Draw2D.java +++ b/src/main/java/Draw2D.java @@ -1,6 +1,6 @@ import java.util.Arrays; -public class Draw2D extends DoublyLinkedListNode { +public class Draw2D extends DoublyLinkedList.Node { public static int[] pixels; public static int width; diff --git a/src/main/java/Entity.java b/src/main/java/Entity.java index ec23c91..6fef21d 100644 --- a/src/main/java/Entity.java +++ b/src/main/java/Entity.java @@ -1,4 +1,4 @@ -public class Entity extends DoublyLinkedListNode { +public class Entity extends DoublyLinkedList.Node { public VertexNormal[] vertexNormal; public int minY = 1000; diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 9b9ed17..ade4e19 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -58,7 +58,7 @@ public class Game extends GameShell { public long sceneLoadStartTime; public int[][] anIntArrayArray825 = new int[104][104]; public int[] anIntArray826 = new int[200]; - public LinkedList[][][] aListArrayArrayArray827 = new LinkedList[4][104][104]; + public DoublyLinkedList[][][] aListArrayArrayArray827 = new DoublyLinkedList[4][104][104]; public int[] anIntArray828; public int[] anIntArray829; public volatile boolean aBoolean831 = false; @@ -210,7 +210,7 @@ public class Game extends GameShell { public int anInt1009; public int anInt1010; public int anInt1011; - public LinkedList aList_1013 = new LinkedList(); + public DoublyLinkedList aList_1013 = new DoublyLinkedList(); public int anInt1014; public int anInt1015; public int anInt1016; @@ -247,7 +247,7 @@ public class Game extends GameShell { public FileArchive archiveTitle; public int anInt1054 = -1; public int anInt1055; - public LinkedList aList_1056 = new LinkedList(); + public DoublyLinkedList aList_1056 = new DoublyLinkedList(); public final int[] anIntArray1057 = new int[33]; public final Component aComponent_1059 = new Component(); public Image8[] imageMapscene = new Image8[100]; @@ -347,7 +347,7 @@ public class Game extends GameShell { public String aString1174 = ""; public boolean errInvalidHost = false; public int anInt1178 = -1; - public LinkedList listTemporaryLocs = new LinkedList(); + public DoublyLinkedList listTemporaryLocs = new DoublyLinkedList(); public int[] anIntArray1180; public int[] anIntArray1181; public int[] anIntArray1182; @@ -1606,8 +1606,8 @@ public class Game extends GameShell { public void method22() { try { anInt985 = -1; - aList_1056.method256(); - aList_1013.method256(); + aList_1056.clear(); + aList_1013.clear(); Draw3D.disposePool(); method23(); scene.method274(); @@ -1728,7 +1728,7 @@ public class Game extends GameShell { method63(); } catch (Exception ignored) { } - LocType.aCache_785.method224(); + LocType.aCache_785.clear(); if (super.frame != null) { aBuffer_1192.putOp(210); aBuffer_1192.put4(0x3f008edd); @@ -1776,13 +1776,13 @@ public class Game extends GameShell { } public void method23() { - LocType.aCache_785.method224(); - LocType.aCache_780.method224(); - NPCType.aCache_95.method224(); - ObjType.aCache_159.method224(); - ObjType.aCache_158.method224(); - PlayerEntity.modelCache.method224(); - SpotAnimType.modelCache.method224(); + LocType.aCache_785.clear(); + LocType.aCache_780.clear(); + NPCType.aCache_95.clear(); + ObjType.aCache_159.clear(); + ObjType.aCache_158.clear(); + PlayerEntity.modelCache.clear(); + SpotAnimType.modelCache.clear(); } public void method24(int i) { @@ -1858,14 +1858,14 @@ public class Game extends GameShell { } public void method25(int i, int j) { - LinkedList list = aListArrayArrayArray827[anInt918][i][j]; + DoublyLinkedList list = aListArrayArrayArray827[anInt918][i][j]; if (list == null) { scene.method295(anInt918, i, j); return; } int k = 0xfa0a1f01; ObjStackEntity obj = null; - for (ObjStackEntity objStack = (ObjStackEntity) list.method252(); objStack != null; objStack = (ObjStackEntity) list.method254()) { + for (ObjStackEntity objStack = (ObjStackEntity) list.peekFront(); objStack != null; objStack = (ObjStackEntity) list.prev()) { ObjType type = ObjType.method198(objStack.anInt1558); int l = type.anInt155; if (type.aBoolean176) { @@ -1876,10 +1876,10 @@ public class Game extends GameShell { obj = objStack; } } - list.method250(obj); + list.pushFront(obj); ObjStackEntity obj1 = null; Entity obj2 = null; - for (ObjStackEntity objStack_1 = (ObjStackEntity) list.method252(); objStack_1 != null; objStack_1 = (ObjStackEntity) list.method254()) { + for (ObjStackEntity objStack_1 = (ObjStackEntity) list.peekFront(); objStack_1 != null; objStack_1 = (ObjStackEntity) list.prev()) { if ((objStack_1.anInt1558 != obj.anInt1558) && (obj1 == null)) { obj1 = objStack_1; } @@ -2250,7 +2250,7 @@ public class Game extends GameShell { if (k == 4) { Draw3D.setBrightness(0.59999999999999998D); } - ObjType.aCache_158.method224(); + ObjType.aCache_158.clear(); aBoolean1255 = true; } if (j == 3) { @@ -3335,9 +3335,9 @@ public class Game extends GameShell { } public void method55() { - for (ProjectileEntity projectile = (ProjectileEntity) aList_1013.method252(); projectile != null; projectile = (ProjectileEntity) aList_1013.method254()) { + for (ProjectileEntity projectile = (ProjectileEntity) aList_1013.peekFront(); projectile != null; projectile = (ProjectileEntity) aList_1013.prev()) { if ((projectile.anInt1597 != anInt918) || (loopCycle > projectile.anInt1572)) { - projectile.method329(); + projectile.unlink(); } else if (loopCycle >= projectile.anInt1571) { if (projectile.anInt1590 > 0) { NPCEntity npc = npcs[projectile.anInt1590 - 1]; @@ -3839,13 +3839,13 @@ public class Game extends GameShell { } public void method63() { - SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.method252(); - for (; loc != null; loc = (SceneLocTemporary) listTemporaryLocs.method254()) { + SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.peekFront(); + for (; loc != null; loc = (SceneLocTemporary) listTemporaryLocs.prev()) { if (loc.anInt1294 == -1) { loc.anInt1302 = 0; method89(loc); } else { - loc.method329(); + loc.unlink(); } } } @@ -4999,9 +4999,9 @@ public class Game extends GameShell { method88(i1, l1, player, j1); } if (k1 == 3) { - LinkedList list = aListArrayArrayArray827[anInt918][i1][j1]; + DoublyLinkedList list = aListArrayArrayArray827[anInt918][i1][j1]; if (list != null) { - for (ObjStackEntity objStack = (ObjStackEntity) list.method253(); objStack != null; objStack = (ObjStackEntity) list.method255()) { + for (ObjStackEntity objStack = (ObjStackEntity) list.peekBack(); objStack != null; objStack = (ObjStackEntity) list.next()) { ObjType type = ObjType.method198(objStack.anInt1558); if (anInt1282 == 1) { aStringArray1199[anInt1133] = "Use " + aString1286 + " with @lre@" + type.aString170; @@ -6064,8 +6064,8 @@ public class Game extends GameShell { npcs[k2] = null; } aPlayer_1126 = players[LOCAL_PLAYER_INDEX] = new PlayerEntity(); - aList_1013.method256(); - aList_1056.method256(); + aList_1013.clear(); + aList_1056.clear(); for (int l2 = 0; l2 < 4; l2++) { for (int i3 = 0; i3 < 104; i3++) { for (int k3 = 0; k3 < 104; k3++) { @@ -6073,7 +6073,7 @@ public class Game extends GameShell { } } } - listTemporaryLocs = new LinkedList(); + listTemporaryLocs = new DoublyLinkedList(); anInt900 = 0; anInt899 = 0; anInt1042 = -1; @@ -7474,14 +7474,14 @@ public class Game extends GameShell { } public void method104() { - SpotAnimEntity spotAnim = (SpotAnimEntity) aList_1056.method252(); - for (; spotAnim != null; spotAnim = (SpotAnimEntity) aList_1056.method254()) { + SpotAnimEntity spotAnim = (SpotAnimEntity) aList_1056.peekFront(); + for (; spotAnim != null; spotAnim = (SpotAnimEntity) aList_1056.prev()) { if ((spotAnim.anInt1560 != anInt918) || spotAnim.aBoolean1567) { - spotAnim.method329(); + spotAnim.unlink(); } else if (loopCycle >= spotAnim.anInt1564) { spotAnim.method454(anInt945); if (spotAnim.aBoolean1567) { - spotAnim.method329(); + spotAnim.unlink(); } else { scene.method285(spotAnim.anInt1560, 0, spotAnim.anInt1563, -1, spotAnim.anInt1562, 60, spotAnim.anInt1561, spotAnim, false); } @@ -8136,14 +8136,14 @@ public class Game extends GameShell { public void method115() { if (sceneState == 2) { - for (SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.method252(); loc != null; loc = (SceneLocTemporary) listTemporaryLocs.method254()) { + for (SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.peekFront(); loc != null; loc = (SceneLocTemporary) listTemporaryLocs.prev()) { if (loc.anInt1294 > 0) { loc.anInt1294--; } if (loc.anInt1294 == 0) { if ((loc.anInt1299 < 0) || SceneBuilder.method178(loc.anInt1299, loc.anInt1301)) { method142(loc.sceneTileZ, loc.anInt1295, loc.anInt1300, loc.anInt1301, loc.sceneTileX, loc.anInt1296, loc.anInt1299); - loc.method329(); + loc.unlink(); } } else { if (loc.anInt1302 > 0) { @@ -8153,9 +8153,9 @@ public class Game extends GameShell { method142(loc.sceneTileZ, loc.anInt1295, loc.anInt1292, loc.anInt1293, loc.sceneTileX, loc.anInt1296, loc.anInt1291); loc.anInt1302 = -1; if ((loc.anInt1291 == loc.anInt1299) && (loc.anInt1299 == -1)) { - loc.method329(); + loc.unlink(); } else if ((loc.anInt1291 == loc.anInt1299) && (loc.anInt1292 == loc.anInt1300) && (loc.anInt1293 == loc.anInt1301)) { - loc.method329(); + loc.unlink(); } } } @@ -8631,7 +8631,7 @@ public class Game extends GameShell { } for (int k5 = 0; k5 < 104; k5++) { for (int l5 = 0; l5 < 104; l5++) { - LinkedList list = aListArrayArrayArray827[anInt918][k5][l5]; + DoublyLinkedList list = aListArrayArrayArray827[anInt918][k5][l5]; if (list != null) { int l = ((k5 * 4) + 2) - (aPlayer_1126.x / 32); int j3 = ((l5 * 4) + 2) - (aPlayer_1126.z / 32); @@ -8797,7 +8797,7 @@ public class Game extends GameShell { public void method130(int j, int k, int l, int i1, int j1, int k1, int l1, int i2, int j2) { SceneLocTemporary loc = null; - for (SceneLocTemporary loc_1 = (SceneLocTemporary) listTemporaryLocs.method252(); loc_1 != null; loc_1 = (SceneLocTemporary) listTemporaryLocs.method254()) { + for (SceneLocTemporary loc_1 = (SceneLocTemporary) listTemporaryLocs.peekFront(); loc_1 != null; loc_1 = (SceneLocTemporary) listTemporaryLocs.prev()) { if ((loc_1.anInt1295 != l1) || (loc_1.sceneTileX != i2) || (loc_1.sceneTileZ != j1) || (loc_1.anInt1296 != i1)) { continue; } @@ -8811,7 +8811,7 @@ public class Game extends GameShell { loc.sceneTileX = i2; loc.sceneTileZ = j1; method89(loc); - listTemporaryLocs.method249(loc); + listTemporaryLocs.pushBack(loc); } loc.anInt1291 = k; loc.anInt1293 = k1; @@ -9110,9 +9110,9 @@ public class Game extends GameShell { int k11 = buffer.get2U(); int l13 = buffer.get2U(); if ((j3 >= 0) && (i6 >= 0) && (j3 < 104) && (i6 < 104)) { - LinkedList list_1 = aListArrayArrayArray827[anInt918][j3][i6]; + DoublyLinkedList list_1 = aListArrayArrayArray827[anInt918][j3][i6]; if (list_1 != null) { - for (ObjStackEntity objStack_3 = (ObjStackEntity) list_1.method252(); objStack_3 != null; objStack_3 = (ObjStackEntity) list_1.method254()) { + for (ObjStackEntity objStack_3 = (ObjStackEntity) list_1.peekFront(); objStack_3 != null; objStack_3 = (ObjStackEntity) list_1.prev()) { if ((objStack_3.anInt1558 != (l8 & 0x7fff)) || (objStack_3.anInt1559 != k11)) { continue; } @@ -9151,9 +9151,9 @@ public class Game extends GameShell { class30_sub2_sub4_sub2_2.anInt1558 = i1; class30_sub2_sub4_sub2_2.anInt1559 = j14; if (aListArrayArrayArray827[anInt918][k6][j9] == null) { - aListArrayArrayArray827[anInt918][k6][j9] = new LinkedList(); + aListArrayArrayArray827[anInt918][k6][j9] = new DoublyLinkedList(); } - aListArrayArrayArray827[anInt918][k6][j9].method249(class30_sub2_sub4_sub2_2); + aListArrayArrayArray827[anInt918][k6][j9].pushBack(class30_sub2_sub4_sub2_2); method25(k6, j9); } return; @@ -9164,16 +9164,16 @@ public class Game extends GameShell { int l6 = anInt1269 + (j1 & 7); int k9 = buffer.get2U(); if ((i4 >= 0) && (l6 >= 0) && (i4 < 104) && (l6 < 104)) { - LinkedList list = aListArrayArrayArray827[anInt918][i4][l6]; + DoublyLinkedList list = aListArrayArrayArray827[anInt918][i4][l6]; if (list != null) { - for (ObjStackEntity objStack = (ObjStackEntity) list.method252(); objStack != null; objStack = (ObjStackEntity) list.method254()) { + for (ObjStackEntity objStack = (ObjStackEntity) list.peekFront(); objStack != null; objStack = (ObjStackEntity) list.prev()) { if (objStack.anInt1558 != (k9 & 0x7fff)) { continue; } - objStack.method329(); + objStack.unlink(); break; } - if (list.method252() == null) { + if (list.peekFront() == null) { aListArrayArrayArray827[anInt918][i4][l6] = null; } method25(i4, l6); @@ -9316,7 +9316,7 @@ public class Game extends GameShell { i5 = (i5 * 128) + 64; l7 = (l7 * 128) + 64; SpotAnimEntity spotAnim = new SpotAnimEntity(anInt918, loopCycle, j15, k10, method42(anInt918, l7, i5) - l12, l7, i5); - aList_1056.method249(spotAnim); + aList_1056.pushBack(spotAnim); } return; } @@ -9331,9 +9331,9 @@ public class Game extends GameShell { objStack_1.anInt1558 = k2; objStack_1.anInt1559 = j5; if (aListArrayArrayArray827[anInt918][l10][i13] == null) { - aListArrayArrayArray827[anInt918][l10][i13] = new LinkedList(); + aListArrayArrayArray827[anInt918][l10][i13] = new DoublyLinkedList(); } - aListArrayArrayArray827[anInt918][l10][i13].method249(objStack_1); + aListArrayArrayArray827[anInt918][l10][i13].pushBack(objStack_1); method25(l10, i13); } return; @@ -9372,7 +9372,7 @@ public class Game extends GameShell { k13 = (k13 * 128) + 64; ProjectileEntity projectile = new ProjectileEntity(i21, l18, k19 + loopCycle, j20 + loopCycle, j21, anInt918, method42(anInt918, k8, l5) - i18, k8, l5, l15, i17); projectile.method455(k19 + loopCycle, k13, method42(anInt918, k13, j11) - l18, j11); - aList_1013.method249(projectile); + aList_1013.pushBack(projectile); } } } @@ -9758,7 +9758,7 @@ public class Game extends GameShell { } } } - for (SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.method252(); loc != null; loc = (SceneLocTemporary) listTemporaryLocs.method254()) { + for (SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.peekFront(); loc != null; loc = (SceneLocTemporary) listTemporaryLocs.prev()) { if ((loc.sceneTileX >= anInt1268) && (loc.sceneTileX < (anInt1268 + 8)) && (loc.sceneTileZ >= anInt1269) && (loc.sceneTileZ < (anInt1269 + 8)) && (loc.anInt1295 == anInt918)) { loc.anInt1294 = 0; } @@ -10109,11 +10109,11 @@ public class Game extends GameShell { } } - for (SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.method252(); loc != null; loc = (SceneLocTemporary) listTemporaryLocs.method254()) { + for (SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.peekFront(); loc != null; loc = (SceneLocTemporary) listTemporaryLocs.prev()) { loc.sceneTileX -= dtx; loc.sceneTileZ -= dtz; if ((loc.sceneTileX < 0) || (loc.sceneTileZ < 0) || (loc.sceneTileX >= 104) || (loc.sceneTileZ >= 104)) { - loc.method329(); + loc.unlink(); } } diff --git a/src/main/java/Hashtable.java b/src/main/java/Hashtable.java deleted file mode 100644 index 3bf8ee8..0000000 --- a/src/main/java/Hashtable.java +++ /dev/null @@ -1,42 +0,0 @@ -// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) - -public class Hashtable { - - public final int anInt39; - public final LinkedListNode[] aNodeArray40; - - public Hashtable(int j) { - anInt39 = j; - aNodeArray40 = new LinkedListNode[j]; - for (int k = 0; k < j; k++) { - LinkedListNode node = aNodeArray40[k] = new LinkedListNode(); - node.aNode_549 = node; - node.aNode_550 = node; - } - } - - public LinkedListNode method148(long l) { - LinkedListNode node = aNodeArray40[(int) (l & (long) (anInt39 - 1))]; - for (LinkedListNode node_1 = node.aNode_549; node_1 != node; node_1 = node_1.aNode_549) { - if (node_1.aLong548 == l) { - return node_1; - } - } - return null; - } - - public void method149(LinkedListNode node, long l) { - if (node.aNode_550 != null) { - node.method329(); - } - LinkedListNode node_1 = aNodeArray40[(int) (l & (long) (anInt39 - 1))]; - node.aNode_550 = node_1.aNode_550; - node.aNode_549 = node_1; - node.aNode_550.aNode_549 = node; - node.aNode_549.aNode_550 = node; - node.aLong548 = l; - } - -} diff --git a/src/main/java/LRUCache.java b/src/main/java/LRUCache.java index 1ee0b8c..e46e1a3 100644 --- a/src/main/java/LRUCache.java +++ b/src/main/java/LRUCache.java @@ -1,61 +1,31 @@ -// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) +import java.util.Iterator; +import java.util.LinkedHashMap; -public class LRUCache { +public class LRUCache { - public int anInt298; - public int anInt299; - public final DoublyLinkedListNode aNode_300 = new DoublyLinkedListNode(); - public final int anInt301; - public int anInt302; - public final Hashtable aHashtable_303 = new Hashtable(1024); - public final DoublyLinkedList aDoublyLinkedList_304 = new DoublyLinkedList(); + private final int capacity; + private final LinkedHashMap map; - public LRUCache(int i) { - anInt301 = i; - anInt302 = i; + public LRUCache(int capacity) { + this.capacity = capacity; + this.map = new LinkedHashMap<>(capacity); } - public DoublyLinkedListNode method222(long l) { - DoublyLinkedListNode node = (DoublyLinkedListNode) aHashtable_303.method148(l); - if (node != null) { - aDoublyLinkedList_304.method150(node); - anInt299++; - } else { - anInt298++; + public T get(long key) { + return map.get(key); + } + + public void put(long key, T value) { + if (map.containsKey(key) && map.size() == capacity) { + Iterator iter = map.keySet().iterator(); + iter.next(); + iter.remove(); } - return node; + map.put(key, value); } - public void method223(DoublyLinkedListNode node, long l) { - if (anInt302 == 0) { - DoublyLinkedListNode node_1 = aDoublyLinkedList_304.method151(); - node_1.method329(); - node_1.method330(); - if (node_1 == aNode_300) { - DoublyLinkedListNode node_2 = aDoublyLinkedList_304.method151(); - node_2.method329(); - node_2.method330(); - } - } else { - anInt302--; - } - aHashtable_303.method149(node, l); - aDoublyLinkedList_304.method150(node); - } - - public void method224() { - do { - DoublyLinkedListNode node = aDoublyLinkedList_304.method151(); - if (node != null) { - node.method329(); - node.method330(); - } else { - anInt302 = anInt301; - return; - } - } while (true); + public void clear() { + map.clear(); } } diff --git a/src/main/java/LinkedList.java b/src/main/java/LinkedList.java deleted file mode 100644 index b95f203..0000000 --- a/src/main/java/LinkedList.java +++ /dev/null @@ -1,102 +0,0 @@ -// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) - -public class LinkedList { - - public final LinkedListNode aNode_346; - public LinkedListNode aNode_347; - - public LinkedList() { - aNode_346 = new LinkedListNode(); - aNode_346.aNode_549 = aNode_346; - aNode_346.aNode_550 = aNode_346; - } - - public void method249(LinkedListNode node) { - if (node.aNode_550 != null) { - node.method329(); - } - node.aNode_550 = aNode_346.aNode_550; - node.aNode_549 = aNode_346; - node.aNode_550.aNode_549 = node; - node.aNode_549.aNode_550 = node; - } - - public void method250(LinkedListNode node) { - if (node.aNode_550 != null) { - node.method329(); - } - node.aNode_550 = aNode_346; - node.aNode_549 = aNode_346.aNode_549; - node.aNode_550.aNode_549 = node; - node.aNode_549.aNode_550 = node; - } - - public LinkedListNode method251() { - LinkedListNode node = aNode_346.aNode_549; - if (node == aNode_346) { - return null; - } else { - node.method329(); - return node; - } - } - - public LinkedListNode method252() { - LinkedListNode node = aNode_346.aNode_549; - if (node == aNode_346) { - aNode_347 = null; - return null; - } else { - aNode_347 = node.aNode_549; - return node; - } - } - - public LinkedListNode method253() { - LinkedListNode node = aNode_346.aNode_550; - if (node == aNode_346) { - aNode_347 = null; - return null; - } else { - aNode_347 = node.aNode_550; - return node; - } - } - - public LinkedListNode method254() { - LinkedListNode node = aNode_347; - if (node == aNode_346) { - aNode_347 = null; - return null; - } else { - aNode_347 = node.aNode_549; - return node; - } - } - - public LinkedListNode method255() { - LinkedListNode node = aNode_347; - if (node == aNode_346) { - aNode_347 = null; - return null; - } - aNode_347 = node.aNode_550; - return node; - } - - public void method256() { - if (aNode_346.aNode_549 == aNode_346) { - return; - } - do { - LinkedListNode node = aNode_346.aNode_549; - if (node == aNode_346) { - return; - } - node.method329(); - } while (true); - } - -} diff --git a/src/main/java/LinkedListNode.java b/src/main/java/LinkedListNode.java deleted file mode 100644 index c5f9e2f..0000000 --- a/src/main/java/LinkedListNode.java +++ /dev/null @@ -1,23 +0,0 @@ -// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) - -public class LinkedListNode { - - public long aLong548; - public LinkedListNode aNode_549; - public LinkedListNode aNode_550; - - public LinkedListNode() { - } - - public void method329() { - if (aNode_550 != null) { - aNode_550.aNode_549 = aNode_549; - aNode_549.aNode_550 = aNode_550; - aNode_549 = null; - aNode_550 = null; - } - } - -} diff --git a/src/main/java/LocType.java b/src/main/java/LocType.java index 25ccac5..1b2f43a 100644 --- a/src/main/java/LocType.java +++ b/src/main/java/LocType.java @@ -226,7 +226,7 @@ public class LocType { return null; } l1 = (long) (((long) anInt754 << 6) + l) + ((long) (k + 1) << 32); - Model model_1 = (Model) aCache_780.method222(l1); + Model model_1 = (Model) aCache_780.get(l1); if (model_1 != null) { return model_1; } @@ -240,7 +240,7 @@ public class LocType { if (flag1) { l2 += 0x10000; } - model = (Model) aCache_785.method222(l2); + model = (Model) aCache_785.get(l2); if (model == null) { model = Model.tryGet(l2 & 0xffff); if (model == null) { @@ -249,7 +249,7 @@ public class LocType { if (flag1) { model.rotateY180(); } - aCache_785.method223(model, l2); + aCache_785.put(l2, model); } if (k1 > 1) { A_MODEL_ARRAY_741[i2] = model; @@ -271,7 +271,7 @@ public class LocType { return null; } l1 = (long) (((long) anInt754 << 6) + ((long) i1 << 3) + l) + ((long) (k + 1) << 32); - Model class30_sub2_sub4_sub6_2 = (Model) aCache_780.method222(l1); + Model class30_sub2_sub4_sub6_2 = (Model) aCache_780.get(l1); if (class30_sub2_sub4_sub6_2 != null) { return class30_sub2_sub4_sub6_2; } @@ -280,7 +280,7 @@ public class LocType { if (flag3) { j2 += 0x10000; } - model = (Model) aCache_785.method222(j2); + model = (Model) aCache_785.get(j2); if (model == null) { model = Model.tryGet(j2 & 0xffff); if (model == null) { @@ -289,7 +289,7 @@ public class LocType { if (flag3) { model.rotateY180(); } - aCache_785.method223(model, j2); + aCache_785.put(j2, model); } } boolean flag; @@ -321,7 +321,7 @@ public class LocType { if (anInt760 == 1) { model_3.anInt1654 = model_3.minY; } - aCache_780.method223(model_3, l1); + aCache_780.put(l1, model_3); return model_3; } diff --git a/src/main/java/NPCType.java b/src/main/java/NPCType.java index e790759..788d8f8 100644 --- a/src/main/java/NPCType.java +++ b/src/main/java/NPCType.java @@ -153,7 +153,7 @@ public class NPCType { return type.method164(j, k, ai); } } - Model model = (Model) aCache_95.method222(aLong78); + Model model = (Model) aCache_95.get(aLong78); if (model == null) { boolean flag = false; for (int value : anIntArray94) { @@ -180,7 +180,7 @@ public class NPCType { } model.createLabelReferences(); model.calculateNormals(64 + anInt85, 850 + anInt92, -30, -50, -30, true); - aCache_95.method223(model, aLong78); + aCache_95.put(aLong78, model); } Model model_1 = Model.EMPTY; model_1.set(model, SeqFrame.isNull(k) & SeqFrame.isNull(j)); diff --git a/src/main/java/ObjType.java b/src/main/java/ObjType.java index 53280d5..0744596 100644 --- a/src/main/java/ObjType.java +++ b/src/main/java/ObjType.java @@ -107,9 +107,9 @@ public class ObjType { public static Image24 method200(int i, int j, int k) { if (k == 0) { - Image24 image = (Image24) aCache_158.method222(i); + Image24 image = (Image24) aCache_158.get(i); if ((image != null) && (image.anInt1445 != j) && (image.anInt1445 != -1)) { - image.method329(); + image.unlink(); image = null; } if (image != null) { @@ -217,7 +217,7 @@ public class ObjType { class30_sub2_sub1_sub1_2.anInt1445 = j6; } if (k == 0) { - aCache_158.method223(class30_sub2_sub1_sub1_1, i); + aCache_158.put(i, class30_sub2_sub1_sub1_1); } Draw2D.bind(ai1, i2, j2); Draw2D.setBounds(j3, k2, l2, i3); @@ -420,7 +420,7 @@ public class ObjType { return method198(j).method201(1); } } - Model model = (Model) aCache_159.method222(anInt157); + Model model = (Model) aCache_159.get(anInt157); if (model != null) { return model; } @@ -438,7 +438,7 @@ public class ObjType { } model.calculateNormals(64 + anInt196, 768 + anInt184, -50, -10, -50, true); model.pickBounds = true; - aCache_159.method223(model, anInt157); + aCache_159.put(anInt157, model); return model; } diff --git a/src/main/java/OnDemand.java b/src/main/java/OnDemand.java index f1b352b..d97811c 100644 --- a/src/main/java/OnDemand.java +++ b/src/main/java/OnDemand.java @@ -7,23 +7,25 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; +import java.util.LinkedList; import java.util.zip.CRC32; import java.util.zip.GZIPInputStream; public class OnDemand implements Runnable { - public final LinkedList aList_1331 = new LinkedList(); + public final DoublyLinkedList aList_1331 = new DoublyLinkedList(); public final CRC32 crc32 = new CRC32(); public final byte[] aByteArray1339 = new byte[500]; public final byte[][] storeFilePriority = new byte[4][]; - public final LinkedList aList_1344 = new LinkedList(); - public final LinkedList aList_1358 = new LinkedList(); + public final DoublyLinkedList aList_1344 = new DoublyLinkedList(); + public final DoublyLinkedList aList_1358 = new DoublyLinkedList(); public final byte[] aByteArray1359 = new byte[65000]; - public final DoublyLinkedList aDoublyLinkedList_1361 = new DoublyLinkedList(); + private final Object lock = new Object(); + private final LinkedList requests = new LinkedList<>(); public final int[][] storeFileVersions = new int[4][]; public final int[][] storeFileChecksums = new int[4][]; - public final LinkedList aList_1368 = new LinkedList(); - public final LinkedList aList_1370 = new LinkedList(); + public final DoublyLinkedList aList_1368 = new DoublyLinkedList(); + public final DoublyLinkedList aList_1370 = new DoublyLinkedList(); public int anInt1330; public int topPriority; public String aString1333 = ""; @@ -82,7 +84,7 @@ public class OnDemand implements Runnable { int l1 = ((aByteArray1339[3] & 0xff) << 8) + (aByteArray1339[4] & 0xff); int i2 = aByteArray1339[5] & 0xff; aRequest_1369 = null; - for (OnDemandRequest request = (OnDemandRequest) aList_1331.method252(); request != null; request = (OnDemandRequest) aList_1331.method254()) { + for (OnDemandRequest request = (OnDemandRequest) aList_1331.peekFront(); request != null; request = (OnDemandRequest) aList_1331.prev()) { if ((request.store == l) && (request.file == j1)) { aRequest_1369 = request; } @@ -97,10 +99,10 @@ public class OnDemand implements Runnable { aRequest_1369.data = null; if (aRequest_1369.aBoolean1422) { synchronized (aList_1358) { - aList_1358.method249(aRequest_1369); + aList_1358.pushBack(aRequest_1369); } } else { - aRequest_1369.method329(); + aRequest_1369.unlink(); } aRequest_1369 = null; } else { @@ -138,10 +140,10 @@ public class OnDemand implements Runnable { } if (aRequest_1369.aBoolean1422) { synchronized (aList_1358) { - aList_1358.method249(aRequest_1369); + aList_1358.pushBack(aRequest_1369); } } else { - aRequest_1369.method329(); + aRequest_1369.unlink(); } } anInt1347 = 0; @@ -240,8 +242,8 @@ public class OnDemand implements Runnable { } public int remaining() { - synchronized (aDoublyLinkedList_1361) { - return aDoublyLinkedList_1361.method154(); + synchronized (lock) { + return requests.size(); } } @@ -318,9 +320,10 @@ public class OnDemand implements Runnable { if (storeFileVersions[archive][file] == 0) { return; } - synchronized (aDoublyLinkedList_1361) { - for (OnDemandRequest request = (OnDemandRequest) aDoublyLinkedList_1361.method152(); request != null; request = (OnDemandRequest) aDoublyLinkedList_1361.method153()) { - if ((request.store == archive) && (request.file == file)) { + + synchronized (lock) { + for (OnDemandRequest request : requests) { + if (request.store == archive && request.file == file) { return; } } @@ -329,9 +332,9 @@ public class OnDemand implements Runnable { request.file = file; request.aBoolean1422 = true; synchronized (aList_1370) { - aList_1370.method249(request); + aList_1370.pushBack(request); } - aDoublyLinkedList_1361.method150(request); + requests.addFirst(request); } } @@ -369,7 +372,7 @@ public class OnDemand implements Runnable { } } boolean flag = false; - for (OnDemandRequest request = (OnDemandRequest) aList_1331.method252(); request != null; request = (OnDemandRequest) aList_1331.method254()) { + for (OnDemandRequest request = (OnDemandRequest) aList_1331.peekFront(); request != null; request = (OnDemandRequest) aList_1331.prev()) { if (request.aBoolean1422) { flag = true; request.anInt1423++; @@ -380,7 +383,7 @@ public class OnDemand implements Runnable { } } if (!flag) { - for (OnDemandRequest request_1 = (OnDemandRequest) aList_1331.method252(); request_1 != null; request_1 = (OnDemandRequest) aList_1331.method254()) { + for (OnDemandRequest request_1 = (OnDemandRequest) aList_1331.peekFront(); request_1 != null; request_1 = (OnDemandRequest) aList_1331.prev()) { flag = true; request_1.anInt1423++; if (request_1.anInt1423 > 50) { @@ -444,20 +447,20 @@ public class OnDemand implements Runnable { request.file = i; request.aBoolean1422 = false; synchronized (aList_1344) { - aList_1344.method249(request); + aList_1344.pushBack(request); } } public OnDemandRequest poll() { OnDemandRequest request; synchronized (aList_1358) { - request = (OnDemandRequest) aList_1358.method251(); + request = (OnDemandRequest) aList_1358.pollFront(); } if (request == null) { return null; } - synchronized (aDoublyLinkedList_1361) { - request.method330(); + synchronized(lock) { + requests.remove(request); } if (request.data == null) { return request; @@ -538,7 +541,7 @@ public class OnDemand implements Runnable { public void method565() { anInt1366 = 0; anInt1367 = 0; - for (OnDemandRequest request = (OnDemandRequest) aList_1331.method252(); request != null; request = (OnDemandRequest) aList_1331.method254()) { + for (OnDemandRequest request = (OnDemandRequest) aList_1331.peekFront(); request != null; request = (OnDemandRequest) aList_1331.prev()) { if (request.aBoolean1422) { anInt1366++; } else { @@ -546,7 +549,7 @@ public class OnDemand implements Runnable { } } while (anInt1366 < 10) { - OnDemandRequest request_1 = (OnDemandRequest) aList_1368.method251(); + OnDemandRequest request_1 = (OnDemandRequest) aList_1368.pollFront(); if (request_1 == null) { break; } @@ -554,7 +557,7 @@ public class OnDemand implements Runnable { anInt1351++; } storeFilePriority[request_1.store][request_1.file] = 0; - aList_1331.method249(request_1); + aList_1331.pushBack(request_1); anInt1366++; method556(request_1); aBoolean1357 = true; @@ -563,14 +566,14 @@ public class OnDemand implements Runnable { public void method566() { synchronized (aList_1344) { - aList_1344.method256(); + aList_1344.clear(); } } public void method567() { OnDemandRequest request; synchronized (aList_1370) { - request = (OnDemandRequest) aList_1370.method251(); + request = (OnDemandRequest) aList_1370.pollFront(); } while (request != null) { aBoolean1357 = true; @@ -583,14 +586,14 @@ public class OnDemand implements Runnable { } synchronized (aList_1370) { if (abyte0 == null) { - aList_1368.method249(request); + aList_1368.pushBack(request); } else { request.data = abyte0; synchronized (aList_1358) { - aList_1358.method249(request); + aList_1358.pushBack(request); } } - request = (OnDemandRequest) aList_1370.method251(); + request = (OnDemandRequest) aList_1370.pollFront(); } } } @@ -602,12 +605,12 @@ public class OnDemand implements Runnable { } OnDemandRequest request; synchronized (aList_1344) { - request = (OnDemandRequest) aList_1344.method251(); + request = (OnDemandRequest) aList_1344.pollFront(); } while (request != null) { if (storeFilePriority[request.store][request.file] != 0) { storeFilePriority[request.store][request.file] = 0; - aList_1331.method249(request); + aList_1331.pushBack(request); method556(request); aBoolean1357 = true; if (anInt1351 < anInt1330) { @@ -620,7 +623,7 @@ public class OnDemand implements Runnable { } } synchronized (aList_1344) { - request = (OnDemandRequest) aList_1344.method251(); + request = (OnDemandRequest) aList_1344.pollFront(); } } for (int j = 0; j < 4; j++) { @@ -633,7 +636,7 @@ public class OnDemand implements Runnable { request_1.store = j; request_1.file = l; request_1.aBoolean1422 = false; - aList_1331.method249(request_1); + aList_1331.pushBack(request_1); method556(request_1); aBoolean1357 = true; if (anInt1351 < anInt1330) { diff --git a/src/main/java/OnDemandRequest.java b/src/main/java/OnDemandRequest.java index d6cd2c1..0c132a0 100644 --- a/src/main/java/OnDemandRequest.java +++ b/src/main/java/OnDemandRequest.java @@ -2,7 +2,7 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) -public class OnDemandRequest extends DoublyLinkedListNode { +public class OnDemandRequest extends DoublyLinkedList.Node { public int store; public byte[] data; diff --git a/src/main/java/PlayerEntity.java b/src/main/java/PlayerEntity.java index e40d481..b20a506 100644 --- a/src/main/java/PlayerEntity.java +++ b/src/main/java/PlayerEntity.java @@ -218,7 +218,7 @@ public class PlayerEntity extends PathingEntity { } else if (super.anInt1517 >= 0) { k = SeqType.instances[super.anInt1517].anIntArray353[super.anInt1518]; } - Model model_1 = (Model) modelCache.method222(l); + Model model_1 = (Model) modelCache.get(l); if (model_1 == null) { boolean flag = false; for (int i2 = 0; i2 < 12; i2++) { @@ -238,7 +238,7 @@ public class PlayerEntity extends PathingEntity { } if (flag) { if (aLong1697 != -1L) { - model_1 = (Model) modelCache.method222(aLong1697); + model_1 = (Model) modelCache.get(aLong1697); } if (model_1 == null) { return null; @@ -280,7 +280,7 @@ public class PlayerEntity extends PathingEntity { } model_1.createLabelReferences(); model_1.calculateNormals(64, 850, -30, -50, -30, true); - modelCache.method223(model_1, l); + modelCache.put(l, model_1); aLong1697 = l; } if (aBoolean1699) { diff --git a/src/main/java/Scene.java b/src/main/java/Scene.java index cb922ad..4bf5d36 100644 --- a/src/main/java/Scene.java +++ b/src/main/java/Scene.java @@ -46,7 +46,7 @@ public class Scene { public static SceneOccluder[][] aOccluderArrayArray474 = new SceneOccluder[anInt472][500]; public static int anInt475; public static final SceneOccluder[] A_OCCLUDER_ARRAY_476 = new SceneOccluder[500]; - public static LinkedList aList_477 = new LinkedList(); + public static DoublyLinkedList aList_477 = new DoublyLinkedList(); public static boolean[][][][] aBooleanArrayArrayArrayArray491 = new boolean[8][32][51][51]; public static boolean[][] aBooleanArrayArray492; public static int anInt493; @@ -1038,11 +1038,11 @@ public class Scene { } public void method314(SceneTile tile, boolean flag) { - aList_477.method249(tile); + aList_477.pushBack(tile); do { SceneTile tile_1; do { - tile_1 = (SceneTile) aList_477.method251(); + tile_1 = (SceneTile) aList_477.pollFront(); if (tile_1 == null) { return; } @@ -1220,25 +1220,25 @@ public class Scene { if ((i < eyeTileX) && ((k4 & 4) != 0)) { SceneTile tile_17 = aclass30_sub3[i + 1][j]; if ((tile_17 != null) && tile_17.aBoolean1323) { - aList_477.method249(tile_17); + aList_477.pushBack(tile_17); } } if ((j < eyeTileZ) && ((k4 & 2) != 0)) { SceneTile tile_18 = aclass30_sub3[i][j + 1]; if ((tile_18 != null) && tile_18.aBoolean1323) { - aList_477.method249(tile_18); + aList_477.pushBack(tile_18); } } if ((i > eyeTileX) && ((k4 & 1) != 0)) { SceneTile tile_19 = aclass30_sub3[i - 1][j]; if ((tile_19 != null) && tile_19.aBoolean1323) { - aList_477.method249(tile_19); + aList_477.pushBack(tile_19); } } if ((j > eyeTileZ) && ((k4 & 8) != 0)) { SceneTile tile_20 = aclass30_sub3[i][j - 1]; if ((tile_20 != null) && tile_20.aBoolean1323) { - aList_477.method249(tile_20); + aList_477.pushBack(tile_20); } } } @@ -1345,9 +1345,9 @@ public class Scene { for (int l8 = loc_3.anInt525; l8 <= loc_3.anInt526; l8++) { SceneTile tile_22 = aclass30_sub3[k7][l8]; if (tile_22.anInt1325 != 0) { - aList_477.method249(tile_22); + aList_477.pushBack(tile_22); } else if (((k7 != i) || (l8 != j)) && tile_22.aBoolean1323) { - aList_477.method249(tile_22); + aList_477.pushBack(tile_22); } } } @@ -1447,31 +1447,31 @@ public class Scene { if (k < (anInt437 - 1)) { SceneTile tile_12 = aTileArrayArrayArray441[k + 1][i][j]; if ((tile_12 != null) && tile_12.aBoolean1323) { - aList_477.method249(tile_12); + aList_477.pushBack(tile_12); } } if (i < eyeTileX) { SceneTile tile_13 = aclass30_sub3[i + 1][j]; if ((tile_13 != null) && tile_13.aBoolean1323) { - aList_477.method249(tile_13); + aList_477.pushBack(tile_13); } } if (j < eyeTileZ) { SceneTile tile_14 = aclass30_sub3[i][j + 1]; if ((tile_14 != null) && tile_14.aBoolean1323) { - aList_477.method249(tile_14); + aList_477.pushBack(tile_14); } } if (i > eyeTileX) { SceneTile tile_15 = aclass30_sub3[i - 1][j]; if ((tile_15 != null) && tile_15.aBoolean1323) { - aList_477.method249(tile_15); + aList_477.pushBack(tile_15); } } if (j > eyeTileZ) { SceneTile tile_16 = aclass30_sub3[i][j - 1]; if ((tile_16 != null) && tile_16.aBoolean1323) { - aList_477.method249(tile_16); + aList_477.pushBack(tile_16); } } } while (true); diff --git a/src/main/java/SceneLocTemporary.java b/src/main/java/SceneLocTemporary.java index 169de56..bd3e70c 100644 --- a/src/main/java/SceneLocTemporary.java +++ b/src/main/java/SceneLocTemporary.java @@ -2,7 +2,7 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) -public class SceneLocTemporary extends LinkedListNode { +public class SceneLocTemporary extends DoublyLinkedList.Node { public int anInt1291; public int anInt1292; diff --git a/src/main/java/SceneTile.java b/src/main/java/SceneTile.java index 89ec6e2..97e5215 100644 --- a/src/main/java/SceneTile.java +++ b/src/main/java/SceneTile.java @@ -2,7 +2,7 @@ // Jad home page: http://www.kpdus.com/jad.html // Decompiler options: packimports(3) -public class SceneTile extends LinkedListNode { +public class SceneTile extends DoublyLinkedList.Node { public int anInt1307; public final int anInt1308; diff --git a/src/main/java/SoundTrack.java b/src/main/java/SoundTrack.java index 92874e9..8d8de01 100644 --- a/src/main/java/SoundTrack.java +++ b/src/main/java/SoundTrack.java @@ -2,13 +2,13 @@ public class SoundTrack { public static final SoundTrack[] tracks = new SoundTrack[5000]; public static final int[] delays = new int[5000]; - public static byte[] buffer; + public static byte[] bbuf; public static Buffer buffer; public static void method240(Buffer src) { - buffer = new byte[441000]; + bbuf = new byte[441000]; - SoundTrack.buffer = new Buffer(buffer); + SoundTrack.buffer = new Buffer(bbuf); SoundTone.init(); do { @@ -128,7 +128,7 @@ public class SoundTrack { int totalSampleCount = sampleCount + ((loopStop - loopStart) * (loopCount - 1)); for (int sample = 44; sample < (totalSampleCount + 44); sample++) { - buffer[sample] = -128; + bbuf[sample] = -128; } for (int tone = 0; tone < 10; tone++) { @@ -141,7 +141,7 @@ public class SoundTrack { int[] samples = tones[tone].generate(toneSampleCount, tones[tone].length); for (int sample = 0; sample < toneSampleCount; sample++) { - buffer[sample + start + 44] += (byte) (samples[sample] >> 8); + bbuf[sample + start + 44] += (byte) (samples[sample] >> 8); } } @@ -154,14 +154,14 @@ public class SoundTrack { // Moves the end of the sound (after the loops) to the true end of the buffer. int endOffset = (totalSampleCount += 44) - sampleCount; for (int sample = sampleCount - 1; sample >= loopStop; sample--) { - buffer[sample + endOffset] = buffer[sample]; + bbuf[sample + endOffset] = bbuf[sample]; } // Duplicates loop area. for (int loop = 1; loop < loopCount; loop++) { int offset = (loopStop - loopStart) * loop; for (int sample = loopStart; sample < loopStop; sample++) { - buffer[sample + offset] = buffer[sample]; + bbuf[sample + offset] = bbuf[sample]; } } diff --git a/src/main/java/SpotAnimType.java b/src/main/java/SpotAnimType.java index 0bc84af..72c5cd4 100644 --- a/src/main/java/SpotAnimType.java +++ b/src/main/java/SpotAnimType.java @@ -71,7 +71,7 @@ public class SpotAnimType { } public Model method266() { - Model model = (Model) modelCache.method222(anInt404); + Model model = (Model) modelCache.get(anInt404); if (model != null) { return model; } @@ -84,7 +84,7 @@ public class SpotAnimType { model.replaceColor(anIntArray408[i], anIntArray409[i]); } } - modelCache.method223(model, anInt404); + modelCache.put(anInt404, model); return model; }