From 3965827f25944f8716731f84984a7db64dfa0fb9 Mon Sep 17 00:00:00 2001 From: thedaneeffect Date: Tue, 22 Jun 2021 07:09:55 -0400 Subject: [PATCH] Restored Archive validating, misc naming... --- 317.iml | 17 +- src/main/java/Buffer.java | 2 +- src/main/java/ChatCompression.java | 4 +- src/main/java/Component.java | 709 ++++++++++---------- src/main/java/FileArchive.java | 14 + src/main/java/FloType.java | 4 +- src/main/java/Game.java | 906 +++++++++++++------------- src/main/java/LocType.java | 933 ++++++++++++++------------- src/main/java/Model.java | 4 +- src/main/java/NPCEntity.java | 2 +- src/main/java/NPCType.java | 562 ++++++++-------- src/main/java/ObjStackEntity.java | 8 +- src/main/java/ObjType.java | 398 ++++++------ src/main/java/OnDemand.java | 37 +- src/main/java/PlayerEntity.java | 103 +-- src/main/java/Scene.java | 79 ++- src/main/java/SceneBuilder.java | 10 +- src/main/java/SceneCollisionMap.java | 16 +- src/main/java/SceneTileOverlay.java | 16 +- src/main/java/SceneTileUnderlay.java | 4 +- src/main/java/SeqFrame.java | 301 ++++----- src/main/java/SoundEnvelope.java | 18 +- src/main/java/SoundTrack.java | 301 +++++---- src/main/java/SpotAnimType.java | 158 ++--- 24 files changed, 2320 insertions(+), 2286 deletions(-) diff --git a/317.iml b/317.iml index 74f3f13..ff02727 100644 --- a/317.iml +++ b/317.iml @@ -1,2 +1,17 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/Buffer.java b/src/main/java/Buffer.java index 8a69471..fbc8195 100644 --- a/src/main/java/Buffer.java +++ b/src/main/java/Buffer.java @@ -229,7 +229,7 @@ public class Buffer extends DoublyLinkedList.Node { public int get2() { position += 2; int i = ((data[position - 2] & 0xff) << 8) + (data[position - 1] & 0xff); - if (i > 0x7fff) { + if (i > 32767) { i -= 0x10000; } return i; diff --git a/src/main/java/ChatCompression.java b/src/main/java/ChatCompression.java index 047304a..64f28b9 100644 --- a/src/main/java/ChatCompression.java +++ b/src/main/java/ChatCompression.java @@ -9,10 +9,10 @@ public class ChatCompression { // the rest are just 'accepted' values. 'm', 'w', 'c', 'y', 'f', 'g', 'p', 'b', 'v', 'k', 'x', 'j', 'q', 'z', // '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // - ' ', '!', '?', '.', ',', ':', ';', '(', ')', '-', '&', '*', '\\', '\'', '@', '#', '+', '=', '£', '$', '%', '"', '[', ']' // + ' ', '!', '?', '.', ',', ':', ';', '(', ')', '-', '&', '*', '\\', '\'', '@', '#', '+', '=', '\u00A3', '$', '%', '"', '[', ']' // }; - private static final int RANGE = ' ' + '£'; // least significant char + most significant char (in terms of value) + private static final int RANGE = ' ' + '\u00A3'; // least significant char + most significant char (in terms of value) public static String unpack(int expectedLength, Buffer buffer) { int length = 0; diff --git a/src/main/java/Component.java b/src/main/java/Component.java index ef8c937..cd7c7b9 100644 --- a/src/main/java/Component.java +++ b/src/main/java/Component.java @@ -8,367 +8,370 @@ import java.io.IOException; public class Component { - public static final LRUMap modelCache = new LRUMap<>(30); - public static LRUMap imageCache; - public static Component[] instances; + public static final LRUMap modelCache = new LRUMap<>(30); + public static LRUMap imageCache; + public static Component[] instances; - public static void unpack(FileArchive archive, BitmapFont[] aclass30_sub2_sub1_sub4, FileArchive archive_1) throws IOException { - imageCache = new LRUMap<>(500); - Buffer buffer = new Buffer(archive.read("data")); - int parentId = -1; - int j = buffer.get2U(); - instances = new Component[j]; - while (buffer.position < buffer.data.length) { - int id = buffer.get2U(); - if (id == 65535) { - parentId = buffer.get2U(); - id = buffer.get2U(); - } - Component component = instances[id] = new Component(); - component.id = id; - component.parentId = parentId; - component.type = buffer.get1U(); - component.optionType = buffer.get1U(); - component.contentType = buffer.get2U(); - component.width = buffer.get2U(); - component.height = buffer.get2U(); - component.aByte254 = (byte) buffer.get1U(); - component.anInt230 = buffer.get1U(); - if (component.anInt230 != 0) { - component.anInt230 = ((component.anInt230 - 1) << 8) + buffer.get1U(); - } else { - component.anInt230 = -1; - } - int i1 = buffer.get1U(); - if (i1 > 0) { - component.anIntArray245 = new int[i1]; - component.anIntArray212 = new int[i1]; - for (int j1 = 0; j1 < i1; j1++) { - component.anIntArray245[j1] = buffer.get1U(); - component.anIntArray212[j1] = buffer.get2U(); - } - } - int k1 = buffer.get1U(); - if (k1 > 0) { - component.anIntArrayArray226 = new int[k1][]; - for (int l1 = 0; l1 < k1; l1++) { - int i3 = buffer.get2U(); - component.anIntArrayArray226[l1] = new int[i3]; - for (int l4 = 0; l4 < i3; l4++) { - component.anIntArrayArray226[l1][l4] = buffer.get2U(); - } - } - } - if (component.type == 0) { - component.innerHeight = buffer.get2U(); - component.aBoolean266 = buffer.get1U() == 1; - int i2 = buffer.get2U(); - component.children = new int[i2]; - component.childX = new int[i2]; - component.childY = new int[i2]; - for (int j3 = 0; j3 < i2; j3++) { - component.children[j3] = buffer.get2U(); - component.childX[j3] = buffer.get2(); - component.childY[j3] = buffer.get2(); - } - } - if (component.type == 1) { - component.unusedInt = buffer.get2U(); - component.unusedBool = buffer.get1U() == 1; - } - if (component.type == 2) { - component.slotObjId = new int[component.width * component.height]; - component.slotAmount = new int[component.width * component.height]; - component.aBoolean259 = buffer.get1U() == 1; - component.aBoolean249 = buffer.get1U() == 1; - component.aBoolean242 = buffer.get1U() == 1; - component.objMoveReplaces = buffer.get1U() == 1; - component.slotMarginX = buffer.get1U(); - component.slotMarginY = buffer.get1U(); - component.slotX = new int[20]; - component.slotY = new int[20]; - component.aImageArray209 = new Image24[20]; - for (int j2 = 0; j2 < 20; j2++) { - int k3 = buffer.get1U(); - if (k3 == 1) { - component.slotX[j2] = buffer.get2(); - component.slotY[j2] = buffer.get2(); - String s1 = buffer.getString(); - if ((archive_1 != null) && (s1.length() > 0)) { - int i5 = s1.lastIndexOf(","); - component.aImageArray209[j2] = method207(Integer.parseInt(s1.substring(i5 + 1)), archive_1, s1.substring(0, i5)); - } - } - } - component.aStringArray225 = new String[5]; - for (int l3 = 0; l3 < 5; l3++) { - component.aStringArray225[l3] = buffer.getString(); - if (component.aStringArray225[l3].length() == 0) { - component.aStringArray225[l3] = null; - } - } - } - if (component.type == 3) { - component.aBoolean227 = buffer.get1U() == 1; - } - if ((component.type == 4) || (component.type == 1)) { - component.aBoolean223 = buffer.get1U() == 1; - int k2 = buffer.get1U(); - if (aclass30_sub2_sub1_sub4 != null) { - component.aFont_243 = aclass30_sub2_sub1_sub4[k2]; - } - component.aBoolean268 = buffer.get1U() == 1; - } - if (component.type == 4) { - component.aString248 = buffer.getString(); - component.aString228 = buffer.getString(); - } - if ((component.type == 1) || (component.type == 3) || (component.type == 4)) { - component.anInt232 = buffer.get4(); - } - if ((component.type == 3) || (component.type == 4)) { - component.anInt219 = buffer.get4(); - component.anInt216 = buffer.get4(); - component.anInt239 = buffer.get4(); - } - if (component.type == 5) { - String s = buffer.getString(); - if ((archive_1 != null) && (s.length() > 0)) { - int i4 = s.lastIndexOf(","); - component.aImage_207 = method207(Integer.parseInt(s.substring(i4 + 1)), archive_1, s.substring(0, i4)); - } - s = buffer.getString(); - if ((archive_1 != null) && (s.length() > 0)) { - int j4 = s.lastIndexOf(","); - component.aImage_260 = method207(Integer.parseInt(s.substring(j4 + 1)), archive_1, s.substring(0, j4)); - } - } - if (component.type == 6) { - int l = buffer.get1U(); - if (l != 0) { - component.anInt233 = 1; - component.anInt234 = ((l - 1) << 8) + buffer.get1U(); - } - l = buffer.get1U(); - if (l != 0) { - component.anInt255 = 1; - component.anInt256 = ((l - 1) << 8) + buffer.get1U(); - } - l = buffer.get1U(); - if (l != 0) { - component.seqId = ((l - 1) << 8) + buffer.get1U(); - } else { - component.seqId = -1; - } - l = buffer.get1U(); - if (l != 0) { - component.scriptSeqId = ((l - 1) << 8) + buffer.get1U(); - } else { - component.scriptSeqId = -1; - } - component.anInt269 = buffer.get2U(); - component.anInt270 = buffer.get2U(); - component.anInt271 = buffer.get2U(); - } - if (component.type == 7) { - component.slotObjId = new int[component.width * component.height]; - component.slotAmount = new int[component.width * component.height]; - component.aBoolean223 = buffer.get1U() == 1; - int l2 = buffer.get1U(); - if (aclass30_sub2_sub1_sub4 != null) { - component.aFont_243 = aclass30_sub2_sub1_sub4[l2]; - } - component.aBoolean268 = buffer.get1U() == 1; - component.anInt232 = buffer.get4(); - component.slotMarginX = buffer.get2(); - component.slotMarginY = buffer.get2(); - component.aBoolean249 = buffer.get1U() == 1; - component.aStringArray225 = new String[5]; - for (int k4 = 0; k4 < 5; k4++) { - component.aStringArray225[k4] = buffer.getString(); - if (component.aStringArray225[k4].length() == 0) { - component.aStringArray225[k4] = null; - } - } - } - if ((component.optionType == 2) || (component.type == 2)) { - component.aString222 = buffer.getString(); - component.aString218 = buffer.getString(); - component.anInt237 = buffer.get2U(); - } - if ((component.optionType == 1) || (component.optionType == 4) || (component.optionType == 5) || (component.optionType == 6)) { - component.aString221 = buffer.getString(); - if (component.aString221.length() == 0) { - if (component.optionType == 1) { - component.aString221 = "Ok"; - } - if (component.optionType == 4) { - component.aString221 = "Select"; - } - if (component.optionType == 5) { - component.aString221 = "Select"; - } - if (component.optionType == 6) { - component.aString221 = "Continue"; - } - } - } - } - imageCache = null; - } + public static void unpack(FileArchive archive, BitmapFont[] aclass30_sub2_sub1_sub4, FileArchive archive_1) throws IOException { + imageCache = new LRUMap<>(500); + Buffer buffer = new Buffer(archive.read("data")); + int parentId = -1; + int j = buffer.get2U(); + instances = new Component[j]; + while (buffer.position < buffer.data.length) { + int id = buffer.get2U(); + if (id == 65535) { + parentId = buffer.get2U(); + id = buffer.get2U(); + } + Component component = instances[id] = new Component(); + component.id = id; + component.parentId = parentId; + component.type = buffer.get1U(); + component.optionType = buffer.get1U(); + component.contentType = buffer.get2U(); + component.width = buffer.get2U(); + component.height = buffer.get2U(); + component.aByte254 = (byte) buffer.get1U(); + component.anInt230 = buffer.get1U(); + if (component.anInt230 != 0) { + component.anInt230 = ((component.anInt230 - 1) << 8) + buffer.get1U(); + } else { + component.anInt230 = -1; + } + int i1 = buffer.get1U(); + if (i1 > 0) { + component.anIntArray245 = new int[i1]; + component.anIntArray212 = new int[i1]; + for (int j1 = 0; j1 < i1; j1++) { + component.anIntArray245[j1] = buffer.get1U(); + component.anIntArray212[j1] = buffer.get2U(); + } + } + int k1 = buffer.get1U(); + if (k1 > 0) { + component.anIntArrayArray226 = new int[k1][]; + for (int l1 = 0; l1 < k1; l1++) { + int i3 = buffer.get2U(); + component.anIntArrayArray226[l1] = new int[i3]; + for (int l4 = 0; l4 < i3; l4++) { + component.anIntArrayArray226[l1][l4] = buffer.get2U(); + } + } + } + if (component.type == 0) { + component.innerHeight = buffer.get2U(); + component.aBoolean266 = buffer.get1U() == 1; + int i2 = buffer.get2U(); + component.children = new int[i2]; + component.childX = new int[i2]; + component.childY = new int[i2]; + for (int j3 = 0; j3 < i2; j3++) { + component.children[j3] = buffer.get2U(); + component.childX[j3] = buffer.get2(); + component.childY[j3] = buffer.get2(); + } + } + if (component.type == 1) { + component.unusedInt = buffer.get2U(); + component.unusedBool = buffer.get1U() == 1; + } + if (component.type == 2) { + component.slotObjId = new int[component.width * component.height]; + component.slotAmount = new int[component.width * component.height]; + component.aBoolean259 = buffer.get1U() == 1; + component.aBoolean249 = buffer.get1U() == 1; + component.aBoolean242 = buffer.get1U() == 1; + component.objMoveReplaces = buffer.get1U() == 1; + component.slotMarginX = buffer.get1U(); + component.slotMarginY = buffer.get1U(); + component.slotX = new int[20]; + component.slotY = new int[20]; + component.aImageArray209 = new Image24[20]; + for (int j2 = 0; j2 < 20; j2++) { + int k3 = buffer.get1U(); + if (k3 == 1) { + component.slotX[j2] = buffer.get2(); + component.slotY[j2] = buffer.get2(); + String s1 = buffer.getString(); + if ((archive_1 != null) && (s1.length() > 0)) { + int i5 = s1.lastIndexOf(","); + component.aImageArray209[j2] = method207(Integer.parseInt(s1.substring(i5 + 1)), archive_1, s1.substring(0, i5)); + } + } + } + component.aStringArray225 = new String[5]; + for (int l3 = 0; l3 < 5; l3++) { + component.aStringArray225[l3] = buffer.getString(); + if (component.aStringArray225[l3].length() == 0) { + component.aStringArray225[l3] = null; + } + } + } + if (component.type == 3) { + component.aBoolean227 = buffer.get1U() == 1; + } + if ((component.type == 4) || (component.type == 1)) { + component.aBoolean223 = buffer.get1U() == 1; + int k2 = buffer.get1U(); + if (aclass30_sub2_sub1_sub4 != null) { + component.aFont_243 = aclass30_sub2_sub1_sub4[k2]; + } + component.aBoolean268 = buffer.get1U() == 1; + } + if (component.type == 4) { + component.aString248 = buffer.getString(); + component.aString228 = buffer.getString(); + } + if ((component.type == 1) || (component.type == 3) || (component.type == 4)) { + component.anInt232 = buffer.get4(); + } + if ((component.type == 3) || (component.type == 4)) { + component.anInt219 = buffer.get4(); + component.anInt216 = buffer.get4(); + component.anInt239 = buffer.get4(); + } + if (component.type == 5) { + String s = buffer.getString(); + if ((archive_1 != null) && (s.length() > 0)) { + int i4 = s.lastIndexOf(","); + component.aImage_207 = method207(Integer.parseInt(s.substring(i4 + 1)), archive_1, s.substring(0, i4)); + } + s = buffer.getString(); + if ((archive_1 != null) && (s.length() > 0)) { + int j4 = s.lastIndexOf(","); + component.aImage_260 = method207(Integer.parseInt(s.substring(j4 + 1)), archive_1, s.substring(0, j4)); + } + } + if (component.type == 6) { + int l = buffer.get1U(); + if (l != 0) { + component.anInt233 = 1; + component.anInt234 = ((l - 1) << 8) + buffer.get1U(); + } + l = buffer.get1U(); + if (l != 0) { + component.anInt255 = 1; + component.anInt256 = ((l - 1) << 8) + buffer.get1U(); + } + l = buffer.get1U(); + if (l != 0) { + component.seqId = ((l - 1) << 8) + buffer.get1U(); + } else { + component.seqId = -1; + } + l = buffer.get1U(); + if (l != 0) { + component.scriptSeqId = ((l - 1) << 8) + buffer.get1U(); + } else { + component.scriptSeqId = -1; + } + component.anInt269 = buffer.get2U(); + component.anInt270 = buffer.get2U(); + component.anInt271 = buffer.get2U(); + } + if (component.type == 7) { + component.slotObjId = new int[component.width * component.height]; + component.slotAmount = new int[component.width * component.height]; + component.aBoolean223 = buffer.get1U() == 1; + int l2 = buffer.get1U(); + if (aclass30_sub2_sub1_sub4 != null) { + component.aFont_243 = aclass30_sub2_sub1_sub4[l2]; + } + component.aBoolean268 = buffer.get1U() == 1; + component.anInt232 = buffer.get4(); + component.slotMarginX = buffer.get2(); + component.slotMarginY = buffer.get2(); + component.aBoolean249 = buffer.get1U() == 1; + component.aStringArray225 = new String[5]; + for (int k4 = 0; k4 < 5; k4++) { + component.aStringArray225[k4] = buffer.getString(); + if (component.aStringArray225[k4].length() == 0) { + component.aStringArray225[k4] = null; + } + } + } + if (component.type == 8) { + component.aString222 = buffer.getString(); + } + if ((component.optionType == 2) || (component.type == 2)) { + component.aString222 = buffer.getString(); + component.aString218 = buffer.getString(); + component.anInt237 = buffer.get2U(); + } + if ((component.optionType == 1) || (component.optionType == 4) || (component.optionType == 5) || (component.optionType == 6)) { + component.aString221 = buffer.getString(); + if (component.aString221.length() == 0) { + if (component.optionType == 1) { + component.aString221 = "Ok"; + } + if (component.optionType == 4) { + component.aString221 = "Select"; + } + if (component.optionType == 5) { + component.aString221 = "Select"; + } + if (component.optionType == 6) { + component.aString221 = "Continue"; + } + } + } + } + imageCache = null; + } - public static Image24 method207(int i, FileArchive archive, String s) { - long l = (StringUtil.hashCode(s) << 8) + (long) i; - Image24 image = imageCache.get(l); - if (image != null) { - return image; - } - try { - image = new Image24(archive, s, i); - imageCache.put(l, image); - } catch (Exception _ex) { - return null; - } - return image; - } + public static Image24 method207(int i, FileArchive archive, String s) { + long l = (StringUtil.hashCode(s) << 8) + (long) i; + Image24 image = imageCache.get(l); + if (image != null) { + return image; + } + try { + image = new Image24(archive, s, i); + imageCache.put(l, image); + } catch (Exception _ex) { + return null; + } + return image; + } - public static void method208(int i, int j, Model model) { - modelCache.clear(); - if ((model != null) && (j != 4)) { - modelCache.put(((long) j << 16) + i, model); - } - } + public static void method208(int i, int j, Model model) { + modelCache.clear(); + if ((model != null) && (j != 4)) { + modelCache.put(((long) j << 16) + i, model); + } + } - public Image24 aImage_207; - public int seqCycle; - public Image24[] aImageArray209; - public int unusedInt; - public int[] anIntArray212; - public int contentType; - public int[] slotX; - public int anInt216; - public int optionType; - public String aString218; - public int anInt219; - public int width; - public String aString221; - public String aString222; - public boolean aBoolean223; - public int scrollY; - public String[] aStringArray225; - public int[][] anIntArrayArray226; - public boolean aBoolean227; - public String aString228; - public int anInt230; - public int slotMarginX; - public int anInt232; - public int anInt233; - public int anInt234; - /** - * When true moving an Obj from one slot to another will simply erase the item from the - * destination slot. - */ - public boolean objMoveReplaces; - public int parentId; - public int anInt237; - public int anInt239; - public int[] children; - public int[] childX; - public boolean aBoolean242; - public BitmapFont aFont_243; - public int slotMarginY; - public int[] anIntArray245; - public int seqFrame; - public int[] slotY; - public String aString248; - public boolean aBoolean249; - public int id; - public boolean unusedBool; - public int[] slotAmount; - public int[] slotObjId; - public byte aByte254; - public int anInt255; - public int anInt256; - public int seqId; - public int scriptSeqId; - public boolean aBoolean259; - public Image24 aImage_260; - public int innerHeight; - public int type; - public int x; - public int y; - public boolean aBoolean266; - public int height; - public boolean aBoolean268; - public int anInt269; - public int anInt270; - public int anInt271; - public int[] childY; + public Image24 aImage_207; + public int seqCycle; + public Image24[] aImageArray209; + public int unusedInt; + public int[] anIntArray212; + public int contentType; + public int[] slotX; + public int anInt216; + public int optionType; + public String aString218; + public int anInt219; + public int width; + public String aString221; + public String aString222; + public boolean aBoolean223; + public int scrollY; + public String[] aStringArray225; + public int[][] anIntArrayArray226; + public boolean aBoolean227; + public String aString228; + public int anInt230; + public int slotMarginX; + public int anInt232; + public int anInt233; + public int anInt234; + /** + * When true moving an Obj from one slot to another will simply erase the item from the + * destination slot. + */ + public boolean objMoveReplaces; + public int parentId; + public int anInt237; + public int anInt239; + public int[] children; + public int[] childX; + public boolean aBoolean242; + public BitmapFont aFont_243; + public int slotMarginY; + public int[] anIntArray245; + public int seqFrame; + public int[] slotY; + public String aString248; + public boolean aBoolean249; + public int id; + public boolean unusedBool; + public int[] slotAmount; + public int[] slotObjId; + public byte aByte254; + public int anInt255; + public int anInt256; + public int seqId; + public int scriptSeqId; + public boolean aBoolean259; + public Image24 aImage_260; + public int innerHeight; + public int type; + public int x; + public int y; + public boolean aBoolean266; + public int height; + public boolean aBoolean268; + public int anInt269; + public int anInt270; + public int anInt271; + public int[] childY; - public Component() { - } + public Component() { + } - public void swapSlots(int src, int dst) { - int tmp = slotObjId[src]; - slotObjId[src] = slotObjId[dst]; - slotObjId[dst] = tmp; + public void swapSlots(int src, int dst) { + int tmp = slotObjId[src]; + slotObjId[src] = slotObjId[dst]; + slotObjId[dst] = tmp; - tmp = slotAmount[src]; - slotAmount[src] = slotAmount[dst]; - slotAmount[dst] = tmp; - } + tmp = slotAmount[src]; + slotAmount[src] = slotAmount[dst]; + slotAmount[dst] = tmp; + } - public Model method206(int i, int j) { - Model model = modelCache.get(((long) i << 16) + j); - if (model != null) { - return model; - } - if (i == 1) { - model = Model.tryGet(j); - } - if (i == 2) { - model = NPCType.get(j).method160(); - } - if (i == 3) { - model = Game.self.method453(); - } - if (i == 4) { - model = ObjType.get(j).method202(50); - } - if (i == 5) { - model = null; - } - if (model != null) { - modelCache.put((long) ((i << 16) + j), model); - } - return model; - } + public Model method206(int i, int j) { + Model model = modelCache.get(((long) i << 16) + j); + if (model != null) { + return model; + } + if (i == 1) { + model = Model.tryGet(j); + } + if (i == 2) { + model = NPCType.get(j).method160(); + } + if (i == 3) { + model = Game.self.method453(); + } + if (i == 4) { + model = ObjType.get(j).getModelUnlit(50); + } + if (i == 5) { + model = null; + } + if (model != null) { + modelCache.put((long) ((i << 16) + j), model); + } + return model; + } - public Model method209(int j, int k, boolean flag) { - Model model; - if (flag) { - model = method206(anInt255, anInt256); - } else { - model = method206(anInt233, anInt234); - } - if (model == null) { - return null; - } - if ((k == -1) && (j == -1) && (model.faceColor == null)) { - return model; - } - Model model_1 = new Model(true, SeqFrame.isNull(k) & SeqFrame.isNull(j), false, model); - if ((k != -1) || (j != -1)) { - model_1.createLabelReferences(); - } - if (k != -1) { - model_1.applySequenceFrame(k); - } - if (j != -1) { - model_1.applySequenceFrame(j); - } - model_1.calculateNormals(64, 768, -50, -10, -50, true); - return model_1; - } + public Model method209(int j, int k, boolean flag) { + Model model; + if (flag) { + model = method206(anInt255, anInt256); + } else { + model = method206(anInt233, anInt234); + } + if (model == null) { + return null; + } + if ((k == -1) && (j == -1) && (model.faceColor == null)) { + return model; + } + Model model_1 = new Model(true, SeqFrame.isNull(k) & SeqFrame.isNull(j), false, model); + if ((k != -1) || (j != -1)) { + model_1.createLabelReferences(); + } + if (k != -1) { + model_1.applySequenceFrame(k); + } + if (j != -1) { + model_1.applySequenceFrame(j); + } + model_1.calculateNormals(64, 768, -50, -10, -50, true); + return model_1; + } } diff --git a/src/main/java/FileArchive.java b/src/main/java/FileArchive.java index 76e1143..1c0843b 100644 --- a/src/main/java/FileArchive.java +++ b/src/main/java/FileArchive.java @@ -1,4 +1,8 @@ +import java.io.FileNotFoundException; import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; /** * A simple file archive format. @@ -50,6 +54,16 @@ public class FileArchive { } } + public void export(String s, Path dst) throws IOException { + byte[] data = read(s); + if (data == null) { + throw new FileNotFoundException(s); + } + try (OutputStream out = Files.newOutputStream(dst)) { + out.write(data); + } + } + public byte[] read(String s) throws IOException { int hash = 0; s = s.toUpperCase(); diff --git a/src/main/java/FloType.java b/src/main/java/FloType.java index 9c3fcd8..a9f3f22 100644 --- a/src/main/java/FloType.java +++ b/src/main/java/FloType.java @@ -24,7 +24,7 @@ public class FloType { } public String unusedString; public int anInt390; - public int anInt391 = -1; + public int textureId = -1; public boolean unusedBool = false; public boolean aBoolean393 = true; public int anInt394; @@ -47,7 +47,7 @@ public class FloType { anInt390 = buffer.get3(); method262(anInt390); } else if (i == 2) { - anInt391 = buffer.get1U(); + textureId = buffer.get1U(); } else if (i == 3) { unusedBool = true; } else if (i == 5) { diff --git a/src/main/java/Game.java b/src/main/java/Game.java index c930714..fb7b0d1 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -38,19 +38,19 @@ public class Game extends GameShell { static { levelExperience = new int[99]; - int i = 0; - for (int j = 0; j < 99; j++) { - int l = j + 1; - int i1 = (int) ((double) l + (300D * Math.pow(2D, (double) l / 7D))); - i += i1; - levelExperience[j] = i / 4; + int acc = 0; + for (int i = 0; i < 99; i++) { + int level = i + 1; + int delta = (int) ((double) level + (300D * Math.pow(2D, (double) level / 7D))); + acc += delta; + levelExperience[i] = acc / 4; } BITMASK = new int[32]; - i = 2; + acc = 2; for (int k = 0; k < 32; k++) { - BITMASK[k] = i - 1; - i += i; + BITMASK[k] = acc - 1; + acc += acc; } } @@ -162,7 +162,7 @@ public class Game extends GameShell { public final long[] aLongArray925 = new long[100]; public final int anInt927 = 0x332d25; public final int[] anIntArray928 = new int[5]; - public final CRC32 aCRC32_930 = new CRC32(); + public final CRC32 crc32 = new CRC32(); public final int[] anIntArray942 = new int[100]; public final String[] aStringArray943 = new String[100]; public final String[] aStringArray944 = new String[100]; @@ -222,7 +222,7 @@ public class Game extends GameShell { public int anInt843; public String chatbackMessage; public int anInt845; - public Buffer aBuffer_847 = Buffer.create(1); + public Buffer login = Buffer.create(1); public boolean aBoolean848 = true; public int[] flameGradient; public int[] flameGradient0; @@ -497,7 +497,7 @@ public class Game extends GameShell { public int invbackComponentId = -1; public int[] flameBuffer0; public int[] flameBuffer1; - public Buffer aBuffer_1192 = Buffer.create(1); + public Buffer out = Buffer.create(1); public int anInt1193; public int anInt1195; public Image8 imageInvback; @@ -743,36 +743,18 @@ public class Game extends GameShell { if (filestores[0] != null) { showProgress(75, "Requesting maps"); - sceneMapLandFile = new int[ondemand.mapIndex.length]; - sceneMapLocFile = new int[ondemand.mapIndex.length]; - sceneMapIndex = new int[ondemand.mapIndex.length]; - sceneMapLandData = new byte[sceneMapIndex.length][]; - sceneMapLocData = new byte[sceneMapIndex.length][]; - - for (int i = 0; i < ondemand.mapIndex.length; i++) { - int landFile = ondemand.mapLandFile[i]; - int locFile = ondemand.mapLocFile[i]; - - sceneMapIndex[i] = ondemand.mapIndex[i]; - sceneMapLandFile[i] = landFile; - sceneMapLocFile[i] = locFile; - - ondemand.request(3, landFile); - ondemand.request(3, locFile); - } - -// ondemand.request(3, ondemand.getMapFile(0, 47, 48)); -// ondemand.request(3, ondemand.getMapFile(1, 47, 48)); -// ondemand.request(3, ondemand.getMapFile(0, 48, 48)); -// ondemand.request(3, ondemand.getMapFile(1, 48, 48)); -// ondemand.request(3, ondemand.getMapFile(0, 49, 48)); -// ondemand.request(3, ondemand.getMapFile(1, 49, 48)); -// ondemand.request(3, ondemand.getMapFile(0, 47, 47)); -// ondemand.request(3, ondemand.getMapFile(1, 47, 47)); -// ondemand.request(3, ondemand.getMapFile(0, 48, 47)); -// ondemand.request(3, ondemand.getMapFile(1, 48, 47)); -// ondemand.request(3, ondemand.getMapFile(0, 48, 148)); -// ondemand.request(3, ondemand.getMapFile(1, 48, 148)); + ondemand.request(3, ondemand.getMapFile(0, 47, 48)); + ondemand.request(3, ondemand.getMapFile(1, 47, 48)); + ondemand.request(3, ondemand.getMapFile(0, 48, 48)); + ondemand.request(3, ondemand.getMapFile(1, 48, 48)); + ondemand.request(3, ondemand.getMapFile(0, 49, 48)); + ondemand.request(3, ondemand.getMapFile(1, 49, 48)); + ondemand.request(3, ondemand.getMapFile(0, 47, 47)); + ondemand.request(3, ondemand.getMapFile(1, 47, 47)); + ondemand.request(3, ondemand.getMapFile(0, 48, 47)); + ondemand.request(3, ondemand.getMapFile(1, 48, 47)); + ondemand.request(3, ondemand.getMapFile(0, 48, 148)); + ondemand.request(3, ondemand.getMapFile(1, 48, 148)); total = ondemand.remaining(); @@ -951,6 +933,7 @@ public class Game extends GameShell { SpotAnimType.unpack(archiveConfig); VarpType.unpack(archiveConfig); VarbitType.unpack(archiveConfig); + if (!lowmem) { showProgress(90, "Unpacking sounds"); byte[] abyte0 = archiveSounds.read("sounds.dat"); @@ -1061,8 +1044,8 @@ public class Game extends GameShell { ondemand = null; } aBuffer_834 = null; - aBuffer_1192 = null; - aBuffer_847 = null; + out = null; + login = null; in = null; sceneMapIndex = null; sceneMapLandData = null; @@ -1593,7 +1576,7 @@ public class Game extends GameShell { } SceneBuilder sceneBuilder = new SceneBuilder(planeTileFlags, 104, 104, anIntArrayArrayArray1214); int k2 = sceneMapLandData.length; - aBuffer_1192.putOp(0); + out.putOp(0); if (!sceneInstanced) { for (int i3 = 0; i3 < k2; i3++) { int i4 = ((sceneMapIndex[i3] >> 8) * 64) - sceneBaseTileX; @@ -1611,7 +1594,7 @@ public class Game extends GameShell { sceneBuilder.method174(k7, 64, 64, l5); } } - aBuffer_1192.putOp(0); + out.putOp(0); for (int i6 = 0; i6 < k2; i6++) { byte[] abyte1 = sceneMapLocData[i6]; if (abyte1 != null) { @@ -1651,7 +1634,7 @@ public class Game extends GameShell { } } } - aBuffer_1192.putOp(0); + out.putOp(0); for (int l6 = 0; l6 < 4; l6++) { for (int j8 = 0; j8 < 13; j8++) { for (int j9 = 0; j9 < 13; j9++) { @@ -1674,10 +1657,10 @@ public class Game extends GameShell { } } } - aBuffer_1192.putOp(0); + out.putOp(0); sceneBuilder.method171(collisions, scene); areaViewport.bind(); - aBuffer_1192.putOp(0); + out.putOp(0); int k3 = SceneBuilder.anInt145; if (k3 > currentPlane) { k3 = currentPlane; @@ -1699,8 +1682,8 @@ public class Game extends GameShell { LocType.modelCache.clear(); if (super.frame != null) { - aBuffer_1192.putOp(210); - aBuffer_1192.put4(0x3f008edd); + out.putOp(210); + out.put4(0x3f008edd); } if (lowmem && (Signlink.cache_dat != null)) { @@ -1760,7 +1743,7 @@ public class Game extends GameShell { Arrays.fill(pixels, 0); for (int z = 1; z < 103; z++) { - int offset = 24628 + ((103 - z) * 512 * 4); + int offset = (48 + (48 * 512)) + ((103 - z) * 512 * 4); for (int x = 1; x < 103; x++) { if ((planeTileFlags[plane][x][z] & 0x18) == 0) { @@ -1775,19 +1758,19 @@ public class Game extends GameShell { } } - int j1 = (((238 + (int) (Math.random() * 20D)) - 10) << 16) + (((238 + (int) (Math.random() * 20D)) - 10) << 8) + ((238 + (int) (Math.random() * 20D)) - 10); - int l1 = ((238 + (int) (Math.random() * 20D)) - 10) << 16; + int wall = 0xEEEEEE; + int door = 0xEE0000; imageMinimap.bind(); for (int z = 1; z < 103; z++) { for (int x = 1; x < 103; x++) { if ((planeTileFlags[plane][x][z] & 0x18) == 0) { - drawMinimapLoc(z, j1, x, l1, plane); + drawMinimapLoc(z, wall, x, door, plane); } if ((plane < 3) && ((planeTileFlags[plane + 1][x][z] & 8) != 0)) { - drawMinimapLoc(z, j1, x, l1, plane + 1); + drawMinimapLoc(z, wall, x, door, plane + 1); } } } @@ -1856,12 +1839,12 @@ public class Game extends GameShell { ObjStackEntity stack2 = null; for (ObjStackEntity stack = (ObjStackEntity) list.peekFront(); stack != null; stack = (ObjStackEntity) list.prev()) { - ObjType type = ObjType.get(stack.anInt1558); + ObjType type = ObjType.get(stack.id); - int l = type.anInt155; + int l = type.cost; - if (type.aBoolean176) { - l *= stack.anInt1559 + 1; + if (type.stackable) { + l *= stack.amount + 1; } if (l > k) { @@ -1873,10 +1856,10 @@ public class Game extends GameShell { list.pushFront(stack0); for (ObjStackEntity stack = (ObjStackEntity) list.peekFront(); stack != null; stack = (ObjStackEntity) list.prev()) { - if ((stack.anInt1558 != stack0.anInt1558) && (stack1 == null)) { + if ((stack.id != stack0.id) && (stack1 == null)) { stack1 = stack; } - if ((stack.anInt1558 != stack0.anInt1558) && (stack.anInt1558 != stack1.anInt1558) && (stack2 == null)) { + if ((stack.id != stack0.id) && (stack.id != stack1.id) && (stack2 == null)) { stack2 = stack; } } @@ -2034,8 +2017,8 @@ public class Game extends GameShell { } else { if (child.aBoolean249) { for (int l3 = 4; l3 >= 3; l3--) { - if ((type.aStringArray189 != null) && (type.aStringArray189[l3] != null)) { - aStringArray1199[menuSize] = type.aStringArray189[l3] + " @lre@" + type.name; + if ((type.inventoryOptions != null) && (type.inventoryOptions[l3] != null)) { + aStringArray1199[menuSize] = type.inventoryOptions[l3] + " @lre@" + type.name; if (l3 == 3) { menuAction[menuSize] = 493; } @@ -2064,10 +2047,10 @@ public class Game extends GameShell { menuParamB[menuSize] = child.id; menuSize++; } - if (child.aBoolean249 && (type.aStringArray189 != null)) { + if (child.aBoolean249 && (type.inventoryOptions != null)) { for (int i4 = 2; i4 >= 0; i4--) { - if (type.aStringArray189[i4] != null) { - aStringArray1199[menuSize] = type.aStringArray189[i4] + " @lre@" + type.name; + if (type.inventoryOptions[i4] != null) { + aStringArray1199[menuSize] = type.inventoryOptions[i4] + " @lre@" + type.name; if (i4 == 0) { menuAction[menuSize] = 74; } @@ -2178,28 +2161,28 @@ public class Game extends GameShell { anInt1287 = (anInt1287 + 1) % 4; aBoolean1233 = true; redrawChatback = true; - aBuffer_1192.putOp(95); - aBuffer_1192.put1(anInt1287); - aBuffer_1192.put1(anInt845); - aBuffer_1192.put1(anInt1248); + out.putOp(95); + out.put1(anInt1287); + out.put1(anInt845); + out.put1(anInt1248); } if ((super.mousePressX >= 135) && (super.mousePressX <= 235) && (super.mousePressY >= 467) && (super.mousePressY <= 499)) { anInt845 = (anInt845 + 1) % 3; aBoolean1233 = true; redrawChatback = true; - aBuffer_1192.putOp(95); - aBuffer_1192.put1(anInt1287); - aBuffer_1192.put1(anInt845); - aBuffer_1192.put1(anInt1248); + out.putOp(95); + out.put1(anInt1287); + out.put1(anInt845); + out.put1(anInt1248); } if ((super.mousePressX >= 273) && (super.mousePressX <= 373) && (super.mousePressY >= 467) && (super.mousePressY <= 499)) { anInt1248 = (anInt1248 + 1) % 3; aBoolean1233 = true; redrawChatback = true; - aBuffer_1192.putOp(95); - aBuffer_1192.put1(anInt1287); - aBuffer_1192.put1(anInt845); - aBuffer_1192.put1(anInt1248); + out.putOp(95); + out.put1(anInt1287); + out.put1(anInt845); + out.put1(anInt1248); } if ((super.mousePressX >= 412) && (super.mousePressX <= 512) && (super.mousePressY >= 467) && (super.mousePressY <= 499)) { if (viewportComponentId == -1) { @@ -2548,8 +2531,8 @@ public class Game extends GameShell { anIntArray826[j] = anIntArray826[j + 1]; aLongArray955[j] = aLongArray955[j + 1]; } - aBuffer_1192.putOp(215); - aBuffer_1192.put8(l); + out.putOp(215); + out.put8(l); break; } } @@ -2805,8 +2788,8 @@ public class Game extends GameShell { anIntArray826[anInt899] = 0; anInt899++; redrawInvback = true; - aBuffer_1192.putOp(188); - aBuffer_1192.put8(l); + out.putOp(188); + out.put8(l); } } @@ -3044,23 +3027,23 @@ public class Game extends GameShell { method45(); } if (type == 326) { - aBuffer_1192.putOp(101); - aBuffer_1192.put1(aBoolean1047 ? 0 : 1); + out.putOp(101); + out.put1(aBoolean1047 ? 0 : 1); for (int i1 = 0; i1 < 7; i1++) { - aBuffer_1192.put1(anIntArray1065[i1]); + out.put1(anIntArray1065[i1]); } for (int l1 = 0; l1 < 5; l1++) { - aBuffer_1192.put1(anIntArray990[l1]); + out.put1(anIntArray990[l1]); } return true; } if ((type >= 601) && (type <= 612)) { method147(); if (aString881.length() > 0) { - aBuffer_1192.putOp(218); - aBuffer_1192.put8(StringUtil.toBase37(aString881)); - aBuffer_1192.put1(type - 601); - aBuffer_1192.put1(aBoolean1158 ? 1 : 0); + out.putOp(218); + out.put8(StringUtil.toBase37(aString881)); + out.put1(type - 601); + out.put1(aBoolean1158 ? 1 : 0); } } return false; @@ -3350,7 +3333,7 @@ public class Game extends GameShell { sceneState = 2; SceneBuilder.anInt131 = currentPlane; method22(); - aBuffer_1192.putOp(121); + out.putOp(121); return 0; } } @@ -3630,12 +3613,12 @@ public class Game extends GameShell { synchronized (aMouseRecorder_879.lock) { if (aBoolean1205) { if ((super.mousePressButton != 0) || (aMouseRecorder_879.anInt810 >= 40)) { - aBuffer_1192.putOp(45); - aBuffer_1192.put1(0); - int j2 = aBuffer_1192.position; + out.putOp(45); + out.put1(0); + int j2 = out.position; int j3 = 0; for (int j4 = 0; j4 < aMouseRecorder_879.anInt810; j4++) { - if ((j2 - aBuffer_1192.position) >= 240) { + if ((j2 - out.position) >= 240) { break; } j3++; @@ -3669,18 +3652,18 @@ public class Game extends GameShell { if ((anInt1022 < 8) && (j6 >= -32) && (j6 <= 31) && (k6 >= -32) && (k6 <= 31)) { j6 += 32; k6 += 32; - aBuffer_1192.put2((anInt1022 << 12) + (j6 << 6) + k6); + out.put2((anInt1022 << 12) + (j6 << 6) + k6); anInt1022 = 0; } else if (anInt1022 < 8) { - aBuffer_1192.put3(0x800000 + (anInt1022 << 19) + i6); + out.put3(0x800000 + (anInt1022 << 19) + i6); anInt1022 = 0; } else { - aBuffer_1192.put4(0xc0000000 + (anInt1022 << 19) + i6); + out.put4(0xc0000000 + (anInt1022 << 19) + i6); anInt1022 = 0; } } } - aBuffer_1192.putSize1(aBuffer_1192.position - j2); + out.putSize1(out.position - j2); if (j3 >= aMouseRecorder_879.anInt810) { aMouseRecorder_879.anInt810 = 0; } else { @@ -3719,8 +3702,8 @@ public class Game extends GameShell { j5 = 1; } int l5 = (int) l; - aBuffer_1192.putOp(241); - aBuffer_1192.put4((l5 << 20) + (j5 << 19) + k4); + out.putOp(241); + out.put4((l5 << 20) + (j5 << 19) + k4); } if (anInt1016 > 0) { anInt1016--; @@ -3731,19 +3714,19 @@ public class Game extends GameShell { if (aBoolean1017 && (anInt1016 <= 0)) { anInt1016 = 20; aBoolean1017 = false; - aBuffer_1192.putOp(86); - aBuffer_1192.put2(anInt1184); - aBuffer_1192.put2A(anInt1185); + out.putOp(86); + out.put2(anInt1184); + out.put2A(anInt1185); } if (super.aBoolean17 && !aBoolean954) { aBoolean954 = true; - aBuffer_1192.putOp(3); - aBuffer_1192.put1(1); + out.putOp(3); + out.put1(1); } if (!super.aBoolean17 && aBoolean954) { aBoolean954 = false; - aBuffer_1192.putOp(3); - aBuffer_1192.put1(0); + out.putOp(3); + out.put1(0); } method53(); method115(); @@ -3834,11 +3817,11 @@ public class Game extends GameShell { } else { component.swapSlots(objDragSlot, hoveredSlot); } - aBuffer_1192.putOp(214); - aBuffer_1192.put2LEA(objDragComponentId); - aBuffer_1192.put1C(mode); - aBuffer_1192.put2LEA(objDragSlot); - aBuffer_1192.put2LE(hoveredSlot); + out.putOp(214); + out.put2LEA(objDragComponentId); + out.put1C(mode); + out.put2LEA(objDragSlot); + out.put2LE(hoveredSlot); } } else if (((mouseButtonsOption == 1) || method17(menuSize - 1)) && (menuSize > 2)) { showContextMenu(); @@ -3887,16 +3870,16 @@ public class Game extends GameShell { if (super.idleCycles > 4500) { anInt1011 = 250; super.idleCycles -= 500; - aBuffer_1192.putOp(202); + out.putOp(202); } anInt1010++; if (anInt1010 > 50) { - aBuffer_1192.putOp(0); + out.putOp(0); } try { - if ((connection != null) && (aBuffer_1192.position > 0)) { - connection.write(aBuffer_1192.data, 0, aBuffer_1192.position); - aBuffer_1192.position = 0; + if ((connection != null) && (out.position > 0)) { + connection.write(out.data, 0, out.position); + out.position = 0; anInt1010 = 0; } } catch (IOException _ex) { @@ -4022,49 +4005,48 @@ public class Game extends GameShell { return true; } - public FileArchive loadArchive(int i, String s, String s1, int j, int k) throws IOException { - byte[] abyte0 = null; - int l = 5; + public FileArchive loadArchive(int fileId, String caption, String fileName, int checksum, int progress) throws IOException { + byte[] data = null; + int wait = 5; try { if (filestores[0] != null) { - abyte0 = filestores[0].read(i); + data = filestores[0].read(fileId); } } catch (Exception ignored) { } - if (abyte0 != null) { - aCRC32_930.reset(); - aCRC32_930.update(abyte0); - int i1 = (int) aCRC32_930.getValue(); - if (i1 != j) { - abyte0 = null; + if (data != null) { + crc32.reset(); + crc32.update(data); + if ((int) crc32.getValue() != checksum) { + data = null; } } - if (abyte0 != null) { - return new FileArchive(abyte0); + if (data != null) { + return new FileArchive(data); } int j1 = 0; - while (abyte0 == null) { + while (data == null) { String s2 = "Unknown error"; - showProgress(k, "Requesting " + s); + showProgress(progress, "Requesting " + caption); try { int k1 = 0; - DataInputStream datainputstream = openURL(s1 + j); + DataInputStream datainputstream = openURL(fileName + checksum); byte[] abyte1 = new byte[6]; datainputstream.readFully(abyte1, 0, 6); Buffer buffer = new Buffer(abyte1); buffer.position = 3; int i2 = buffer.get3() + 6; int j2 = 6; - abyte0 = new byte[i2]; + data = new byte[i2]; for (int k2 = 0; k2 < 6; k2++) { - abyte0[k2] = abyte1[k2]; + data[k2] = abyte1[k2]; } while (j2 < i2) { int l2 = i2 - j2; if (l2 > 1000) { l2 = 1000; } - int j3 = datainputstream.read(abyte0, j2, l2); + int j3 = datainputstream.read(data, j2, l2); if (j3 < 0) { s2 = "Length error: " + j2 + "/" + i2; throw new IOException("EOF"); @@ -4072,24 +4054,24 @@ public class Game extends GameShell { j2 += j3; int k3 = (j2 * 100) / i2; if (k3 != k1) { - showProgress(k, "Loading " + s + " - " + k3 + "%"); + showProgress(progress, "Loading " + caption + " - " + k3 + "%"); } k1 = k3; } datainputstream.close(); try { if (filestores[0] != null) { - filestores[0].write(abyte0, i, abyte0.length); + filestores[0].write(data, fileId, data.length); } } catch (Exception _ex) { filestores[0] = null; } - if (abyte0 != null) { - aCRC32_930.reset(); - aCRC32_930.update(abyte0); - int i3 = (int) aCRC32_930.getValue(); - if (i3 != j) { - abyte0 = null; + if (data != null) { + crc32.reset(); + crc32.update(data); + int i3 = (int) crc32.getValue(); + if (i3 != checksum) { + //data = null; j1++; s2 = "Checksum error: " + i3; } @@ -4098,47 +4080,47 @@ public class Game extends GameShell { if (s2.equals("Unknown error")) { s2 = "Connection error"; } - abyte0 = null; + data = null; } catch (NullPointerException _ex) { s2 = "Null error"; - abyte0 = null; + data = null; if (!Signlink.reporterror) { return null; } } catch (ArrayIndexOutOfBoundsException _ex) { s2 = "Bounds error"; - abyte0 = null; + data = null; if (!Signlink.reporterror) { return null; } } catch (Exception _ex) { s2 = "Unexpected error"; - abyte0 = null; + data = null; if (!Signlink.reporterror) { return null; } } - if (abyte0 == null) { - for (int l1 = l; l1 > 0; l1--) { + if (data == null) { + for (int l1 = wait; l1 > 0; l1--) { if (j1 >= 3) { - showProgress(k, "Game updated - please reload page"); + showProgress(progress, "Game updated - please reload page"); l1 = 10; } else { - showProgress(k, s2 + " - Retrying in " + l1); + showProgress(progress, s2 + " - Retrying in " + l1); } try { Thread.sleep(1000L); } catch (Exception ignored) { } } - l *= 2; - if (l > 60) { - l = 60; + wait *= 2; + if (wait > 60) { + wait = 60; } useJaggrab = !useJaggrab; } } - return new FileArchive(abyte0); + return new FileArchive(data); } public void method68() { @@ -4193,11 +4175,11 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(57); - aBuffer_1192.put2A(anInt1285); - aBuffer_1192.put2A(c); - aBuffer_1192.put2LE(anInt1283); - aBuffer_1192.put2A(anInt1284); + out.putOp(57); + out.put2A(anInt1285); + out.put2A(c); + out.put2LE(anInt1283); + out.put2A(anInt1284); } } if (action == 234) { @@ -4209,19 +4191,19 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(236); - aBuffer_1192.put2LE(b + sceneBaseTileZ); - aBuffer_1192.put2(c); - aBuffer_1192.put2LE(a + sceneBaseTileX); + out.putOp(236); + out.put2LE(b + sceneBaseTileZ); + out.put2(c); + out.put2LE(a + sceneBaseTileX); } if ((action == 62) && method66(c, b, a)) { - aBuffer_1192.putOp(192); - aBuffer_1192.put2(anInt1284); - aBuffer_1192.put2LE((c >> 14) & 0x7fff); - aBuffer_1192.put2LEA(b + sceneBaseTileZ); - aBuffer_1192.put2LE(anInt1283); - aBuffer_1192.put2LEA(a + sceneBaseTileX); - aBuffer_1192.put2(anInt1285); + out.putOp(192); + out.put2(anInt1284); + out.put2LE((c >> 14) & 0x7fff); + out.put2LEA(b + sceneBaseTileZ); + out.put2LE(anInt1283); + out.put2LEA(a + sceneBaseTileX); + out.put2(anInt1285); } if (action == 511) { boolean flag2 = method85(2, 0, 0, 0, self.pathTileZ[0], 0, 0, b, self.pathTileX[0], false, a); @@ -4232,19 +4214,19 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(25); - aBuffer_1192.put2LE(anInt1284); - aBuffer_1192.put2A(anInt1285); - aBuffer_1192.put2(c); - aBuffer_1192.put2A(b + sceneBaseTileZ); - aBuffer_1192.put2LEA(anInt1283); - aBuffer_1192.put2(a + sceneBaseTileX); + out.putOp(25); + out.put2LE(anInt1284); + out.put2A(anInt1285); + out.put2(c); + out.put2A(b + sceneBaseTileZ); + out.put2LEA(anInt1283); + out.put2(a + sceneBaseTileX); } if (action == 74) { - aBuffer_1192.putOp(122); - aBuffer_1192.put2LEA(b); - aBuffer_1192.put2A(a); - aBuffer_1192.put2LE(c); + out.putOp(122); + out.put2LEA(b); + out.put2A(a); + out.put2LE(c); anInt1243 = 0; anInt1244 = b; anInt1245 = a; @@ -4263,8 +4245,8 @@ public class Game extends GameShell { notify = handleComponentAction(component); } if (notify) { - aBuffer_1192.putOp(185); - aBuffer_1192.put2(b); + out.putOp(185); + out.put2(b); } } if (action == 561) { @@ -4275,8 +4257,8 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(128); - aBuffer_1192.put2(c); + out.putOp(128); + out.put2(c); } } if (action == 20) { @@ -4287,8 +4269,8 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(155); - aBuffer_1192.put2LE(c); + out.putOp(155); + out.put2LE(c); } } if (action == 779) { @@ -4299,8 +4281,8 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(153); - aBuffer_1192.put2LE(c); + out.putOp(153); + out.put2LE(c); } } if (action == 516) { @@ -4312,21 +4294,21 @@ public class Game extends GameShell { } if (action == 1062) { method66(c, b, a); - aBuffer_1192.putOp(228); - aBuffer_1192.put2A((c >> 14) & 0x7fff); - aBuffer_1192.put2A(b + sceneBaseTileZ); - aBuffer_1192.put2(a + sceneBaseTileX); + out.putOp(228); + out.put2A((c >> 14) & 0x7fff); + out.put2A(b + sceneBaseTileZ); + out.put2(a + sceneBaseTileX); } if ((action == 679) && !aBoolean1149) { - aBuffer_1192.putOp(40); - aBuffer_1192.put2(b); + out.putOp(40); + out.put2(b); aBoolean1149 = true; } if (action == 431) { - aBuffer_1192.putOp(129); - aBuffer_1192.put2A(a); - aBuffer_1192.put2(b); - aBuffer_1192.put2A(c); + out.putOp(129); + out.put2A(a); + out.put2(b); + out.put2A(c); anInt1243 = 0; anInt1244 = b; anInt1245 = a; @@ -4358,10 +4340,10 @@ public class Game extends GameShell { } } if (action == 53) { - aBuffer_1192.putOp(135); - aBuffer_1192.put2LE(a); - aBuffer_1192.put2A(b); - aBuffer_1192.put2LE(c); + out.putOp(135); + out.put2LE(a); + out.put2A(b); + out.put2LE(c); anInt1243 = 0; anInt1244 = b; anInt1245 = a; @@ -4374,10 +4356,10 @@ public class Game extends GameShell { } } if (action == 539) { - aBuffer_1192.putOp(16); - aBuffer_1192.put2A(c); - aBuffer_1192.put2LEA(a); - aBuffer_1192.put2LEA(b); + out.putOp(16); + out.put2A(c); + out.put2LEA(a); + out.put2LEA(b); anInt1243 = 0; anInt1244 = b; anInt1245 = a; @@ -4403,12 +4385,12 @@ public class Game extends GameShell { } method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, player_7.pathTileZ[0], self.pathTileX[0], false, player_7.pathTileX[0]); if (action == 484) { - aBuffer_1192.putOp(139); - aBuffer_1192.put2LE(anIntArray892[j3]); + out.putOp(139); + out.put2LE(anIntArray892[j3]); } if (action == 6) { - aBuffer_1192.putOp(128); - aBuffer_1192.put2(anIntArray892[j3]); + out.putOp(128); + out.put2(anIntArray892[j3]); } flag9 = true; break; @@ -4419,13 +4401,13 @@ public class Game extends GameShell { } } if (action == 870) { - aBuffer_1192.putOp(53); - aBuffer_1192.put2(a); - aBuffer_1192.put2A(anInt1283); - aBuffer_1192.put2LEA(c); - aBuffer_1192.put2(anInt1284); - aBuffer_1192.put2LE(anInt1285); - aBuffer_1192.put2(b); + out.putOp(53); + out.put2(a); + out.put2A(anInt1283); + out.put2LEA(c); + out.put2(anInt1284); + out.put2LE(anInt1285); + out.put2(b); anInt1243 = 0; anInt1244 = b; anInt1245 = a; @@ -4438,10 +4420,10 @@ public class Game extends GameShell { } } if (action == 847) { - aBuffer_1192.putOp(87); - aBuffer_1192.put2A(c); - aBuffer_1192.put2(b); - aBuffer_1192.put2A(a); + out.putOp(87); + out.put2A(c); + out.put2(b); + out.put2A(a); anInt1243 = 0; anInt1244 = b; anInt1245 = a; @@ -4477,10 +4459,10 @@ public class Game extends GameShell { return; } if (action == 78) { - aBuffer_1192.putOp(117); - aBuffer_1192.put2LEA(b); - aBuffer_1192.put2LEA(c); - aBuffer_1192.put2LE(a); + out.putOp(117); + out.put2LEA(b); + out.put2LEA(c); + out.put2LE(a); anInt1243 = 0; anInt1244 = b; anInt1245 = a; @@ -4500,8 +4482,8 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(73); - aBuffer_1192.put2LE(c); + out.putOp(73); + out.put2LE(c); } } if (action == 213) { @@ -4513,16 +4495,16 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(79); - aBuffer_1192.put2LE(b + sceneBaseTileZ); - aBuffer_1192.put2(c); - aBuffer_1192.put2A(a + sceneBaseTileX); + out.putOp(79); + out.put2LE(b + sceneBaseTileZ); + out.put2(c); + out.put2A(a + sceneBaseTileX); } if (action == 632) { - aBuffer_1192.putOp(145); - aBuffer_1192.put2A(b); - aBuffer_1192.put2A(a); - aBuffer_1192.put2A(c); + out.putOp(145); + out.put2A(b); + out.put2A(a); + out.put2A(c); anInt1243 = 0; anInt1244 = b; anInt1245 = a; @@ -4535,10 +4517,10 @@ public class Game extends GameShell { } } if (action == 493) { - aBuffer_1192.putOp(75); - aBuffer_1192.put2LEA(b); - aBuffer_1192.put2LE(a); - aBuffer_1192.put2A(c); + out.putOp(75); + out.put2LEA(b); + out.put2LE(a); + out.put2A(c); anInt1243 = 0; anInt1244 = b; anInt1245 = a; @@ -4559,10 +4541,10 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(156); - aBuffer_1192.put2A(a + sceneBaseTileX); - aBuffer_1192.put2LE(b + sceneBaseTileZ); - aBuffer_1192.put2LEA(c); + out.putOp(156); + out.put2A(a + sceneBaseTileX); + out.put2LE(b + sceneBaseTileZ); + out.put2LEA(c); } if (action == 94) { boolean flag5 = method85(2, 0, 0, 0, self.pathTileZ[0], 0, 0, b, self.pathTileX[0], false, a); @@ -4573,15 +4555,15 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(181); - aBuffer_1192.put2LE(b + sceneBaseTileZ); - aBuffer_1192.put2(c); - aBuffer_1192.put2LE(a + sceneBaseTileX); - aBuffer_1192.put2A(anInt1137); + out.putOp(181); + out.put2LE(b + sceneBaseTileZ); + out.put2(c); + out.put2LE(a + sceneBaseTileX); + out.put2A(anInt1137); } if (action == 646) { - aBuffer_1192.putOp(185); - aBuffer_1192.put2(b); + out.putOp(185); + out.put2(b); Component component_2 = Component.instances[b]; if ((component_2.anIntArrayArray226 != null) && (component_2.anIntArrayArray226[0][0] == 5)) { int i2 = component_2.anIntArrayArray226[0][1]; @@ -4600,8 +4582,8 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(17); - aBuffer_1192.put2LEA(c); + out.putOp(17); + out.put2LEA(c); } } if (action == 965) { @@ -4612,8 +4594,8 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(21); - aBuffer_1192.put2(c); + out.putOp(21); + out.put2(c); } } if (action == 413) { @@ -4624,9 +4606,9 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(131); - aBuffer_1192.put2LEA(c); - aBuffer_1192.put2A(anInt1137); + out.putOp(131); + out.put2LEA(c); + out.put2A(anInt1137); } } if (action == 200) { @@ -4641,10 +4623,10 @@ public class Game extends GameShell { } if (type != null) { String s9; - if (type.aByteArray89 != null) { - s9 = new String(type.aByteArray89); + if (type.desc != null) { + s9 = new String(type.desc); } else { - s9 = "It's a " + type.aString65 + "."; + s9 = "It's a " + type.name + "."; } method77(0, "", s9); } @@ -4652,10 +4634,10 @@ public class Game extends GameShell { } if (action == 900) { method66(c, b, a); - aBuffer_1192.putOp(252); - aBuffer_1192.put2LEA((c >> 14) & 0x7fff); - aBuffer_1192.put2LE(b + sceneBaseTileZ); - aBuffer_1192.put2A(a + sceneBaseTileX); + out.putOp(252); + out.put2LEA((c >> 14) & 0x7fff); + out.put2LE(b + sceneBaseTileZ); + out.put2A(a + sceneBaseTileX); } if (action == 412) { NPCEntity npc_6 = npcs[c]; @@ -4665,8 +4647,8 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(72); - aBuffer_1192.put2A(c); + out.putOp(72); + out.put2A(c); } } if (action == 365) { @@ -4677,9 +4659,9 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(249); - aBuffer_1192.put2A(c); - aBuffer_1192.put2LE(anInt1137); + out.putOp(249); + out.put2A(c); + out.put2LE(anInt1137); } } if (action == 729) { @@ -4690,8 +4672,8 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(39); - aBuffer_1192.put2LE(c); + out.putOp(39); + out.put2LE(c); } } if (action == 577) { @@ -4702,16 +4684,16 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(139); - aBuffer_1192.put2LE(c); + out.putOp(139); + out.put2LE(c); } } if ((action == 956) && method66(c, b, a)) { - aBuffer_1192.putOp(35); - aBuffer_1192.put2LE(a + sceneBaseTileX); - aBuffer_1192.put2A(anInt1137); - aBuffer_1192.put2A(b + sceneBaseTileZ); - aBuffer_1192.put2LE((c >> 14) & 0x7fff); + out.putOp(35); + out.put2LE(a + sceneBaseTileX); + out.put2A(anInt1137); + out.put2A(b + sceneBaseTileZ); + out.put2LE((c >> 14) & 0x7fff); } if (action == 567) { boolean flag6 = method85(2, 0, 0, 0, self.pathTileZ[0], 0, 0, b, self.pathTileX[0], false, a); @@ -4722,16 +4704,16 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(23); - aBuffer_1192.put2LE(b + sceneBaseTileZ); - aBuffer_1192.put2LE(c); - aBuffer_1192.put2LE(a + sceneBaseTileX); + out.putOp(23); + out.put2LE(b + sceneBaseTileZ); + out.put2LE(c); + out.put2LE(a + sceneBaseTileX); } if (action == 867) { - aBuffer_1192.putOp(43); - aBuffer_1192.put2LE(b); - aBuffer_1192.put2A(c); - aBuffer_1192.put2A(a); + out.putOp(43); + out.put2LE(b); + out.put2A(c); + out.put2A(a); anInt1243 = 0; anInt1244 = b; anInt1245 = a; @@ -4744,11 +4726,11 @@ public class Game extends GameShell { } } if (action == 543) { - aBuffer_1192.putOp(237); - aBuffer_1192.put2(a); - aBuffer_1192.put2A(c); - aBuffer_1192.put2(b); - aBuffer_1192.put2A(anInt1137); + out.putOp(237); + out.put2(a); + out.put2A(c); + out.put2(b); + out.put2A(anInt1137); anInt1243 = 0; anInt1244 = b; anInt1245 = a; @@ -4788,11 +4770,11 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(14); - aBuffer_1192.put2A(anInt1284); - aBuffer_1192.put2(c); - aBuffer_1192.put2(anInt1285); - aBuffer_1192.put2LE(anInt1283); + out.putOp(14); + out.put2A(anInt1284); + out.put2(c); + out.put2(anInt1285); + out.put2LE(anInt1283); } } if (action == 639) { @@ -4820,10 +4802,10 @@ public class Game extends GameShell { } } if (action == 454) { - aBuffer_1192.putOp(41); - aBuffer_1192.put2(c); - aBuffer_1192.put2A(a); - aBuffer_1192.put2A(b); + out.putOp(41); + out.put2(c); + out.put2A(a); + out.put2A(b); anInt1243 = 0; anInt1244 = b; anInt1245 = a; @@ -4843,30 +4825,30 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(18); - aBuffer_1192.put2LE(c); + out.putOp(18); + out.put2LE(c); } } if (action == 113) { method66(c, b, a); - aBuffer_1192.putOp(70); - aBuffer_1192.put2LE(a + sceneBaseTileX); - aBuffer_1192.put2(b + sceneBaseTileZ); - aBuffer_1192.put2LEA((c >> 14) & 0x7fff); + out.putOp(70); + out.put2LE(a + sceneBaseTileX); + out.put2(b + sceneBaseTileZ); + out.put2LEA((c >> 14) & 0x7fff); } if (action == 872) { method66(c, b, a); - aBuffer_1192.putOp(234); - aBuffer_1192.put2LEA(a + sceneBaseTileX); - aBuffer_1192.put2A((c >> 14) & 0x7fff); - aBuffer_1192.put2LEA(b + sceneBaseTileZ); + out.putOp(234); + out.put2LEA(a + sceneBaseTileX); + out.put2A((c >> 14) & 0x7fff); + out.put2LEA(b + sceneBaseTileZ); } if (action == 502) { method66(c, b, a); - aBuffer_1192.putOp(132); - aBuffer_1192.put2LEA(a + sceneBaseTileX); - aBuffer_1192.put2((c >> 14) & 0x7fff); - aBuffer_1192.put2A(b + sceneBaseTileZ); + out.putOp(132); + out.put2LEA(a + sceneBaseTileX); + out.put2((c >> 14) & 0x7fff); + out.put2A(b + sceneBaseTileZ); } if (action == 1125) { ObjType type = ObjType.get(c); @@ -4874,16 +4856,16 @@ public class Game extends GameShell { String s5; if ((component_4 != null) && (component_4.slotAmount[a] >= 0x186a0)) { s5 = component_4.slotAmount[a] + " x " + type.name; - } else if (type.description != null) { - s5 = new String(type.description); + } else if (type.examine != null) { + s5 = new String(type.examine); } else { s5 = "It's a " + type.name + "."; } method77(0, "", s5); } if (action == 169) { - aBuffer_1192.putOp(185); - aBuffer_1192.put2(b); + out.putOp(185); + out.put2(b); Component component_3 = Component.instances[b]; if ((component_3.anIntArrayArray226 != null) && (component_3.anIntArrayArray226[0][0] == 5)) { int l2 = component_3.anIntArrayArray226[0][1]; @@ -4922,16 +4904,16 @@ public class Game extends GameShell { crossY = super.mousePressY; crossMode = 2; crossCycle = 0; - aBuffer_1192.putOp(253); - aBuffer_1192.put2LE(a + sceneBaseTileX); - aBuffer_1192.put2LEA(b + sceneBaseTileZ); - aBuffer_1192.put2A(c); + out.putOp(253); + out.put2LE(a + sceneBaseTileX); + out.put2LEA(b + sceneBaseTileZ); + out.put2A(c); } if (action == 1448) { ObjType type_1 = ObjType.get(c); String s6; - if (type_1.description != null) { - s6 = new String(type_1.description); + if (type_1.examine != null) { + s6 = new String(type_1.examine); } else { s6 = "It's a " + type_1.name + "."; } @@ -5075,11 +5057,11 @@ public class Game extends GameShell { DoublyLinkedList list = aListArrayArrayArray827[currentPlane][i1][j1]; if (list != null) { for (ObjStackEntity objStack = (ObjStackEntity) list.peekBack(); objStack != null; objStack = (ObjStackEntity) list.next()) { - ObjType type = ObjType.get(objStack.anInt1558); + ObjType type = ObjType.get(objStack.id); if (anInt1282 == 1) { aStringArray1199[menuSize] = "Use " + aString1286 + " with @lre@" + type.name; menuAction[menuSize] = 511; - menuParamC[menuSize] = objStack.anInt1558; + menuParamC[menuSize] = objStack.id; menuParamA[menuSize] = i1; menuParamB[menuSize] = j1; menuSize++; @@ -5087,15 +5069,15 @@ public class Game extends GameShell { if ((anInt1138 & 1) == 1) { aStringArray1199[menuSize] = aString1139 + " @lre@" + type.name; menuAction[menuSize] = 94; - menuParamC[menuSize] = objStack.anInt1558; + menuParamC[menuSize] = objStack.id; menuParamA[menuSize] = i1; menuParamB[menuSize] = j1; menuSize++; } } else { for (int j3 = 4; j3 >= 0; j3--) { - if ((type.aStringArray168 != null) && (type.aStringArray168[j3] != null)) { - aStringArray1199[menuSize] = type.aStringArray168[j3] + " @lre@" + type.name; + if ((type.groundOptions != null) && (type.groundOptions[j3] != null)) { + aStringArray1199[menuSize] = type.groundOptions[j3] + " @lre@" + type.name; if (j3 == 0) { menuAction[menuSize] = 652; } @@ -5111,14 +5093,14 @@ public class Game extends GameShell { if (j3 == 4) { menuAction[menuSize] = 213; } - menuParamC[menuSize] = objStack.anInt1558; + menuParamC[menuSize] = objStack.id; menuParamA[menuSize] = i1; menuParamB[menuSize] = j1; menuSize++; } else if (j3 == 2) { aStringArray1199[menuSize] = "Take @lre@" + type.name; menuAction[menuSize] = 234; - menuParamC[menuSize] = objStack.anInt1558; + menuParamC[menuSize] = objStack.id; menuParamA[menuSize] = i1; menuParamB[menuSize] = j1; menuSize++; @@ -5126,7 +5108,7 @@ public class Game extends GameShell { } aStringArray1199[menuSize] = "Examine @lre@" + type.name; menuAction[menuSize] = 1448; - menuParamC[menuSize] = objStack.anInt1558; + menuParamC[menuSize] = objStack.id; menuParamA[menuSize] = i1; menuParamB[menuSize] = j1; menuSize++; @@ -5194,22 +5176,22 @@ public class Game extends GameShell { method35(l1); } if ((socialAction == 3) && (socialInput.length() > 0)) { - aBuffer_1192.putOp(126); - aBuffer_1192.put1(0); - int k = aBuffer_1192.position; - aBuffer_1192.put8(aLong953); - ChatCompression.pack(socialInput, aBuffer_1192); - aBuffer_1192.putSize1(aBuffer_1192.position - k); + out.putOp(126); + out.put1(0); + int k = out.position; + out.put8(aLong953); + ChatCompression.pack(socialInput, out); + out.putSize1(out.position - k); socialInput = ChatCompression.method527(socialInput); socialInput = Censor.method497(socialInput, 0); method77(6, StringUtil.formatName(StringUtil.fromBase37(aLong953)), socialInput); if (anInt845 == 2) { anInt845 = 1; aBoolean1233 = true; - aBuffer_1192.putOp(95); - aBuffer_1192.put1(anInt1287); - aBuffer_1192.put1(anInt845); - aBuffer_1192.put1(anInt1248); + out.putOp(95); + out.put1(anInt1287); + out.put1(anInt845); + out.put1(anInt1248); } } if ((socialAction == 4) && (anInt822 < 100)) { @@ -5237,8 +5219,8 @@ public class Game extends GameShell { i1 = Integer.parseInt(chatbackInput); } catch (Exception ignored) { } - aBuffer_1192.putOp(208); - aBuffer_1192.put4(i1); + out.putOp(208); + out.put4(i1); } chatbackInputType = 0; redrawChatback = true; @@ -5254,8 +5236,8 @@ public class Game extends GameShell { } if ((j == 13) || (j == 10)) { if (chatbackInput.length() > 0) { - aBuffer_1192.putOp(60); - aBuffer_1192.put8(StringUtil.toBase37(chatbackInput)); + out.putOp(60); + out.put8(StringUtil.toBase37(chatbackInput)); } chatbackInputType = 0; redrawChatback = true; @@ -5299,9 +5281,9 @@ public class Game extends GameShell { } } if (aString887.startsWith("::")) { - aBuffer_1192.putOp(103); - aBuffer_1192.put1(aString887.length() - 1); - aBuffer_1192.put(aString887.substring(2)); + out.putOp(103); + out.put1(aString887.length() - 1); + out.put(aString887.substring(2)); } else { String s = aString887.toLowerCase(); int j2 = 0; @@ -5360,15 +5342,15 @@ public class Game extends GameShell { i3 = 5; aString887 = aString887.substring(6); } - aBuffer_1192.putOp(4); - aBuffer_1192.put1(0); - int j3 = aBuffer_1192.position; - aBuffer_1192.put1S(i3); - aBuffer_1192.put1S(j2); + out.putOp(4); + out.put1(0); + int j3 = out.position; + out.put1S(i3); + out.put1S(j2); aBuffer_834.position = 0; ChatCompression.pack(aString887, aBuffer_834); - aBuffer_1192.putA(aBuffer_834.data, 0, aBuffer_834.position); - aBuffer_1192.putSize1(aBuffer_1192.position - j3); + out.putA(aBuffer_834.data, 0, aBuffer_834.position); + out.putSize1(out.position - j3); aString887 = ChatCompression.method527(aString887); aString887 = Censor.method497(aString887, 0); self.aString1506 = aString887; @@ -5385,10 +5367,10 @@ public class Game extends GameShell { if (anInt1287 == 2) { anInt1287 = 3; aBoolean1233 = true; - aBuffer_1192.putOp(95); - aBuffer_1192.put1(anInt1287); - aBuffer_1192.put1(anInt845); - aBuffer_1192.put1(anInt1248); + out.putOp(95); + out.put1(anInt1287); + out.put1(anInt845); + out.put1(anInt1248); } } aString887 = ""; @@ -5942,7 +5924,7 @@ public class Game extends GameShell { int k2 = (int) (Math.cos(d) * 57D); imageMapedge.drawRotated((94 + j2 + 4) - 10, 83 - k2 - 20, 20, 20, 15, 15, d, 256); } else { - method141(image, k, j); + drawInMinimapArea(image, k, j); } } @@ -6030,10 +6012,10 @@ public class Game extends GameShell { connection = new Connection(this, openSocket(43594 + portOffset)); long l = StringUtil.toBase37(username); int i = (int) ((l >> 16) & 31L); - aBuffer_1192.position = 0; - aBuffer_1192.put1(14); - aBuffer_1192.put1(i); - connection.write(aBuffer_1192.data, 0, 2); + out.position = 0; + out.put1(14); + out.put1(i); + connection.write(out.data, 0, 2); for (int j = 0; j < 8; j++) { connection.read(); } @@ -6051,36 +6033,36 @@ public class Game extends GameShell { seed[1] = (int) (Math.random() * 99999999D); seed[2] = (int) (aLong1215 >> 32); seed[3] = (int) aLong1215; - aBuffer_1192.position = 0; - aBuffer_1192.put1(10); - aBuffer_1192.put4(seed[0]); - aBuffer_1192.put4(seed[1]); - aBuffer_1192.put4(seed[2]); - aBuffer_1192.put4(seed[3]); - aBuffer_1192.put4(Signlink.uid); - aBuffer_1192.put(username); - aBuffer_1192.put(password); - aBuffer_1192.encrypt(RSA_EXPONENT, RSA_MODULUS); - aBuffer_847.position = 0; + out.position = 0; + out.put1(10); + out.put4(seed[0]); + out.put4(seed[1]); + out.put4(seed[2]); + out.put4(seed[3]); + out.put4(Signlink.uid); + out.put(username); + out.put(password); + out.encrypt(RSA_EXPONENT, RSA_MODULUS); + login.position = 0; if (reconnect) { - aBuffer_847.put1(18); + login.put1(18); } else { - aBuffer_847.put1(16); + login.put1(16); } - aBuffer_847.put1(aBuffer_1192.position + 36 + 1 + 1 + 2); - aBuffer_847.put1(255); - aBuffer_847.put2(317); - aBuffer_847.put1(lowmem ? 1 : 0); + login.put1(out.position + 36 + 1 + 1 + 2); + login.put1(255); + login.put2(317); + login.put1(lowmem ? 1 : 0); for (int l1 = 0; l1 < 9; l1++) { - aBuffer_847.put4(archiveChecksum[l1]); + login.put4(archiveChecksum[l1]); } - aBuffer_847.put(aBuffer_1192.data, 0, aBuffer_1192.position); - aBuffer_1192.random = new ISAACRandom(seed); + login.put(out.data, 0, out.position); + out.random = new ISAACRandom(seed); for (int j2 = 0; j2 < 4; j2++) { seed[j2] += 50; } randomIn = new ISAACRandom(seed); - connection.write(aBuffer_847.data, 0, aBuffer_847.position); + connection.write(login.data, 0, login.position); k = connection.read(); } if (k == 1) { @@ -6100,7 +6082,7 @@ public class Game extends GameShell { super.aBoolean17 = true; aBoolean954 = true; ingame = true; - aBuffer_1192.position = 0; + out.position = 0; in.position = 0; ptype = -1; anInt841 = -1; @@ -6240,7 +6222,7 @@ public class Game extends GameShell { } if (k == 15) { ingame = true; - aBuffer_1192.position = 0; + out.position = 0; in.position = 0; ptype = -1; anInt841 = -1; @@ -6467,27 +6449,27 @@ public class Game extends GameShell { int k6 = anIntArray1280[i4]; int i7 = anIntArray1281[i4]; if (i == 0) { - aBuffer_1192.putOp(164); - aBuffer_1192.put1(k4 + k4 + 3); + out.putOp(164); + out.put1(k4 + k4 + 3); } if (i == 1) { - aBuffer_1192.putOp(248); - aBuffer_1192.put1(k4 + k4 + 3 + 14); + out.putOp(248); + out.put1(k4 + k4 + 3 + 14); } if (i == 2) { - aBuffer_1192.putOp(98); - aBuffer_1192.put1(k4 + k4 + 3); + out.putOp(98); + out.put1(k4 + k4 + 3); } - aBuffer_1192.put2LEA(k6 + sceneBaseTileX); + out.put2LEA(k6 + sceneBaseTileX); anInt1261 = anIntArray1280[0]; anInt1262 = anIntArray1281[0]; for (int j7 = 1; j7 < k4; j7++) { i4--; - aBuffer_1192.put1(anIntArray1280[i4] - k6); - aBuffer_1192.put1(anIntArray1281[i4] - i7); + out.put1(anIntArray1280[i4] - k6); + out.put1(anIntArray1281[i4] - i7); } - aBuffer_1192.put2LE(i7 + sceneBaseTileZ); - aBuffer_1192.put1C((super.actionKey[5] != 1) ? 0 : 1); + out.put2LE(i7 + sceneBaseTileZ); + out.put1C((super.actionKey[5] != 1) ? 0 : 1); return true; } return i != 1; @@ -6594,7 +6576,7 @@ public class Game extends GameShell { if (!type.aBoolean84) { return; } - String s = type.aString65; + String s = type.name; if (type.anInt61 != 0) { s = s + method110(self.anInt1705, type.anInt61) + " (level-" + type.anInt61 + ")"; } @@ -6617,10 +6599,10 @@ public class Game extends GameShell { menuSize++; } } else { - if (type.aStringArray66 != null) { + if (type.op != null) { for (int l = 4; l >= 0; l--) { - if ((type.aStringArray66[l] != null) && !type.aStringArray66[l].equalsIgnoreCase("attack")) { - aStringArray1199[menuSize] = type.aStringArray66[l] + " @yel@" + s; + if ((type.op[l] != null) && !type.op[l].equalsIgnoreCase("attack")) { + aStringArray1199[menuSize] = type.op[l] + " @yel@" + s; if (l == 0) { menuAction[menuSize] = 20; } @@ -6643,14 +6625,14 @@ public class Game extends GameShell { } } } - if (type.aStringArray66 != null) { + if (type.op != null) { for (int i1 = 4; i1 >= 0; i1--) { - if ((type.aStringArray66[i1] != null) && type.aStringArray66[i1].equalsIgnoreCase("attack")) { + if ((type.op[i1] != null) && type.op[i1].equalsIgnoreCase("attack")) { char c = '\0'; if (type.anInt61 > self.anInt1705) { c = '\u07D0'; } - aStringArray1199[menuSize] = type.aStringArray66[i1] + " @yel@" + s; + aStringArray1199[menuSize] = type.op[i1] + " @yel@" + s; if (i1 == 0) { menuAction[menuSize] = 20 + c; } @@ -6720,8 +6702,8 @@ public class Game extends GameShell { if (player.anInt1705 > self.anInt1705) { c = '\u07D0'; } - if ((self.anInt1701 != 0) && (player.anInt1701 != 0)) { - if (self.anInt1701 == player.anInt1701) { + if ((self.team != 0) && (player.team != 0)) { + if (self.team == player.team) { c = '\u07D0'; } else { c = '\0'; @@ -6894,17 +6876,17 @@ public class Game extends GameShell { int j2 = (self.z - l1) >> 7; boolean flag1 = method85(1, 0, 0, 0, self.pathTileZ[0], 0, 0, j2, self.pathTileX[0], true, i2); if (flag1) { - aBuffer_1192.put1(i); - aBuffer_1192.put1(j); - aBuffer_1192.put2(anInt1185); - aBuffer_1192.put1(57); - aBuffer_1192.put1(anInt1209); - aBuffer_1192.put1(minimapZoom); - aBuffer_1192.put1(89); - aBuffer_1192.put2(self.x); - aBuffer_1192.put2(self.z); - aBuffer_1192.put1(anInt1264); - aBuffer_1192.put1(63); + out.put1(i); + out.put1(j); + out.put2(anInt1185); + out.put1(57); + out.put1(anInt1209); + out.put1(minimapZoom); + out.put1(89); + out.put2(self.x); + out.put2(self.z); + out.put1(anInt1264); + out.put1(63); } } } @@ -7436,8 +7418,8 @@ public class Game extends GameShell { if (aBoolean1103) { if ((anInt1054 != -1) && (anInt1054 == selectedTab)) { anInt1054 = -1; - aBuffer_1192.putOp(120); - aBuffer_1192.put1(selectedTab); + out.putOp(120); + out.put1(selectedTab); } aBoolean1103 = false; aArea_1125.bind(); @@ -7930,7 +7912,7 @@ public class Game extends GameShell { if (child.slotObjId[k4] > 0) { ObjType type = ObjType.get(child.slotObjId[k4] - 1); String s2 = type.name; - if (type.aBoolean176 || (child.slotAmount[k4] != 1)) { + if (type.stackable || (child.slotAmount[k4] != 1)) { s2 = s2 + " x" + method14(child.slotAmount[k4]); } int i9 = cx + (i6 * (115 + child.slotMarginX)); @@ -8289,8 +8271,8 @@ public class Game extends GameShell { } aLongArray925[anInt822++] = l; redrawInvback = true; - aBuffer_1192.putOp(133); - aBuffer_1192.put8(l); + out.putOp(133); + out.put8(l); } public void method114() { @@ -8631,8 +8613,8 @@ public class Game extends GameShell { for (int k = j; k < anInt822; k++) { aLongArray925[k] = aLongArray925[k + 1]; } - aBuffer_1192.putOp(74); - aBuffer_1192.put8(l); + out.putOp(74); + out.put8(l); return; } } @@ -8673,7 +8655,7 @@ public class Game extends GameShell { if (j1 == 4) { Component component_1 = Component.instances[ai[l++]]; int k2 = ai[l++]; - if ((k2 >= 0) && (k2 < ObjType.anInt203) && (!ObjType.get(k2).members || members)) { + if ((k2 >= 0) && (k2 < ObjType.count) && (!ObjType.get(k2).members || members)) { for (int j3 = 0; j3 < component_1.slotObjId.length; j3++) { if (component_1.slotObjId[j3] == (k2 + 1)) { k1 += component_1.slotAmount[j3]; @@ -8703,7 +8685,7 @@ public class Game extends GameShell { if (j1 == 10) { Component component_2 = Component.instances[ai[l++]]; int l2 = ai[l++] + 1; - if ((l2 >= 0) && (l2 < ObjType.anInt203) && (!ObjType.get(l2).members || members)) { + if ((l2 >= 0) && (l2 < ObjType.count) && (!ObjType.get(l2).members || members)) { for (int k3 = 0; k3 < component_2.slotObjId.length; k3++) { if (component_2.slotObjId[k3] != l2) { continue; @@ -8818,7 +8800,7 @@ public class Game extends GameShell { for (int j5 = 0; j5 < activeMapFunctionCount; j5++) { int k = ((activeMapFunctionX[j5] * 4) + 2) - (self.x / 32); int i3 = ((activeMapFunctionZ[j5] * 4) + 2) - (self.z / 32); - method141(activeMapFunctions[j5], k, i3); + drawInMinimapArea(activeMapFunctions[j5], k, i3); } for (int k5 = 0; k5 < 104; k5++) { @@ -8827,7 +8809,7 @@ public class Game extends GameShell { if (list != null) { int l = ((k5 * 4) + 2) - (self.x / 32); int j3 = ((l5 * 4) + 2) - (self.z / 32); - method141(imageMapdot0, l, j3); + drawInMinimapArea(imageMapdot0, l, j3); } } } @@ -8841,7 +8823,7 @@ public class Game extends GameShell { if ((type != null) && type.aBoolean87 && type.aBoolean84) { int i1 = (npc.x / 32) - (self.x / 32); int k3 = (npc.z / 32) - (self.z / 32); - method141(imageMapdot1, i1, k3); + drawInMinimapArea(imageMapdot1, i1, k3); } } } @@ -8860,15 +8842,15 @@ public class Game extends GameShell { break; } boolean flag2 = false; - if ((player.anInt1701 != 0) && (self.anInt1701 == player.anInt1701)) { + if ((player.team != 0) && (self.team == player.team)) { flag2 = true; } if (flag1) { - method141(imageMapdot3, j1, l3); + drawInMinimapArea(imageMapdot3, j1, l3); } else if (flag2) { - method141(imageMapdot4, j1, l3); + drawInMinimapArea(imageMapdot4, j1, l3); } else { - method141(imageMapdot2, j1, l3); + drawInMinimapArea(imageMapdot2, j1, l3); } } } @@ -8898,7 +8880,7 @@ public class Game extends GameShell { if (anInt1261 != 0) { int j2 = ((anInt1261 * 4) + 2) - (self.x / 32); int l4 = ((anInt1262 * 4) + 2) - (self.z / 32); - method141(imageMapmarker0, j2, l4); + drawInMinimapArea(imageMapmarker0, j2, l4); } Draw2D.fillRect(97, 78, 3, 3, 0xffffff); areaViewport.bind(); @@ -9316,10 +9298,10 @@ public class Game extends GameShell { DoublyLinkedList list_1 = aListArrayArrayArray827[currentPlane][j3][i6]; if (list_1 != null) { 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)) { + if ((objStack_3.id != (l8 & 0x7fff)) || (objStack_3.amount != k11)) { continue; } - objStack_3.anInt1559 = l13; + objStack_3.amount = l13; break; } method25(j3, i6); @@ -9351,8 +9333,8 @@ public class Game extends GameShell { int j14 = buffer.get2U(); if ((k6 >= 0) && (j9 >= 0) && (k6 < 104) && (j9 < 104) && (i12 != selfPlayerId)) { ObjStackEntity class30_sub2_sub4_sub2_2 = new ObjStackEntity(); - class30_sub2_sub4_sub2_2.anInt1558 = i1; - class30_sub2_sub4_sub2_2.anInt1559 = j14; + class30_sub2_sub4_sub2_2.id = i1; + class30_sub2_sub4_sub2_2.amount = j14; if (aListArrayArrayArray827[currentPlane][k6][j9] == null) { aListArrayArrayArray827[currentPlane][k6][j9] = new DoublyLinkedList(); } @@ -9370,7 +9352,7 @@ public class Game extends GameShell { DoublyLinkedList list = aListArrayArrayArray827[currentPlane][i4][l6]; if (list != null) { for (ObjStackEntity objStack = (ObjStackEntity) list.peekFront(); objStack != null; objStack = (ObjStackEntity) list.prev()) { - if (objStack.anInt1558 != (k9 & 0x7fff)) { + if (objStack.id != (k9 & 0x7fff)) { continue; } objStack.unlink(); @@ -9531,8 +9513,8 @@ public class Game extends GameShell { int i13 = anInt1269 + (i8 & 7); if ((l10 >= 0) && (i13 >= 0) && (l10 < 104) && (i13 < 104)) { ObjStackEntity objStack_1 = new ObjStackEntity(); - objStack_1.anInt1558 = k2; - objStack_1.anInt1559 = j5; + objStack_1.id = k2; + objStack_1.amount = j5; if (aListArrayArrayArray827[currentPlane][l10][i13] == null) { aListArrayArrayArray827[currentPlane][l10][i13] = new DoublyLinkedList(); } @@ -9732,22 +9714,22 @@ public class Game extends GameShell { } } - public void method141(Image24 image, int i, int j) { - int k = (anInt1185 + anInt1209) & 0x7ff; - int l = (i * i) + (j * j); - if (l > 6400) { + public void drawInMinimapArea(Image24 image, int dx, int dy) { + int angle = (anInt1185 + anInt1209) & 0x7ff; + int distance = (dx * dx) + (dy * dy); + if (distance > 6400) { return; } - int i1 = Model.sin[k]; - int j1 = Model.cos[k]; - i1 = (i1 * 256) / (minimapZoom + 256); - j1 = (j1 * 256) / (minimapZoom + 256); - int k1 = ((j * i1) + (i * j1)) >> 16; - int l1 = ((j * j1) - (i * i1)) >> 16; - if (l > 2500) { - image.drawMasked(imageMapback, 83 - l1 - (image.cropH / 2) - 4, ((94 + k1) - (image.cropW / 2)) + 4); + int sinAngle = Model.sin[angle]; + int cosAngle = Model.cos[angle]; + sinAngle = (sinAngle * 256) / (minimapZoom + 256); + cosAngle = (cosAngle * 256) / (minimapZoom + 256); + int x = ((dy * sinAngle) + (dx * cosAngle)) >> 16; + int y = ((dy * cosAngle) - (dx * sinAngle)) >> 16; + if (distance > 2500) { + image.drawMasked(imageMapback, 83 - y - (image.cropH / 2) - 4, ((94 + x) - (image.cropW / 2)) + 4); } else { - image.draw(((94 + k1) - (image.cropW / 2)) + 4, 83 - l1 - (image.cropH / 2) - 4); + image.draw(((94 + x) - (image.cropW / 2)) + 4, 83 - y - (image.cropH / 2) - 4); } } @@ -9973,7 +9955,7 @@ public class Game extends GameShell { int k = in.get2ULEA(); Component.instances[k].anInt233 = 3; if (self.aType_1698 == null) { - Component.instances[k].anInt234 = (self.anIntArray1700[0] << 25) + (self.anIntArray1700[4] << 20) + (self.anIntArray1717[0] << 15) + (self.anIntArray1717[8] << 10) + (self.anIntArray1717[11] << 5) + self.anIntArray1717[1]; + Component.instances[k].anInt234 = (self.anIntArray1700[0] << 25) + (self.anIntArray1700[4] << 20) + (self.appearance[0] << 15) + (self.appearance[8] << 10) + (self.appearance[11] << 5) + self.appearance[1]; } else { Component.instances[k].anInt234 = (int) (0x12345678L + self.aType_1698.uid); } @@ -11098,7 +11080,7 @@ public class Game extends GameShell { } public void method147() { - aBuffer_1192.putOp(130); + out.putOp(130); if (invbackComponentId != -1) { invbackComponentId = -1; redrawInvback = true; diff --git a/src/main/java/LocType.java b/src/main/java/LocType.java index 7880aa7..0798a78 100644 --- a/src/main/java/LocType.java +++ b/src/main/java/LocType.java @@ -5,496 +5,503 @@ import org.apache.commons.collections4.map.LRUMap; import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; public class LocType { - public static final Model[] TMP_MODELS = new Model[4]; - public static boolean lowmem; - public static Buffer dat; - public static int[] offsets; - public static int count; - public static Game game; - public static int anInt771; - public static LRUMap aCache_780 = new LRUMap(30); - public static LocType[] cache; - public static LRUMap modelCache = new LRUMap(500); + public static final Model[] TMP_MODELS = new Model[4]; + public static boolean lowmem; + public static Buffer dat; + public static int[] offsets; + public static int count; + public static Game game; + public static int anInt771; + public static LRUMap aCache_780 = new LRUMap(30); + public static LocType[] cache; + public static LRUMap modelCache = new LRUMap(500); - public static LocType get(int i) { - for (int j = 0; j < 20; j++) { - if (cache[j].index == i) { - return cache[j]; - } - } - anInt771 = (anInt771 + 1) % 20; - LocType type = cache[anInt771]; - dat.position = offsets[i]; - type.index = i; - type.reset(); - type.method582(dat); - return type; - } + public static LocType get(int i) { + if (i >= count) { + i = 0; + } + for (int j = 0; j < 20; j++) { + if (cache[j].index == i) { + return cache[j]; + } + } + anInt771 = (anInt771 + 1) % 20; + LocType type = cache[anInt771]; + dat.position = offsets[i]; + type.index = i; + type.reset(); + type.method582(dat); + return type; + } - public static void unload() { - modelCache = null; - aCache_780 = null; - offsets = null; - cache = null; - dat = null; - } + public static void unload() { + modelCache = null; + aCache_780 = null; + offsets = null; + cache = null; + dat = null; + } - public static void unpack(FileArchive archive) throws IOException { - dat = new Buffer(archive.read("loc.dat")); - Buffer buffer = new Buffer(archive.read("loc.idx")); - count = buffer.get2U(); - offsets = new int[count]; - int i = 2; - for (int j = 0; j < count; j++) { - offsets[j] = i; - i += buffer.get2U(); - } - cache = new LocType[20]; - for (int k = 0; k < 20; k++) { - cache[k] = new LocType(); - } - } + public static void unpack(FileArchive archive) throws IOException { + dat = new Buffer(archive.read("loc.dat")); + Buffer buffer = new Buffer(archive.read("loc.idx")); + count = buffer.get2U(); + offsets = new int[count]; + int i = 2; + for (int j = 0; j < count; j++) { + offsets[j] = i; + i += buffer.get2U(); + } + cache = new LocType[20]; + for (int k = 0; k < 20; k++) { + cache[k] = new LocType(); + } + } - public boolean important; - public byte lightAmbient; - public int translateX; - public String name; - public int scaleY; - public byte lightAttenuation; - public int sizeX; - public int translateY; - public int mapfunctionIcon; - public int[] dstColor; - public int scaleX; - public int varp; - public boolean invert; - public int index = -1; - public boolean blocksProjectiles; - public int mapsceneIcon; - public int[] overrideIds; - public int supportsObj; - public int sizeZ; - public boolean adjustToTerrain; - public boolean occludes; - public boolean decorative; - public boolean solid; - public int interactionSideFlags; - /** - * Models flagged as dynamic will always copy their models face information by making copyFaces - * equal true. - * @see Model#Model(boolean, boolean, Model) - */ - public boolean dynamic; - public int scaleZ; - public int[] modelIds; - public int varbit; - public int decorationPadding; - public int[] modelTypes; - public String description; - public boolean interactable; - public boolean castShadow; - public int seqId; - public int translateZ; - public int[] srcColor; - public String[] actions; + public boolean important; + public byte lightAmbient; + public int translateX; + public String name; + public int scaleY; + public byte lightAttenuation; + public int sizeX; + public int translateY; + public int mapfunctionIcon; + public int[] dstColor; + public int scaleX; + public int varp; + public boolean invert; + public int index = -1; + public boolean blocksProjectiles; + public int mapsceneIcon; + public int[] overrideIds; + public int supportsObj; + public int sizeZ; + public boolean adjustToTerrain; + public boolean occludes; + public boolean decorative; + public boolean solid; + public int interactionSideFlags; + /** + * Models flagged as dynamic will always copy their models face information by making copyFaces + * equal true. + * + * @see Model#Model(boolean, boolean, Model) + */ + public boolean dynamic; + public int scaleZ; + public int[] modelIds; + public int varbit; + public int decorationPadding; + public int[] modelTypes; + public String description; + public boolean interactable; + public boolean castShadow; + public int seqId; + public int translateZ; + public int[] srcColor; + public String[] actions; - public LocType() { - } + public LocType() { + } - public void reset() { - modelIds = null; - modelTypes = null; - name = null; - description = null; - srcColor = null; - dstColor = null; - sizeX = 1; - sizeZ = 1; - solid = true; - blocksProjectiles = true; - interactable = false; - adjustToTerrain = false; - dynamic = false; - occludes = false; - seqId = -1; - decorationPadding = 16; - lightAmbient = 0; - lightAttenuation = 0; - actions = null; - mapfunctionIcon = -1; - mapsceneIcon = -1; - invert = false; - castShadow = true; - scaleX = 128; - scaleZ = 128; - scaleY = 128; - interactionSideFlags = 0; - translateX = 0; - translateY = 0; - translateZ = 0; - important = false; - decorative = false; - supportsObj = -1; - varbit = -1; - varp = -1; - overrideIds = null; - } + public void reset() { + modelIds = null; + modelTypes = null; + name = null; + description = null; + srcColor = null; + dstColor = null; + sizeX = 1; + sizeZ = 1; + solid = true; + blocksProjectiles = true; + interactable = false; + adjustToTerrain = false; + dynamic = false; + occludes = false; + seqId = -1; + decorationPadding = 16; + lightAmbient = 0; + lightAttenuation = 0; + actions = null; + mapfunctionIcon = -1; + mapsceneIcon = -1; + invert = false; + castShadow = true; + scaleX = 128; + scaleZ = 128; + scaleY = 128; + interactionSideFlags = 0; + translateX = 0; + translateY = 0; + translateZ = 0; + important = false; + decorative = false; + supportsObj = -1; + varbit = -1; + varp = -1; + overrideIds = null; + } - public void method574(OnDemand onDemand) { - if (modelIds == null) { - return; - } - for (int k : modelIds) { - onDemand.method560(k & 0xffff, 0); - } - } + public void method574(OnDemand onDemand) { + if (modelIds == null) { + return; + } + for (int k : modelIds) { + onDemand.method560(k & 0xffff, 0); + } + } - public boolean method577(int i) { - if (modelTypes == null) { - if (modelIds == null) { - return true; - } - if (i != 10) { - return true; - } - boolean flag1 = true; - for (int j : modelIds) { - flag1 &= Model.validate(j & 0xffff); - } - return flag1; - } - for (int j = 0; j < modelTypes.length; j++) { - if (modelTypes[j] == i) { - return Model.validate(modelIds[j] & 0xffff); - } - } - return true; - } + public boolean method577(int i) { + if (modelTypes == null) { + if (modelIds == null) { + return true; + } + if (i != 10) { + return true; + } + boolean flag1 = true; + for (int j : modelIds) { + flag1 &= Model.validate(j & 0xffff); + } + return flag1; + } + for (int j = 0; j < modelTypes.length; j++) { + if (modelTypes[j] == i) { + return Model.validate(modelIds[j] & 0xffff); + } + } + return true; + } - public Model method578(int i, int j, int k, int l, int i1, int j1, int k1) { - Model model = method581(i, k1, j); - if (model == null) { - return null; - } - if (adjustToTerrain || dynamic) { - model = new Model(adjustToTerrain, dynamic, model); - } - if (adjustToTerrain) { - int l1 = (k + l + i1 + j1) / 4; - for (int i2 = 0; i2 < model.vertexCount; i2++) { - int j2 = model.vertexX[i2]; - int k2 = model.vertexZ[i2]; - int l2 = k + (((l - k) * (j2 + 64)) / 128); - int i3 = j1 + (((i1 - j1) * (j2 + 64)) / 128); - int j3 = l2 + (((i3 - l2) * (k2 + 64)) / 128); - model.vertexY[i2] += j3 - l1; - } - model.calculateBoundsY(); - } - return model; - } + public Model method578(int i, int j, int k, int l, int i1, int j1, int k1) { + Model model = method581(i, k1, j); + if (model == null) { + return null; + } + if (adjustToTerrain || dynamic) { + model = new Model(adjustToTerrain, dynamic, model); + } + if (adjustToTerrain) { + int l1 = (k + l + i1 + j1) / 4; + for (int i2 = 0; i2 < model.vertexCount; i2++) { + int j2 = model.vertexX[i2]; + int k2 = model.vertexZ[i2]; + int l2 = k + (((l - k) * (j2 + 64)) / 128); + int i3 = j1 + (((i1 - j1) * (j2 + 64)) / 128); + int j3 = l2 + (((i3 - l2) * (k2 + 64)) / 128); + model.vertexY[i2] += j3 - l1; + } + model.calculateBoundsY(); + } + return model; + } - public boolean method579() { - if (modelIds == null) { - return true; - } - boolean flag1 = true; - for (int j : modelIds) { - flag1 &= Model.validate(j & 0xffff); - } - return flag1; - } + public boolean method579() { + if (modelIds == null) { + return true; + } + boolean flag1 = true; + for (int j : modelIds) { + flag1 &= Model.validate(j & 0xffff); + } + return flag1; + } - public LocType method580() { - int i = -1; - if (varbit != -1) { - VarbitType varbit = VarbitType.instances[this.varbit]; - int j = varbit.varp; - int k = varbit.lsb; - int l = varbit.msb; - int i1 = Game.BITMASK[l - k]; - i = (game.variables[j] >> k) & i1; - } else if (varp != -1) { - i = game.variables[varp]; - } - if ((i < 0) || (i >= overrideIds.length) || (overrideIds[i] == -1)) { - return null; - } else { - return get(overrideIds[i]); - } - } + public LocType method580() { + int i = -1; + if (varbit != -1) { + VarbitType varbit = VarbitType.instances[this.varbit]; + int j = varbit.varp; + int k = varbit.lsb; + int l = varbit.msb; + int i1 = Game.BITMASK[l - k]; + i = (game.variables[j] >> k) & i1; + } else if (varp != -1) { + i = game.variables[varp]; + } + if ((i < 0) || (i >= overrideIds.length) || (overrideIds[i] == -1)) { + return null; + } else { + return get(overrideIds[i]); + } + } - public Model method581(int type, int seqFrame, int rotation) { - Model model = null; - long bitset; - if (modelTypes == null) { - if (type != 10) { - return null; - } - bitset = ((long) index << 6) + rotation + ((long) (seqFrame + 1) << 32); - Model model_1 = aCache_780.get(bitset); - if (model_1 != null) { - return model_1; - } - if (modelIds == null) { - return null; - } - boolean flip = invert ^ (rotation > 3); - int modelCount = modelIds.length; + public Model method581(int type, int seqFrame, int rotation) { + Model model = null; + long bitset; + if (modelTypes == null) { + if (type != 10) { + return null; + } + bitset = ((long) index << 6) + rotation + ((long) (seqFrame + 1) << 32); + Model model_1 = aCache_780.get(bitset); + if (model_1 != null) { + return model_1; + } + if (modelIds == null) { + return null; + } + boolean flip = invert ^ (rotation > 3); + int modelCount = modelIds.length; - for (int i = 0; i < modelCount; i++) { - int modelId = modelIds[i]; + for (int i = 0; i < modelCount; i++) { + int modelId = modelIds[i]; - if (flip) { - modelId += 0x10000; - } + if (flip) { + modelId += 0x10000; + } - model = modelCache.get(modelId); - if (model == null) { - model = Model.tryGet(modelId & 0xffff); - if (model == null) { - return null; - } - if (flip) { - model.rotateY180(); - } - modelCache.put((long) modelId, model); - } + model = modelCache.get(modelId); + if (model == null) { + model = Model.tryGet(modelId & 0xffff); + if (model == null) { + return null; + } + if (flip) { + model.rotateY180(); + } + modelCache.put((long) modelId, model); + } - if (modelCount > 1) { - TMP_MODELS[i] = model; - } - } + if (modelCount > 1) { + TMP_MODELS[i] = model; + } + } - if (modelCount > 1) { - model = new Model(modelCount, TMP_MODELS); - } - } else { - int typeId = -1; - for (int i = 0; i < modelTypes.length; i++) { - if (modelTypes[i] != type) { - continue; - } - typeId = i; - break; - } + if (modelCount > 1) { + model = new Model(modelCount, TMP_MODELS); + } + } else { + int typeId = -1; + for (int i = 0; i < modelTypes.length; i++) { + if (modelTypes[i] != type) { + continue; + } + typeId = i; + break; + } - if (typeId == -1) { - return null; - } + if (typeId == -1) { + return null; + } - bitset = ((long) index << 6) + ((long) typeId << 3) + rotation + ((long) (seqFrame + 1) << 32); + bitset = ((long) index << 6) + ((long) typeId << 3) + rotation + ((long) (seqFrame + 1) << 32); - Model class30_sub2_sub4_sub6_2 = aCache_780.get(bitset); - if (class30_sub2_sub4_sub6_2 != null) { - return class30_sub2_sub4_sub6_2; - } - int j2 = modelIds[typeId]; - boolean flag3 = invert ^ (rotation > 3); - if (flag3) { - j2 += 0x10000; - } - model = modelCache.get(j2); - if (model == null) { - model = Model.tryGet(j2 & 0xffff); - if (model == null) { - return null; - } - if (flag3) { - model.rotateY180(); - } - modelCache.put((long) j2, model); - } - } + Model class30_sub2_sub4_sub6_2 = aCache_780.get(bitset); + if (class30_sub2_sub4_sub6_2 != null) { + return class30_sub2_sub4_sub6_2; + } + int j2 = modelIds[typeId]; + boolean flag3 = invert ^ (rotation > 3); + if (flag3) { + j2 += 0x10000; + } + model = modelCache.get(j2); + if (model == null) { + model = Model.tryGet(j2 & 0xffff); + if (model == null) { + return null; + } + if (flag3) { + model.rotateY180(); + } + modelCache.put((long) j2, model); + } + } - boolean scaled = (scaleX != 128) || (scaleZ != 128) || (scaleY != 128); - boolean translated = (translateX != 0) || (translateY != 0) || (translateZ != 0); + boolean scaled = (scaleX != 128) || (scaleZ != 128) || (scaleY != 128); + boolean translated = (translateX != 0) || (translateY != 0) || (translateZ != 0); - Model model_3 = new Model(srcColor == null, SeqFrame.isNull(seqFrame), (rotation == 0) && (seqFrame == -1) && !scaled && !translated, model); + Model model_3 = new Model(srcColor == null, SeqFrame.isNull(seqFrame), (rotation == 0) && (seqFrame == -1) && !scaled && !translated, model); - if (seqFrame != -1) { - model_3.createLabelReferences(); - model_3.applySequenceFrame(seqFrame); - model_3.labelFaces = null; - model_3.labelVertices = null; - } + if (seqFrame != -1) { + model_3.createLabelReferences(); + model_3.applySequenceFrame(seqFrame); + model_3.labelFaces = null; + model_3.labelVertices = null; + } - while (rotation-- > 0) { - model_3.rotateY90(); - } - if (srcColor != null) { - for (int k2 = 0; k2 < srcColor.length; k2++) { - model_3.recolor(srcColor[k2], dstColor[k2]); - } - } - if (scaled) { - model_3.scale(scaleX, scaleY, scaleZ); - } - if (translated) { - model_3.translate(translateX, translateY, translateZ); - } - model_3.calculateNormals(64 + lightAmbient, 768 + (lightAttenuation * 5), -50, -10, -50, !dynamic); - if (supportsObj == 1) { - model_3.objRaise = model_3.minY; - } - aCache_780.put(bitset, model_3); - return model_3; - } + while (rotation-- > 0) { + model_3.rotateY90(); + } + if (srcColor != null) { + for (int k2 = 0; k2 < srcColor.length; k2++) { + model_3.recolor(srcColor[k2], dstColor[k2]); + } + } + if (scaled) { + model_3.scale(scaleX, scaleY, scaleZ); + } + if (translated) { + model_3.translate(translateX, translateY, translateZ); + } + model_3.calculateNormals(64 + lightAmbient, 768 + (lightAttenuation * 5), -50, -10, -50, !dynamic); + if (supportsObj == 1) { + model_3.objRaise = model_3.minY; + } + aCache_780.put(bitset, model_3); + return model_3; + } - public void method582(Buffer buffer) { - int i = -1; - label0: - do { - int j; - do { - j = buffer.get1U(); - if (j == 0) { - break label0; - } - if (j == 1) { - int k = buffer.get1U(); - if (k > 0) { - if ((modelIds == null) || lowmem) { - modelTypes = new int[k]; - modelIds = new int[k]; - for (int k1 = 0; k1 < k; k1++) { - modelIds[k1] = buffer.get2U(); - modelTypes[k1] = buffer.get1U(); - } - } else { - buffer.position += k * 3; - } - } - } else if (j == 2) { - name = buffer.getString(); - } else if (j == 3) { - description = buffer.getString(); - } else if (j == 5) { - int l = buffer.get1U(); - if (l > 0) { - if ((modelIds == null) || lowmem) { - modelTypes = null; - modelIds = new int[l]; - for (int l1 = 0; l1 < l; l1++) { - modelIds[l1] = buffer.get2U(); - } - } else { - buffer.position += l * 2; - } - } - } else if (j == 14) { - sizeX = buffer.get1U(); - } else if (j == 15) { - sizeZ = buffer.get1U(); - } else if (j == 17) { - solid = false; - } else if (j == 18) { - blocksProjectiles = false; - } else if (j == 19) { - i = buffer.get1U(); - if (i == 1) { - interactable = true; - } - } else if (j == 21) { - adjustToTerrain = true; - } else if (j == 22) { - dynamic = true; - } else if (j == 23) { - occludes = true; - } else if (j == 24) { - seqId = buffer.get2U(); - if (seqId == 65535) { - seqId = -1; - } - } else if (j == 28) { - decorationPadding = buffer.get1U(); - } else if (j == 29) { - lightAmbient = buffer.get1(); - } else if (j == 39) { - lightAttenuation = buffer.get1(); - } else if ((j >= 30) && (j < 39)) { - if (actions == null) { - actions = new String[5]; - } - actions[j - 30] = buffer.getString(); - if (actions[j - 30].equalsIgnoreCase("hidden")) { - actions[j - 30] = null; - } - } else if (j == 40) { - int i1 = buffer.get1U(); - srcColor = new int[i1]; - dstColor = new int[i1]; - for (int i2 = 0; i2 < i1; i2++) { - srcColor[i2] = buffer.get2U(); - dstColor[i2] = buffer.get2U(); - } - } else if (j == 60) { - mapfunctionIcon = buffer.get2U(); - } else if (j == 62) { - invert = true; - } else if (j == 64) { - castShadow = false; - } else if (j == 65) { - scaleX = buffer.get2U(); - } else if (j == 66) { - scaleZ = buffer.get2U(); - } else if (j == 67) { - scaleY = buffer.get2U(); - } else if (j == 68) { - mapsceneIcon = buffer.get2U(); - } else if (j == 69) { - interactionSideFlags = buffer.get1U(); - } else if (j == 70) { - translateX = buffer.get2(); - } else if (j == 71) { - translateY = buffer.get2(); - } else if (j == 72) { - translateZ = buffer.get2(); - } else if (j == 73) { - important = true; - } else if (j == 74) { - decorative = true; - } else { - if (j != 75) { - continue; - } - supportsObj = buffer.get1U(); - } - continue label0; - } while (j != 77); - varbit = buffer.get2U(); - if (varbit == 65535) { - varbit = -1; - } - varp = buffer.get2U(); - if (varp == 65535) { - varp = -1; - } - int j1 = buffer.get1U(); - overrideIds = new int[j1 + 1]; - for (int j2 = 0; j2 <= j1; j2++) { - overrideIds[j2] = buffer.get2U(); - if (overrideIds[j2] == 65535) { - overrideIds[j2] = -1; - } - } - } while (true); - if (i == -1) { - interactable = (modelIds != null) && ((modelTypes == null) || (modelTypes[0] == 10)); - if (actions != null) { - interactable = true; - } - } - if (decorative) { - solid = false; - blocksProjectiles = false; - } - if (supportsObj == -1) { - supportsObj = solid ? 1 : 0; - } - } + public void method582(Buffer buffer) { + int i = -1; + label0: + do { + int j; + do { + j = buffer.get1U(); + if (j == 0) { + break label0; + } + if (j == 1) { + int k = buffer.get1U(); + if (k > 0) { + if ((modelIds == null) || lowmem) { + modelTypes = new int[k]; + modelIds = new int[k]; + for (int k1 = 0; k1 < k; k1++) { + modelIds[k1] = buffer.get2U(); + modelTypes[k1] = buffer.get1U(); + } + } else { + buffer.position += k * 3; + } + } + } else if (j == 2) { + name = buffer.getString(); + } else if (j == 3) { + description = buffer.getString(); + } else if (j == 5) { + int l = buffer.get1U(); + if (l > 0) { + if ((modelIds == null) || lowmem) { + modelTypes = null; + modelIds = new int[l]; + for (int l1 = 0; l1 < l; l1++) { + modelIds[l1] = buffer.get2U(); + } + } else { + buffer.position += l * 2; + } + } + } else if (j == 14) { + sizeX = buffer.get1U(); + } else if (j == 15) { + sizeZ = buffer.get1U(); + } else if (j == 17) { + solid = false; + } else if (j == 18) { + blocksProjectiles = false; + } else if (j == 19) { + i = buffer.get1U(); + if (i == 1) { + interactable = true; + } + } else if (j == 21) { + adjustToTerrain = true; + } else if (j == 22) { + dynamic = true; + } else if (j == 23) { + occludes = true; + } else if (j == 24) { + seqId = buffer.get2U(); + if (seqId == 65535) { + seqId = -1; + } + } else if (j == 28) { + decorationPadding = buffer.get1U(); + } else if (j == 29) { + lightAmbient = buffer.get1(); + } else if (j == 39) { + lightAttenuation = buffer.get1(); + } else if ((j >= 30) && (j < 39)) { + if (actions == null) { + actions = new String[5]; + } + actions[j - 30] = buffer.getString(); + if (actions[j - 30].equalsIgnoreCase("hidden")) { + actions[j - 30] = null; + } + } else if (j == 40) { + int i1 = buffer.get1U(); + srcColor = new int[i1]; + dstColor = new int[i1]; + for (int i2 = 0; i2 < i1; i2++) { + srcColor[i2] = buffer.get2U(); + dstColor[i2] = buffer.get2U(); + } + } else if (j == 60) { + mapfunctionIcon = buffer.get2U(); + } else if (j == 62) { + invert = true; + } else if (j == 64) { + castShadow = false; + } else if (j == 65) { + scaleX = buffer.get2U(); + } else if (j == 66) { + scaleZ = buffer.get2U(); + } else if (j == 67) { + scaleY = buffer.get2U(); + } else if (j == 68) { + mapsceneIcon = buffer.get2U(); + } else if (j == 69) { + interactionSideFlags = buffer.get1U(); + } else if (j == 70) { + translateX = buffer.get2(); + } else if (j == 71) { + translateY = buffer.get2(); + } else if (j == 72) { + translateZ = buffer.get2(); + } else if (j == 73) { + important = true; + } else if (j == 74) { + decorative = true; + } else { + if (j != 75) { + continue; + } + supportsObj = buffer.get1U(); + } + continue label0; + } while (j != 77); + varbit = buffer.get2U(); + if (varbit == 65535) { + varbit = -1; + } + varp = buffer.get2U(); + if (varp == 65535) { + varp = -1; + } + int j1 = buffer.get1U(); + overrideIds = new int[j1 + 1]; + for (int j2 = 0; j2 <= j1; j2++) { + overrideIds[j2] = buffer.get2U(); + if (overrideIds[j2] == 65535) { + overrideIds[j2] = -1; + } + } + } while (true); + if (i == -1) { + interactable = (modelIds != null) && ((modelTypes == null) || (modelTypes[0] == 10)); + if (actions != null) { + interactable = true; + } + } + if (decorative) { + solid = false; + blocksProjectiles = false; + } + if (supportsObj == -1) { + supportsObj = solid ? 1 : 0; + } + } } diff --git a/src/main/java/Model.java b/src/main/java/Model.java index 70fe2e9..731fb0b 100644 --- a/src/main/java/Model.java +++ b/src/main/java/Model.java @@ -308,7 +308,7 @@ public class Model extends Entity { * * @see #draw(int, int, int, int, int, int, int, int, int) */ - public boolean pickBounds = false; + public boolean pickable = false; /** * A storage for the original vertex normals to give {@link Scene#method308(Model, Model, int, int, int, boolean)} * a reference. @@ -1915,7 +1915,7 @@ public class Model extends Entity { int mouseY = Model.mouseY - Draw3D.centerY; if ((mouseX > leftX) && (mouseX < rightX) && (mouseY > topY) && (mouseY < bottomY)) { - if (pickBounds) { + if (pickable) { pickedBitsets[pickedCount++] = bitset; } else { picking = true; diff --git a/src/main/java/NPCEntity.java b/src/main/java/NPCEntity.java index 66014a5..3a4a087 100644 --- a/src/main/java/NPCEntity.java +++ b/src/main/java/NPCEntity.java @@ -55,7 +55,7 @@ public class NPCEntity extends PathingEntity { } } if (type.size == 1) { - model.pickBounds = true; + model.pickable = true; } return model; } diff --git a/src/main/java/NPCType.java b/src/main/java/NPCType.java index da82667..a5f3cde 100644 --- a/src/main/java/NPCType.java +++ b/src/main/java/NPCType.java @@ -8,303 +8,301 @@ import java.io.IOException; public class NPCType { - private static int cachePosition; - private static Buffer dat; - public static int[] offsets; - private static NPCType[] cache; - public static Game game; - public static LRUMap modelCache = new LRUMap<>(30); + private static int cachePosition; + private static Buffer dat; + public static int[] offsets; + private static NPCType[] cache; + public static Game game; + public static int count; + public static LRUMap modelCache = new LRUMap<>(30); - public static NPCType get(int id) { - if (id > cache.length) { - id = 0; - } - for (int j = 0; j < 20; j++) { - if (cache[j].uid == (long) id) { - return cache[j]; - } - } - cachePosition = (cachePosition + 1) % 20; - NPCType type = cache[cachePosition] = new NPCType(); - dat.position = offsets[id]; - type.uid = id; - type.read(dat); - return type; - } + public static NPCType get(int id) { + for (int j = 0; j < 20; j++) { + if (cache[j].uid == (long) id) { + return cache[j]; + } + } + cachePosition = (cachePosition + 1) % 20; + NPCType type = cache[cachePosition] = new NPCType(); + dat.position = offsets[id]; + type.uid = id; + type.read(dat); + return type; + } - public static void unpack(FileArchive archive) throws IOException { - dat = new Buffer(archive.read("npc.dat")); - Buffer buffer = new Buffer(archive.read("npc.idx")); - int count = buffer.get2U(); - offsets = new int[count]; + public static void unpack(FileArchive archive) throws IOException { + dat = new Buffer(archive.read("npc.dat")); + Buffer buffer = new Buffer(archive.read("npc.idx")); + count = buffer.get2U(); + offsets = new int[count]; - int offset = 2; - for (int i = 0; i < count; i++) { - offsets[i] = offset; - offset += buffer.get2U(); - } + int offset = 2; + for (int i = 0; i < count; i++) { + offsets[i] = offset; + offset += buffer.get2U(); + } - cache = new NPCType[20]; + cache = new NPCType[20]; - for (int k = 0; k < 20; k++) { - cache[k] = new NPCType(); - } - } + for (int k = 0; k < 20; k++) { + cache[k] = new NPCType(); + } + } - public static void unload() { - modelCache = null; - offsets = null; - cache = null; - dat = null; - } + public static void unload() { + modelCache = null; + offsets = null; + cache = null; + dat = null; + } - public int seqTurnRight = -1; - public int varbit = -1; - public int seqTurnAround = -1; - public int varp = -1; - public int anInt61 = -1; - public String aString65; - public String[] aStringArray66; - public int seqWalk = -1; - public byte size = 1; - public int[] anIntArray70; - public int unusedInt0 = -1; - public int[] anIntArray73; - public int anInt75 = -1; - public int[] anIntArray76; - public int seqStand = -1; - public long uid = -1L; - public int turnSpeed = 32; - public int seqTurnLeft = -1; - public boolean aBoolean84 = true; - public int anInt85; - public int anInt86 = 128; - public boolean aBoolean87 = true; - public int[] overrides; - public byte[] aByteArray89; - public int unusedInt1 = -1; - public int anInt91 = 128; - public int anInt92; - public boolean aBoolean93 = false; - public int[] anIntArray94; - public int unusedInt2 = -1; + public int seqTurnRight = -1; + public int varbit = -1; + public int seqTurnAround = -1; + public int varp = -1; + public int anInt61 = -1; + public String name; + public String[] op; + public int seqWalk = -1; + public byte size = 1; + public int[] anIntArray70; + public int unusedInt0 = -1; + public int[] anIntArray73; + public int anInt75 = -1; + public int[] anIntArray76; + public int seqStand = -1; + public long uid = -1L; + public int turnSpeed = 32; + public int seqTurnLeft = -1; + public boolean aBoolean84 = true; + public int anInt85; + public int anInt86 = 128; + public boolean aBoolean87 = true; + public int[] overrides; + public byte[] desc; + public int unusedInt1 = -1; + public int anInt91 = 128; + public int anInt92; + public boolean aBoolean93 = false; + public int[] anIntArray94; + public int unusedInt2 = -1; - public NPCType() { - } + public NPCType() { + } - public Model method160() { - if (overrides != null) { - NPCType type = getOverrideType(); - if (type == null) { - return null; - } else { - return type.method160(); - } - } - if (anIntArray73 == null) { - return null; - } - boolean flag1 = false; - for (int value : anIntArray73) { - if (!Model.validate(value)) { - flag1 = true; - } - } - if (flag1) { - return null; - } - Model[] aclass30_sub2_sub4_sub6 = new Model[anIntArray73.length]; - for (int j = 0; j < anIntArray73.length; j++) { - aclass30_sub2_sub4_sub6[j] = Model.tryGet(anIntArray73[j]); - } - Model model; - if (aclass30_sub2_sub4_sub6.length == 1) { - model = aclass30_sub2_sub4_sub6[0]; - } else { - model = new Model(aclass30_sub2_sub4_sub6.length, aclass30_sub2_sub4_sub6); - } - if (anIntArray76 != null) { - for (int k = 0; k < anIntArray76.length; k++) { - model.recolor(anIntArray76[k], anIntArray70[k]); - } - } - return model; - } + public Model method160() { + if (overrides != null) { + NPCType type = getOverrideType(); + if (type == null) { + return null; + } else { + return type.method160(); + } + } + if (anIntArray73 == null) { + return null; + } + boolean flag1 = false; + for (int value : anIntArray73) { + if (!Model.validate(value)) { + flag1 = true; + } + } + if (flag1) { + return null; + } + Model[] aclass30_sub2_sub4_sub6 = new Model[anIntArray73.length]; + for (int j = 0; j < anIntArray73.length; j++) { + aclass30_sub2_sub4_sub6[j] = Model.tryGet(anIntArray73[j]); + } + Model model; + if (aclass30_sub2_sub4_sub6.length == 1) { + model = aclass30_sub2_sub4_sub6[0]; + } else { + model = new Model(aclass30_sub2_sub4_sub6.length, aclass30_sub2_sub4_sub6); + } + if (anIntArray76 != null) { + for (int k = 0; k < anIntArray76.length; k++) { + model.recolor(anIntArray76[k], anIntArray70[k]); + } + } + return model; + } - public NPCType getOverrideType() { - int value = -1; + public NPCType getOverrideType() { + int value = -1; - if (varbit != -1) { - VarbitType vb = VarbitType.instances[this.varbit]; - int varp = vb.varp; - int lsb = vb.lsb; - int msb = vb.msb; - int mask = Game.BITMASK[msb - lsb]; - value = (game.variables[varp] >> lsb) & mask; - } else if (varp != -1) { - value = game.variables[varp]; - } + if (varbit != -1) { + VarbitType vb = VarbitType.instances[this.varbit]; + int varp = vb.varp; + int lsb = vb.lsb; + int msb = vb.msb; + int mask = Game.BITMASK[msb - lsb]; + value = (game.variables[varp] >> lsb) & mask; + } else if (varp != -1) { + value = game.variables[varp]; + } - if ((value < 0) || (value >= overrides.length) || (overrides[value] == -1)) { - return null; - } else { - return get(overrides[value]); - } - } + if ((value < 0) || (value >= overrides.length) || (overrides[value] == -1)) { + return null; + } else { + return get(overrides[value]); + } + } - public Model method164(int j, int k, int[] ai) { - if (overrides != null) { - NPCType type = getOverrideType(); - if (type == null) { - return null; - } else { - return type.method164(j, k, ai); - } - } + public Model method164(int j, int k, int[] ai) { + if (overrides != null) { + NPCType type = getOverrideType(); + if (type == null) { + return null; + } else { + return type.method164(j, k, ai); + } + } - Model model = modelCache.get(uid); + Model model = modelCache.get(uid); - if (model == null) { - boolean flag = false; - for (int value : anIntArray94) { - if (!Model.validate(value)) { - flag = true; - } - } - if (flag) { - return null; - } - Model[] aclass30_sub2_sub4_sub6 = new Model[anIntArray94.length]; - for (int j1 = 0; j1 < anIntArray94.length; j1++) { - aclass30_sub2_sub4_sub6[j1] = Model.tryGet(anIntArray94[j1]); - } - if (aclass30_sub2_sub4_sub6.length == 1) { - model = aclass30_sub2_sub4_sub6[0]; - } else { - model = new Model(aclass30_sub2_sub4_sub6.length, aclass30_sub2_sub4_sub6); - } - if (anIntArray76 != null) { - for (int k1 = 0; k1 < anIntArray76.length; k1++) { - model.recolor(anIntArray76[k1], anIntArray70[k1]); - } - } - model.createLabelReferences(); - model.calculateNormals(64 + anInt85, 850 + anInt92, -30, -50, -30, true); - modelCache.put(uid, model); - } - Model model_1 = Model.EMPTY; - model_1.set(model, SeqFrame.isNull(k) & SeqFrame.isNull(j)); - if ((k != -1) && (j != -1)) { - model_1.applySequenceFrames(k, j, ai); - } else if (k != -1) { - model_1.applySequenceFrame(k); - } - if ((anInt91 != 128) || (anInt86 != 128)) { - model_1.scale(anInt91, anInt91, anInt86); - } - model_1.calculateBoundsCylinder(); - model_1.labelFaces = null; - model_1.labelVertices = null; - if (size == 1) { - model_1.pickBounds = true; - } - return model_1; - } + if (model == null) { + boolean flag = false; + for (int value : anIntArray94) { + if (!Model.validate(value)) { + flag = true; + } + } + if (flag) { + return null; + } + Model[] aclass30_sub2_sub4_sub6 = new Model[anIntArray94.length]; + for (int j1 = 0; j1 < anIntArray94.length; j1++) { + aclass30_sub2_sub4_sub6[j1] = Model.tryGet(anIntArray94[j1]); + } + if (aclass30_sub2_sub4_sub6.length == 1) { + model = aclass30_sub2_sub4_sub6[0]; + } else { + model = new Model(aclass30_sub2_sub4_sub6.length, aclass30_sub2_sub4_sub6); + } + if (anIntArray76 != null) { + for (int k1 = 0; k1 < anIntArray76.length; k1++) { + model.recolor(anIntArray76[k1], anIntArray70[k1]); + } + } + model.createLabelReferences(); + model.calculateNormals(64 + anInt85, 850 + anInt92, -30, -50, -30, true); + modelCache.put(uid, model); + } + Model model_1 = Model.EMPTY; + model_1.set(model, SeqFrame.isNull(k) & SeqFrame.isNull(j)); + if ((k != -1) && (j != -1)) { + model_1.applySequenceFrames(k, j, ai); + } else if (k != -1) { + model_1.applySequenceFrame(k); + } + if ((anInt91 != 128) || (anInt86 != 128)) { + model_1.scale(anInt91, anInt91, anInt86); + } + model_1.calculateBoundsCylinder(); + model_1.labelFaces = null; + model_1.labelVertices = null; + if (size == 1) { + model_1.pickable = true; + } + return model_1; + } - public void read(Buffer buffer) { - do { - int i = buffer.get1U(); - if (i == 0) { - return; - } - if (i == 1) { - int j = buffer.get1U(); - anIntArray94 = new int[j]; - for (int j1 = 0; j1 < j; j1++) { - anIntArray94[j1] = buffer.get2U(); - } - } else if (i == 2) { - aString65 = buffer.getString(); - } else if (i == 3) { - aByteArray89 = buffer.getStringRaw(); - } else if (i == 12) { - size = buffer.get1(); - } else if (i == 13) { - seqStand = buffer.get2U(); - } else if (i == 14) { - seqWalk = buffer.get2U(); - } else if (i == 17) { - seqWalk = buffer.get2U(); - seqTurnAround = buffer.get2U(); - seqTurnLeft = buffer.get2U(); - seqTurnRight = buffer.get2U(); - } else if ((i >= 30) && (i < 40)) { - if (aStringArray66 == null) { - aStringArray66 = new String[5]; - } - aStringArray66[i - 30] = buffer.getString(); - if (aStringArray66[i - 30].equalsIgnoreCase("hidden")) { - aStringArray66[i - 30] = null; - } - } else if (i == 40) { - int k = buffer.get1U(); - anIntArray76 = new int[k]; - anIntArray70 = new int[k]; - for (int k1 = 0; k1 < k; k1++) { - anIntArray76[k1] = buffer.get2U(); - anIntArray70[k1] = buffer.get2U(); - } - } else if (i == 60) { - int l = buffer.get1U(); - anIntArray73 = new int[l]; - for (int l1 = 0; l1 < l; l1++) { - anIntArray73[l1] = buffer.get2U(); - } - } else if (i == 90) { - unusedInt2 = buffer.get2U(); - } else if (i == 91) { - unusedInt0 = buffer.get2U(); - } else if (i == 92) { - unusedInt1 = buffer.get2U(); - } else if (i == 93) { - aBoolean87 = false; - } else if (i == 95) { - anInt61 = buffer.get2U(); - } else if (i == 97) { - anInt91 = buffer.get2U(); - } else if (i == 98) { - anInt86 = buffer.get2U(); - } else if (i == 99) { - aBoolean93 = true; - } else if (i == 100) { - anInt85 = buffer.get1(); - } else if (i == 101) { - anInt92 = buffer.get1() * 5; - } else if (i == 102) { - anInt75 = buffer.get2U(); - } else if (i == 103) { - turnSpeed = buffer.get2U(); - } else if (i == 106) { - varbit = buffer.get2U(); - if (varbit == 65535) { - varbit = -1; - } - varp = buffer.get2U(); - if (varp == 65535) { - varp = -1; - } - int i1 = buffer.get1U(); - overrides = new int[i1 + 1]; - for (int i2 = 0; i2 <= i1; i2++) { - overrides[i2] = buffer.get2U(); - if (overrides[i2] == 65535) { - overrides[i2] = -1; - } - } - } else if (i == 107) { - aBoolean84 = false; - } - } while (true); - } + public void read(Buffer buffer) { + do { + int i = buffer.get1U(); + if (i == 0) { + return; + } + if (i == 1) { + int j = buffer.get1U(); + anIntArray94 = new int[j]; + for (int j1 = 0; j1 < j; j1++) { + anIntArray94[j1] = buffer.get2U(); + } + } else if (i == 2) { + name = buffer.getString(); + } else if (i == 3) { + desc = buffer.getStringRaw(); + } else if (i == 12) { + size = buffer.get1(); + } else if (i == 13) { + seqStand = buffer.get2U(); + } else if (i == 14) { + seqWalk = buffer.get2U(); + } else if (i == 17) { + seqWalk = buffer.get2U(); + seqTurnAround = buffer.get2U(); + seqTurnLeft = buffer.get2U(); + seqTurnRight = buffer.get2U(); + } else if ((i >= 30) && (i < 40)) { + if (op == null) { + op = new String[5]; + } + op[i - 30] = buffer.getString(); + if (op[i - 30].equalsIgnoreCase("hidden")) { + op[i - 30] = null; + } + } else if (i == 40) { + int k = buffer.get1U(); + anIntArray76 = new int[k]; + anIntArray70 = new int[k]; + for (int k1 = 0; k1 < k; k1++) { + anIntArray76[k1] = buffer.get2U(); + anIntArray70[k1] = buffer.get2U(); + } + } else if (i == 60) { + int l = buffer.get1U(); + anIntArray73 = new int[l]; + for (int l1 = 0; l1 < l; l1++) { + anIntArray73[l1] = buffer.get2U(); + } + } else if (i == 90) { + unusedInt2 = buffer.get2U(); + } else if (i == 91) { + unusedInt0 = buffer.get2U(); + } else if (i == 92) { + unusedInt1 = buffer.get2U(); + } else if (i == 93) { + aBoolean87 = false; + } else if (i == 95) { + anInt61 = buffer.get2U(); + } else if (i == 97) { + anInt91 = buffer.get2U(); + } else if (i == 98) { + anInt86 = buffer.get2U(); + } else if (i == 99) { + aBoolean93 = true; + } else if (i == 100) { + anInt85 = buffer.get1(); + } else if (i == 101) { + anInt92 = buffer.get1() * 5; + } else if (i == 102) { + anInt75 = buffer.get2U(); + } else if (i == 103) { + turnSpeed = buffer.get2U(); + } else if (i == 106) { + varbit = buffer.get2U(); + if (varbit == 65535) { + varbit = -1; + } + varp = buffer.get2U(); + if (varp == 65535) { + varp = -1; + } + int i1 = buffer.get1U(); + overrides = new int[i1 + 1]; + for (int i2 = 0; i2 <= i1; i2++) { + overrides[i2] = buffer.get2U(); + if (overrides[i2] == 65535) { + overrides[i2] = -1; + } + } + } else if (i == 107) { + aBoolean84 = false; + } + } while (true); + } } diff --git a/src/main/java/ObjStackEntity.java b/src/main/java/ObjStackEntity.java index 42bbaa1..c64836d 100644 --- a/src/main/java/ObjStackEntity.java +++ b/src/main/java/ObjStackEntity.java @@ -4,16 +4,16 @@ public class ObjStackEntity extends Entity { - public int anInt1558; - public int anInt1559; + public int id; + public int amount; public ObjStackEntity() { } @Override public Model getModel() { - ObjType type = ObjType.get(anInt1558); - return type.getModel(anInt1559); + ObjType type = ObjType.get(id); + return type.getModel(amount); } } diff --git a/src/main/java/ObjType.java b/src/main/java/ObjType.java index 2e41fb7..1da7d8b 100644 --- a/src/main/java/ObjType.java +++ b/src/main/java/ObjType.java @@ -5,6 +5,11 @@ import org.apache.commons.collections4.map.LRUMap; import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; + +import static java.nio.file.Files.*; public class ObjType { @@ -12,27 +17,27 @@ public class ObjType { public static LRUMap modelCache = new LRUMap<>(50); public static ObjType[] cached; public static int cachePos; - public static Buffer buf; + public static Buffer dat; public static int[] typeOffset; - public static int anInt203; + public static int count; public static void unload() { modelCache = null; iconCache = null; typeOffset = null; cached = null; - buf = null; + dat = null; } public static void unpack(FileArchive archive) throws IOException { - buf = new Buffer(archive.read("obj.dat")); - Buffer buffer = new Buffer(archive.read("obj.idx")); - anInt203 = buffer.get2U(); - typeOffset = new int[anInt203]; + dat = new Buffer(archive.read("obj.dat")); + Buffer idx = new Buffer(archive.read("obj.idx")); + count = idx.get2U(); + typeOffset = new int[count]; int i = 2; - for (int j = 0; j < anInt203; j++) { + for (int j = 0; j < count; j++) { typeOffset[j] = i; - i += buffer.get2U(); + i += idx.get2U(); } cached = new ObjType[10]; for (int k = 0; k < 10; k++) { @@ -48,19 +53,19 @@ public class ObjType { } cachePos = (cachePos + 1) % 10; ObjType type = cached[cachePos]; - buf.position = typeOffset[id]; + dat.position = typeOffset[id]; type.id = id; type.reset(); - type.read(buf); - if (type.linkedId != -1) { - type.link(); + type.read(dat); + if (type.certificateId != -1) { + type.toCertificate(); } if (!Game.members && type.members) { type.name = "Members Object"; - type.description = "Login to a members' server to use this object.".getBytes(); - type.aStringArray168 = null; - type.aStringArray189 = null; - type.anInt202 = 0; + type.examine = "Login to a members' server to use this object.".getBytes(); + type.groundOptions = null; + type.inventoryOptions = null; + type.team = 0; } return type; } @@ -104,12 +109,12 @@ public class ObjType { } // this will typically be the certificate item for noted stuff - Image24 linkedIcon = null; + Image24 originalIcon = null; - if (type.linkedId != -1) { - linkedIcon = getIcon(type.anInt179, 10, -1); + if (type.certificateId != -1) { + originalIcon = getIcon(type.linkedId, 10, -1); - if (linkedIcon == null) { + if (originalIcon == null) { return null; } } @@ -196,14 +201,14 @@ public class ObjType { } } - if (type.linkedId != -1) { - int w = linkedIcon.cropW; - int h = linkedIcon.cropH; - linkedIcon.cropW = 32; - linkedIcon.cropH = 32; - linkedIcon.draw(0, 0); - linkedIcon.cropW = w; - linkedIcon.cropH = h; + if (type.certificateId != -1) { + int w = originalIcon.cropW; + int h = originalIcon.cropH; + originalIcon.cropW = 32; + originalIcon.cropH = 32; + originalIcon.draw(0, 0); + originalIcon.cropW = w; + originalIcon.cropH = h; } if (outlineColor == 0) { @@ -218,7 +223,7 @@ public class ObjType { Draw3D.lineOffset = _loff; Draw3D.jagged = true; - if (type.aBoolean176) { + if (type.stackable) { icon.cropW = 33; } else { icon.cropW = 32; @@ -228,162 +233,157 @@ public class ObjType { return icon; } - public byte aByte154; - public int anInt155; + public byte femaleOffsetY; + public int cost; public int[] srcColor; public int id = -1; public int[] dstColor; public boolean members; - public int anInt162; - public int linkedId; - public int anInt164; - public int anInt165; - public int anInt166; + public int femaleModelId2; + public int certificateId; + public int femaleModelId1; + public int maleModelId0; + public int maleHeadModelId1; public int scaleX; - public String[] aStringArray168; + public String[] groundOptions; public int iconOffsetX; public String name; - public int anInt173; - public int anInt174; - public int anInt175; - public boolean aBoolean176; - public byte[] description; - public int anInt179; + public int femaleHeadModel1; + public int modelId; + public int maleHeadModelId0; + public boolean stackable; + public byte[] examine; + public int linkedId; public int iconZoom; - public int anInt184; - public int anInt185; - public int anInt188; - public String[] aStringArray189; + public int lightAttenuation; + public int maleModelId2; + public int maleModelId1; + public String[] inventoryOptions; public int iconPitch; public int scaleY; public int scaleZ; public int[] stackId; public int iconOffsetY; - public int anInt196; - public int anInt197; + public int lightAmbient; + public int femaleHeadModel0; public int iconYaw; public int unusedInt; - public int anInt200; + public int femaleModelId0; public int[] stackAmount; - public int anInt202; + public int team; public int iconRoll; - public byte aByte205; + public byte maleOffsetY; public ObjType() { } - public boolean method192(int j) { - int k = anInt175; - int l = anInt166; - if (j == 1) { - k = anInt197; - l = anInt173; + public boolean validateHeadModel(int gender) { + int m0 = maleHeadModelId0; + int m1 = maleHeadModelId1; + if (gender == 1) { + m0 = femaleHeadModel0; + m1 = femaleHeadModel1; } - if (k == -1) { + if (m0 == -1) { return true; } - boolean flag = true; - if (!Model.validate(k)) { - flag = false; + boolean valid = Model.validate(m0); + if ((m1 != -1) && !Model.validate(m1)) { + valid = false; } - if ((l != -1) && !Model.validate(l)) { - flag = false; - } - return flag; + return valid; } - public Model method194(int j) { - int k = anInt175; - int l = anInt166; - if (j == 1) { - k = anInt197; - l = anInt173; + public Model getHeadModel(int gender) { + int m0 = maleHeadModelId0; + int m1 = maleHeadModelId1; + if (gender == 1) { + m0 = femaleHeadModel0; + m1 = femaleHeadModel1; } - if (k == -1) { + if (m0 == -1) { return null; } - Model model = Model.tryGet(k); - if (l != -1) { - Model model_1 = Model.tryGet(l); - Model[] aclass30_sub2_sub4_sub6 = {model, model_1}; - model = new Model(2, aclass30_sub2_sub4_sub6); + Model model = Model.tryGet(m0); + if (m1 != -1) { + model = new Model(2, new Model[]{model, Model.tryGet(m1)}); } if (srcColor != null) { - for (int i1 = 0; i1 < srcColor.length; i1++) { - model.recolor(srcColor[i1], dstColor[i1]); + for (int i = 0; i < srcColor.length; i++) { + model.recolor(srcColor[i], dstColor[i]); } } return model; } - public boolean method195(int j) { - int k = anInt165; - int l = anInt188; - int i1 = anInt185; - if (j == 1) { - k = anInt200; - l = anInt164; - i1 = anInt162; + public boolean validateWornModel(int gender) { + int m0 = maleModelId0; + int m1 = maleModelId1; + int m2 = maleModelId2; + if (gender == 1) { + m0 = femaleModelId0; + m1 = femaleModelId1; + m2 = femaleModelId2; } - if (k == -1) { + if (m0 == -1) { return true; } - boolean flag = true; - if (!Model.validate(k)) { - flag = false; + boolean valid = Model.validate(m0); + if ((m1 != -1) && !Model.validate(m1)) { + valid = false; } - if ((l != -1) && !Model.validate(l)) { - flag = false; + if ((m2 != -1) && !Model.validate(m2)) { + valid = false; } - if ((i1 != -1) && !Model.validate(i1)) { - flag = false; - } - return flag; + return valid; } - public Model method196(int i) { - int j = anInt165; - int k = anInt188; - int l = anInt185; - if (i == 1) { - j = anInt200; - k = anInt164; - l = anInt162; + public Model getWornModel(int gender) { + int m0 = maleModelId0; + int m1 = maleModelId1; + int m2 = maleModelId2; + + if (gender == 1) { + m0 = femaleModelId0; + m1 = femaleModelId1; + m2 = femaleModelId2; } - if (j == -1) { + + if (m0 == -1) { return null; } - Model model = Model.tryGet(j); - if (k != -1) { - if (l != -1) { - Model model_1 = Model.tryGet(k); - Model model_3 = Model.tryGet(l); - Model[] aclass30_sub2_sub4_sub6_1 = {model, model_1, model_3}; - model = new Model(3, aclass30_sub2_sub4_sub6_1); + + Model model = Model.tryGet(m0); + + if (m1 != -1) { + if (m2 != -1) { + model = new Model(3, new Model[]{model, Model.tryGet(m1), Model.tryGet(m2)}); } else { - Model class30_sub2_sub4_sub6_2 = Model.tryGet(k); - Model[] aclass30_sub2_sub4_sub6 = {model, class30_sub2_sub4_sub6_2}; - model = new Model(2, aclass30_sub2_sub4_sub6); + model = new Model(2, new Model[]{model, Model.tryGet(m1)}); } } - if ((i == 0) && (aByte205 != 0)) { - model.translate(0, aByte205, 0); + + if ((gender == 0) && (maleOffsetY != 0)) { + model.translate(0, maleOffsetY, 0); } - if ((i == 1) && (aByte154 != 0)) { - model.translate(0, aByte154, 0); + + if ((gender == 1) && (femaleOffsetY != 0)) { + model.translate(0, femaleOffsetY, 0); } + if (srcColor != null) { for (int i1 = 0; i1 < srcColor.length; i1++) { model.recolor(srcColor[i1], dstColor[i1]); } } + return model; } public void reset() { - anInt174 = 0; + modelId = 0; name = null; - description = null; + examine = null; srcColor = null; dstColor = null; iconZoom = 2000; @@ -393,57 +393,57 @@ public class ObjType { iconOffsetX = 0; iconOffsetY = 0; unusedInt = -1; - aBoolean176 = false; - anInt155 = 1; + stackable = false; + cost = 1; members = false; - aStringArray168 = null; - aStringArray189 = null; - anInt165 = -1; - anInt188 = -1; - aByte205 = 0; - anInt200 = -1; - anInt164 = -1; - aByte154 = 0; - anInt185 = -1; - anInt162 = -1; - anInt175 = -1; - anInt166 = -1; - anInt197 = -1; - anInt173 = -1; + groundOptions = null; + inventoryOptions = null; + maleModelId0 = -1; + maleModelId1 = -1; + maleOffsetY = 0; + femaleModelId0 = -1; + femaleModelId1 = -1; + femaleOffsetY = 0; + maleModelId2 = -1; + femaleModelId2 = -1; + maleHeadModelId0 = -1; + maleHeadModelId1 = -1; + femaleHeadModel0 = -1; + femaleHeadModel1 = -1; stackId = null; stackAmount = null; - anInt179 = -1; linkedId = -1; + certificateId = -1; scaleX = 128; scaleZ = 128; scaleY = 128; - anInt196 = 0; - anInt184 = 0; - anInt202 = 0; + lightAmbient = 0; + lightAttenuation = 0; + team = 0; } - public void link() { - ObjType type = get(linkedId); - anInt174 = type.anInt174; - iconZoom = type.iconZoom; - iconPitch = type.iconPitch; - iconYaw = type.iconYaw; - iconRoll = type.iconRoll; - iconOffsetX = type.iconOffsetX; - iconOffsetY = type.iconOffsetY; - srcColor = type.srcColor; - dstColor = type.dstColor; - ObjType type_1 = get(anInt179); - name = type_1.name; - members = type_1.members; - anInt155 = type_1.anInt155; + public void toCertificate() { + ObjType cert = get(certificateId); + modelId = cert.modelId; + iconZoom = cert.iconZoom; + iconPitch = cert.iconPitch; + iconYaw = cert.iconYaw; + iconRoll = cert.iconRoll; + iconOffsetX = cert.iconOffsetX; + iconOffsetY = cert.iconOffsetY; + srcColor = cert.srcColor; + dstColor = cert.dstColor; + ObjType linked = get(linkedId); + name = linked.name; + members = linked.members; + cost = linked.cost; String s = "a"; - char c = type_1.name.charAt(0); + char c = linked.name.charAt(0); if ((c == 'A') || (c == 'E') || (c == 'I') || (c == 'O') || (c == 'U')) { s = "an"; } - description = ("Swap this note at any bank for " + s + " " + type_1.name + ".").getBytes(); - aBoolean176 = true; + examine = ("Swap this note at any bank for " + s + " " + linked.name + ".").getBytes(); + stackable = true; } public Model getModel(int amount) { @@ -465,7 +465,7 @@ public class ObjType { return model; } - model = Model.tryGet(anInt174); + model = Model.tryGet(modelId); if (model == null) { return null; @@ -481,25 +481,25 @@ public class ObjType { } } - model.calculateNormals(64 + anInt196, 768 + anInt184, -50, -10, -50, true); - model.pickBounds = true; + model.calculateNormals(64 + lightAmbient, 768 + lightAttenuation, -50, -10, -50, true); + model.pickable = true; modelCache.put(id, model); return model; } - public Model method202(int i) { - if ((stackId != null) && (i > 1)) { + public Model getModelUnlit(int amount) { + if ((stackId != null) && (amount > 1)) { int j = -1; for (int k = 0; k < 10; k++) { - if ((i >= stackAmount[k]) && (stackAmount[k] != 0)) { + if ((amount >= stackAmount[k]) && (stackAmount[k] != 0)) { j = stackId[k]; } } if (j != -1) { - return get(j).method202(1); + return get(j).getModelUnlit(1); } } - Model model = Model.tryGet(anInt174); + Model model = Model.tryGet(modelId); if (model == null) { return null; } @@ -518,11 +518,11 @@ public class ObjType { return; } if (i == 1) { - anInt174 = buffer.get2U(); + modelId = buffer.get2U(); } else if (i == 2) { name = buffer.getString(); } else if (i == 3) { - description = buffer.getStringRaw(); + examine = buffer.getStringRaw(); } else if (i == 4) { iconZoom = buffer.get2U(); } else if (i == 5) { @@ -542,34 +542,34 @@ public class ObjType { } else if (i == 10) { unusedInt = buffer.get2U(); } else if (i == 11) { - aBoolean176 = true; + stackable = true; } else if (i == 12) { - anInt155 = buffer.get4(); + cost = buffer.get4(); } else if (i == 16) { members = true; } else if (i == 23) { - anInt165 = buffer.get2U(); - aByte205 = buffer.get1(); + maleModelId0 = buffer.get2U(); + maleOffsetY = buffer.get1(); } else if (i == 24) { - anInt188 = buffer.get2U(); + maleModelId1 = buffer.get2U(); } else if (i == 25) { - anInt200 = buffer.get2U(); - aByte154 = buffer.get1(); + femaleModelId0 = buffer.get2U(); + femaleOffsetY = buffer.get1(); } else if (i == 26) { - anInt164 = buffer.get2U(); + femaleModelId1 = buffer.get2U(); } else if ((i >= 30) && (i < 35)) { - if (aStringArray168 == null) { - aStringArray168 = new String[5]; + if (groundOptions == null) { + groundOptions = new String[5]; } - aStringArray168[i - 30] = buffer.getString(); - if (aStringArray168[i - 30].equalsIgnoreCase("hidden")) { - aStringArray168[i - 30] = null; + groundOptions[i - 30] = buffer.getString(); + if (groundOptions[i - 30].equalsIgnoreCase("hidden")) { + groundOptions[i - 30] = null; } } else if ((i >= 35) && (i < 40)) { - if (aStringArray189 == null) { - aStringArray189 = new String[5]; + if (inventoryOptions == null) { + inventoryOptions = new String[5]; } - aStringArray189[i - 35] = buffer.getString(); + inventoryOptions[i - 35] = buffer.getString(); } else if (i == 40) { int j = buffer.get1U(); srcColor = new int[j]; @@ -579,23 +579,23 @@ public class ObjType { dstColor[k] = buffer.get2U(); } } else if (i == 78) { - anInt185 = buffer.get2U(); + maleModelId2 = buffer.get2U(); } else if (i == 79) { - anInt162 = buffer.get2U(); + femaleModelId2 = buffer.get2U(); } else if (i == 90) { - anInt175 = buffer.get2U(); + maleHeadModelId0 = buffer.get2U(); } else if (i == 91) { - anInt197 = buffer.get2U(); + femaleHeadModel0 = buffer.get2U(); } else if (i == 92) { - anInt166 = buffer.get2U(); + maleHeadModelId1 = buffer.get2U(); } else if (i == 93) { - anInt173 = buffer.get2U(); + femaleHeadModel1 = buffer.get2U(); } else if (i == 95) { iconRoll = buffer.get2U(); } else if (i == 97) { - anInt179 = buffer.get2U(); - } else if (i == 98) { linkedId = buffer.get2U(); + } else if (i == 98) { + certificateId = buffer.get2U(); } else if ((i >= 100) && (i < 110)) { if (stackId == null) { stackId = new int[10]; @@ -610,11 +610,11 @@ public class ObjType { } else if (i == 112) { scaleY = buffer.get2U(); } else if (i == 113) { - anInt196 = buffer.get1(); + lightAmbient = buffer.get1(); } else if (i == 114) { - anInt184 = buffer.get1() * 5; + lightAttenuation = buffer.get1() * 5; } else if (i == 115) { - anInt202 = buffer.get1U(); + team = buffer.get1U(); } } while (true); } diff --git a/src/main/java/OnDemand.java b/src/main/java/OnDemand.java index 94aa8ca..5cba7c5 100644 --- a/src/main/java/OnDemand.java +++ b/src/main/java/OnDemand.java @@ -1,3 +1,5 @@ +import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -5,7 +7,6 @@ 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 { @@ -334,22 +335,22 @@ public class OnDemand implements Runnable { return animIndex.length; } - public void request(int archive, int file) { - if ((archive < 0) || (archive > storeFileVersions.length) || (file < 0) || (file > storeFileVersions[archive].length)) { + public void request(int store, int file) { + if ((store < 0) || (store > storeFileVersions.length) || (file < 0) || (file > storeFileVersions[store].length)) { return; } - if (storeFileVersions[archive][file] == 0) { + if (storeFileVersions[store][file] == 0) { return; } synchronized (lock) { for (OnDemandRequest request : requests) { - if (request.store == archive && request.file == file) { + if (request.store == store && request.file == file) { return; } } OnDemandRequest request = new OnDemandRequest(); - request.store = archive; + request.store = store; request.file = file; request.important = true; synchronized (queue) { @@ -492,7 +493,7 @@ public class OnDemand implements Runnable { } } - public OnDemandRequest poll() { + public OnDemandRequest poll() throws IOException { OnDemandRequest request; synchronized (completed) { @@ -511,26 +512,10 @@ public class OnDemand implements Runnable { return request; } - int i = 0; - try { - GZIPInputStream gzipinputstream = new GZIPInputStream(new ByteArrayInputStream(request.data)); - do { - if (i == aByteArray1359.length) { - throw new RuntimeException("buffer overflow!"); - } - int k = gzipinputstream.read(aByteArray1359, i, aByteArray1359.length - i); - if (k == -1) { - break; - } - i += k; - } while (true); - } catch (IOException _ex) { - throw new RuntimeException("error unzipping"); - } - request.data = new byte[i]; - for (int j = 0; j < i; j++) { - request.data[j] = aByteArray1359[j]; + try (GzipCompressorInputStream gzis = new GzipCompressorInputStream(new ByteArrayInputStream(request.data))) { + request.data = gzis.readAllBytes(); } + return request; } diff --git a/src/main/java/PlayerEntity.java b/src/main/java/PlayerEntity.java index f11db18..3a43bc9 100644 --- a/src/main/java/PlayerEntity.java +++ b/src/main/java/PlayerEntity.java @@ -8,12 +8,12 @@ public class PlayerEntity extends PathingEntity { public static LRUMap modelCache = new LRUMap<>(260); public final int[] anIntArray1700 = new int[5]; - public final int[] anIntArray1717 = new int[12]; + public final int[] appearance = new int[12]; public long aLong1697 = -1L; public NPCType aType_1698; public boolean aBoolean1699 = false; - public int anInt1701; - public int anInt1702; + public int team; + public int gender; public String aString1703; public int anInt1705; public int anInt1706; @@ -45,7 +45,7 @@ public class PlayerEntity extends PathingEntity { return null; } super.anInt1507 = model.minY; - model.pickBounds = true; + model.pickable = true; if (aBoolean1699) { return model; } @@ -99,32 +99,32 @@ public class PlayerEntity extends PathingEntity { model_1.translate(super.x - anInt1711, y - anInt1712, super.z - anInt1713); } } - model.pickBounds = true; + model.pickable = true; return model; } public void method451(Buffer buffer) { buffer.position = 0; - anInt1702 = buffer.get1U(); + gender = buffer.get1U(); anInt1706 = buffer.get1U(); aType_1698 = null; - anInt1701 = 0; + team = 0; for (int j = 0; j < 12; j++) { int k = buffer.get1U(); if (k == 0) { - anIntArray1717[j] = 0; + appearance[j] = 0; continue; } int i1 = buffer.get1U(); - anIntArray1717[j] = (k << 8) + i1; - if ((j == 0) && (anIntArray1717[0] == 65535)) { + appearance[j] = (k << 8) + i1; + if ((j == 0) && (appearance[0] == 65535)) { aType_1698 = NPCType.get(buffer.get2U()); break; } - if ((anIntArray1717[j] >= 512) && ((anIntArray1717[j] - 512) < ObjType.anInt203)) { - int l1 = ObjType.get(anIntArray1717[j] - 512).anInt202; + if ((appearance[j] >= 512) && ((appearance[j] - 512) < ObjType.count)) { + int l1 = ObjType.get(appearance[j] - 512).team; if (l1 != 0) { - anInt1701 = l1; + team = l1; } } } @@ -170,22 +170,22 @@ public class PlayerEntity extends PathingEntity { aLong1718 = 0L; for (int k1 = 0; k1 < 12; k1++) { aLong1718 <<= 4; - if (anIntArray1717[k1] >= 256) { - aLong1718 += anIntArray1717[k1] - 256; + if (appearance[k1] >= 256) { + aLong1718 += appearance[k1] - 256; } } - if (anIntArray1717[0] >= 256) { - aLong1718 += (anIntArray1717[0] - 256) >> 4; + if (appearance[0] >= 256) { + aLong1718 += (appearance[0] - 256) >> 4; } - if (anIntArray1717[1] >= 256) { - aLong1718 += (anIntArray1717[1] - 256) >> 8; + if (appearance[1] >= 256) { + aLong1718 += (appearance[1] - 256) >> 8; } for (int i2 = 0; i2 < 5; i2++) { aLong1718 <<= 3; aLong1718 += anIntArray1700[i2]; } aLong1718 <<= 1; - aLong1718 += anInt1702; + aLong1718 += gender; } public Model method452() { @@ -211,30 +211,32 @@ public class PlayerEntity extends PathingEntity { } if (type.anInt360 >= 0) { j1 = type.anInt360; - l += ((long) j1 - anIntArray1717[5]) << 8; + l += ((long) j1 - appearance[5]) << 8; } if (type.anInt361 >= 0) { k1 = type.anInt361; - l += ((long) k1 - anIntArray1717[3]) << 16; + l += ((long) k1 - appearance[3]) << 16; } } else if (super.seqCurrent >= 0) { k = SeqType.instances[super.seqCurrent].primaryFrames[super.seqFrame]; } + Model model_1 = modelCache.get(l); + if (model_1 == null) { boolean flag = false; - for (int i2 = 0; i2 < 12; i2++) { - int k2 = anIntArray1717[i2]; - if ((k1 >= 0) && (i2 == 3)) { - k2 = k1; + for (int part = 0; part < 12; part++) { + int value = appearance[part]; + if ((k1 >= 0) && (part == 3)) { + value = k1; } - if ((j1 >= 0) && (i2 == 5)) { - k2 = j1; + if ((j1 >= 0) && (part == 5)) { + value = j1; } - if ((k2 >= 256) && (k2 < 512) && !IDKType.instances[k2 - 256].method537()) { + if ((value >= 256) && (value < 512) && !IDKType.instances[value - 256].method537()) { flag = true; } - if ((k2 >= 512) && !ObjType.get(k2 - 512).method195(anInt1702)) { + if ((value >= 512) && !ObjType.get(value - 512).validateWornModel(gender)) { flag = true; } } @@ -247,31 +249,32 @@ public class PlayerEntity extends PathingEntity { } } } + if (model_1 == null) { - Model[] aclass30_sub2_sub4_sub6 = new Model[12]; - int j2 = 0; - for (int l2 = 0; l2 < 12; l2++) { - int i3 = anIntArray1717[l2]; - if ((k1 >= 0) && (l2 == 3)) { - i3 = k1; + Model[] models = new Model[12]; + int modelCount = 0; + for (int part = 0; part < 12; part++) { + int value = appearance[part]; + if ((k1 >= 0) && (part == 3)) { + value = k1; } - if ((j1 >= 0) && (l2 == 5)) { - i3 = j1; + if ((j1 >= 0) && (part == 5)) { + value = j1; } - if ((i3 >= 256) && (i3 < 512)) { - Model model_3 = IDKType.instances[i3 - 256].method538(); + if ((value >= 256) && (value < 512)) { + Model model_3 = IDKType.instances[value - 256].method538(); if (model_3 != null) { - aclass30_sub2_sub4_sub6[j2++] = model_3; + models[modelCount++] = model_3; } } - if (i3 >= 512) { - Model class30_sub2_sub4_sub6_4 = ObjType.get(i3 - 512).method196(anInt1702); - if (class30_sub2_sub4_sub6_4 != null) { - aclass30_sub2_sub4_sub6[j2++] = class30_sub2_sub4_sub6_4; + if (value >= 512) { + Model model = ObjType.get(value - 512).getWornModel(gender); + if (model != null) { + models[modelCount++] = model; } } } - model_1 = new Model(j2, aclass30_sub2_sub4_sub6); + model_1 = new Model(modelCount, models); for (int j3 = 0; j3 < 5; j3++) { if (anIntArray1700[j3] != 0) { model_1.recolor(Game.anIntArrayArray1003[j3][0], Game.anIntArrayArray1003[j3][anIntArray1700[j3]]); @@ -315,11 +318,11 @@ public class PlayerEntity extends PathingEntity { } boolean flag = false; for (int i = 0; i < 12; i++) { - int j = anIntArray1717[i]; + int j = appearance[i]; if ((j >= 256) && (j < 512) && !IDKType.instances[j - 256].method539()) { flag = true; } - if ((j >= 512) && !ObjType.get(j - 512).method192(anInt1702)) { + if ((j >= 512) && !ObjType.get(j - 512).validateHeadModel(gender)) { flag = true; } } @@ -329,7 +332,7 @@ public class PlayerEntity extends PathingEntity { Model[] aclass30_sub2_sub4_sub6 = new Model[12]; int k = 0; for (int l = 0; l < 12; l++) { - int i1 = anIntArray1717[l]; + int i1 = appearance[l]; if ((i1 >= 256) && (i1 < 512)) { Model model_1 = IDKType.instances[i1 - 256].method540(); if (model_1 != null) { @@ -337,7 +340,7 @@ public class PlayerEntity extends PathingEntity { } } if (i1 >= 512) { - Model class30_sub2_sub4_sub6_2 = ObjType.get(i1 - 512).method194(anInt1702); + Model class30_sub2_sub4_sub6_2 = ObjType.get(i1 - 512).getHeadModel(gender); if (class30_sub2_sub4_sub6_2 != null) { aclass30_sub2_sub4_sub6[k++] = class30_sub2_sub4_sub6_2; } diff --git a/src/main/java/Scene.java b/src/main/java/Scene.java index 420f25c..e15fe21 100644 --- a/src/main/java/Scene.java +++ b/src/main/java/Scene.java @@ -166,8 +166,8 @@ public class Scene { public final int[][][] planeTileOcclusionCycles; public final int[] anIntArray486 = new int[10000]; public final int[] anIntArray487 = new int[10000]; - public final int[][] anIntArrayArray489 = {new int[16], {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1}, {0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1}, {1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1}}; - public final int[][] anIntArrayArray490 = {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {12, 8, 4, 0, 13, 9, 5, 1, 14, 10, 6, 2, 15, 11, 7, 3}, {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, {3, 7, 11, 15, 2, 6, 10, 14, 1, 5, 9, 13, 0, 4, 8, 12}}; + public final int[][] MINIMAP_TILE_MASK = {new int[16], {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1}, {0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1}, {1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1}}; + public final int[][] MINIMAP_TILE_ROTATION_MAP = {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {12, 8, 4, 0, 13, 9, 5, 1, 14, 10, 6, 2, 15, 11, 7, 3}, {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, {3, 7, 11, 15, 2, 6, 10, 14, 1, 5, 9, 13, 0, 4, 8, 12}}; public int minPlane; public int temporaryLocCount; public int anInt488; @@ -863,61 +863,70 @@ public class Scene { } } - public void drawMinimapTile(int[] ai, int i, int j, int k, int l, int i1) { - SceneTile tile = planeTiles[k][l][i1]; + public void drawMinimapTile(int[] dst, int offset, int step, int plane, int x, int z) { + SceneTile tile = planeTiles[plane][x][z]; + if (tile == null) { return; } + SceneTileUnderlay underlay = tile.underlay; if (underlay != null) { - int j1 = underlay.anInt722; - if (j1 == 0) { + int rgb = underlay.rgb; + + if (rgb == 0) { return; } + for (int k1 = 0; k1 < 4; k1++) { - ai[i] = j1; - ai[i + 1] = j1; - ai[i + 2] = j1; - ai[i + 3] = j1; - i += j; + dst[offset] = rgb; + dst[offset + 1] = rgb; + dst[offset + 2] = rgb; + dst[offset + 3] = rgb; + offset += step; } return; } + SceneTileOverlay overlay = tile.overlay; + if (overlay == null) { return; } - int l1 = overlay.anInt684; - int i2 = overlay.anInt685; - int j2 = overlay.anInt686; - int k2 = overlay.anInt687; - int[] ai1 = anIntArrayArray489[l1]; - int[] ai2 = anIntArrayArray490[i2]; - int l2 = 0; - if (j2 != 0) { - for (int i3 = 0; i3 < 4; i3++) { - ai[i] = (ai1[ai2[l2++]] != 0) ? k2 : j2; - ai[i + 1] = (ai1[ai2[l2++]] != 0) ? k2 : j2; - ai[i + 2] = (ai1[ai2[l2++]] != 0) ? k2 : j2; - ai[i + 3] = (ai1[ai2[l2++]] != 0) ? k2 : j2; - i += j; + + int shape = overlay.shape; + int angle = overlay.angle; + int background = overlay.backgroundRGB; + int foreground = overlay.foregroundRGB; + int[] mask = MINIMAP_TILE_MASK[shape]; + int[] rotation = MINIMAP_TILE_ROTATION_MAP[angle]; + int off = 0; + + if (background != 0) { + for (int i = 0; i < 4; i++) { + dst[offset] = (mask[rotation[off++]] != 0) ? foreground : background; + dst[offset + 1] = (mask[rotation[off++]] != 0) ? foreground : background; + dst[offset + 2] = (mask[rotation[off++]] != 0) ? foreground : background; + dst[offset + 3] = (mask[rotation[off++]] != 0) ? foreground : background; + offset += step; } return; } - for (int j3 = 0; j3 < 4; j3++) { - if (ai1[ai2[l2++]] != 0) { - ai[i] = k2; + + for (int i = 0; i < 4; i++) { + if (mask[rotation[off++]] != 0) { + dst[offset] = foreground; } - if (ai1[ai2[l2++]] != 0) { - ai[i + 1] = k2; + if (mask[rotation[off++]] != 0) { + dst[offset + 1] = foreground; } - if (ai1[ai2[l2++]] != 0) { - ai[i + 2] = k2; + if (mask[rotation[off++]] != 0) { + dst[offset + 2] = foreground; } - if (ai1[ai2[l2++]] != 0) { - ai[i + 3] = k2; + if (mask[rotation[off++]] != 0) { + dst[offset + 3] = foreground; } - i += j; + offset += step; } } diff --git a/src/main/java/SceneBuilder.java b/src/main/java/SceneBuilder.java index 061f915..6f4ad8b 100644 --- a/src/main/java/SceneBuilder.java +++ b/src/main/java/SceneBuilder.java @@ -547,21 +547,21 @@ public class SceneBuilder { int i_59_ = ((aByteArrayArrayArray136[plane][i_29_][i_40_]) + 1); byte i_60_ = (aByteArrayArrayArray148[plane][i_29_][i_40_]); FloType type = FloType.instances[i_44_ - 1]; - int i_61_ = type.anInt391; + int textureId = type.textureId; int i_62_; int i_63_; - if (i_61_ >= 0) { - i_62_ = Draw3D.getAverageTextureRGB(i_61_); + if (textureId >= 0) { + i_62_ = Draw3D.getAverageTextureRGB(textureId); i_63_ = -1; } else if (type.anInt390 == 16711935) { i_62_ = 0; i_63_ = -2; - i_61_ = -1; + textureId = -1; } else { i_63_ = method177(type.anInt394, type.anInt395, type.anInt396); i_62_ = (Draw3D.palette[method185(type.anInt399, 96)]); } - scene.method279(plane, i_29_, i_40_, i_59_, i_60_, i_61_, i_45_, i_46_, i_47_, i_48_, method187(i_53_, i_49_), method187(i_53_, i_50_), method187(i_53_, i_51_), method187(i_53_, i_52_), method185(i_63_, i_49_), method185(i_63_, i_50_), method185(i_63_, i_51_), method185(i_63_, i_52_), i_58_, i_62_); + scene.method279(plane, i_29_, i_40_, i_59_, i_60_, textureId, i_45_, i_46_, i_47_, i_48_, method187(i_53_, i_49_), method187(i_53_, i_50_), method187(i_53_, i_51_), method187(i_53_, i_52_), method185(i_63_, i_49_), method185(i_63_, i_50_), method185(i_63_, i_51_), method185(i_63_, i_52_), i_58_, i_62_); } } } diff --git a/src/main/java/SceneCollisionMap.java b/src/main/java/SceneCollisionMap.java index 379a948..583fa51 100644 --- a/src/main/java/SceneCollisionMap.java +++ b/src/main/java/SceneCollisionMap.java @@ -519,22 +519,22 @@ public class SceneCollisionMap { return false; } - public boolean method221(int i, int j, int k, int l, int i1, int j1, int k1) { - int l1 = (j + j1) - 1; - int i2 = (i + l) - 1; - if ((k >= j) && (k <= l1) && (k1 >= i) && (k1 <= i2)) { + public boolean method221(int z0, int x0, int x, int sizeZ, int flags, int sizeX, int z) { + int x1 = (x0 + sizeX) - 1; + int z1 = (z0 + sizeZ) - 1; + if ((x >= x0) && (x <= x1) && (z >= z0) && (z <= z1)) { return true; } - if ((k == (j - 1)) && (k1 >= i) && (k1 <= i2) && ((flags[k - anInt290][k1 - anInt291] & 8) == 0) && ((i1 & 8) == 0)) { + if ((x == (x0 - 1)) && (z >= z0) && (z <= z1) && ((this.flags[x - anInt290][z - anInt291] & 8) == 0) && ((flags & 8) == 0)) { return true; } - if ((k == (l1 + 1)) && (k1 >= i) && (k1 <= i2) && ((flags[k - anInt290][k1 - anInt291] & 0x80) == 0) && ((i1 & 2) == 0)) { + if ((x == (x1 + 1)) && (z >= z0) && (z <= z1) && ((this.flags[x - anInt290][z - anInt291] & 0x80) == 0) && ((flags & 2) == 0)) { return true; } - if ((k1 == (i - 1)) && (k >= j) && (k <= l1) && ((flags[k - anInt290][k1 - anInt291] & 2) == 0) && ((i1 & 4) == 0)) { + if ((z == (z0 - 1)) && (x >= x0) && (x <= x1) && ((this.flags[x - anInt290][z - anInt291] & 2) == 0) && ((flags & 4) == 0)) { return true; } - return (k1 == (i2 + 1)) && (k >= j) && (k <= l1) && ((flags[k - anInt290][k1 - anInt291] & 0x20) == 0) && ((i1 & 1) == 0); + return (z == (z1 + 1)) && (x >= x0) && (x <= x1) && ((this.flags[x - anInt290][z - anInt291] & 0x20) == 0) && ((flags & 1) == 0); } } diff --git a/src/main/java/SceneTileOverlay.java b/src/main/java/SceneTileOverlay.java index cea00cf..bde978d 100644 --- a/src/main/java/SceneTileOverlay.java +++ b/src/main/java/SceneTileOverlay.java @@ -21,18 +21,18 @@ public class SceneTileOverlay { public final int[] anIntArray680; public final int[] anIntArray681; public final boolean aBoolean683; - public final int anInt684; - public final int anInt685; - public final int anInt686; - public final int anInt687; + public final int shape; + public final int angle; + public final int backgroundRGB; + public final int foregroundRGB; public int[] anIntArray682; public SceneTileOverlay(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2, int j2, int k2, int l2, int i3, int j3, int k3, int l3, int i4, int k4, int l4) { aBoolean683 = (i3 == l2) && (i3 == l) && (i3 == k2); - anInt684 = j3; - anInt685 = k1; - anInt686 = i2; - anInt687 = l4; + shape = j3; + angle = k1; + backgroundRGB = i2; + foregroundRGB = l4; char c = '\200'; int i5 = c / 2; int j5 = c / 4; diff --git a/src/main/java/SceneTileUnderlay.java b/src/main/java/SceneTileUnderlay.java index 6de3dab..324ea34 100644 --- a/src/main/java/SceneTileUnderlay.java +++ b/src/main/java/SceneTileUnderlay.java @@ -9,7 +9,7 @@ public class SceneTileUnderlay { public final int anInt718; public final int anInt719; public final int anInt720; - public final int anInt722; + public final int rgb; public boolean aBoolean721; public SceneTileUnderlay(int i, int j, int k, int l, int i1, int j1, boolean flag) { @@ -19,7 +19,7 @@ public class SceneTileUnderlay { anInt718 = k; anInt719 = l; anInt720 = i1; - anInt722 = j1; + rgb = j1; aBoolean721 = flag; } diff --git a/src/main/java/SeqFrame.java b/src/main/java/SeqFrame.java index df676b0..f9e6b30 100644 --- a/src/main/java/SeqFrame.java +++ b/src/main/java/SeqFrame.java @@ -6,181 +6,182 @@ */ public class SeqFrame { - private static SeqFrame[] instances; + public static SeqFrame[] instances; - /** - * Syntax sugar. - * - * @param id the id - * @return id == -1 - */ - public static boolean isNull(int id) { - return id == -1; - } + /** + * Syntax sugar. + * + * @param id the id + * @return id == -1 + */ + public static boolean isNull(int id) { + return id == -1; + } - /** - * Initializes the array of instances. - * - * @param count the count - */ - public static void init(int count) { - instances = new SeqFrame[count + 1]; - } + /** + * Initializes the array of instances. + * + * @param count the count + */ + public static void init(int count) { + instances = new SeqFrame[count + 1]; + } - /** - * Nullifies the array of instances. - */ - public static void unload() { - instances = null; - } + /** + * Nullifies the array of instances. + */ + public static void unload() { + instances = null; + } - /** - * Gets the {@link SeqFrame} - * - * @param id the frame id. - * @return the {@link SeqFrame} or null if it does not exist. - */ - public static SeqFrame get(int id) { - if ((instances == null) || (id < 0) || (id >= instances.length)) { - return null; - } else { - return instances[id]; - } - } + /** + * Gets the {@link SeqFrame} + * + * @param id the frame id. + * @return the {@link SeqFrame} or null if it does not exist. + */ + public static SeqFrame get(int id) { + if ((instances == null) || (id < 0) || (id >= instances.length)) { + return null; + } else { + return instances[id]; + } + } - /** - * Reads the animation data and stores its frames in {@link #instances}. - *

- * Note: This method can read multiple {@link SeqFrame} which means the input data can be an entire working - * animation. - * - * @param src the animation data. - * @see #get(int) - */ - public static void unpack(byte[] src) { - Buffer offsets = new Buffer(src); - offsets.position = src.length - 8; + /** + * Reads the animation data and stores its frames in {@link #instances}. + *

+ * Note: This method can read multiple {@link SeqFrame} which means the input data can be an entire working + * animation. + * + * @param src the animation data. + * @see #get(int) + */ + public static void unpack(byte[] src) { + Buffer offsets = new Buffer(src); + offsets.position = src.length - 8; - Buffer header = new Buffer(src); - Buffer tran1 = new Buffer(src); - Buffer tran2 = new Buffer(src); - Buffer del = new Buffer(src); - Buffer skel = new Buffer(src); + Buffer header = new Buffer(src); + Buffer tran1 = new Buffer(src); + Buffer tran2 = new Buffer(src); + Buffer del = new Buffer(src); + Buffer skel = new Buffer(src); - int offset = 0; - header.position = offset; - offset += offsets.get2U() + 2; + int offset = 0; + header.position = offset; + offset += offsets.get2U() + 2; - tran1.position = offset; - offset += offsets.get2U(); + tran1.position = offset; + offset += offsets.get2U(); - tran2.position = offset; - offset += offsets.get2U(); + tran2.position = offset; + offset += offsets.get2U(); - del.position = offset; - offset += offsets.get2U(); + del.position = offset; + offset += offsets.get2U(); - skel.position = offset; + skel.position = offset; - SeqSkeleton skeleton = new SeqSkeleton(skel); + SeqSkeleton skeleton = new SeqSkeleton(skel); - int frameCount = header.get2U(); - int[] bases = new int[500]; - int[] x = new int[500]; - int[] y = new int[500]; - int[] z = new int[500]; + int frameCount = header.get2U(); + int[] bases = new int[500]; + int[] x = new int[500]; + int[] y = new int[500]; + int[] z = new int[500]; - for (int i = 0; i < frameCount; i++) { - SeqFrame frame = instances[header.get2U()] = new SeqFrame(); - frame.delay = del.get1U(); - frame.skeleton = skeleton; + for (int i = 0; i < frameCount; i++) { + SeqFrame frame = instances[header.get2U()] = new SeqFrame(); + frame.delay = del.get1U(); + frame.skeleton = skeleton; - int baseCount = header.get1U(); - int lastBase = -1; - int length = 0; - for (int base = 0; base < baseCount; base++) { - int flags = tran1.get1U(); + int baseCount = header.get1U(); + int lastBase = -1; + int length = 0; + for (int base = 0; base < baseCount; base++) { + int flags = tran1.get1U(); - if (flags <= 0) { - continue; - } + if (flags <= 0) { + continue; + } - if (skeleton.baseTypes[base] != SeqSkeleton.OP_BASE) { - for (int cur = base - 1; cur > lastBase; cur--) { - if (skeleton.baseTypes[cur] == SeqSkeleton.OP_BASE) { - bases[length] = cur; - x[length] = 0; - y[length] = 0; - z[length] = 0; - length++; - break; - } - } - } + if (skeleton.baseTypes[base] != SeqSkeleton.OP_BASE) { + for (int cur = base - 1; cur > lastBase; cur--) { + if (skeleton.baseTypes[cur] == SeqSkeleton.OP_BASE) { + bases[length] = cur; + x[length] = 0; + y[length] = 0; + z[length] = 0; + length++; + break; + } + } + } - bases[length] = base; + bases[length] = base; - int defaultValue = 0; + int defaultValue = 0; - if (skeleton.baseTypes[base] == SeqSkeleton.OP_SCALE) { - defaultValue = 128; - } + if (skeleton.baseTypes[base] == SeqSkeleton.OP_SCALE) { + defaultValue = 128; + } - if ((flags & 1) != 0) { - x[length] = tran2.getSmart(); - } else { - x[length] = defaultValue; - } + if ((flags & 1) != 0) { + x[length] = tran2.getSmart(); + } else { + x[length] = defaultValue; + } - if ((flags & 2) != 0) { - y[length] = tran2.getSmart(); - } else { - y[length] = defaultValue; - } + if ((flags & 2) != 0) { + y[length] = tran2.getSmart(); + } else { + y[length] = defaultValue; + } - if ((flags & 4) != 0) { - z[length] = tran2.getSmart(); - } else { - z[length] = defaultValue; - } + if ((flags & 4) != 0) { + z[length] = tran2.getSmart(); + } else { + z[length] = defaultValue; + } - lastBase = base; - length++; - } + lastBase = base; + length++; + } - frame.length = length; - frame.bases = new int[length]; - frame.x = new int[length]; - frame.y = new int[length]; - frame.z = new int[length]; + frame.length = length; + frame.bases = new int[length]; + frame.x = new int[length]; + frame.y = new int[length]; + frame.z = new int[length]; - for (int j = 0; j < length; j++) { - frame.bases[j] = bases[j]; - frame.x[j] = x[j]; - frame.y[j] = y[j]; - frame.z[j] = z[j]; - } - } - } - /** - * The skeleton associated to this frame. - */ - public SeqSkeleton skeleton; - /** - * The delay in ticks. - */ - public int delay; - /** - * The number of operations the frame performs. - */ - public int length; - /** - * The list of bases the frame uses. - */ - public int[] bases; - /** - * The frame parameters. - */ - public int[] x, y, z; + for (int j = 0; j < length; j++) { + frame.bases[j] = bases[j]; + frame.x[j] = x[j]; + frame.y[j] = y[j]; + frame.z[j] = z[j]; + } + } + } + + /** + * The skeleton associated to this frame. + */ + public SeqSkeleton skeleton; + /** + * The delay in ticks. + */ + public int delay; + /** + * The number of operations the frame performs. + */ + public int length; + /** + * The list of bases the frame uses. + */ + public int[] bases; + /** + * The frame parameters. + */ + public int[] x, y, z; } diff --git a/src/main/java/SoundEnvelope.java b/src/main/java/SoundEnvelope.java index 8a93542..e590790 100644 --- a/src/main/java/SoundEnvelope.java +++ b/src/main/java/SoundEnvelope.java @@ -7,8 +7,8 @@ public class SoundEnvelope { public int length; - public int[] durations; - public int[] peaks; + public int[] shapeDelta; + public int[] shapePeak; public int start; public int end; public int form; @@ -30,11 +30,11 @@ public class SoundEnvelope { public void readShape(Buffer buffer) { length = buffer.get1U(); - durations = new int[length]; - peaks = new int[length]; + shapeDelta = new int[length]; + shapePeak = new int[length]; for (int i = 0; i < length; i++) { - durations[i] = buffer.get2U(); - peaks[i] = buffer.get2U(); + shapeDelta[i] = buffer.get2U(); + shapePeak[i] = buffer.get2U(); } } @@ -48,13 +48,13 @@ public class SoundEnvelope { public int evaluate(int delta) { if (ticks >= threshold) { - amplitude = peaks[position++] << 15; + amplitude = shapePeak[position++] << 15; if (position >= length) { position = length - 1; } - threshold = (int) (((double) durations[position] / 65536D) * (double) delta); + threshold = (int) (((double) shapeDelta[position] / 65536D) * (double) delta); if (threshold > ticks) { - this.delta = ((peaks[position] << 15) - amplitude) / (threshold - ticks); + this.delta = ((shapePeak[position] << 15) - amplitude) / (threshold - ticks); } } amplitude += this.delta; diff --git a/src/main/java/SoundTrack.java b/src/main/java/SoundTrack.java index 8d8de01..9469239 100644 --- a/src/main/java/SoundTrack.java +++ b/src/main/java/SoundTrack.java @@ -1,173 +1,188 @@ +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; + public class SoundTrack { - public static final SoundTrack[] tracks = new SoundTrack[5000]; - public static final int[] delays = new int[5000]; - public static byte[] bbuf; - public static Buffer buffer; + public static final SoundTrack[] tracks = new SoundTrack[5000]; + public static final int[] delays = new int[5000]; + public static byte[] bbuf; + public static Buffer buffer; - public static void method240(Buffer src) { - bbuf = new byte[441000]; + public static void method240(Buffer src) { + bbuf = new byte[441000]; - SoundTrack.buffer = new Buffer(bbuf); - SoundTone.init(); + SoundTrack.buffer = new Buffer(bbuf); + SoundTone.init(); - do { - int id = src.get2U(); - if (id == 65535) { - return; - } - tracks[id] = new SoundTrack(); - tracks[id].read(src); - delays[id] = tracks[id].trim(); - } while (true); - } + do { + int id = src.get2U(); + if (id == 65535) { + return; + } - public static Buffer generate(int loopCount, int id) { - if (tracks[id] != null) { - SoundTrack track = tracks[id]; - return track.getWaveform(loopCount); - } else { - return null; - } - } + int start = src.position; + tracks[id] = new SoundTrack(); + tracks[id].read(src); + int end = src.position; - public final SoundTone[] tones = new SoundTone[10]; - public int loopBegin; - public int loopEnd; + try (OutputStream out = Files.newOutputStream(Paths.get(String.format("377_synth/%d.synth", id)))) { + out.write(src.data,start,end-start); + } catch (IOException e) { + e.printStackTrace(); + } - public SoundTrack() { - } + delays[id] = tracks[id].trim(); + } while (true); + } - public void read(Buffer buffer) { - for (int tone = 0; tone < 10; tone++) { - if (buffer.get1U() != 0) { - buffer.position--; - tones[tone] = new SoundTone(); - tones[tone].read(buffer); - } - } - loopBegin = buffer.get2U(); - loopEnd = buffer.get2U(); - } + public static Buffer generate(int loopCount, int id) { + if (tracks[id] != null) { + SoundTrack track = tracks[id]; + return track.getWaveform(loopCount); + } else { + return null; + } + } - public int trim() { - int start = 9999999; - for (int tone = 0; tone < 10; tone++) { - if ((tones[tone] != null) && ((tones[tone].start / 20) < start)) { - start = tones[tone].start / 20; - } - } + public final SoundTone[] tones = new SoundTone[10]; + public int loopBegin; + public int loopEnd; - if ((loopBegin < loopEnd) && ((loopBegin / 20) < start)) { - start = loopBegin / 20; - } + public SoundTrack() { + } - if ((start == 9999999) || (start == 0)) { - return 0; - } + public void read(Buffer buffer) { + for (int tone = 0; tone < 10; tone++) { + if (buffer.get1U() != 0) { + buffer.position--; + tones[tone] = new SoundTone(); + tones[tone].read(buffer); + } + } + loopBegin = buffer.get2U(); + loopEnd = buffer.get2U(); + } - for (int tone = 0; tone < 10; tone++) { - if (tones[tone] != null) { - tones[tone].start -= start * 20; - } - } - if (loopBegin < loopEnd) { - loopBegin -= start * 20; - loopEnd -= start * 20; - } - return start; - } + public int trim() { + int start = 9999999; + for (int tone = 0; tone < 10; tone++) { + if ((tones[tone] != null) && ((tones[tone].start / 20) < start)) { + start = tones[tone].start / 20; + } + } - /** - * WaveFormat - * - * @param loopCount the loop count. - * @return the {@link Buffer} containing the waveform data. - */ - public Buffer getWaveform(int loopCount) { - int length = generate(loopCount); - buffer.position = 0; - buffer.put4(0x52494646); // "RIFF" ChunkID - buffer.put4LE(36 + length); // ChunkSize - buffer.put4(0x57415645); // "WAVE" format - buffer.put4(0x666d7420); // "fmt " chunk id - buffer.put4LE(16); // chunk size - buffer.put2LE(1); // audio format - buffer.put2LE(1); // num channels - buffer.put4LE(22050); // sample rate - buffer.put4LE(22050); // byte rate - buffer.put2LE(1); // block align - buffer.put2LE(8); // bits per sample - buffer.put4(0x64617461); // "data" - buffer.put4LE(length); - buffer.position += length; - return buffer; - } + if ((loopBegin < loopEnd) && ((loopBegin / 20) < start)) { + start = loopBegin / 20; + } - public int generate(int loopCount) { - int duration = 0; + if ((start == 9999999) || (start == 0)) { + return 0; + } - for (int tone = 0; tone < 10; tone++) { - if ((tones[tone] != null) && ((tones[tone].length + tones[tone].start) > duration)) { - duration = tones[tone].length + tones[tone].start; - } - } + for (int tone = 0; tone < 10; tone++) { + if (tones[tone] != null) { + tones[tone].start -= start * 20; + } + } + if (loopBegin < loopEnd) { + loopBegin -= start * 20; + loopEnd -= start * 20; + } + return start; + } - if (duration == 0) { - return 0; - } + /** + * WaveFormat + * + * @param loopCount the loop count. + * @return the {@link Buffer} containing the waveform data. + */ + public Buffer getWaveform(int loopCount) { + int length = generate(loopCount); + buffer.position = 0; + buffer.put4(0x52494646); // "RIFF" ChunkID + buffer.put4LE(36 + length); // ChunkSize + buffer.put4(0x57415645); // "WAVE" format + buffer.put4(0x666d7420); // "fmt " chunk id + buffer.put4LE(16); // chunk size + buffer.put2LE(1); // audio format + buffer.put2LE(1); // num channels + buffer.put4LE(22050); // sample rate + buffer.put4LE(22050); // byte rate + buffer.put2LE(1); // block align + buffer.put2LE(8); // bits per sample + buffer.put4(0x64617461); // "data" + buffer.put4LE(length); + buffer.position += length; + return buffer; + } - int sampleCount = (22050 * duration) / 1000; - int loopStart = (22050 * loopBegin) / 1000; - int loopStop = (22050 * loopEnd) / 1000; + public int generate(int loopCount) { + int duration = 0; - if ((loopStart < 0) || (loopStop < 0) || (loopStop > sampleCount) || (loopStart >= loopStop)) { - loopCount = 0; - } + for (int tone = 0; tone < 10; tone++) { + if ((tones[tone] != null) && ((tones[tone].length + tones[tone].start) > duration)) { + duration = tones[tone].length + tones[tone].start; + } + } - int totalSampleCount = sampleCount + ((loopStop - loopStart) * (loopCount - 1)); + if (duration == 0) { + return 0; + } - for (int sample = 44; sample < (totalSampleCount + 44); sample++) { - bbuf[sample] = -128; - } + int sampleCount = (22050 * duration) / 1000; + int loopStart = (22050 * loopBegin) / 1000; + int loopStop = (22050 * loopEnd) / 1000; - for (int tone = 0; tone < 10; tone++) { - if (tones[tone] == null) { - continue; - } + if ((loopStart < 0) || (loopStop < 0) || (loopStop > sampleCount) || (loopStart >= loopStop)) { + loopCount = 0; + } - int toneSampleCount = (tones[tone].length * 22050) / 1000; - int start = (tones[tone].start * 22050) / 1000; - int[] samples = tones[tone].generate(toneSampleCount, tones[tone].length); + int totalSampleCount = sampleCount + ((loopStop - loopStart) * (loopCount - 1)); - for (int sample = 0; sample < toneSampleCount; sample++) { - bbuf[sample + start + 44] += (byte) (samples[sample] >> 8); - } - } + for (int sample = 44; sample < (totalSampleCount + 44); sample++) { + bbuf[sample] = -128; + } - if (loopCount > 1) { - // All of these 44's are because we're avoiding the area where the WAV header will be written. - loopStart += 44; - loopStop += 44; - sampleCount += 44; + for (int tone = 0; tone < 10; tone++) { + if (tones[tone] == null) { + continue; + } - // 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--) { - bbuf[sample + endOffset] = bbuf[sample]; - } + int toneSampleCount = (tones[tone].length * 22050) / 1000; + int start = (tones[tone].start * 22050) / 1000; + int[] samples = tones[tone].generate(toneSampleCount, tones[tone].length); - // Duplicates loop area. - for (int loop = 1; loop < loopCount; loop++) { - int offset = (loopStop - loopStart) * loop; - for (int sample = loopStart; sample < loopStop; sample++) { - bbuf[sample + offset] = bbuf[sample]; - } - } + for (int sample = 0; sample < toneSampleCount; sample++) { + bbuf[sample + start + 44] += (byte) (samples[sample] >> 8); + } + } - totalSampleCount -= 44; - } - return totalSampleCount; - } + if (loopCount > 1) { + // All of these 44's are because we're avoiding the area where the WAV header will be written. + loopStart += 44; + loopStop += 44; + sampleCount += 44; + + // 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--) { + 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++) { + bbuf[sample + offset] = bbuf[sample]; + } + } + + totalSampleCount -= 44; + } + return totalSampleCount; + } } diff --git a/src/main/java/SpotAnimType.java b/src/main/java/SpotAnimType.java index a89bdcc..4fae166 100644 --- a/src/main/java/SpotAnimType.java +++ b/src/main/java/SpotAnimType.java @@ -8,87 +8,89 @@ import java.io.IOException; public class SpotAnimType { - public static SpotAnimType[] instances; - public static LRUMap modelCache = new LRUMap<>(30); + public static int count; + public static SpotAnimType[] instances; + public static LRUMap modelCache = new LRUMap<>(30); - public static void unpack(FileArchive archive) throws IOException { - Buffer buffer = new Buffer(archive.read("spotanim.dat")); - int count = buffer.get2U(); - if (instances == null) { - instances = new SpotAnimType[count]; - } - for (int i = 0; i < count; i++) { - if (instances[i] == null) { - instances[i] = new SpotAnimType(); - } - instances[i].index = i; - instances[i].method265(buffer); - } - } - public final int[] anIntArray408 = new int[6]; - public final int[] anIntArray409 = new int[6]; - public int index; - public int anInt405; - public int anInt406 = -1; - public SeqType seq; - public int anInt410 = 128; - public int anInt411 = 128; - public int anInt412; - public int anInt413; - public int anInt414; + public static void unpack(FileArchive archive) throws IOException { + Buffer buffer = new Buffer(archive.read("spotanim.dat")); + count = buffer.get2U(); + if (instances == null) { + instances = new SpotAnimType[count]; + } + for (int i = 0; i < count; i++) { + if (instances[i] == null) { + instances[i] = new SpotAnimType(); + } + instances[i].index = i; + instances[i].method265(buffer); + } + } - public SpotAnimType() { - } + public final int[] anIntArray408 = new int[6]; + public final int[] anIntArray409 = new int[6]; + public int index; + public int anInt405; + public int seqId = -1; + public SeqType seq; + public int anInt410 = 128; + public int anInt411 = 128; + public int anInt412; + public int anInt413; + public int anInt414; - public void method265(Buffer buffer) { - do { - int i = buffer.get1U(); - if (i == 0) { - return; - } - if (i == 1) { - anInt405 = buffer.get2U(); - } else if (i == 2) { - anInt406 = buffer.get2U(); - if (SeqType.instances != null) { - seq = SeqType.instances[anInt406]; - } - } else if (i == 4) { - anInt410 = buffer.get2U(); - } else if (i == 5) { - anInt411 = buffer.get2U(); - } else if (i == 6) { - anInt412 = buffer.get2U(); - } else if (i == 7) { - anInt413 = buffer.get1U(); - } else if (i == 8) { - anInt414 = buffer.get1U(); - } else if ((i >= 40) && (i < 50)) { - anIntArray408[i - 40] = buffer.get2U(); - } else if ((i >= 50) && (i < 60)) { - anIntArray409[i - 50] = buffer.get2U(); - } else { - System.out.println("Error unrecognised spotanim config code: " + i); - } - } while (true); - } + public SpotAnimType() { + } - public Model method266() { - Model model = modelCache.get(index); - if (model != null) { - return model; - } - model = Model.tryGet(anInt405); - if (model == null) { - return null; - } - for (int i = 0; i < 6; i++) { - if (anIntArray408[0] != 0) { - model.recolor(anIntArray408[i], anIntArray409[i]); - } - } - modelCache.put(index, model); - return model; - } + public void method265(Buffer buffer) { + do { + int i = buffer.get1U(); + if (i == 0) { + return; + } + if (i == 1) { + anInt405 = buffer.get2U(); + } else if (i == 2) { + seqId = buffer.get2U(); + if (SeqType.instances != null) { + seq = SeqType.instances[seqId]; + } + } else if (i == 4) { + anInt410 = buffer.get2U(); + } else if (i == 5) { + anInt411 = buffer.get2U(); + } else if (i == 6) { + anInt412 = buffer.get2U(); + } else if (i == 7) { + anInt413 = buffer.get1U(); + } else if (i == 8) { + anInt414 = buffer.get1U(); + } else if ((i >= 40) && (i < 50)) { + anIntArray408[i - 40] = buffer.get2U(); + } else if ((i >= 50) && (i < 60)) { + anIntArray409[i - 50] = buffer.get2U(); + } else { + System.out.println("Error unrecognised spotanim config code: " + i); + } + } while (true); + } + + public Model method266() { + Model model = modelCache.get(index); + if (model != null) { + return model; + } + model = Model.tryGet(anInt405); + if (model == null) { + return null; + } + for (int i = 0; i < 6; i++) { + if (anIntArray408[0] != 0) { + model.recolor(anIntArray408[i], anIntArray409[i]); + } + } + modelCache.put(index, model); + return model; + } }