From 172a880a85f9ae8c867915eb802984ce7304ef55 Mon Sep 17 00:00:00 2001 From: thedaneeffect Date: Tue, 19 Jul 2022 21:28:55 -0600 Subject: [PATCH] Tons of renaming --- src/main/java/Buffer.java | 10 +- src/main/java/Component.java | 21 +- src/main/java/FloType.java | 216 ++++++----- src/main/java/Game.java | 555 ++++++++++++++------------- src/main/java/IDKType.java | 80 ++-- src/main/java/LocType.java | 56 +-- src/main/java/NPCEntity.java | 64 +-- src/main/java/NPCType.java | 162 ++++---- src/main/java/ObjType.java | 4 +- src/main/java/PathingEntity.java | 18 +- src/main/java/PlayerEntity.java | 439 ++++++++++++--------- src/main/java/ProjectileEntity.java | 8 +- src/main/java/Scene.java | 2 +- src/main/java/SceneBuilder.java | 401 ++++++++++--------- src/main/java/SceneLocTemporary.java | 4 +- src/main/java/SeqFrame.java | 2 + src/main/java/SeqSkeleton.java | 84 ++-- src/main/java/SeqType.java | 12 +- src/main/java/SpotAnimEntity.java | 99 ++--- src/main/java/SpotAnimType.java | 51 +-- 20 files changed, 1242 insertions(+), 1046 deletions(-) diff --git a/src/main/java/Buffer.java b/src/main/java/Buffer.java index 38dcbb0..790df01 100644 --- a/src/main/java/Buffer.java +++ b/src/main/java/Buffer.java @@ -184,10 +184,10 @@ public class Buffer extends DoublyLinkedList.Node { */ public int getSmart() { int i = data[position] & 0xff; - if (i < 0x80) { - return get1U() - 0x40; + if (i < 128) { + return get1U() - 64; } else { - return get2U() - 0xC000; + return get2U() - 49152; } } @@ -198,10 +198,10 @@ public class Buffer extends DoublyLinkedList.Node { */ public int getSmartU() { int i = data[position] & 0xff; - if (i < 0x80) { + if (i < 128) { return get1U(); } else { - return get2U() - 0x8000; + return get2U() - 32768; } } diff --git a/src/main/java/Component.java b/src/main/java/Component.java index 5f09a39..f45a838 100644 --- a/src/main/java/Component.java +++ b/src/main/java/Component.java @@ -165,13 +165,13 @@ public class Component { int tmp = in.get1U(); if (tmp != 0) { c.modelCategory = 1; - c.modelID = ((tmp - 1) << 8) + in.get1U(); + c.modelId = ((tmp - 1) << 8) + in.get1U(); } tmp = in.get1U(); if (tmp != 0) { c.activeModelCategory = 1; - c.activeModelID = ((tmp - 1) << 8) + in.get1U(); + c.activeModelId = ((tmp - 1) << 8) + in.get1U(); } tmp = in.get1U(); @@ -270,7 +270,7 @@ public class Component { public int activeHoverColor; public Image24 activeImage; public int activeModelCategory; - public int activeModelID; + public int activeModelId; public int activeSeqId; public String activeText; public boolean center; @@ -300,7 +300,7 @@ public class Component { public boolean invUsable; public int modelEyePitch; public int modelCategory; - public int modelID; + public int modelId; public int modelYaw; public int modelZoom; public String option; @@ -350,16 +350,13 @@ public class Component { model = Model.tryGet(id); } if (category == 2) { - model = NPCType.get(id).method160(); + model = NPCType.get(id).getUnlitHeadModel(); } if (category == 3) { - model = Game.localPlayer.method453(); + model = Game.localPlayer.getUnlitHeadModel(); } if (category == 4) { - model = ObjType.get(id).getModelUnlit(50); - } - if (category == 5) { - model = null; + model = ObjType.get(id).getUnlitModel(50); } if (model != null) { modelCache.put((long) ((category << 16) + id), model); @@ -371,9 +368,9 @@ public class Component { Model model; if (active) { - model = getModel(activeModelCategory, activeModelID); + model = getModel(activeModelCategory, activeModelId); } else { - model = getModel(modelCategory, modelID); + model = getModel(modelCategory, modelId); } if (model == null) { diff --git a/src/main/java/FloType.java b/src/main/java/FloType.java index bf5bb83..560cf18 100644 --- a/src/main/java/FloType.java +++ b/src/main/java/FloType.java @@ -6,16 +6,16 @@ import java.io.IOException; public class FloType { - public static int anInt387; + public static int count; public static FloType[] instances; public static void unpack(FileArchive archive) throws IOException { Buffer buffer = new Buffer(archive.read("flo.dat")); - anInt387 = buffer.get2U(); + count = buffer.get2U(); if (instances == null) { - instances = new FloType[anInt387]; + instances = new FloType[count]; } - for (int j = 0; j < anInt387; j++) { + for (int j = 0; j < count; j++) { if (instances[j] == null) { instances[j] = new FloType(); } @@ -24,16 +24,16 @@ public class FloType { } public String unusedString; - public int anInt390; + public int rgb; public int textureId = -1; public boolean unusedBool = false; public boolean aBoolean393 = true; - public int anInt394; - public int anInt395; - public int anInt396; - public int anInt397; - public int anInt398; - public int anInt399; + public int hue; + public int saturation; + public int lightness; + public int chroma; + public int luminance; + public int hsl; public FloType() { } @@ -45,8 +45,8 @@ public class FloType { return; } if (i == 1) { - anInt390 = buffer.get3(); - method262(anInt390); + rgb = buffer.get3(); + setColor(rgb); } else if (i == 2) { textureId = buffer.get1U(); } else if (i == 3) { @@ -56,117 +56,141 @@ public class FloType { } else if (i == 6) { unusedString = buffer.getString(); } else if (i == 7) { - int j = anInt394; - int k = anInt395; - int l = anInt396; - int i1 = anInt397; - int j1 = buffer.get3(); - method262(j1); - anInt394 = j; - anInt395 = k; - anInt396 = l; - anInt397 = i1; - anInt398 = i1; + int hue = this.hue; + int saturation = this.saturation; + int lightness = this.lightness; + int chroma = this.chroma; + int rgb = buffer.get3(); + setColor(rgb); + this.hue = hue; + this.saturation = saturation; + this.lightness = lightness; + this.chroma = chroma; + luminance = chroma; } else { System.out.println("Error unrecognised config code: " + i); } } while (true); } - public void method262(int i) { - double d = (double) ((i >> 16) & 0xff) / 256D; - double d1 = (double) ((i >> 8) & 0xff) / 256D; - double d2 = (double) (i & 0xff) / 256D; - double d3 = d; - if (d1 < d3) { - d3 = d1; + public void setColor(int rgb) { + double red = (double) ((rgb >> 16) & 0xff) / 256D; + double green = (double) ((rgb >> 8) & 0xff) / 256D; + double blue = (double) (rgb & 0xff) / 256D; + + double min = red; + + if (green < min) { + min = green; } - if (d2 < d3) { - d3 = d2; + + if (blue < min) { + min = blue; } - double d4 = d; - if (d1 > d4) { - d4 = d1; + + double max = red; + + if (green > max) { + max = green; } - if (d2 > d4) { - d4 = d2; + + if (blue > max) { + max = blue; } - double d5 = 0.0D; - double d6 = 0.0D; - double d7 = (d3 + d4) / 2D; - if (d3 != d4) { - if (d7 < 0.5D) { - d6 = (d4 - d3) / (d4 + d3); + + double h = 0.0D; + double s = 0.0D; + double l = (min + max) / 2D; + + if (min != max) { + if (l < 0.5D) { + s = (max - min) / (max + min); } - if (d7 >= 0.5D) { - d6 = (d4 - d3) / (2D - d4 - d3); + + if (l >= 0.5D) { + s = (max - min) / (2D - max - min); } - if (d == d4) { - d5 = (d1 - d2) / (d4 - d3); - } else if (d1 == d4) { - d5 = 2D + ((d2 - d) / (d4 - d3)); - } else if (d2 == d4) { - d5 = 4D + ((d - d1) / (d4 - d3)); + + if (red == max) { + h = (green - blue) / (max - min); + } else if (green == max) { + h = 2D + ((blue - red) / (max - min)); + } else if (blue == max) { + h = 4D + ((red - green) / (max - min)); } } - d5 /= 6D; - anInt394 = (int) (d5 * 256D); - anInt395 = (int) (d6 * 256D); - anInt396 = (int) (d7 * 256D); - if (anInt395 < 0) { - anInt395 = 0; - } else if (anInt395 > 255) { - anInt395 = 255; + + h /= 6D; + + this.hue = (int) (h * 256D); + this.saturation = (int) (s * 256D); + this.lightness = (int) (l * 256D); + + if (this.saturation < 0) { + this.saturation = 0; + } else if (this.saturation > 255) { + this.saturation = 255; } - if (anInt396 < 0) { - anInt396 = 0; - } else if (anInt396 > 255) { - anInt396 = 255; + + if (this.lightness < 0) { + this.lightness = 0; + } else if (this.lightness > 255) { + this.lightness = 255; } - if (d7 > 0.5D) { - anInt398 = (int) ((1.0D - d7) * d6 * 512D); + + if (l > 0.5D) { + luminance = (int) ((1.0D - l) * s * 512D); } else { - anInt398 = (int) (d7 * d6 * 512D); + luminance = (int) (l * s * 512D); } - if (anInt398 < 1) { - anInt398 = 1; + + if (luminance < 1) { + luminance = 1; } - anInt397 = (int) (d5 * (double) anInt398); - int k = (anInt394 + (int) (Math.random() * 16D)) - 8; - if (k < 0) { - k = 0; - } else if (k > 255) { - k = 255; + + chroma = (int) (h * (double) luminance); + + int hue = (this.hue + (int) (Math.random() * 16D)) - 8; + + if (hue < 0) { + hue = 0; + } else if (hue > 255) { + hue = 255; } - int l = (anInt395 + (int) (Math.random() * 48D)) - 24; - if (l < 0) { - l = 0; - } else if (l > 255) { - l = 255; + + int saturation = (this.saturation + (int) (Math.random() * 48D)) - 24; + + if (saturation < 0) { + saturation = 0; + } else if (saturation > 255) { + saturation = 255; } - int i1 = (anInt396 + (int) (Math.random() * 48D)) - 24; - if (i1 < 0) { - i1 = 0; - } else if (i1 > 255) { - i1 = 255; + + int lightness = (this.lightness + (int) (Math.random() * 48D)) - 24; + + if (lightness < 0) { + lightness = 0; + } else if (lightness > 255) { + lightness = 255; } - anInt399 = method263(k, l, i1); + + hsl = decimateHSL(hue, saturation, lightness); } - public int method263(int i, int j, int k) { - if (k > 179) { - j /= 2; + public int decimateHSL(int hue, int saturation, int lightness) { + if (lightness > 179) { + saturation /= 2; } - if (k > 192) { - j /= 2; + if (lightness > 192) { + saturation /= 2; } - if (k > 217) { - j /= 2; + if (lightness > 217) { + saturation /= 2; } - if (k > 243) { - j /= 2; + if (lightness > 243) { + saturation /= 2; } - return ((i / 4) << 10) + ((j / 32) << 7) + (k / 2); + return ((hue / 4) << 10) + ((saturation / 32) << 7) + (lightness / 2); } } diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 9fec27a..0872387 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -19,8 +19,8 @@ import java.util.zip.CRC32; public class Game extends GameShell { - public static final int[][] anIntArrayArray1003 = {{6798, 107, 10283, 16, 4797, 7744, 5799, 4634, 33697, 22433, 2983, 54193}, {8741, 12, 64030, 43162, 7735, 8404, 1701, 38430, 24094, 10153, 56621, 4783, 1341, 16578, 35003, 25239}, {25238, 8742, 12, 64030, 43162, 7735, 8404, 1701, 38430, 24094, 10153, 56621, 4783, 1341, 16578, 35003}, {4626, 11146, 6439, 12, 4758, 10270}, {4550, 4537, 5681, 5673, 5790, 6806, 8076, 4574}}; - public static final int[] anIntArray1204 = {9104, 10275, 7595, 3610, 7975, 8526, 918, 38802, 24466, 10145, 58654, 5027, 1457, 16565, 34991, 25486}; + public static final int[][] designPartColor = {{6798, 107, 10283, 16, 4797, 7744, 5799, 4634, 33697, 22433, 2983, 54193}, {8741, 12, 64030, 43162, 7735, 8404, 1701, 38430, 24094, 10153, 56621, 4783, 1341, 16578, 35003, 25239}, {25238, 8742, 12, 64030, 43162, 7735, 8404, 1701, 38430, 24094, 10153, 56621, 4783, 1341, 16578, 35003}, {4626, 11146, 6439, 12, 4758, 10270}, {4550, 4537, 5681, 5673, 5790, 6806, 8076, 4574}}; + public static final int[] designHairColor = {9104, 10275, 7595, 3610, 7975, 8526, 918, 38802, 24466, 10145, 58654, 5027, 1457, 16565, 34991, 25486}; public static final BigInteger RSA_MODULUS = new BigInteger("115021795079507343952614936197913546438580135096169635842480712252120509788529535203161526625251797553017433341968661761641695154871087245548928967487006467485383337651405009623296611208539069524887502151216922299338355736930449024798579974392565651281911869750633089962840628929607415810272098208925607905239"); public static final int[] levelExperience; public static final BigInteger RSA_EXPONENT = new BigInteger("65537"); @@ -189,7 +189,7 @@ public class Game extends GameShell { public final int[] chatStyles = new int[anInt975]; public final int[] chatTimers = new int[anInt975]; public final String[] chatMessages = new String[anInt975]; - public final int[] anIntArray990 = new int[5]; + public final int[] designColors = new int[5]; public final int anInt1002 = 0x23201b; public final int[] anIntArray1030 = new int[5]; public final int[] anIntArray1045 = new int[2000]; @@ -197,14 +197,14 @@ public class Game extends GameShell { public final int[] compassMaskLineLengths = new int[33]; public final Component aComponent_1059 = new Component(); public final int anInt1063 = 0x4d4233; - public final int[] anIntArray1065 = new int[7]; + public final int[] designIdentikits = new int[7]; public final int[] archiveChecksum = new int[9]; public final String[] aStringArray1127 = new String[5]; public final boolean[] aBooleanArray1128 = new boolean[5]; public final int[][][] sceneInstancedChunkBitset = new int[4][13][13]; public final int[] tabComponentId = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; public final int[] anIntArray1203 = new int[5]; - public final int[] waveIDs = new int[50]; + public final int[] waveIds = new int[50]; public final Image8[] imageModIcons = new Image8[2]; public final int[] minimapMaskLineLengths = new int[151]; public final int[] anIntArray1240 = new int[100]; @@ -261,7 +261,7 @@ public class Game extends GameShell { public MouseRecorder mouseRecorder; public volatile boolean flamesThread = false; public String aString881 = ""; - public int localPlayerID = -1; + public int localPlayerId = -1; public boolean menuVisible = false; public int lastHoveredComponentId; public String chatTyped = ""; @@ -365,7 +365,7 @@ public class Game extends GameShell { public Image8 imageBackbase1; public Image8 imageBackbase2; public Image8 imageBackhmid1; - public boolean aBoolean1031 = false; + public boolean updateDesignModel = false; public Image24[] imageMapfunction = new Image24[100]; public int sceneBaseTileX; public int sceneBaseTileZ; @@ -377,13 +377,13 @@ public class Game extends GameShell { public int flameGradientCycle1; public int stickyChatbackComponentId = -1; public int anInt1046; - public boolean aBoolean1047 = true; + public boolean designGender = true; public int invbackHoveredComponentId; public String lastProgressMessage; public FileArchive archiveTitle; public int anInt1054 = -1; public int anInt1055; - public DoublyLinkedList aList_1056 = new DoublyLinkedList(); + public DoublyLinkedList spotanims = new DoublyLinkedList(); public Image8[] imageMapscene = new Image8[100]; public int waveCount; /** @@ -1130,7 +1130,7 @@ public class Game extends GameShell { planeObjStacks = null; temporaryLocs = null; aList_1013 = null; - aList_1056 = null; + spotanims = null; menuParamA = null; menuParamB = null; menuAction = null; @@ -1607,7 +1607,7 @@ public class Game extends GameShell { public void method22() { try { minimapPlane = -1; - aList_1056.clear(); + spotanims.clear(); aList_1013.clear(); Draw3D.clearTexels(); clearCaches(); @@ -2942,15 +2942,15 @@ public class Game extends GameShell { nextMusicDelay = 0; } - public void method45() { - aBoolean1031 = true; - for (int j = 0; j < 7; j++) { - anIntArray1065[j] = -1; - for (int k = 0; k < IDKType.anInt655; k++) { - if (IDKType.instances[k].aBoolean662 || (IDKType.instances[k].anInt657 != (j + (aBoolean1047 ? 0 : 7)))) { + public void validateCharacterDesign() { + updateDesignModel = true; + for (int part = 0; part < 7; part++) { + designIdentikits[part] = -1; + for (int kit = 0; kit < IDKType.count; kit++) { + if (IDKType.instances[kit].selectable || (IDKType.instances[kit].type != (part + (designGender ? 0 : 7)))) { continue; } - anIntArray1065[j] = k; + designIdentikits[part] = kit; break; } } @@ -2984,10 +2984,10 @@ public class Game extends GameShell { } npc.size = npc.type.size; npc.turnSpeed = npc.type.turnSpeed; - npc.seqWalk = npc.type.seqWalk; - npc.seqTurnAround = npc.type.seqTurnAround; + npc.seqWalk = npc.type.seqWalkId; + npc.seqTurnAround = npc.type.seqTurnAroundId; npc.seqTurnLeft = npc.type.seqTurnLeft; - npc.seqTurnRight = npc.type.seqTurnRight; + npc.seqTurnRight = npc.type.seqTurnRightId; npc.seqStand = npc.type.seqStand; npc.move(localPlayer.pathTileX[0] + x, localPlayer.pathTileZ[0] + z, j1 == 1); } @@ -3021,7 +3021,7 @@ public class Game extends GameShell { continue; } - player.aBoolean1699 = ((lowmem && (playerCount > 50)) || (playerCount > 200)) && !local && (player.seqCurrent == player.seqStand); + player.lowmem = ((lowmem && (playerCount > 50)) || (playerCount > 200)) && !local && (player.seqId2 == player.seqStand); int stx = player.x >> 7; int stz = player.z >> 7; @@ -3030,8 +3030,8 @@ public class Game extends GameShell { continue; } - if ((player.model != null) && (loopCycle >= player.anInt1707) && (loopCycle < player.anInt1708)) { - player.aBoolean1699 = false; + if ((player.locModel != null) && (loopCycle >= player.locStartCycle) && (loopCycle < player.locStopCycle)) { + player.lowmem = false; player.y = getHeightmapY(currentPlane, player.x, player.z); scene.addTemporary(player, currentPlane, player.minSceneTileX, player.minSceneTileZ, player.maxSceneTileX, player.maxSceneTileZ, player.x, player.z, player.y, player.yaw, index); continue; @@ -3097,51 +3097,56 @@ public class Game extends GameShell { socialMessage = "Enter name of player to delete from list"; } if ((type >= 300) && (type <= 313)) { - int k = (type - 300) / 2; - int j1 = type & 1; - int i2 = anIntArray1065[k]; - if (i2 != -1) { + int part = (type - 300) / 2; + int direction = type & 1; + int kit = designIdentikits[part]; + + if (kit != -1) { do { - if ((j1 == 0) && (--i2 < 0)) { - i2 = IDKType.anInt655 - 1; + if ((direction == 0) && (--kit < 0)) { + kit = IDKType.count - 1; } - if ((j1 == 1) && (++i2 >= IDKType.anInt655)) { - i2 = 0; + if ((direction == 1) && (++kit >= IDKType.count)) { + kit = 0; } - } while (IDKType.instances[i2].aBoolean662 || (IDKType.instances[i2].anInt657 != (k + (aBoolean1047 ? 0 : 7)))); - anIntArray1065[k] = i2; - aBoolean1031 = true; + } while (IDKType.instances[kit].selectable || (IDKType.instances[kit].type != (part + (designGender ? 0 : 7)))); + + designIdentikits[part] = kit; + updateDesignModel = true; } } if ((type >= 314) && (type <= 323)) { - int l = (type - 314) / 2; - int k1 = type & 1; - int j2 = anIntArray990[l]; - if ((k1 == 0) && (--j2 < 0)) { - j2 = anIntArrayArray1003[l].length - 1; + int part = (type - 314) / 2; + int direction = type & 1; + int color = designColors[part]; + + if ((direction == 0) && (--color < 0)) { + color = designPartColor[part].length - 1; } - if ((k1 == 1) && (++j2 >= anIntArrayArray1003[l].length)) { - j2 = 0; + + if ((direction == 1) && (++color >= designPartColor[part].length)) { + color = 0; } - anIntArray990[l] = j2; - aBoolean1031 = true; + + designColors[part] = color; + updateDesignModel = true; } - if ((type == 324) && !aBoolean1047) { - aBoolean1047 = true; - method45(); + if ((type == 324) && !designGender) { + designGender = true; + validateCharacterDesign(); } - if ((type == 325) && aBoolean1047) { - aBoolean1047 = false; - method45(); + if ((type == 325) && designGender) { + designGender = false; + validateCharacterDesign(); } if (type == 326) { out.putOp(101); - out.put1(aBoolean1047 ? 0 : 1); - for (int i1 = 0; i1 < 7; i1++) { - out.put1(anIntArray1065[i1]); + out.put1(designGender ? 0 : 1); + for (int i = 0; i < 7; i++) { + out.put1(designIdentikits[i]); } - for (int l1 = 0; l1 < 5; l1++) { - out.put1(anIntArray990[l1]); + for (int i = 0; i < 5; i++) { + out.put1(designColors[i]); } return true; } @@ -3262,8 +3267,8 @@ public class Game extends GameShell { int info = scene.getInfo(plane, x, z, bitset); int rotation = (info >> 6) & 3; int kind = info & 0x1f; - int typeID = (bitset >> 14) & 0x7fff; - LocType type = LocType.get(typeID); + int locId = (bitset >> 14) & 0x7fff; + LocType type = LocType.get(locId); if (type.mapsceneIcon != -1) { Image8 icon = imageMapscene[type.mapsceneIcon]; @@ -3300,8 +3305,8 @@ public class Game extends GameShell { bitset = scene.getGroundDecorationBitset(plane, x, z); if (bitset != 0) { - int typeID = (bitset >> 14) & 0x7fff; - LocType type = LocType.get(typeID); + int locId = (bitset >> 14) & 0x7fff; + LocType type = LocType.get(locId); if (type.mapsceneIcon != -1) { Image8 icon = imageMapscene[type.mapsceneIcon]; @@ -3476,7 +3481,7 @@ public class Game extends GameShell { if (projectile.anInt1590 < 0) { int j = -projectile.anInt1590 - 1; PlayerEntity player; - if (j == localPlayerID) { + if (j == localPlayerId) { player = localPlayer; } else { player = players[j]; @@ -5103,23 +5108,23 @@ public class Game extends GameShell { int i1 = bitset & 0x7f; int j1 = (bitset >> 7) & 0x7f; int k1 = (bitset >> 29) & 3; - int locID = (bitset >> 14) & 0x7fff; + int locId = (bitset >> 14) & 0x7fff; if (bitset == j) { continue; } j = bitset; if ((k1 == 2) && (scene.getInfo(currentPlane, i1, j1, bitset) >= 0)) { - LocType type = LocType.get(locID); + LocType loc = LocType.get(locId); - if (type.overrideTypeIDs != null) { - type = type.getOverrideType(); + if (loc.overrideTypeIDs != null) { + loc = loc.getOverrideType(); } - if (type == null) { + if (loc == null) { continue; } if (anInt1282 == 1) { - menuOption[menuSize] = "Use " + aString1286 + " with @cya@" + type.name; + menuOption[menuSize] = "Use " + aString1286 + " with @cya@" + loc.name; menuAction[menuSize] = 62; menuParamC[menuSize] = bitset; menuParamA[menuSize] = i1; @@ -5127,7 +5132,7 @@ public class Game extends GameShell { menuSize++; } else if (anInt1136 == 1) { if ((activeSpellFlags & 4) == 4) { - menuOption[menuSize] = spellCaption + " @cya@" + type.name; + menuOption[menuSize] = spellCaption + " @cya@" + loc.name; menuAction[menuSize] = 956; menuParamC[menuSize] = bitset; menuParamA[menuSize] = i1; @@ -5135,10 +5140,10 @@ public class Game extends GameShell { menuSize++; } } else { - if (type.actions != null) { + if (loc.actions != null) { for (int i2 = 4; i2 >= 0; i2--) { - if (type.actions[i2] != null) { - menuOption[menuSize] = type.actions[i2] + " @cya@" + type.name; + if (loc.actions[i2] != null) { + menuOption[menuSize] = loc.actions[i2] + " @cya@" + loc.name; if (i2 == 0) { menuAction[menuSize] = 502; } @@ -5161,16 +5166,16 @@ public class Game extends GameShell { } } } - menuOption[menuSize] = "Examine @cya@" + type.name; + menuOption[menuSize] = "Examine @cya@" + loc.name; menuAction[menuSize] = 1226; - menuParamC[menuSize] = type.index << 14; + menuParamC[menuSize] = loc.index << 14; menuParamA[menuSize] = i1; menuParamB[menuSize] = j1; menuSize++; } } if (k1 == 1) { - NPCEntity npc = npcs[locID]; + NPCEntity npc = npcs[locId]; if ((npc.type.size == 1) && ((npc.x & 0x7f) == 64) && ((npc.z & 0x7f) == 64)) { for (int j2 = 0; j2 < npcCount; j2++) { NPCEntity class30_sub2_sub4_sub1_sub1_1 = npcs[npcIndices[j2]]; @@ -5185,10 +5190,10 @@ public class Game extends GameShell { } } } - method87(npc.type, locID, j1, i1); + method87(npc.type, locId, j1, i1); } if (k1 == 0) { - PlayerEntity player = players[locID]; + PlayerEntity player = players[locId]; if (((player.x & 0x7f) == 64) && ((player.z & 0x7f) == 64)) { for (int k2 = 0; k2 < npcCount; k2++) { NPCEntity class30_sub2_sub4_sub1_sub1_2 = npcs[npcIndices[k2]]; @@ -5203,7 +5208,7 @@ public class Game extends GameShell { } } } - method88(i1, locID, player, j1); + method88(i1, locId, player, j1); } if (k1 == 3) { DoublyLinkedList list = planeObjStacks[currentPlane][i1][j1]; @@ -5720,36 +5725,43 @@ public class Game extends GameShell { if (type == 327) { component.modelEyePitch = 150; component.modelYaw = (int) (Math.sin((double) loopCycle / 40D) * 256D) & 0x7ff; - if (aBoolean1031) { - for (int k1 = 0; k1 < 7; k1++) { - int l1 = anIntArray1065[k1]; - if ((l1 >= 0) && !IDKType.instances[l1].method537()) { + + if (updateDesignModel) { + for (int i = 0; i < 7; i++) { + int kit = designIdentikits[i]; + if ((kit >= 0) && !IDKType.instances[kit].validateModel()) { return; } } - aBoolean1031 = false; - Model[] aclass30_sub2_sub4_sub6 = new Model[7]; - int i2 = 0; - for (int j2 = 0; j2 < 7; j2++) { - int k2 = anIntArray1065[j2]; - if (k2 >= 0) { - aclass30_sub2_sub4_sub6[i2++] = IDKType.instances[k2].method538(); + + updateDesignModel = false; + + Model[] models = new Model[7]; + int modelCount = 0; + for (int part = 0; part < 7; part++) { + int kit = designIdentikits[part]; + + if (kit >= 0) { + models[modelCount++] = IDKType.instances[kit].getModel(); } } - Model model = new Model(i2, aclass30_sub2_sub4_sub6); - for (int l2 = 0; l2 < 5; l2++) { - if (anIntArray990[l2] != 0) { - model.recolor(anIntArrayArray1003[l2][0], anIntArrayArray1003[l2][anIntArray990[l2]]); - if (l2 == 1) { - model.recolor(anIntArray1204[0], anIntArray1204[anIntArray990[l2]]); + + Model model = new Model(modelCount, models); + for (int part = 0; part < 5; part++) { + if (designColors[part] != 0) { + model.recolor(designPartColor[part][0], designPartColor[part][designColors[part]]); + if (part == 1) { + model.recolor(designHairColor[0], designHairColor[designColors[part]]); } } } + model.createLabelReferences(); model.applySequenceFrame(SeqType.instances[localPlayer.seqStand].primaryFrames[0]); model.calculateNormals(64, 850, -30, -50, -30, true); + component.modelCategory = 5; - component.modelID = 0; + component.modelId = 0; Component.cacheModel(0, 5, model); } return; @@ -5759,7 +5771,7 @@ public class Game extends GameShell { aImage_931 = component.image; aImage_932 = component.activeImage; } - if (aBoolean1047) { + if (designGender) { component.image = aImage_932; } else { component.image = aImage_931; @@ -5771,7 +5783,7 @@ public class Game extends GameShell { aImage_931 = component.image; aImage_932 = component.activeImage; } - if (aBoolean1047) { + if (designGender) { component.image = aImage_931; } else { component.image = aImage_932; @@ -6294,7 +6306,7 @@ public class Game extends GameShell { } localPlayer = players[LOCAL_PLAYER_INDEX] = new PlayerEntity(); aList_1013.clear(); - aList_1056.clear(); + spotanims.clear(); for (int l2 = 0; l2 < 4; l2++) { for (int i3 = 0; i3 < 104; i3++) { for (int k3 = 0; k3 < 104; k3++) { @@ -6318,10 +6330,10 @@ public class Game extends GameShell { chatbackMessage = null; anInt1055 = 0; anInt1054 = -1; - aBoolean1047 = true; - method45(); + designGender = true; + validateCharacterDesign(); for (int j3 = 0; j3 < 5; j3++) { - anIntArray990[j3] = 0; + designColors[j3] = 0; } for (int l3 = 0; l3 < 5; l3++) { aStringArray1127[l3] = null; @@ -6694,10 +6706,10 @@ public class Game extends GameShell { i1 = -1; } int i2 = buffer.get1U(); - if ((i1 == npc.anInt1526) && (i1 != -1)) { + if ((i1 == npc.seqId1) && (i1 != -1)) { int l2 = SeqType.instances[i1].anInt365; if (l2 == 1) { - npc.anInt1527 = 0; + npc.seqFrame1 = 0; npc.anInt1528 = 0; npc.anInt1529 = i2; npc.anInt1530 = 0; @@ -6705,9 +6717,9 @@ public class Game extends GameShell { if (l2 == 2) { npc.anInt1530 = 0; } - } else if ((i1 == -1) || (npc.anInt1526 == -1) || (SeqType.instances[i1].anInt359 >= SeqType.instances[npc.anInt1526].anInt359)) { - npc.anInt1526 = i1; - npc.anInt1527 = 0; + } else if ((i1 == -1) || (npc.seqId1 == -1) || (SeqType.instances[i1].priority >= SeqType.instances[npc.seqId1].priority)) { + npc.seqId1 = i1; + npc.seqFrame1 = 0; npc.anInt1528 = 0; npc.anInt1529 = i2; npc.anInt1530 = 0; @@ -6725,7 +6737,7 @@ public class Game extends GameShell { if ((l & 0x80) != 0) { npc.spotanim = buffer.get2U(); int k1 = buffer.get4(); - npc.anInt1524 = k1 >> 16; + npc.spotanimY = k1 >> 16; npc.anInt1523 = loopCycle + (k1 & 0xffff); npc.spotanimFrame = 0; npc.spotanimCycle = 0; @@ -6758,10 +6770,10 @@ public class Game extends GameShell { npc.type = NPCType.get(buffer.get2ULEA()); npc.size = npc.type.size; npc.turnSpeed = npc.type.turnSpeed; - npc.seqWalk = npc.type.seqWalk; - npc.seqTurnAround = npc.type.seqTurnAround; + npc.seqWalk = npc.type.seqWalkId; + npc.seqTurnAround = npc.type.seqTurnAroundId; npc.seqTurnLeft = npc.type.seqTurnLeft; - npc.seqTurnRight = npc.type.seqTurnRight; + npc.seqTurnRight = npc.type.seqTurnRightId; npc.seqStand = npc.type.seqStand; } if ((l & 4) != 0) { @@ -6785,8 +6797,8 @@ public class Game extends GameShell { return; } String s = type.name; - if (type.anInt61 != 0) { - s = s + method110(localPlayer.combatLevel, type.anInt61) + " (level-" + type.anInt61 + ")"; + if (type.level != 0) { + s = s + method110(localPlayer.combatLevel, type.level) + " (level-" + type.level + ")"; } if (anInt1282 == 1) { menuOption[menuSize] = "Use " + aString1286 + " with @yel@" + s; @@ -6837,7 +6849,7 @@ public class Game extends GameShell { for (int i1 = 4; i1 >= 0; i1--) { if ((type.op[i1] != null) && type.op[i1].equalsIgnoreCase("attack")) { char c = '\0'; - if (type.anInt61 > localPlayer.combatLevel) { + if (type.level > localPlayer.combatLevel) { c = '\u07D0'; } menuOption[menuSize] = type.op[i1] + " @yel@" + s; @@ -6952,28 +6964,28 @@ public class Game extends GameShell { public void storeLoc(SceneLocTemporary loc) { int bitset = 0; - int locID = -1; + int locId = -1; int kind = 0; int rotation = 0; - if (loc.classID == 0) { + if (loc.classId == 0) { bitset = scene.getWallBitset(loc.plane, loc.localX, loc.localZ); } - if (loc.classID == 1) { + if (loc.classId == 1) { bitset = scene.getWallDecorationBitset(loc.plane, loc.localX, loc.localZ); } - if (loc.classID == 2) { + if (loc.classId == 2) { bitset = scene.getLocBitset(loc.plane, loc.localX, loc.localZ); } - if (loc.classID == 3) { + if (loc.classId == 3) { bitset = scene.getGroundDecorationBitset(loc.plane, loc.localX, loc.localZ); } if (bitset != 0) { int info = scene.getInfo(loc.plane, loc.localX, loc.localZ, bitset); - locID = (bitset >> 14) & 0x7fff; + locId = (bitset >> 14) & 0x7fff; kind = info & 0x1f; rotation = info >> 6; } - loc.savedLocID = locID; + loc.savedLocId = locId; loc.savedKind = kind; loc.savedRotation = rotation; } @@ -6986,12 +6998,12 @@ public class Game extends GameShell { boolean failed = false; try { - if ((waveIDs[i] == lastWaveId) && (waveLoops[i] == lastWaveLoops)) { + if ((waveIds[i] == lastWaveId) && (waveLoops[i] == lastWaveLoops)) { if (!wavereplay()) { failed = true; } } else { - Buffer buffer = SoundTrack.generate(waveLoops[i], waveIDs[i]); + Buffer buffer = SoundTrack.generate(waveLoops[i], waveIds[i]); // the sample rate is 22050Hz and sample size is 1 byte which means dividing the bytes by 22 is // roughly converting the bytes to time in milliseconds @@ -7000,7 +7012,7 @@ public class Game extends GameShell { lastWaveStartTime = System.currentTimeMillis(); if (wavesave(buffer.data, buffer.position)) { - lastWaveId = waveIDs[i]; + lastWaveId = waveIds[i]; lastWaveLoops = waveLoops[i]; } else { failed = true; @@ -7013,7 +7025,7 @@ public class Game extends GameShell { if (!failed || (waveDelay[i] == -5)) { waveCount--; for (int j = i; j < waveCount; j++) { - waveIDs[j] = waveIDs[j + 1]; + waveIds[j] = waveIds[j + 1]; waveLoops[j] = waveLoops[j + 1]; waveDelay[j] = waveDelay[j + 1]; } @@ -7179,7 +7191,7 @@ public class Game extends GameShell { public void method96(PathingEntity entity) { if ((entity.x < 128) || (entity.z < 128) || (entity.x >= 13184) || (entity.z >= 13184)) { - entity.anInt1526 = -1; + entity.seqId1 = -1; entity.spotanim = -1; entity.forceMoveEndCycle = 0; entity.forceMoveStartCycle = 0; @@ -7188,7 +7200,7 @@ public class Game extends GameShell { entity.method446(); } if ((entity == localPlayer) && ((entity.x < 1536) || (entity.z < 1536) || (entity.x >= 11776) || (entity.z >= 11776))) { - entity.anInt1526 = -1; + entity.seqId1 = -1; entity.spotanim = -1; entity.forceMoveEndCycle = 0; entity.forceMoveStartCycle = 0; @@ -7232,7 +7244,7 @@ public class Game extends GameShell { } public void method98(PathingEntity entity) { - if ((entity.forceMoveStartCycle == loopCycle) || (entity.anInt1526 == -1) || (entity.anInt1529 != 0) || ((entity.anInt1528 + 1) > SeqType.instances[entity.anInt1526].getFrameDelay(entity.anInt1527))) { + if ((entity.forceMoveStartCycle == loopCycle) || (entity.seqId1 == -1) || (entity.anInt1529 != 0) || ((entity.anInt1528 + 1) > SeqType.instances[entity.seqId1].getFrameDelay(entity.seqFrame1))) { int duration = entity.forceMoveStartCycle - entity.forceMoveEndCycle; int delta = loopCycle - entity.forceMoveEndCycle; int dx0 = (entity.forceMoveStartSceneTileX * 128) + (entity.size * 64); @@ -7261,15 +7273,15 @@ public class Game extends GameShell { } public void method99(PathingEntity entity) { - entity.seqCurrent = entity.seqStand; + entity.seqId2 = entity.seqStand; if (entity.pathRemaining == 0) { entity.anInt1503 = 0; return; } - if ((entity.anInt1526 != -1) && (entity.anInt1529 == 0)) { - SeqType type = SeqType.instances[entity.anInt1526]; + if ((entity.seqId1 != -1) && (entity.anInt1529 == 0)) { + SeqType type = SeqType.instances[entity.seqId1]; if ((entity.anInt1542 > 0) && (type.anInt363 == 0)) { entity.anInt1503++; @@ -7343,7 +7355,7 @@ public class Game extends GameShell { seq = entity.seqWalk; } - entity.seqCurrent = seq; + entity.seqId2 = seq; int moveSpeed = 4; @@ -7368,8 +7380,8 @@ public class Game extends GameShell { moveSpeed <<= 1; } - if ((moveSpeed >= 8) && (entity.seqCurrent == entity.seqWalk) && (entity.seqRun != -1)) { - entity.seqCurrent = entity.seqRun; + if ((moveSpeed >= 8) && (entity.seqId2 == entity.seqWalk) && (entity.seqRun != -1)) { + entity.seqId2 = entity.seqRun; } if (x < dstX) { @@ -7422,7 +7434,7 @@ public class Game extends GameShell { if (e.index >= 32768) { int index = e.index - 32768; - if (index == localPlayerID) { + if (index == localPlayerId) { index = LOCAL_PLAYER_INDEX; } @@ -7463,13 +7475,13 @@ public class Game extends GameShell { e.yaw &= 0x7ff; - if ((e.seqCurrent == e.seqStand) && (e.yaw != e.dstYaw)) { + if ((e.seqId2 == e.seqStand) && (e.yaw != e.dstYaw)) { if (e.seqTurn != -1) { - e.seqCurrent = e.seqTurn; + e.seqId2 = e.seqTurn; return; } - e.seqCurrent = e.seqWalk; + e.seqId2 = e.seqWalk; } } } @@ -7477,18 +7489,18 @@ public class Game extends GameShell { public void method101(PathingEntity e) { e.aBoolean1541 = false; - if (e.seqCurrent != -1) { - SeqType seq = SeqType.instances[e.seqCurrent]; + if (e.seqId2 != -1) { + SeqType seq = SeqType.instances[e.seqId2]; e.seqCycle++; - if ((e.seqFrame < seq.frameCount) && (e.seqCycle > seq.getFrameDelay(e.seqFrame))) { + if ((e.seqFrame2 < seq.frameCount) && (e.seqCycle > seq.getFrameDelay(e.seqFrame2))) { e.seqCycle = 0; - e.seqFrame++; + e.seqFrame2++; } - if (e.seqFrame >= seq.frameCount) { + if (e.seqFrame2 >= seq.frameCount) { e.seqCycle = 0; - e.seqFrame = 0; + e.seqFrame2 = 0; } } @@ -7508,8 +7520,8 @@ public class Game extends GameShell { } } - if ((e.anInt1526 != -1) && (e.anInt1529 <= 1)) { - SeqType seq = SeqType.instances[e.anInt1526]; + if ((e.seqId1 != -1) && (e.anInt1529 <= 1)) { + SeqType seq = SeqType.instances[e.seqId1]; if ((seq.anInt363 == 1) && (e.anInt1542 > 0) && (e.forceMoveEndCycle <= loopCycle) && (e.forceMoveStartCycle < loopCycle)) { e.anInt1529 = 1; @@ -7517,22 +7529,22 @@ public class Game extends GameShell { } } - if ((e.anInt1526 != -1) && (e.anInt1529 == 0)) { - SeqType seq = SeqType.instances[e.anInt1526]; + if ((e.seqId1 != -1) && (e.anInt1529 == 0)) { + SeqType seq = SeqType.instances[e.seqId1]; - for (e.anInt1528++; (e.anInt1527 < seq.frameCount) && (e.anInt1528 > seq.getFrameDelay(e.anInt1527)); e.anInt1527++) { - e.anInt1528 -= seq.getFrameDelay(e.anInt1527); + for (e.anInt1528++; (e.seqFrame1 < seq.frameCount) && (e.anInt1528 > seq.getFrameDelay(e.seqFrame1)); e.seqFrame1++) { + e.anInt1528 -= seq.getFrameDelay(e.seqFrame1); } - if (e.anInt1527 >= seq.frameCount) { - e.anInt1527 -= seq.speed; + if (e.seqFrame1 >= seq.frameCount) { + e.seqFrame1 -= seq.speed; e.anInt1530++; if (e.anInt1530 >= seq.anInt362) { - e.anInt1526 = -1; + e.seqId1 = -1; } - if ((e.anInt1527 < 0) || (e.anInt1527 >= seq.frameCount)) { - e.anInt1526 = -1; + if ((e.seqFrame1 < 0) || (e.seqFrame1 >= seq.frameCount)) { + e.seqId1 = -1; } } e.aBoolean1541 = seq.aBoolean358; @@ -7814,17 +7826,18 @@ public class Game extends GameShell { } } - public void method104() { - SpotAnimEntity spotAnim = (SpotAnimEntity) aList_1056.peekFront(); - for (; spotAnim != null; spotAnim = (SpotAnimEntity) aList_1056.prev()) { - if ((spotAnim.anInt1560 != currentPlane) || spotAnim.aBoolean1567) { - spotAnim.unlink(); - } else if (loopCycle >= spotAnim.anInt1564) { - spotAnim.method454(delta); - if (spotAnim.aBoolean1567) { - spotAnim.unlink(); + public void updateSpotAnims() { + SpotAnimEntity anim = (SpotAnimEntity) spotanims.peekFront(); + + for (; anim != null; anim = (SpotAnimEntity) spotanims.prev()) { + if ((anim.plane != currentPlane) || anim.seqComplete) { + anim.unlink(); + } else if (loopCycle >= anim.startCycle) { + anim.update(delta); + if (anim.seqComplete) { + anim.unlink(); } else { - scene.addTemporary(spotAnim, spotAnim.anInt1560, spotAnim.anInt1561, spotAnim.anInt1562, spotAnim.anInt1563, 0, -1, false, 60); + scene.addTemporary(anim, anim.plane, anim.x, anim.z, anim.y, 0, -1, false, 60); } } } @@ -8216,7 +8229,7 @@ public class Game extends GameShell { if ((i & 0x100) != 0) { player.spotanim = buffer.get2ULE(); int k = buffer.get4(); - player.anInt1524 = k >> 16; + player.spotanimY = k >> 16; player.anInt1523 = loopCycle + (k & 0xffff); player.spotanimFrame = 0; player.spotanimCycle = 0; @@ -8228,15 +8241,15 @@ public class Game extends GameShell { } } if ((i & 8) != 0) { - int l = buffer.get2ULE(); - if (l == 65535) { - l = -1; + int seqId = buffer.get2ULE(); + if (seqId == 65535) { + seqId = -1; } int i2 = buffer.get1UC(); - if ((l == player.anInt1526) && (l != -1)) { - int i3 = SeqType.instances[l].anInt365; + if ((seqId == player.seqId1) && (seqId != -1)) { + int i3 = SeqType.instances[seqId].anInt365; if (i3 == 1) { - player.anInt1527 = 0; + player.seqFrame1 = 0; player.anInt1528 = 0; player.anInt1529 = i2; player.anInt1530 = 0; @@ -8244,9 +8257,9 @@ public class Game extends GameShell { if (i3 == 2) { player.anInt1530 = 0; } - } else if ((l == -1) || (player.anInt1526 == -1) || (SeqType.instances[l].anInt359 >= SeqType.instances[player.anInt1526].anInt359)) { - player.anInt1526 = l; - player.anInt1527 = 0; + } else if ((seqId == -1) || (player.seqId1 == -1) || (SeqType.instances[seqId].priority >= SeqType.instances[player.seqId1].priority)) { + player.seqId1 = seqId; + player.seqFrame1 = 0; player.anInt1528 = 0; player.anInt1529 = i2; player.anInt1530 = 0; @@ -8270,7 +8283,7 @@ public class Game extends GameShell { int j2 = buffer.get1U(); int j3 = buffer.get1UC(); int k3 = buffer.position; - if ((player.name != null) && player.aBoolean1710) { + if ((player.name != null) && player.visible) { long l3 = StringUtil.toBase37(player.name); boolean flag = false; if (j2 <= 1) { @@ -8548,8 +8561,8 @@ public class Game extends GameShell { loc.anInt1294--; } if (loc.anInt1294 == 0) { - if ((loc.savedLocID < 0) || SceneBuilder.isLocReady(loc.savedLocID, loc.savedKind)) { - addLoc(loc.localZ, loc.plane, loc.savedRotation, loc.savedKind, loc.localX, loc.classID, loc.savedLocID); + if ((loc.savedLocId < 0) || SceneBuilder.isLocReady(loc.savedLocId, loc.savedKind)) { + addLoc(loc.localZ, loc.plane, loc.savedRotation, loc.savedKind, loc.localX, loc.classId, loc.savedLocId); loc.unlink(); } } else { @@ -8557,11 +8570,11 @@ public class Game extends GameShell { loc.anInt1302--; } if ((loc.anInt1302 == 0) && (loc.localX >= 1) && (loc.localZ >= 1) && (loc.localX <= 102) && (loc.localZ <= 102) && ((loc.anInt1291 < 0) || SceneBuilder.isLocReady(loc.anInt1291, loc.anInt1293))) { - addLoc(loc.localZ, loc.plane, loc.anInt1292, loc.anInt1293, loc.localX, loc.classID, loc.anInt1291); + addLoc(loc.localZ, loc.plane, loc.anInt1292, loc.anInt1293, loc.localX, loc.classId, loc.anInt1291); loc.anInt1302 = -1; - if ((loc.anInt1291 == loc.savedLocID) && (loc.savedLocID == -1)) { + if ((loc.anInt1291 == loc.savedLocId) && (loc.savedLocId == -1)) { loc.unlink(); - } else if ((loc.anInt1291 == loc.savedLocID) && (loc.anInt1292 == loc.savedRotation) && (loc.anInt1293 == loc.savedKind)) { + } else if ((loc.anInt1291 == loc.savedLocId) && (loc.anInt1292 == loc.savedRotation) && (loc.anInt1293 == loc.savedKind)) { loc.unlink(); } } @@ -9239,10 +9252,10 @@ public class Game extends GameShell { } } - public void method130(int j, int k, int l, int classID, int z, int k1, int plane, int x, int j2) { + public void method130(int j, int k, int l, int classId, int z, int k1, int plane, int x, int j2) { SceneLocTemporary loc = null; for (SceneLocTemporary other = (SceneLocTemporary) temporaryLocs.peekFront(); other != null; other = (SceneLocTemporary) temporaryLocs.prev()) { - if ((other.plane != plane) || (other.localX != x) || (other.localZ != z) || (other.classID != classID)) { + if ((other.plane != plane) || (other.localX != x) || (other.localZ != z) || (other.classId != classId)) { continue; } loc = other; @@ -9251,7 +9264,7 @@ public class Game extends GameShell { if (loc == null) { loc = new SceneLocTemporary(); loc.plane = plane; - loc.classID = classID; + loc.classId = classId; loc.localX = x; loc.localZ = z; storeLoc(loc); @@ -9581,14 +9594,14 @@ public class Game extends GameShell { int pos = buffer.get1U(); int x = zoneX + ((pos >> 4) & 7); int z = zoneZ + (pos & 7); - int objID = buffer.get2U(); + int objId = buffer.get2U(); int objAmount = buffer.get2U(); int newAmount = buffer.get2U(); if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104)) { DoublyLinkedList stacks = planeObjStacks[currentPlane][x][z]; if (stacks != null) { for (ObjStackEntity stack = (ObjStackEntity) stacks.peekFront(); stack != null; stack = (ObjStackEntity) stacks.prev()) { - if ((stack.id != (objID & 0x7fff)) || (stack.amount != objAmount)) { + if ((stack.id != (objId & 0x7fff)) || (stack.amount != objAmount)) { continue; } stack.amount = newAmount; @@ -9605,29 +9618,29 @@ public class Game extends GameShell { int pos = buffer.get1U(); int x = zoneX + ((pos >> 4) & 7); int z = zoneZ + (pos & 7); - int waveID = buffer.get2U(); + int waveId = buffer.get2U(); int info = buffer.get1U(); int maxDist = (info >> 4) & 0xf; int loopCount = info & 0b111; if ((localPlayer.pathTileX[0] >= (x - maxDist)) && (localPlayer.pathTileX[0] <= (x + maxDist)) && (localPlayer.pathTileZ[0] >= (z - maxDist)) && (localPlayer.pathTileZ[0] <= (z + maxDist)) && aBoolean848 && !lowmem && (waveCount < 50)) { - waveIDs[waveCount] = waveID; + waveIds[waveCount] = waveId; waveLoops[waveCount] = loopCount; - waveDelay[waveCount] = SoundTrack.delays[waveID]; + waveDelay[waveCount] = SoundTrack.delays[waveId]; waveCount++; } } // reveal obj (this would already be visible to the local player if it belongs to them) if (opcode == 215) { - int objID = buffer.get2UA(); + int objId = buffer.get2UA(); int pos = buffer.get1US(); int x = zoneX + ((pos >> 4) & 7); int z = zoneZ + (pos & 7); - int ownerID = buffer.get2UA(); + int ownerId = buffer.get2UA(); int objAmount = buffer.get2U(); - if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104) && (ownerID != localPlayerID)) { + if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104) && (ownerId != localPlayerId)) { ObjStackEntity obj = new ObjStackEntity(); - obj.id = objID; + obj.id = objId; obj.amount = objAmount; if (planeObjStacks[currentPlane][x][z] == null) { planeObjStacks[currentPlane][x][z] = new DoublyLinkedList(); @@ -9643,12 +9656,12 @@ public class Game extends GameShell { int pos = buffer.get1UA(); int x = zoneX + ((pos >> 4) & 7); int z = zoneZ + (pos & 7); - int objID = buffer.get2U(); + int objId = buffer.get2U(); if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104)) { DoublyLinkedList list = planeObjStacks[currentPlane][x][z]; if (list != null) { for (ObjStackEntity obj = (ObjStackEntity) list.peekFront(); obj != null; obj = (ObjStackEntity) list.prev()) { - if (obj.id != (objID & 0x7fff)) { + if (obj.id != (objId & 0x7fff)) { continue; } obj.unlink(); @@ -9671,8 +9684,8 @@ public class Game extends GameShell { int info = buffer.get1US(); int kind = info >> 2; int rotation = info & 3; - int classID = LOC_KIND_TO_CLASS_ID[kind]; - int seqID = buffer.get2UA(); + int classId = LOC_KIND_TO_CLASS_ID[kind]; + int seqId = buffer.get2UA(); if ((x < 0) || (z < 0) || (x >= 103) || (z >= 103)) { return; @@ -9683,30 +9696,30 @@ public class Game extends GameShell { int heightmapNE = planeHeightmap[currentPlane][x + 1][z + 1]; int heightmapNW = planeHeightmap[currentPlane][x][z + 1]; - if (classID == 0) { + if (classId == 0) { SceneWall wall = scene.getWall(currentPlane, x, z); if (wall != null) { - int locID = (wall.bitset >> 14) & 0x7fff; + int locId = (wall.bitset >> 14) & 0x7fff; if (kind == 2) { - wall.entityA = new LocEntity(locID, 4 + rotation, 2, heightmapSE, heightmapNE, heightmapSW, heightmapNW, seqID, false); - wall.entityB = new LocEntity(locID, (rotation + 1) & 3, 2, heightmapSE, heightmapNE, heightmapSW, heightmapNW, seqID, false); + wall.entityA = new LocEntity(locId, 4 + rotation, 2, heightmapSE, heightmapNE, heightmapSW, heightmapNW, seqId, false); + wall.entityB = new LocEntity(locId, (rotation + 1) & 3, 2, heightmapSE, heightmapNE, heightmapSW, heightmapNW, seqId, false); } else { - wall.entityA = new LocEntity(locID, rotation, kind, heightmapSE, heightmapNE, heightmapSW, heightmapNW, seqID, false); + wall.entityA = new LocEntity(locId, rotation, kind, heightmapSE, heightmapNE, heightmapSW, heightmapNW, seqId, false); } } } - if (classID == 1) { + if (classId == 1) { SceneWallDecoration deco = scene.getWallDecoration(currentPlane, x, z); if (deco != null) { - deco.entity = new LocEntity((deco.bitset >> 14) & 0x7fff, 0, 4, heightmapSE, heightmapNE, heightmapSW, heightmapNW, seqID, false); + deco.entity = new LocEntity((deco.bitset >> 14) & 0x7fff, 0, 4, heightmapSE, heightmapNE, heightmapSW, heightmapNW, seqId, false); } } - if (classID == 2) { + if (classId == 2) { SceneLoc loc = scene.getLoc(currentPlane, x, z); if (kind == 11) { @@ -9714,15 +9727,15 @@ public class Game extends GameShell { } if (loc != null) { - loc.entity = new LocEntity((loc.bitset >> 14) & 0x7fff, rotation, kind, heightmapSE, heightmapNE, heightmapSW, heightmapNW, seqID, false); + loc.entity = new LocEntity((loc.bitset >> 14) & 0x7fff, rotation, kind, heightmapSE, heightmapNE, heightmapSW, heightmapNW, seqId, false); } } - if (classID == 3) { + if (classId == 3) { SceneGroundDecoration deco = scene.getGroundDecoration(z, x, currentPlane); if (deco != null) { - deco.entity = new LocEntity((deco.bitset >> 14) & 0x7fff, rotation, 22, heightmapSE, heightmapNE, heightmapSW, heightmapNW, seqID, false); + deco.entity = new LocEntity((deco.bitset >> 14) & 0x7fff, rotation, 22, heightmapSE, heightmapNE, heightmapSW, heightmapNW, seqId, false); } } return; @@ -9732,62 +9745,69 @@ public class Game extends GameShell { int pos = buffer.get1US(); int x = zoneX + ((pos >> 4) & 7); int z = zoneZ + (pos & 7); - int playerID = buffer.get2U(); - byte byte0 = buffer.get1S(); - int l14 = buffer.get2ULE(); - byte byte1 = buffer.get1C(); - int k17 = buffer.get2U(); + int pid = buffer.get2U(); + byte maxX = buffer.get1S(); + int startCycle = buffer.get2ULE(); + byte maxZ = buffer.get1C(); + int stopCycle = buffer.get2U(); int info = buffer.get1US(); int kind = info >> 2; int rotation = info & 3; - int classID = LOC_KIND_TO_CLASS_ID[kind]; - byte byte2 = buffer.get1(); - int l21 = buffer.get2U(); - byte byte3 = buffer.get1C(); + int classId = LOC_KIND_TO_CLASS_ID[kind]; + byte minX = buffer.get1(); + int locId = buffer.get2U(); + byte minZ = buffer.get1C(); PlayerEntity player; - if (playerID == localPlayerID) { + if (pid == localPlayerId) { player = localPlayer; } else { - player = players[playerID]; + player = players[pid]; } if (player != null) { - LocType type = LocType.get(l21); + LocType type = LocType.get(locId); int heightmapSW = planeHeightmap[currentPlane][x][z]; int heightmapSE = planeHeightmap[currentPlane][x + 1][z]; int heightmapNE = planeHeightmap[currentPlane][x + 1][z + 1]; int heightmapNW = planeHeightmap[currentPlane][x][z + 1]; + Model model = type.getModel(kind, rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, -1); if (model != null) { - method130(k17 + 1, -1, 0, classID, z, 0, currentPlane, x, l14 + 1); - player.anInt1707 = l14 + loopCycle; - player.anInt1708 = k17 + loopCycle; - player.model = model; - int i23 = type.width; - int j23 = type.length; + method130(stopCycle + 1, -1, 0, classId, z, 0, currentPlane, x, startCycle + 1); + + player.locStartCycle = startCycle + loopCycle; + player.locStopCycle = stopCycle + loopCycle; + player.locModel = model; + int sizeX = type.width; + int sizeZ = type.length; + if ((rotation == 1) || (rotation == 3)) { - i23 = type.length; - j23 = type.width; + sizeX = type.length; + sizeZ = type.width; } - player.anInt1711 = (x * 128) + (i23 * 64); - player.anInt1713 = (z * 128) + (j23 * 64); - player.anInt1712 = getHeightmapY(currentPlane, player.anInt1711, player.anInt1713); - if (byte2 > byte0) { - byte byte4 = byte2; - byte2 = byte0; - byte0 = byte4; + + player.locOffsetX = (x * 128) + (sizeX * 64); + player.locOffsetZ = (z * 128) + (sizeZ * 64); + player.locOffsetY = getHeightmapY(currentPlane, player.locOffsetX, player.locOffsetZ); + + if (minX > maxX) { + byte tmp = minX; + minX = maxX; + maxX = tmp; } - if (byte3 > byte1) { - byte byte5 = byte3; - byte3 = byte1; - byte1 = byte5; + + if (minZ > maxZ) { + byte tmp = minZ; + minZ = maxZ; + maxZ = tmp; } - player.minSceneTileX = x + byte2; - player.maxSceneTileX = x + byte0; - player.minSceneTileZ = z + byte3; - player.maxSceneTileZ = z + byte1; + + player.minSceneTileX = x + minX; + player.maxSceneTileX = x + maxX; + player.minSceneTileZ = z + minZ; + player.maxSceneTileZ = z + maxZ; } } } @@ -9808,17 +9828,18 @@ public class Game extends GameShell { } if (opcode == 4) { - int j2 = buffer.get1U(); - int i5 = zoneX + ((j2 >> 4) & 7); - int l7 = zoneZ + (j2 & 7); - int k10 = buffer.get2U(); - int l12 = buffer.get1U(); - int j15 = buffer.get2U(); - if ((i5 >= 0) && (l7 >= 0) && (i5 < 104) && (l7 < 104)) { - i5 = (i5 * 128) + 64; - l7 = (l7 * 128) + 64; - SpotAnimEntity spotAnim = new SpotAnimEntity(currentPlane, loopCycle, j15, k10, getHeightmapY(currentPlane, i5, l7) - l12, l7, i5); - aList_1056.pushBack(spotAnim); + int pos = buffer.get1U(); + int x = zoneX + ((pos >> 4) & 7); + int z = zoneZ + (pos & 7); + int id = buffer.get2U(); + int y = buffer.get1U(); + int delay = buffer.get2U(); + + if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104)) { + x = (x * 128) + 64; + z = (z * 128) + 64; + SpotAnimEntity spotAnim = new SpotAnimEntity(currentPlane, loopCycle, delay, id, getHeightmapY(currentPlane, x, z) - y, z, x); + spotanims.pushBack(spotAnim); } return; } @@ -10099,13 +10120,13 @@ public class Game extends GameShell { if (bitset != 0) { int info = scene.getInfo(plane, x, z, bitset); - int otherID = (bitset >> 14) & 0x7fff; + int otherId = (bitset >> 14) & 0x7fff; int otherKind = info & 0x1f; int otherRotation = info >> 6; if (classID == 0) { scene.removeWall(x, plane, z); - LocType type = LocType.get(otherID); + LocType type = LocType.get(otherId); if (type.solid) { collisions[plane].remove(otherRotation, otherKind, type.blocksProjectiles, x, z); } @@ -10117,7 +10138,7 @@ public class Game extends GameShell { if (classID == 2) { scene.removeLoc(plane, x, z); - LocType type = LocType.get(otherID); + LocType type = LocType.get(otherId); if (((x + type.width) > 103) || ((z + type.width) > 103) || ((x + type.length) > 103) || ((z + type.length) > 103)) { return; @@ -10130,7 +10151,7 @@ public class Game extends GameShell { if (classID == 3) { scene.removeGroundDecoration(plane, x, z); - LocType type_2 = LocType.get(otherID); + LocType type_2 = LocType.get(otherId); if (type_2.solid && type_2.interactable) { collisions[plane].method218(z, x); } @@ -10309,10 +10330,10 @@ public class Game extends GameShell { if (ptype == 185) { int k = in.get2ULEA(); Component.instances[k].modelCategory = 3; - if (localPlayer.aType_1698 == null) { - Component.instances[k].modelID = (localPlayer.anIntArray1700[0] << 25) + (localPlayer.anIntArray1700[4] << 20) + (localPlayer.appearance[0] << 15) + (localPlayer.appearance[8] << 10) + (localPlayer.appearance[11] << 5) + localPlayer.appearance[1]; + if (localPlayer.npcType == null) { + Component.instances[k].modelId = (localPlayer.colors[0] << 25) + (localPlayer.colors[4] << 20) + (localPlayer.appearances[0] << 15) + (localPlayer.appearances[8] << 10) + (localPlayer.appearances[11] << 5) + localPlayer.appearances[1]; } else { - Component.instances[k].modelID = (int) (0x12345678L + localPlayer.aType_1698.uid); + Component.instances[k].modelId = (int) (0x12345678L + localPlayer.npcType.uid); } ptype = -1; return true; @@ -10684,7 +10705,7 @@ public class Game extends GameShell { int npcId = in.get2ULEA(); int componentId = in.get2ULEA(); Component.instances[componentId].modelCategory = 2; - Component.instances[componentId].modelID = npcId; + Component.instances[componentId].modelId = npcId; ptype = -1; return true; } @@ -10721,7 +10742,7 @@ public class Game extends GameShell { int l11 = in.get1U(); int k17 = in.get2U(); if (aBoolean848 && !lowmem && (waveCount < 50)) { - waveIDs[waveCount] = i4; + waveIds[waveCount] = i4; waveLoops[waveCount] = l11; waveDelay[waveCount] = k17 + SoundTrack.delays[i4]; waveCount++; @@ -10802,12 +10823,12 @@ public class Game extends GameShell { if (ptype == 1) { for (PlayerEntity player : players) { if (player != null) { - player.anInt1526 = -1; + player.seqId1 = -1; } } for (NPCEntity npc : npcs) { if (npc != null) { - npc.anInt1526 = -1; + npc.seqId1 = -1; } } ptype = -1; @@ -11024,7 +11045,7 @@ public class Game extends GameShell { } else { ObjType type = ObjType.get(objId); Component.instances[componentId].modelCategory = 4; - Component.instances[componentId].modelID = objId; + Component.instances[componentId].modelId = objId; Component.instances[componentId].modelEyePitch = type.iconPitch; Component.instances[componentId].modelYaw = type.iconYaw; Component.instances[componentId].modelZoom = (type.iconZoom * 100) / zoom; @@ -11094,7 +11115,7 @@ public class Game extends GameShell { int componentId = in.get2ULEA(); int modelId = in.get2U(); Component.instances[componentId].modelCategory = 1; - Component.instances[componentId].modelID = modelId; + Component.instances[componentId].modelId = modelId; ptype = -1; return true; } @@ -11178,7 +11199,7 @@ public class Game extends GameShell { } if (ptype == 249) { anInt1046 = in.get1UA(); - localPlayerID = in.get2ULEA(); + localPlayerId = in.get2ULEA(); ptype = -1; return true; } @@ -11365,7 +11386,7 @@ public class Game extends GameShell { method47(false); method26(false); method55(); - method104(); + updateSpotAnims(); if (!aBoolean1160) { int pitch = cameraPitch; diff --git a/src/main/java/IDKType.java b/src/main/java/IDKType.java index 72843d0..68871ee 100644 --- a/src/main/java/IDKType.java +++ b/src/main/java/IDKType.java @@ -6,16 +6,16 @@ import java.io.IOException; public class IDKType { - public static int anInt655; + public static int count; public static IDKType[] instances; public static void unpack(FileArchive archive) throws IOException { Buffer buffer = new Buffer(archive.read("idk.dat")); - anInt655 = buffer.get2U(); + count = buffer.get2U(); if (instances == null) { - instances = new IDKType[anInt655]; + instances = new IDKType[count]; } - for (int j = 0; j < anInt655; j++) { + for (int j = 0; j < count; j++) { if (instances[j] == null) { instances[j] = new IDKType(); } @@ -23,12 +23,12 @@ public class IDKType { } } - public final int[] anIntArray659 = new int[6]; - public final int[] anIntArray660 = new int[6]; - public final int[] anIntArray661 = {-1, -1, -1, -1, -1}; - public int anInt657 = -1; - public int[] anIntArray658; - public boolean aBoolean662 = false; + public final int[] colorSrc = new int[6]; + public final int[] colorDst = new int[6]; + public final int[] headModelIds = {-1, -1, -1, -1, -1}; + public int type = -1; + public int[] modelIds; + public boolean selectable = false; public IDKType() { } @@ -40,47 +40,47 @@ public class IDKType { return; } if (i == 1) { - anInt657 = buffer.get1U(); + type = buffer.get1U(); } else if (i == 2) { int j = buffer.get1U(); - anIntArray658 = new int[j]; + modelIds = new int[j]; for (int k = 0; k < j; k++) { - anIntArray658[k] = buffer.get2U(); + modelIds[k] = buffer.get2U(); } } else if (i == 3) { - aBoolean662 = true; + selectable = true; } else if ((i >= 40) && (i < 50)) { - anIntArray659[i - 40] = buffer.get2U(); + colorSrc[i - 40] = buffer.get2U(); } else if ((i >= 50) && (i < 60)) { - anIntArray660[i - 50] = buffer.get2U(); + colorDst[i - 50] = buffer.get2U(); } else if ((i >= 60) && (i < 70)) { - anIntArray661[i - 60] = buffer.get2U(); + headModelIds[i - 60] = buffer.get2U(); } else { System.out.println("Error unrecognised config code: " + i); } } while (true); } - public boolean method537() { - if (anIntArray658 == null) { + public boolean validateModel() { + if (modelIds == null) { return true; } - boolean flag = true; - for (int i : anIntArray658) { - if (!Model.validate(i)) { - flag = false; + boolean loaded = true; + for (int modelId : modelIds) { + if (!Model.validate(modelId)) { + loaded = false; } } - return flag; + return loaded; } - public Model method538() { - if (anIntArray658 == null) { + public Model getModel() { + if (modelIds == null) { return null; } - Model[] aclass30_sub2_sub4_sub6 = new Model[anIntArray658.length]; - for (int i = 0; i < anIntArray658.length; i++) { - aclass30_sub2_sub4_sub6[i] = Model.tryGet(anIntArray658[i]); + Model[] aclass30_sub2_sub4_sub6 = new Model[modelIds.length]; + for (int i = 0; i < modelIds.length; i++) { + aclass30_sub2_sub4_sub6[i] = Model.tryGet(modelIds[i]); } Model model; if (aclass30_sub2_sub4_sub6.length == 1) { @@ -89,38 +89,38 @@ public class IDKType { model = new Model(aclass30_sub2_sub4_sub6.length, aclass30_sub2_sub4_sub6); } for (int j = 0; j < 6; j++) { - if (anIntArray659[j] == 0) { + if (colorSrc[j] == 0) { break; } - model.recolor(anIntArray659[j], anIntArray660[j]); + model.recolor(colorSrc[j], colorDst[j]); } return model; } - public boolean method539() { - boolean flag1 = true; + public boolean validateHeadModel() { + boolean loaded = true; for (int i = 0; i < 5; i++) { - if ((anIntArray661[i] != -1) && !Model.validate(anIntArray661[i])) { - flag1 = false; + if ((headModelIds[i] != -1) && !Model.validate(headModelIds[i])) { + loaded = false; } } - return flag1; + return loaded; } public Model method540() { Model[] aclass30_sub2_sub4_sub6 = new Model[5]; int j = 0; for (int k = 0; k < 5; k++) { - if (anIntArray661[k] != -1) { - aclass30_sub2_sub4_sub6[j++] = Model.tryGet(anIntArray661[k]); + if (headModelIds[k] != -1) { + aclass30_sub2_sub4_sub6[j++] = Model.tryGet(headModelIds[k]); } } Model model = new Model(j, aclass30_sub2_sub4_sub6); for (int l = 0; l < 6; l++) { - if (anIntArray659[l] == 0) { + if (colorSrc[l] == 0) { break; } - model.recolor(anIntArray659[l], anIntArray660[l]); + model.recolor(colorSrc[l], colorDst[l]); } return model; } diff --git a/src/main/java/LocType.java b/src/main/java/LocType.java index 3ad1017..52f34c0 100644 --- a/src/main/java/LocType.java +++ b/src/main/java/LocType.java @@ -99,7 +99,7 @@ public class LocType { */ public boolean dynamic; public int scaleZ; - public int[] modelIDs; + public int[] modelIds; public int varbit; public int decorationPadding; public int[] modelKinds; @@ -115,7 +115,7 @@ public class LocType { } public void reset() { - modelIDs = null; + modelIds = null; modelKinds = null; name = null; description = null; @@ -154,31 +154,31 @@ public class LocType { } public void method574(OnDemand onDemand) { - if (modelIDs == null) { + if (modelIds == null) { return; } - for (int k : modelIDs) { + for (int k : modelIds) { onDemand.method560(k & 0xffff, 0); } } public boolean validate(int kind) { if (modelKinds == null) { - if (modelIDs == null) { + if (modelIds == null) { return true; } if (kind != 10) { return true; } boolean valid = true; - for (int modelID : modelIDs) { + for (int modelID : modelIds) { valid &= Model.validate(modelID & 0xffff); } return valid; } for (int i = 0; i < modelKinds.length; i++) { if (modelKinds[i] == kind) { - return Model.validate(modelIDs[i] & 0xffff); + return Model.validate(modelIds[i] & 0xffff); } } return true; @@ -211,11 +211,11 @@ public class LocType { } public boolean method579() { - if (modelIDs == null) { + if (modelIds == null) { return true; } boolean flag1 = true; - for (int j : modelIDs) { + for (int j : modelIds) { flag1 &= Model.validate(j & 0xffff); } return flag1; @@ -258,30 +258,30 @@ public class LocType { return cached; } - if (modelIDs == null) { + if (modelIds == null) { return null; } boolean flip = invert ^ (rotation > 3); - int modelCount = modelIDs.length; + int modelCount = modelIds.length; for (int i = 0; i < modelCount; i++) { - int modelID = modelIDs[i]; + int modelId = modelIds[i]; if (flip) { - modelID += 0x10000; + modelId += 0x10000; } - model = staticCache.get(modelID); + model = staticCache.get(modelId); if (model == null) { - model = Model.tryGet(modelID & 0xffff); + model = Model.tryGet(modelId & 0xffff); if (model == null) { return null; } if (flip) { model.rotateY180(); } - staticCache.put((long) modelID, model); + staticCache.put((long) modelId, model); } if (modelCount > 1) { @@ -315,17 +315,17 @@ public class LocType { return cached; } - int modelID = modelIDs[kindIndex]; + int modelId = modelIds[kindIndex]; boolean flip = invert ^ (rotation > 3); if (flip) { - modelID += 0x10000; + modelId += 0x10000; } - model = staticCache.get(modelID); + model = staticCache.get(modelId); if (model == null) { - model = Model.tryGet(modelID & 0xffff); + model = Model.tryGet(modelId & 0xffff); if (model == null) { return null; @@ -335,7 +335,7 @@ public class LocType { model.rotateY180(); } - staticCache.put((long) modelID, model); + staticCache.put((long) modelId, model); } } @@ -392,11 +392,11 @@ public class LocType { if (j == 1) { int k = buffer.get1U(); if (k > 0) { - if ((modelIDs == null) || lowmem) { + if ((modelIds == null) || lowmem) { modelKinds = new int[k]; - modelIDs = new int[k]; + modelIds = new int[k]; for (int k1 = 0; k1 < k; k1++) { - modelIDs[k1] = buffer.get2U(); + modelIds[k1] = buffer.get2U(); modelKinds[k1] = buffer.get1U(); } } else { @@ -410,11 +410,11 @@ public class LocType { } else if (j == 5) { int l = buffer.get1U(); if (l > 0) { - if ((modelIDs == null) || lowmem) { + if ((modelIds == null) || lowmem) { modelKinds = null; - modelIDs = new int[l]; + modelIds = new int[l]; for (int l1 = 0; l1 < l; l1++) { - modelIDs[l1] = buffer.get2U(); + modelIds[l1] = buffer.get2U(); } } else { buffer.position += l * 2; @@ -518,7 +518,7 @@ public class LocType { } } while (true); if (i == -1) { - interactable = (modelIDs != null) && ((modelKinds == null) || (modelKinds[0] == 10)); + interactable = (modelIds != null) && ((modelKinds == null) || (modelKinds[0] == 10)); if (actions != null) { interactable = true; } diff --git a/src/main/java/NPCEntity.java b/src/main/java/NPCEntity.java index ad672d3..42107af 100644 --- a/src/main/java/NPCEntity.java +++ b/src/main/java/NPCEntity.java @@ -9,20 +9,22 @@ public class NPCEntity extends PathingEntity { public NPCEntity() { } - public Model method450() { - if ((super.anInt1526 >= 0) && (super.anInt1529 == 0)) { - int k = SeqType.instances[super.anInt1526].primaryFrames[super.anInt1527]; - int i1 = -1; - if ((super.seqCurrent >= 0) && (super.seqCurrent != super.seqStand)) { - i1 = SeqType.instances[super.seqCurrent].primaryFrames[super.seqFrame]; + public Model getSequencedModel() { + if ((super.seqId1 >= 0) && (super.anInt1529 == 0)) { + int frame1 = SeqType.instances[super.seqId1].primaryFrames[super.seqFrame1]; + int frame2 = -1; + if ((super.seqId2 >= 0) && (super.seqId2 != super.seqStand)) { + frame2 = SeqType.instances[super.seqId2].primaryFrames[super.seqFrame2]; } - return type.method164(i1, k, SeqType.instances[super.anInt1526].anIntArray357); + return type.getSequencedModel(frame2, frame1, SeqType.instances[super.seqId1].anIntArray357); } - int l = -1; - if (super.seqCurrent >= 0) { - l = SeqType.instances[super.seqCurrent].primaryFrames[super.seqFrame]; + + int frame = -1; + + if (super.seqId2 >= 0) { + frame = SeqType.instances[super.seqId2].primaryFrames[super.seqFrame2]; } - return type.method164(-1, l, null); + return type.getSequencedModel(-1, frame, null); } @Override @@ -30,28 +32,36 @@ public class NPCEntity extends PathingEntity { if (type == null) { return null; } - Model model = method450(); + + Model model = getSequencedModel(); + if (model == null) { return null; } + super.height = model.minY; + if ((super.spotanim != -1) && (super.spotanimFrame != -1)) { - SpotAnimType type = SpotAnimType.instances[super.spotanim]; - Model model_1 = type.method266(); - if (model_1 != null) { - int j = type.seq.primaryFrames[super.spotanimFrame]; - Model class30_sub2_sub4_sub6_2 = new Model(true, SeqFrame.isNull(j), false, model_1); - class30_sub2_sub4_sub6_2.translate(0, -super.anInt1524, 0); - class30_sub2_sub4_sub6_2.createLabelReferences(); - class30_sub2_sub4_sub6_2.applySequenceFrame(j); - class30_sub2_sub4_sub6_2.labelFaces = null; - class30_sub2_sub4_sub6_2.labelVertices = null; - if ((type.anInt410 != 128) || (type.anInt411 != 128)) { - class30_sub2_sub4_sub6_2.scale(type.anInt410, type.anInt410, type.anInt411); + SpotAnimType spotanim = SpotAnimType.instances[super.spotanim]; + Model model0 = spotanim.getModel(); + + if (model0 != null) { + int frame = spotanim.seq.primaryFrames[super.spotanimFrame]; + + // create a copy of the model + Model model1 = new Model(true, SeqFrame.isNull(frame), false, model0); + model1.translate(0, -super.spotanimY, 0); + model1.createLabelReferences(); + model1.applySequenceFrame(frame); + model1.labelFaces = null; + model1.labelVertices = null; + + if ((spotanim.scaleXY != 128) || (spotanim.scaleZ != 128)) { + model1.scale(spotanim.scaleXY, spotanim.scaleXY, spotanim.scaleZ); } - class30_sub2_sub4_sub6_2.calculateNormals(64 + type.anInt413, 850 + type.anInt414, -30, -50, -30, true); - Model[] aclass30_sub2_sub4_sub6 = {model, class30_sub2_sub4_sub6_2}; - model = new Model(2, -819, aclass30_sub2_sub4_sub6); + + model1.calculateNormals(64 + spotanim.lightAmbient, 850 + spotanim.lightAttenuation, -30, -50, -30, true); + model = new Model(2, -819, new Model[]{model, model1}); } } if (type.size == 1) { diff --git a/src/main/java/NPCType.java b/src/main/java/NPCType.java index 019d62c..4fc4c6b 100644 --- a/src/main/java/NPCType.java +++ b/src/main/java/NPCType.java @@ -56,20 +56,20 @@ public class NPCType { dat = null; } - public int seqTurnRight = -1; - public int varbit = -1; - public int seqTurnAround = -1; - public int varp = -1; - public int anInt61 = -1; + public int seqTurnRightId = -1; + public int varbitId = -1; + public int seqTurnAroundId = -1; + public int varpId = -1; + public int level = -1; public String name; public String[] op; - public int seqWalk = -1; + public int seqWalkId = -1; public byte size = 1; - public int[] anIntArray70; + public int[] colorDst; public int unusedInt0 = -1; - public int[] anIntArray73; + public int[] headModelIds; public int headicon = -1; - public int[] anIntArray76; + public int[] colorSrc; public int seqStand = -1; public long uid = -1L; public int turnSpeed = 32; @@ -84,46 +84,55 @@ public class NPCType { public int anInt91 = 128; public int anInt92; public boolean aBoolean93 = false; - public int[] anIntArray94; + public int[] modelIds; public int unusedInt2 = -1; public NPCType() { } - public Model method160() { + public Model getUnlitHeadModel() { if (overrides != null) { NPCType type = getOverrideType(); if (type == null) { return null; } else { - return type.method160(); + return type.getUnlitHeadModel(); } } - if (anIntArray73 == null) { + + if (headModelIds == null) { return null; } - boolean flag1 = false; - for (int value : anIntArray73) { + + boolean loaded = false; + + for (int value : headModelIds) { if (!Model.validate(value)) { - flag1 = true; + loaded = true; } } - if (flag1) { + + if (loaded) { 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[] models = new Model[headModelIds.length]; + + for (int i = 0; i < headModelIds.length; i++) { + models[i] = Model.tryGet(headModelIds[i]); } + Model model; - if (aclass30_sub2_sub4_sub6.length == 1) { - model = aclass30_sub2_sub4_sub6[0]; + + if (models.length == 1) { + model = models[0]; } else { - model = new Model(aclass30_sub2_sub4_sub6.length, aclass30_sub2_sub4_sub6); + model = new Model(models.length, models); } - if (anIntArray76 != null) { - for (int k = 0; k < anIntArray76.length; k++) { - model.recolor(anIntArray76[k], anIntArray70[k]); + + if (colorSrc != null) { + for (int i = 0; i < colorSrc.length; i++) { + model.recolor(colorSrc[i], colorDst[i]); } } return model; @@ -132,15 +141,15 @@ public class NPCType { public NPCType getOverrideType() { int value = -1; - if (varbit != -1) { - VarbitType vb = VarbitType.instances[this.varbit]; + if (varbitId != -1) { + VarbitType vb = VarbitType.instances[this.varbitId]; 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]; + } else if (varpId != -1) { + value = game.variables[varpId]; } if ((value < 0) || (value >= overrides.length) || (overrides[value] == -1)) { @@ -150,59 +159,70 @@ public class NPCType { } } - public Model method164(int j, int k, int[] ai) { + public Model getSequencedModel(int seqFrame2, int seqFrame1, int[] seqMask) { if (overrides != null) { - NPCType type = getOverrideType(); - if (type == null) { + NPCType override = getOverrideType(); + if (override == null) { return null; } else { - return type.method164(j, k, ai); + return override.getSequencedModel(seqFrame2, seqFrame1, seqMask); } } Model model = modelCache.get(uid); if (model == null) { - boolean flag = false; - for (int value : anIntArray94) { + boolean invalid = false; + + for (int value : modelIds) { if (!Model.validate(value)) { - flag = true; + invalid = true; } } - if (flag) { + + if (invalid) { 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]); + + Model[] models = new Model[modelIds.length]; + + for (int i = 0; i < modelIds.length; i++) { + models[i] = Model.tryGet(modelIds[i]); } - if (aclass30_sub2_sub4_sub6.length == 1) { - model = aclass30_sub2_sub4_sub6[0]; + + if (models.length == 1) { + model = models[0]; } else { - model = new Model(aclass30_sub2_sub4_sub6.length, aclass30_sub2_sub4_sub6); + model = new Model(models.length, models); } - if (anIntArray76 != null) { - for (int k1 = 0; k1 < anIntArray76.length; k1++) { - model.recolor(anIntArray76[k1], anIntArray70[k1]); + + if (colorSrc != null) { + for (int i = 0; i < colorSrc.length; i++) { + model.recolor(colorSrc[i], colorDst[i]); } } + 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); + model_1.set(model, SeqFrame.isNull(seqFrame1) & SeqFrame.isNull(seqFrame2)); + + if ((seqFrame1 != -1) && (seqFrame2 != -1)) { + model_1.applySequenceFrames(seqFrame1, seqFrame2, seqMask); + } else if (seqFrame1 != -1) { + model_1.applySequenceFrame(seqFrame1); } + 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; } @@ -217,9 +237,9 @@ public class NPCType { } if (i == 1) { int j = buffer.get1U(); - anIntArray94 = new int[j]; + modelIds = new int[j]; for (int j1 = 0; j1 < j; j1++) { - anIntArray94[j1] = buffer.get2U(); + modelIds[j1] = buffer.get2U(); } } else if (i == 2) { name = buffer.getString(); @@ -230,12 +250,12 @@ public class NPCType { } else if (i == 13) { seqStand = buffer.get2U(); } else if (i == 14) { - seqWalk = buffer.get2U(); + seqWalkId = buffer.get2U(); } else if (i == 17) { - seqWalk = buffer.get2U(); - seqTurnAround = buffer.get2U(); + seqWalkId = buffer.get2U(); + seqTurnAroundId = buffer.get2U(); seqTurnLeft = buffer.get2U(); - seqTurnRight = buffer.get2U(); + seqTurnRightId = buffer.get2U(); } else if ((i >= 30) && (i < 40)) { if (op == null) { op = new String[5]; @@ -246,17 +266,17 @@ public class NPCType { } } else if (i == 40) { int k = buffer.get1U(); - anIntArray76 = new int[k]; - anIntArray70 = new int[k]; + colorSrc = new int[k]; + colorDst = new int[k]; for (int k1 = 0; k1 < k; k1++) { - anIntArray76[k1] = buffer.get2U(); - anIntArray70[k1] = buffer.get2U(); + colorSrc[k1] = buffer.get2U(); + colorDst[k1] = buffer.get2U(); } } else if (i == 60) { int l = buffer.get1U(); - anIntArray73 = new int[l]; + headModelIds = new int[l]; for (int l1 = 0; l1 < l; l1++) { - anIntArray73[l1] = buffer.get2U(); + headModelIds[l1] = buffer.get2U(); } } else if (i == 90) { unusedInt2 = buffer.get2U(); @@ -267,7 +287,7 @@ public class NPCType { } else if (i == 93) { aBoolean87 = false; } else if (i == 95) { - anInt61 = buffer.get2U(); + level = buffer.get2U(); } else if (i == 97) { anInt91 = buffer.get2U(); } else if (i == 98) { @@ -283,13 +303,13 @@ public class NPCType { } else if (i == 103) { turnSpeed = buffer.get2U(); } else if (i == 106) { - varbit = buffer.get2U(); - if (varbit == 65535) { - varbit = -1; + varbitId = buffer.get2U(); + if (varbitId == 65535) { + varbitId = -1; } - varp = buffer.get2U(); - if (varp == 65535) { - varp = -1; + varpId = buffer.get2U(); + if (varpId == 65535) { + varpId = -1; } int i1 = buffer.get1U(); overrides = new int[i1 + 1]; diff --git a/src/main/java/ObjType.java b/src/main/java/ObjType.java index 8ea3005..3031a69 100644 --- a/src/main/java/ObjType.java +++ b/src/main/java/ObjType.java @@ -482,7 +482,7 @@ public class ObjType { return model; } - public Model getModelUnlit(int amount) { + public Model getUnlitModel(int amount) { if ((stackId != null) && (amount > 1)) { int j = -1; for (int k = 0; k < 10; k++) { @@ -491,7 +491,7 @@ public class ObjType { } } if (j != -1) { - return get(j).getModelUnlit(1); + return get(j).getUnlitModel(1); } } Model model = Model.tryGet(modelId); diff --git a/src/main/java/PathingEntity.java b/src/main/java/PathingEntity.java index e7c544b..753da21 100644 --- a/src/main/java/PathingEntity.java +++ b/src/main/java/PathingEntity.java @@ -20,17 +20,17 @@ public class PathingEntity extends Entity { public int seqStand = -1; public int seqTurn = -1; public int chatColor; - public int seqCurrent = -1; - public int seqFrame; + public int seqId2 = -1; + public int seqFrame2; public int seqCycle; public int spotanim = -1; public int spotanimFrame; public int spotanimCycle; public int anInt1523; - public int anInt1524; + public int spotanimY; public int pathRemaining; - public int anInt1526 = -1; - public int anInt1527; + public int seqId1 = -1; + public int seqFrame1; public int anInt1528; public int anInt1529; public int anInt1530; @@ -64,8 +64,8 @@ public class PathingEntity extends Entity { } public void move(int x, int z, boolean teleport) { - if ((anInt1526 != -1) && (SeqType.instances[anInt1526].anInt364 == 1)) { - anInt1526 = -1; + if ((seqId1 != -1) && (SeqType.instances[seqId1].anInt364 == 1)) { + seqId1 = -1; } if (!teleport) { int dx = x - pathTileX[0]; @@ -144,8 +144,8 @@ public class PathingEntity extends Entity { j++; k--; } - if ((anInt1526 != -1) && (SeqType.instances[anInt1526].anInt364 == 1)) { - anInt1526 = -1; + if ((seqId1 != -1) && (SeqType.instances[seqId1].anInt364 == 1)) { + seqId1 = -1; } if (pathRemaining < 9) { pathRemaining++; diff --git a/src/main/java/PlayerEntity.java b/src/main/java/PlayerEntity.java index 070fe9a..16a65c7 100644 --- a/src/main/java/PlayerEntity.java +++ b/src/main/java/PlayerEntity.java @@ -7,25 +7,25 @@ import org.apache.commons.collections4.map.LRUMap; public class PlayerEntity extends PathingEntity { public static LRUMap modelCache = new LRUMap<>(260); - public final int[] anIntArray1700 = new int[5]; - public final int[] appearance = new int[12]; - public long aLong1697 = -1L; - public NPCType aType_1698; - public boolean aBoolean1699 = false; + public final int[] colors = new int[5]; + public final int[] appearances = new int[12]; + public long modelUID = -1L; + public NPCType npcType; + public boolean lowmem = false; public int team; public int gender; public String name; public int combatLevel; public int headicons; - public int anInt1707; - public int anInt1708; + public int locStartCycle; + public int locStopCycle; public int y; - public boolean aBoolean1710 = false; - public int anInt1711; - public int anInt1712; - public int anInt1713; - public Model model; - public long aLong1718; + public boolean visible = false; + public int locOffsetX; + public int locOffsetY; + public int locOffsetZ; + public Model locModel; + public long appearanceHashcode; public int minSceneTileX; public int minSceneTileZ; public int maxSceneTileX; @@ -37,68 +37,79 @@ public class PlayerEntity extends PathingEntity { @Override public Model getModel() { - if (!aBoolean1710) { + if (!visible) { return null; } - Model model = method452(); + + Model model = getSequencedModel(); + if (model == null) { return null; } + super.height = model.minY; model.pickable = true; - if (aBoolean1699) { + + if (lowmem) { return model; } + if ((super.spotanim != -1) && (super.spotanimFrame != -1)) { - SpotAnimType type = SpotAnimType.instances[super.spotanim]; - Model class30_sub2_sub4_sub6_2 = type.method266(); - if (class30_sub2_sub4_sub6_2 != null) { - Model model_3 = new Model(true, SeqFrame.isNull(super.spotanimFrame), false, class30_sub2_sub4_sub6_2); - model_3.translate(0, -super.anInt1524, 0); - model_3.createLabelReferences(); - model_3.applySequenceFrame(type.seq.primaryFrames[super.spotanimFrame]); - model_3.labelFaces = null; - model_3.labelVertices = null; - if ((type.anInt410 != 128) || (type.anInt411 != 128)) { - model_3.scale(type.anInt410, type.anInt410, type.anInt411); + SpotAnimType spot = SpotAnimType.instances[super.spotanim]; + Model spotModel1 = spot.getModel(); + + if (spotModel1 != null) { + Model spotModel2 = new Model(true, SeqFrame.isNull(super.spotanimFrame), false, spotModel1); + spotModel2.translate(0, -super.spotanimY, 0); + spotModel2.createLabelReferences(); + spotModel2.applySequenceFrame(spot.seq.primaryFrames[super.spotanimFrame]); + spotModel2.labelFaces = null; + spotModel2.labelVertices = null; + if ((spot.scaleXY != 128) || (spot.scaleZ != 128)) { + spotModel2.scale(spot.scaleXY, spot.scaleXY, spot.scaleZ); } - model_3.calculateNormals(64 + type.anInt413, 850 + type.anInt414, -30, -50, -30, true); - Model[] aclass30_sub2_sub4_sub6_1 = {model, model_3}; - model = new Model(2, -819, aclass30_sub2_sub4_sub6_1); + spotModel2.calculateNormals(64 + spot.lightAmbient, 850 + spot.lightAttenuation, -30, -50, -30, true); + model = new Model(2, -819, new Model[]{model, spotModel2}); } } - if (this.model != null) { - if (Game.loopCycle >= anInt1708) { - this.model = null; + + if (this.locModel != null) { + if (Game.loopCycle >= locStopCycle) { + this.locModel = null; } - if ((Game.loopCycle >= anInt1707) && (Game.loopCycle < anInt1708)) { - Model model_1 = this.model; - model_1.translate(anInt1711 - super.x, anInt1712 - y, anInt1713 - super.z); + + if ((Game.loopCycle >= locStartCycle) && (Game.loopCycle < locStopCycle)) { + Model model1 = this.locModel; + model1.translate(locOffsetX - super.x, locOffsetY - y, locOffsetZ - super.z); + if (super.dstYaw == 512) { - model_1.rotateY90(); - model_1.rotateY90(); - model_1.rotateY90(); + model1.rotateY90(); + model1.rotateY90(); + model1.rotateY90(); } else if (super.dstYaw == 1024) { - model_1.rotateY90(); - model_1.rotateY90(); + model1.rotateY90(); + model1.rotateY90(); } else if (super.dstYaw == 1536) { - model_1.rotateY90(); + model1.rotateY90(); } - Model[] aclass30_sub2_sub4_sub6 = {model, model_1}; - model = new Model(2, -819, aclass30_sub2_sub4_sub6); + + model = new Model(2, -819, new Model[]{model, model1}); + if (super.dstYaw == 512) { - model_1.rotateY90(); + model1.rotateY90(); } else if (super.dstYaw == 1024) { - model_1.rotateY90(); - model_1.rotateY90(); + model1.rotateY90(); + model1.rotateY90(); } else if (super.dstYaw == 1536) { - model_1.rotateY90(); - model_1.rotateY90(); - model_1.rotateY90(); + model1.rotateY90(); + model1.rotateY90(); + model1.rotateY90(); } - model_1.translate(super.x - anInt1711, y - anInt1712, super.z - anInt1713); + + model1.translate(super.x - locOffsetX, y - locOffsetY, super.z - locOffsetZ); } } + model.pickable = true; return model; } @@ -107,34 +118,44 @@ public class PlayerEntity extends PathingEntity { buffer.position = 0; gender = buffer.get1U(); headicons = buffer.get1U(); - aType_1698 = null; + npcType = null; team = 0; - for (int j = 0; j < 12; j++) { - int k = buffer.get1U(); - if (k == 0) { - appearance[j] = 0; + + for (int part = 0; part < 12; part++) { + int msb = buffer.get1U(); + + if (msb == 0) { + appearances[part] = 0; continue; } - int i1 = buffer.get1U(); - appearance[j] = (k << 8) + i1; - if ((j == 0) && (appearance[0] == 65535)) { - aType_1698 = NPCType.get(buffer.get2U()); + + int lsb = buffer.get1U(); + appearances[part] = (msb << 8) + lsb; + + if ((part == 0) && (appearances[0] == 65535)) { + npcType = NPCType.get(buffer.get2U()); break; } - if ((appearance[j] >= 512) && ((appearance[j] - 512) < ObjType.count)) { - int l1 = ObjType.get(appearance[j] - 512).team; - if (l1 != 0) { - team = l1; + + if ((appearances[part] >= 512) && ((appearances[part] - 512) < ObjType.count)) { + int team = ObjType.get(appearances[part] - 512).team; + + if (team != 0) { + this.team = team; } } } - for (int l = 0; l < 5; l++) { - int j1 = buffer.get1U(); - if ((j1 < 0) || (j1 >= Game.anIntArrayArray1003[l].length)) { - j1 = 0; + + for (int part = 0; part < 5; part++) { + int color = buffer.get1U(); + + if ((color < 0) || (color >= Game.designPartColor[part].length)) { + color = 0; } - anIntArray1700[l] = j1; + + colors[part] = color; } + super.seqStand = buffer.get2U(); if (super.seqStand == 65535) { super.seqStand = -1; @@ -166,192 +187,228 @@ public class PlayerEntity extends PathingEntity { name = StringUtil.formatName(StringUtil.fromBase37(buffer.get8())); combatLevel = buffer.get1U(); skillLevel = buffer.get2U(); - aBoolean1710 = true; - aLong1718 = 0L; - for (int k1 = 0; k1 < 12; k1++) { - aLong1718 <<= 4; - if (appearance[k1] >= 256) { - aLong1718 += appearance[k1] - 256; + visible = true; + + appearanceHashcode = 0L; + + for (int part = 0; part < 12; part++) { + appearanceHashcode <<= 4; + if (appearances[part] >= 256) { + appearanceHashcode += appearances[part] - 256; } } - if (appearance[0] >= 256) { - aLong1718 += (appearance[0] - 256) >> 4; + + if (appearances[0] >= 256) { + appearanceHashcode += (appearances[0] - 256) >> 4; } - if (appearance[1] >= 256) { - aLong1718 += (appearance[1] - 256) >> 8; + + if (appearances[1] >= 256) { + appearanceHashcode += (appearances[1] - 256) >> 8; } + for (int i2 = 0; i2 < 5; i2++) { - aLong1718 <<= 3; - aLong1718 += anIntArray1700[i2]; + appearanceHashcode <<= 3; + appearanceHashcode += colors[i2]; } - aLong1718 <<= 1; - aLong1718 += gender; + + appearanceHashcode <<= 1; + appearanceHashcode += gender; } - public Model method452() { - if (aType_1698 != null) { - int j = -1; - if ((super.anInt1526 >= 0) && (super.anInt1529 == 0)) { - j = SeqType.instances[super.anInt1526].primaryFrames[super.anInt1527]; - } else if (super.seqCurrent >= 0) { - j = SeqType.instances[super.seqCurrent].primaryFrames[super.seqFrame]; + public Model getSequencedModel() { + if (npcType != null) { + int frame = -1; + if ((super.seqId1 >= 0) && (super.anInt1529 == 0)) { + frame = SeqType.instances[super.seqId1].primaryFrames[super.seqFrame1]; + } else if (super.seqId2 >= 0) { + frame = SeqType.instances[super.seqId2].primaryFrames[super.seqFrame2]; } - return aType_1698.method164(-1, j, null); - } - long l = aLong1718; - int k = -1; - int i1 = -1; - int j1 = -1; - int k1 = -1; - if ((super.anInt1526 >= 0) && (super.anInt1529 == 0)) { - SeqType type = SeqType.instances[super.anInt1526]; - k = type.primaryFrames[super.anInt1527]; - if ((super.seqCurrent >= 0) && (super.seqCurrent != super.seqStand)) { - i1 = SeqType.instances[super.seqCurrent].primaryFrames[super.seqFrame]; - } - if (type.anInt360 >= 0) { - j1 = type.anInt360; - l += ((long) j1 - appearance[5]) << 8; - } - if (type.anInt361 >= 0) { - k1 = type.anInt361; - l += ((long) k1 - appearance[3]) << 16; - } - } else if (super.seqCurrent >= 0) { - k = SeqType.instances[super.seqCurrent].primaryFrames[super.seqFrame]; + return npcType.getSequencedModel(-1, frame, null); } - Model model_1 = modelCache.get(l); + long hashCode = this.appearanceHashcode; + int frame1 = -1; + int frame2 = -1; + int rightHandValue = -1; + int leftHandValue = -1; + + if ((super.seqId1 >= 0) && (super.anInt1529 == 0)) { + SeqType type = SeqType.instances[super.seqId1]; + frame1 = type.primaryFrames[super.seqFrame1]; + + if ((super.seqId2 >= 0) && (super.seqId2 != super.seqStand)) { + frame2 = SeqType.instances[super.seqId2].primaryFrames[super.seqFrame2]; + } + + if (type.rightHandOverride >= 0) { + rightHandValue = type.rightHandOverride; + hashCode += ((long) rightHandValue - appearances[5]) << 8; + } + + if (type.leftHandOverride >= 0) { + leftHandValue = type.leftHandOverride; + hashCode += ((long) leftHandValue - appearances[3]) << 16; + } + } else if (super.seqId2 >= 0) { + frame1 = SeqType.instances[super.seqId2].primaryFrames[super.seqFrame2]; + } + + Model model = modelCache.get(hashCode); + + if (model == null) { + boolean invalid = false; - if (model_1 == null) { - boolean flag = false; for (int part = 0; part < 12; part++) { - int value = appearance[part]; - if ((k1 >= 0) && (part == 3)) { - value = k1; + int value = appearances[part]; + + if ((leftHandValue >= 0) && (part == 3)) { + value = leftHandValue; } - if ((j1 >= 0) && (part == 5)) { - value = j1; + + if ((rightHandValue >= 0) && (part == 5)) { + value = rightHandValue; } - if ((value >= 256) && (value < 512) && !IDKType.instances[value - 256].method537()) { - flag = true; + + if ((value >= 256) && (value < 512) && !IDKType.instances[value - 256].validateModel()) { + invalid = true; } + if ((value >= 512) && !ObjType.get(value - 512).validateWornModel(gender)) { - flag = true; + invalid = true; } } - if (flag) { - if (aLong1697 != -1L) { - model_1 = modelCache.get(aLong1697); + + if (invalid) { + if (modelUID != -1L) { + model = modelCache.get(modelUID); } - if (model_1 == null) { + if (model == null) { return null; } } } - if (model_1 == null) { + if (model == null) { 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; + int value = appearances[part]; + + if ((leftHandValue >= 0) && (part == 3)) { + value = leftHandValue; } - if ((j1 >= 0) && (part == 5)) { - value = j1; + + if ((rightHandValue >= 0) && (part == 5)) { + value = rightHandValue; } + if ((value >= 256) && (value < 512)) { - Model model_3 = IDKType.instances[value - 256].method538(); - if (model_3 != null) { - models[modelCount++] = model_3; + Model kitModel = IDKType.instances[value - 256].getModel(); + if (kitModel != null) { + models[modelCount++] = kitModel; } } + if (value >= 512) { - Model model = ObjType.get(value - 512).getWornModel(gender); - if (model != null) { - models[modelCount++] = model; + Model objModel = ObjType.get(value - 512).getWornModel(gender); + + if (objModel != null) { + models[modelCount++] = objModel; } } } - 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]]); - if (j3 == 1) { - model_1.recolor(Game.anIntArray1204[0], Game.anIntArray1204[anIntArray1700[j3]]); + + model = new Model(modelCount, models); + for (int part = 0; part < 5; part++) { + if (colors[part] != 0) { + model.recolor(Game.designPartColor[part][0], Game.designPartColor[part][colors[part]]); + if (part == 1) { + model.recolor(Game.designHairColor[0], Game.designHairColor[colors[part]]); } } } - model_1.createLabelReferences(); - model_1.calculateNormals(64, 850, -30, -50, -30, true); - modelCache.put(l, model_1); - aLong1697 = l; + model.createLabelReferences(); + model.calculateNormals(64, 850, -30, -50, -30, true); + modelCache.put(hashCode, model); + modelUID = hashCode; } - if (aBoolean1699) { - return model_1; + + if (lowmem) { + return model; } - Model class30_sub2_sub4_sub6_2 = Model.EMPTY; - class30_sub2_sub4_sub6_2.set(model_1, SeqFrame.isNull(k) & SeqFrame.isNull(i1)); - if ((k != -1) && (i1 != -1)) { - class30_sub2_sub4_sub6_2.applySequenceFrames(k, i1, SeqType.instances[super.anInt1526].anIntArray357); - } else if (k != -1) { - class30_sub2_sub4_sub6_2.applySequenceFrame(k); + + Model animated = Model.EMPTY; + animated.set(model, SeqFrame.isNull(frame1) & SeqFrame.isNull(frame2)); + + if ((frame1 != -1) && (frame2 != -1)) { + animated.applySequenceFrames(frame1, frame2, SeqType.instances[super.seqId1].anIntArray357); + } else if (frame1 != -1) { + animated.applySequenceFrame(frame1); } - class30_sub2_sub4_sub6_2.calculateBoundsCylinder(); - class30_sub2_sub4_sub6_2.labelFaces = null; - class30_sub2_sub4_sub6_2.labelVertices = null; - return class30_sub2_sub4_sub6_2; + + animated.calculateBoundsCylinder(); + animated.labelFaces = null; + animated.labelVertices = null; + return animated; } @Override public boolean isVisible() { - return aBoolean1710; + return visible; } - public Model method453() { - if (!aBoolean1710) { + public Model getUnlitHeadModel() { + if (!visible) { return null; } - if (aType_1698 != null) { - return aType_1698.method160(); + + if (npcType != null) { + return npcType.getUnlitHeadModel(); } - boolean flag = false; - for (int i = 0; i < 12; i++) { - int j = appearance[i]; - if ((j >= 256) && (j < 512) && !IDKType.instances[j - 256].method539()) { - flag = true; + + boolean invalid = false; + + for (int part = 0; part < 12; part++) { + int value = appearances[part]; + + if ((value >= 256) && (value < 512) && !IDKType.instances[value - 256].validateHeadModel()) { + invalid = true; } - if ((j >= 512) && !ObjType.get(j - 512).validateHeadModel(gender)) { - flag = true; + + if ((value >= 512) && !ObjType.get(value - 512).validateHeadModel(gender)) { + invalid = true; } } - if (flag) { + + if (invalid) { return null; } - Model[] aclass30_sub2_sub4_sub6 = new Model[12]; - int k = 0; - for (int l = 0; l < 12; l++) { - int i1 = appearance[l]; - if ((i1 >= 256) && (i1 < 512)) { - Model model_1 = IDKType.instances[i1 - 256].method540(); - if (model_1 != null) { - aclass30_sub2_sub4_sub6[k++] = model_1; + + Model[] models = new Model[12]; + int modelCount = 0; + for (int part = 0; part < 12; part++) { + int value = appearances[part]; + + if ((value >= 256) && (value < 512)) { + Model model = IDKType.instances[value - 256].method540(); + if (model != null) { + models[modelCount++] = model; } } - if (i1 >= 512) { - 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; + if (value >= 512) { + Model model = ObjType.get(value - 512).getHeadModel(gender); + if (model != null) { + models[modelCount++] = model; } } } - Model model = new Model(k, aclass30_sub2_sub4_sub6); + Model model = new Model(modelCount, models); for (int j1 = 0; j1 < 5; j1++) { - if (anIntArray1700[j1] != 0) { - model.recolor(Game.anIntArrayArray1003[j1][0], Game.anIntArrayArray1003[j1][anIntArray1700[j1]]); + if (colors[j1] != 0) { + model.recolor(Game.designPartColor[j1][0], Game.designPartColor[j1][colors[j1]]); if (j1 == 1) { - model.recolor(Game.anIntArray1204[0], Game.anIntArray1204[anIntArray1700[j1]]); + model.recolor(Game.designHairColor[0], Game.designHairColor[colors[j1]]); } } } diff --git a/src/main/java/ProjectileEntity.java b/src/main/java/ProjectileEntity.java index 8963d08..8306158 100644 --- a/src/main/java/ProjectileEntity.java +++ b/src/main/java/ProjectileEntity.java @@ -64,7 +64,7 @@ public class ProjectileEntity extends Entity { @Override public Model getModel() { - Model model = aType_1592.method266(); + Model model = aType_1592.getModel(); if (model == null) { return null; } @@ -79,11 +79,11 @@ public class ProjectileEntity extends Entity { model_1.labelFaces = null; model_1.labelVertices = null; } - if ((aType_1592.anInt410 != 128) || (aType_1592.anInt411 != 128)) { - model_1.scale(aType_1592.anInt410, aType_1592.anInt410, aType_1592.anInt411); + if ((aType_1592.scaleXY != 128) || (aType_1592.scaleZ != 128)) { + model_1.scale(aType_1592.scaleXY, aType_1592.scaleXY, aType_1592.scaleZ); } model_1.rotateX(anInt1596); - model_1.calculateNormals(64 + aType_1592.anInt413, 850 + aType_1592.anInt414, -30, -50, -30, true); + model_1.calculateNormals(64 + aType_1592.lightAmbient, 850 + aType_1592.lightAttenuation, -30, -50, -30, true); return model_1; } diff --git a/src/main/java/Scene.java b/src/main/java/Scene.java index 7555539..ecceceb 100644 --- a/src/main/java/Scene.java +++ b/src/main/java/Scene.java @@ -250,7 +250,7 @@ public class Scene { } } - public void method279(int plane, int stx, int stz, int type, 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 j4, int k4, int l4) { + public void setTile(int plane, int stx, int stz, int type, 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 j4, int k4, int l4) { if (type == 0) { SceneTileUnderlay underlay = new SceneTileUnderlay(k2, l2, i3, j3, -1, k4, false); for (int p = plane; p >= 0; p--) { diff --git a/src/main/java/SceneBuilder.java b/src/main/java/SceneBuilder.java index 3ec16c7..cbecaa5 100644 --- a/src/main/java/SceneBuilder.java +++ b/src/main/java/SceneBuilder.java @@ -22,7 +22,7 @@ public class SceneBuilder { } public static int method172(int i, int i_108_) { - int i_109_ = ((method176(i + 45365, i_108_ + 91923, 4) - 128) + ((method176(i + 10294, i_108_ + 37821, 2) - 128) >> 1) + ((method176(i, i_108_, 1) - 128) >> 2)); + int i_109_ = (method176(i + 45365, i_108_ + 91923, 4) - 128) + ((method176(i + 10294, i_108_ + 37821, 2) - 128) >> 1) + ((method176(i, i_108_, 1) - 128) >> 2); i_109_ = (int) ((double) i_109_ * 0.3) + 35; if (i_109_ < 10) { i_109_ = 10; @@ -85,28 +85,29 @@ public class SceneBuilder { } public static int method184(int i, int i_216_, int i_217_, int i_218_) { - int i_219_ = ((65536 - Draw3D.cos[(i_217_ * 1024) / i_218_]) >> 1); + int i_219_ = (65536 - Draw3D.cos[(i_217_ * 1024) / i_218_]) >> 1; return ((i * (65536 - i_219_)) >> 16) + ((i_216_ * i_219_) >> 16); } public static int method186(int i, int i_221_) { - int i_222_ = (method170(i - 1, i_221_ - 1) + method170(i + 1, i_221_ - 1) + method170(i - 1, i_221_ + 1) + method170(i + 1, i_221_ + 1)); - int i_223_ = (method170(i - 1, i_221_) + method170(i + 1, i_221_) + method170(i, i_221_ - 1) + method170(i, i_221_ + 1)); + int i_222_ = method170(i - 1, i_221_ - 1) + method170(i + 1, i_221_ - 1) + method170(i - 1, i_221_ + 1) + method170(i + 1, i_221_ + 1); + int i_223_ = method170(i - 1, i_221_) + method170(i + 1, i_221_) + method170(i, i_221_ - 1) + method170(i, i_221_ + 1); int i_224_ = method170(i, i_221_); return (i_222_ / 16) + (i_223_ / 8) + (i_224_ / 4); } - public static int method187(int i, int i_225_) { - if (i == -1) { + public static int mulHSL(int hsl, int lightness) { + if (hsl == -1) { return 12345678; } - i_225_ = (i_225_ * (i & 0x7f)) / 128; - if (i_225_ < 2) { - i_225_ = 2; - } else if (i_225_ > 126) { - i_225_ = 126; + lightness = (lightness * (hsl & 0x7f)) / 128; + + if (lightness < 2) { + lightness = 2; + } else if (lightness > 126) { + lightness = 126; } - return (i & 0xff80) + i_225_; + return (hsl & 0xff80) + lightness; } public static void addLoc(Scene scene, int rotation, int z, int kind, int plane, SceneCollisionMap collision, int[][][] planeHeightmap, int x, int locID, int dataPlane) { @@ -396,7 +397,7 @@ public class SceneBuilder { public final byte[][][] planeShademap; public final int[][][] planeOccludemap; public final byte[][][] aByteArrayArrayArray136; - public final int[][] anIntArrayArray139; + public final int[][] planeTileLightness; public final byte[][][] aByteArrayArrayArray142; public final int maxTileX; public final int maxTileZ; @@ -415,7 +416,7 @@ public class SceneBuilder { aByteArrayArrayArray148 = new byte[4][this.maxTileX][this.maxTileZ]; planeOccludemap = new int[4][this.maxTileX + 1][this.maxTileZ + 1]; planeShademap = new byte[4][this.maxTileX + 1][this.maxTileZ + 1]; - anIntArrayArray139 = new int[this.maxTileX + 1][this.maxTileZ + 1]; + planeTileLightness = new int[this.maxTileX + 1][this.maxTileZ + 1]; anIntArray124 = new int[this.maxTileZ]; anIntArray125 = new int[this.maxTileZ]; anIntArray126 = new int[this.maxTileZ]; @@ -423,203 +424,245 @@ public class SceneBuilder { anIntArray128 = new int[this.maxTileZ]; } - public void method171(SceneCollisionMap[] collisionMaps, Scene scene) { - for (int i_6_ = 0; i_6_ < 4; i_6_++) { - for (int i_7_ = 0; i_7_ < 104; i_7_++) { - for (int i_8_ = 0; i_8_ < 104; i_8_++) { - if ((planeTileFlags[i_6_][i_7_][i_8_] & 0x1) == 1) { - int i_9_ = i_6_; - if ((planeTileFlags[1][i_7_][i_8_] & 0x2) == 2) { - i_9_--; + public void method171(SceneCollisionMap[] planeCollisions, Scene scene) { + for (int plane = 0; plane < 4; plane++) { + for (int x = 0; x < 104; x++) { + for (int z = 0; z < 104; z++) { + if ((planeTileFlags[plane][x][z] & 0x1) == 1) { + int physicalPlane = plane; + + // bridge + if ((planeTileFlags[1][x][z] & 0x2) == 2) { + physicalPlane--; } - if (i_9_ >= 0) { - collisionMaps[i_9_].addSolid(i_8_, i_7_); + + if (physicalPlane >= 0) { + planeCollisions[physicalPlane].addSolid(z, x); } } } } + } anInt123 += (int) (Math.random() * 5.0) - 2; + if (anInt123 < -8) { anInt123 = -8; } + if (anInt123 > 8) { anInt123 = 8; } + anInt133 += (int) (Math.random() * 5.0) - 2; + if (anInt133 < -16) { anInt133 = -16; } + if (anInt133 > 16) { anInt133 = 16; } + for (int plane = 0; plane < 4; plane++) { - byte[][] is = planeShademap[plane]; - int i_11_ = 96; - int i_12_ = 768; - int i_13_ = -50; - int i_14_ = -10; - int i_15_ = -50; - int i_16_ = (int) Math.sqrt((i_13_ * i_13_) + (i_14_ * i_14_) + (i_15_ * i_15_)); - int i_17_ = (i_12_ * i_16_) >> 8; - for (int i_18_ = 1; i_18_ < (maxTileZ - 1); i_18_++) { - for (int i_19_ = 1; i_19_ < (maxTileX - 1); i_19_++) { - int i_20_ = (planeHeightmap[plane][i_19_ + 1][i_18_] - planeHeightmap[plane][i_19_ - 1][i_18_]); - int i_21_ = (planeHeightmap[plane][i_19_][i_18_ + 1] - planeHeightmap[plane][i_19_][i_18_ - 1]); - int i_22_ = (int) Math.sqrt((i_20_ * i_20_) + 65536 + (i_21_ * i_21_)); - int i_23_ = (i_20_ << 8) / i_22_; - int i_24_ = 65536 / i_22_; - int i_25_ = (i_21_ << 8) / i_22_; - int i_26_ = i_11_ + (((i_13_ * i_23_) + (i_14_ * i_24_) + (i_15_ * i_25_)) / i_17_); - int i_27_ = ((is[i_19_ - 1][i_18_] >> 2) + (is[i_19_ + 1][i_18_] >> 3) + (is[i_19_][i_18_ - 1] >> 2) + (is[i_19_][i_18_ + 1] >> 3) + (is[i_19_][i_18_] >> 1)); - anIntArrayArray139[i_19_][i_18_] = i_26_ - i_27_; + byte[][] shademap = planeShademap[plane]; + int lightAmbient = 96; + int lightAttenuation = 768; + int lightX = -50; + int lightY = -10; + int lightZ = -50; + int lightMagnitude = (lightAttenuation * (int) Math.sqrt((lightX * lightX) + (lightY * lightY) + (lightZ * lightZ))) >> 8; + + for (int z = 1; z < (maxTileZ - 1); z++) { + for (int x = 1; x < (maxTileX - 1); x++) { + int dx = planeHeightmap[plane][x + 1][z] - planeHeightmap[plane][x - 1][z]; + int dz = planeHeightmap[plane][x][z + 1] - planeHeightmap[plane][x][z - 1]; + int len = (int) Math.sqrt((dx * dx) + 65536 + (dz * dz)); + int nx = (dx << 8) / len; + int ny = 65536 / len; + int nz = (dz << 8) / len; + int light = lightAmbient + (((lightX * nx) + (lightY * ny) + (lightZ * nz)) / lightMagnitude); + int shade = (shademap[x - 1][z] >> 2) + (shademap[x + 1][z] >> 3) + (shademap[x][z - 1] >> 2) + (shademap[x][z + 1] >> 3) + (shademap[x][z] >> 1); + planeTileLightness[x][z] = light - shade; } } - for (int i_28_ = 0; i_28_ < maxTileZ; i_28_++) { - anIntArray124[i_28_] = 0; - anIntArray125[i_28_] = 0; - anIntArray126[i_28_] = 0; - anIntArray127[i_28_] = 0; - anIntArray128[i_28_] = 0; + + for (int z = 0; z < maxTileZ; z++) { + anIntArray124[z] = 0; + anIntArray125[z] = 0; + anIntArray126[z] = 0; + anIntArray127[z] = 0; + anIntArray128[z] = 0; } - for (int i_29_ = -5; i_29_ < (maxTileX + 5); i_29_++) { - for (int i_30_ = 0; i_30_ < maxTileZ; i_30_++) { - int i_31_ = i_29_ + 5; - if ((i_31_ >= 0) && (i_31_ < maxTileX)) { - int i_32_ = aByteArrayArrayArray142[plane][i_31_][i_30_] & 0xff; - if (i_32_ > 0) { - FloType type = FloType.instances[i_32_ - 1]; - anIntArray124[i_30_] += type.anInt397; - anIntArray125[i_30_] += type.anInt395; - anIntArray126[i_30_] += type.anInt396; - anIntArray127[i_30_] += type.anInt398; - anIntArray128[i_30_]++; + + for (int x0 = -5; x0 < (maxTileX + 5); x0++) { + for (int z0 = 0; z0 < maxTileZ; z0++) { + int x1 = x0 + 5; + + if ((x1 >= 0) && (x1 < maxTileX)) { + int floId = aByteArrayArrayArray142[plane][x1][z0] & 0xff; + + if (floId > 0) { + FloType flo = FloType.instances[floId - 1]; + anIntArray124[z0] += flo.chroma; + anIntArray125[z0] += flo.saturation; + anIntArray126[z0] += flo.lightness; + anIntArray127[z0] += flo.luminance; + anIntArray128[z0]++; } } - int i_33_ = i_29_ - 5; - if ((i_33_ >= 0) && (i_33_ < maxTileX)) { - int i_34_ = aByteArrayArrayArray142[plane][i_33_][i_30_] & 0xff; - if (i_34_ > 0) { - FloType type = FloType.instances[i_34_ - 1]; - anIntArray124[i_30_] -= type.anInt397; - anIntArray125[i_30_] -= type.anInt395; - anIntArray126[i_30_] -= type.anInt396; - anIntArray127[i_30_] -= type.anInt398; - anIntArray128[i_30_]--; + + int x2 = x0 - 5; + + if ((x2 >= 0) && (x2 < maxTileX)) { + int floId = aByteArrayArrayArray142[plane][x2][z0] & 0xff; + + if (floId > 0) { + FloType flo = FloType.instances[floId - 1]; + anIntArray124[z0] -= flo.chroma; + anIntArray125[z0] -= flo.saturation; + anIntArray126[z0] -= flo.lightness; + anIntArray127[z0] -= flo.luminance; + anIntArray128[z0]--; } } } - if ((i_29_ >= 1) && (i_29_ < (maxTileX - 1))) { + + if ((x0 >= 1) && (x0 < (maxTileX - 1))) { int i_35_ = 0; int i_36_ = 0; int i_37_ = 0; int i_38_ = 0; int i_39_ = 0; - for (int i_40_ = -5; i_40_ < (maxTileZ + 5); i_40_++) { - int i_41_ = i_40_ + 5; - if ((i_41_ >= 0) && (i_41_ < maxTileZ)) { - i_35_ += anIntArray124[i_41_]; - i_36_ += anIntArray125[i_41_]; - i_37_ += anIntArray126[i_41_]; - i_38_ += anIntArray127[i_41_]; - i_39_ += anIntArray128[i_41_]; + + for (int z0 = -5; z0 < (maxTileZ + 5); z0++) { + int dz1 = z0 + 5; + + if ((dz1 >= 0) && (dz1 < maxTileZ)) { + i_35_ += anIntArray124[dz1]; + i_36_ += anIntArray125[dz1]; + i_37_ += anIntArray126[dz1]; + i_38_ += anIntArray127[dz1]; + i_39_ += anIntArray128[dz1]; } - int i_42_ = i_40_ - 5; - if ((i_42_ >= 0) && (i_42_ < maxTileZ)) { - i_35_ -= anIntArray124[i_42_]; - i_36_ -= anIntArray125[i_42_]; - i_37_ -= anIntArray126[i_42_]; - i_38_ -= anIntArray127[i_42_]; - i_39_ -= anIntArray128[i_42_]; + + int dz2 = z0 - 5; + + if ((dz2 >= 0) && (dz2 < maxTileZ)) { + i_35_ -= anIntArray124[dz2]; + i_36_ -= anIntArray125[dz2]; + i_37_ -= anIntArray126[dz2]; + i_38_ -= anIntArray127[dz2]; + i_39_ -= anIntArray128[dz2]; } - if ((i_40_ >= 1) && (i_40_ < (maxTileZ - 1)) && (!lowmem || ((planeTileFlags[0][i_29_][i_40_] & 0x2) != 0) || (((planeTileFlags[plane][i_29_][i_40_] & 0x10) == 0) && (getDrawPlane(plane, i_29_, i_40_) == anInt131)))) { + + if ((z0 >= 1) && (z0 < (maxTileZ - 1)) && (!lowmem || ((planeTileFlags[0][x0][z0] & 0x2) != 0) || (((planeTileFlags[plane][x0][z0] & 0x10) == 0) && (getDrawPlane(plane, x0, z0) == anInt131)))) { if (plane < minPlane) { minPlane = plane; } - int i_43_ = (aByteArrayArrayArray142[plane][i_29_][i_40_] & 0xff); - int i_44_ = (aByteArrayArrayArray130[plane][i_29_][i_40_] & 0xff); - if ((i_43_ > 0) || (i_44_ > 0)) { - int i_45_ = planeHeightmap[plane][i_29_][i_40_]; - int i_46_ = (planeHeightmap[plane][i_29_ + 1][i_40_]); - int i_47_ = (planeHeightmap[plane][i_29_ + 1][i_40_ + 1]); - int i_48_ = (planeHeightmap[plane][i_29_][i_40_ + 1]); - int i_49_ = anIntArrayArray139[i_29_][i_40_]; - int i_50_ = anIntArrayArray139[i_29_ + 1][i_40_]; - int i_51_ = anIntArrayArray139[i_29_ + 1][i_40_ + 1]; - int i_52_ = anIntArrayArray139[i_29_][i_40_ + 1]; + + int i_43_ = aByteArrayArrayArray142[plane][x0][z0] & 0xff; + int floId = aByteArrayArrayArray130[plane][x0][z0] & 0xff; + + if ((i_43_ > 0) || (floId > 0)) { + int heightSW = planeHeightmap[plane][x0][z0]; + int heightSE = planeHeightmap[plane][x0 + 1][z0]; + int heightNE = planeHeightmap[plane][x0 + 1][z0 + 1]; + int heightNW = planeHeightmap[plane][x0][z0 + 1]; + + int tileHeight00 = planeTileLightness[x0][z0]; + int tileHeight10 = planeTileLightness[x0 + 1][z0]; + int tileHeight11 = planeTileLightness[x0 + 1][z0 + 1]; + int tileHeight01 = planeTileLightness[x0][z0 + 1]; + int i_53_ = -1; int i_54_ = -1; + if (i_43_ > 0) { - int i_55_ = (i_35_ * 256) / i_38_; - int i_56_ = i_36_ / i_39_; - int i_57_ = i_37_ / i_39_; - i_53_ = method177(i_55_, i_56_, i_57_); - i_55_ = (i_55_ + anInt123) & 0xff; - i_57_ += anInt133; - if (i_57_ < 0) { - i_57_ = 0; - } else if (i_57_ > 255) { - i_57_ = 255; + int hue = (i_35_ * 256) / i_38_; + int saturation = i_36_ / i_39_; + int lightness = i_37_ / i_39_; + + i_53_ = decimateHSL(hue, saturation, lightness); + + hue = (hue + anInt123) & 0xff; + lightness += anInt133; + + if (lightness < 0) { + lightness = 0; + } else if (lightness > 255) { + lightness = 255; } - i_54_ = method177(i_55_, i_56_, i_57_); + + i_54_ = decimateHSL(hue, saturation, lightness); } + if (plane > 0) { boolean bool = true; - if ((i_43_ == 0) && ((aByteArrayArrayArray136[plane][i_29_][i_40_]) != 0)) { + if ((i_43_ == 0) && (aByteArrayArrayArray136[plane][x0][z0] != 0)) { bool = false; } - if ((i_44_ > 0) && !(FloType.instances[i_44_ - 1].aBoolean393)) { + if ((floId > 0) && !FloType.instances[floId - 1].aBoolean393) { bool = false; } - if (bool && (i_45_ == i_46_) && (i_45_ == i_47_) && (i_45_ == i_48_)) { - planeOccludemap[plane][i_29_][i_40_] |= 0x924; + if (bool && (heightSW == heightSE) && (heightSW == heightNE) && (heightSW == heightNW)) { + planeOccludemap[plane][x0][z0] |= 0x924; } } + int i_58_ = 0; + if (i_53_ != -1) { - i_58_ = (Draw3D.palette[method187(i_54_, 96)]); + i_58_ = Draw3D.palette[mulHSL(i_54_, 96)]; } - if (i_44_ == 0) { - scene.method279(plane, i_29_, i_40_, 0, 0, -1, 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_), 0, 0, 0, 0, i_58_, 0); + + if (floId == 0) { + scene.setTile(plane, x0, z0, 0, 0, -1, heightSW, heightSE, heightNE, heightNW, mulHSL(i_53_, tileHeight00), mulHSL(i_53_, tileHeight10), mulHSL(i_53_, tileHeight11), mulHSL(i_53_, tileHeight01), 0, 0, 0, 0, i_58_, 0); } else { - 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 textureId = type.textureId; - int i_62_; - int i_63_; + int i_59_ = aByteArrayArrayArray136[plane][x0][z0] + 1; + byte i_60_ = aByteArrayArrayArray148[plane][x0][z0]; + FloType flo = FloType.instances[floId - 1]; + int textureId = flo.textureId; + int rgb; + int hsl; + if (textureId >= 0) { - i_62_ = Draw3D.getAverageTextureRGB(textureId); - i_63_ = -1; - } else if (type.anInt390 == 16711935) { - i_62_ = 0; - i_63_ = -2; + rgb = Draw3D.getAverageTextureRGB(textureId); + hsl = -1; + } else if (flo.rgb == 16711935) { + rgb = 0; + hsl = -2; textureId = -1; } else { - i_63_ = method177(type.anInt394, type.anInt395, type.anInt396); - i_62_ = (Draw3D.palette[method185(type.anInt399, 96)]); + hsl = decimateHSL(flo.hue, flo.saturation, flo.lightness); + rgb = Draw3D.palette[adjustLightness(flo.hsl, 96)]; } - 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_); + + scene.setTile(plane, x0, z0, i_59_, i_60_, textureId, heightSW, heightSE, heightNE, heightNW, mulHSL(i_53_, tileHeight00), mulHSL(i_53_, tileHeight10), mulHSL(i_53_, tileHeight11), mulHSL(i_53_, tileHeight01), adjustLightness(hsl, tileHeight00), adjustLightness(hsl, tileHeight10), adjustLightness(hsl, tileHeight11), adjustLightness(hsl, tileHeight01), i_58_, rgb); } } } } } } + for (int stz = 1; stz < (maxTileZ - 1); stz++) { for (int stx = 1; stx < (maxTileX - 1); stx++) { scene.setDrawPlane(plane, stx, stz, getDrawPlane(plane, stx, stz)); } } } + scene.method305(-10, 64, -50, 768, -50); - for (int i_66_ = 0; i_66_ < maxTileX; i_66_++) { - for (int i_67_ = 0; i_67_ < maxTileZ; i_67_++) { - if ((planeTileFlags[1][i_66_][i_67_] & 0x2) == 2) { - scene.setBridge(i_66_, i_67_); + + for (int x = 0; x < maxTileX; x++) { + for (int z = 0; z < maxTileZ; z++) { + if ((planeTileFlags[1][x][z] & 0x2) == 2) { + scene.setBridge(x, z); } } } + int i_68_ = 1; int i_69_ = 2; int i_70_ = 4; @@ -638,19 +681,19 @@ public class SceneBuilder { int i_77_ = plane; int i_78_ = plane; for (/**/; i_75_ > 0; i_75_--) { - if (((planeOccludemap[plane][x][i_75_ - 1]) & i_68_) == 0) { + if ((planeOccludemap[plane][x][i_75_ - 1] & i_68_) == 0) { break; } } for (/**/; i_76_ < maxTileZ; i_76_++) { - if (((planeOccludemap[plane][x][i_76_ + 1]) & i_68_) == 0) { + if ((planeOccludemap[plane][x][i_76_ + 1] & i_68_) == 0) { break; } } while_0_: for (/**/; i_77_ > 0; i_77_--) { for (int i_79_ = i_75_; i_79_ <= i_76_; i_79_++) { - if (((planeOccludemap[i_77_ - 1][x][i_79_]) & i_68_) == 0) { + if ((planeOccludemap[i_77_ - 1][x][i_79_] & i_68_) == 0) { break while_0_; } } @@ -658,7 +701,7 @@ public class SceneBuilder { while_1_: for (/**/; i_78_ < i_71_; i_78_++) { for (int i_80_ = i_75_; i_80_ <= i_76_; i_80_++) { - if (((planeOccludemap[i_78_ + 1][x][i_80_]) & i_68_) == 0) { + if ((planeOccludemap[i_78_ + 1][x][i_80_] & i_68_) == 0) { break while_1_; } } @@ -666,7 +709,7 @@ public class SceneBuilder { int i_81_ = ((i_78_ + 1) - i_77_) * ((i_76_ - i_75_) + 1); if (i_81_ >= 8) { int i_82_ = 240; - int i_83_ = (planeHeightmap[i_78_][x][i_75_] - i_82_); + int i_83_ = planeHeightmap[i_78_][x][i_75_] - i_82_; int i_84_ = planeHeightmap[i_77_][x][i_75_]; Scene.method277(i_71_, x * 128, i_84_, x * 128, (i_76_ * 128) + 128, i_83_, i_75_ * 128, 1); for (int i_85_ = i_77_; i_85_ <= i_78_; i_85_++) { @@ -682,19 +725,19 @@ public class SceneBuilder { int i_89_ = plane; int i_90_ = plane; for (/**/; i_87_ > 0; i_87_--) { - if (((planeOccludemap[plane][i_87_ - 1][z]) & i_69_) == 0) { + if ((planeOccludemap[plane][i_87_ - 1][z] & i_69_) == 0) { break; } } for (/**/; i_88_ < maxTileX; i_88_++) { - if (((planeOccludemap[plane][i_88_ + 1][z]) & i_69_) == 0) { + if ((planeOccludemap[plane][i_88_ + 1][z] & i_69_) == 0) { break; } } while_2_: for (/**/; i_89_ > 0; i_89_--) { for (int i_91_ = i_87_; i_91_ <= i_88_; i_91_++) { - if (((planeOccludemap[i_89_ - 1][i_91_][z]) & i_69_) == 0) { + if ((planeOccludemap[i_89_ - 1][i_91_][z] & i_69_) == 0) { break while_2_; } } @@ -702,7 +745,7 @@ public class SceneBuilder { while_3_: for (/**/; i_90_ < i_71_; i_90_++) { for (int i_92_ = i_87_; i_92_ <= i_88_; i_92_++) { - if (((planeOccludemap[i_90_ + 1][i_92_][z]) & i_69_) == 0) { + if ((planeOccludemap[i_90_ + 1][i_92_][z] & i_69_) == 0) { break while_3_; } } @@ -710,7 +753,7 @@ public class SceneBuilder { int i_93_ = ((i_90_ + 1) - i_89_) * ((i_88_ - i_87_) + 1); if (i_93_ >= 8) { int i_94_ = 240; - int i_95_ = (planeHeightmap[i_90_][i_87_][z] - i_94_); + int i_95_ = planeHeightmap[i_90_][i_87_][z] - i_94_; int i_96_ = planeHeightmap[i_89_][i_87_][z]; Scene.method277(i_71_, i_87_ * 128, i_96_, (i_88_ * 128) + 128, z * 128, i_95_, z * 128, 2); for (int i_97_ = i_89_; i_97_ <= i_90_; i_97_++) { @@ -726,19 +769,19 @@ public class SceneBuilder { int i_101_ = z; int i_102_ = z; for (/**/; i_101_ > 0; i_101_--) { - if (((planeOccludemap[plane][x][i_101_ - 1]) & i_70_) == 0) { + if ((planeOccludemap[plane][x][i_101_ - 1] & i_70_) == 0) { break; } } for (/**/; i_102_ < maxTileZ; i_102_++) { - if (((planeOccludemap[plane][x][i_102_ + 1]) & i_70_) == 0) { + if ((planeOccludemap[plane][x][i_102_ + 1] & i_70_) == 0) { break; } } while_4_: for (/**/; i_99_ > 0; i_99_--) { for (int i_103_ = i_101_; i_103_ <= i_102_; i_103_++) { - if (((planeOccludemap[plane][i_99_ - 1][i_103_]) & i_70_) == 0) { + if ((planeOccludemap[plane][i_99_ - 1][i_103_] & i_70_) == 0) { break while_4_; } } @@ -746,7 +789,7 @@ public class SceneBuilder { while_5_: for (/**/; i_100_ < maxTileX; i_100_++) { for (int i_104_ = i_101_; i_104_ <= i_102_; i_104_++) { - if (((planeOccludemap[plane][i_100_ + 1][i_104_]) & i_70_) == 0) { + if ((planeOccludemap[plane][i_100_ + 1][i_104_] & i_70_) == 0) { break while_5_; } } @@ -871,7 +914,7 @@ public class SceneBuilder { shade = 30; } - if (shade > (planeShademap[plane][x + dx][z + dz])) { + if (shade > planeShademap[plane][x + dx][z + dz]) { planeShademap[plane][x + dx][z + dz] = (byte) shade; } } @@ -1117,27 +1160,27 @@ public class SceneBuilder { } } - public int method177(int i, int i_156_, int i_157_) { - if (i_157_ > 179) { - i_156_ /= 2; + public int decimateHSL(int hue, int saturation, int lightness) { + if (lightness > 179) { + saturation /= 2; } - if (i_157_ > 192) { - i_156_ /= 2; + if (lightness > 192) { + saturation /= 2; } - if (i_157_ > 217) { - i_156_ /= 2; + if (lightness > 217) { + saturation /= 2; } - if (i_157_ > 243) { - i_156_ /= 2; + if (lightness > 243) { + saturation /= 2; } - return ((i / 4) << 10) + ((i_156_ / 32) << 7) + (i_157_ / 2); + return ((hue / 4) << 10) + ((saturation / 32) << 7) + (lightness / 2); } public void method179(int i, int i_162_, SceneCollisionMap[] collisionMaps, int i_164_, int i_165_, byte[] is, int i_166_, int i_167_, int i_168_) { for (int i_169_ = 0; i_169_ < 8; i_169_++) { for (int i_170_ = 0; i_170_ < 8; i_170_++) { if (((i_164_ + i_169_) > 0) && ((i_164_ + i_169_) < 103) && ((i_168_ + i_170_) > 0) && ((i_168_ + i_170_) < 103)) { - collisionMaps[i_167_].flags[i_164_ + i_169_][(i_168_ + i_170_)] &= ~0x1000000; + collisionMaps[i_167_].flags[i_164_ + i_169_][i_168_ + i_170_] &= ~0x1000000; } } } @@ -1197,7 +1240,7 @@ public class SceneBuilder { if (i_187_ == 0) { planeHeightmap[0][i_186_][i] = -i_192_ * 8; } else { - planeHeightmap[i_187_][i_186_][i] = (planeHeightmap[i_187_ - 1][i_186_][i] - (i_192_ * 8)); + planeHeightmap[i_187_][i_186_][i] = planeHeightmap[i_187_ - 1][i_186_][i] - (i_192_ * 8); break; } break; @@ -1281,26 +1324,30 @@ public class SceneBuilder { } } - public int method185(int i, int i_220_) { - if (i == -2) { + public int adjustLightness(int hsl, int scalar) { + if (hsl == -2) { return 12345678; } - if (i == -1) { - if (i_220_ < 0) { - i_220_ = 0; - } else if (i_220_ > 127) { - i_220_ = 127; + + if (hsl == -1) { + if (scalar < 0) { + scalar = 0; + } else if (scalar > 127) { + scalar = 127; } - i_220_ = 127 - i_220_; - return i_220_; + scalar = 127 - scalar; + return scalar; } - i_220_ = (i_220_ * (i & 0x7f)) / 128; - if (i_220_ < 2) { - i_220_ = 2; - } else if (i_220_ > 126) { - i_220_ = 126; + + scalar = (scalar * (hsl & 0x7f)) / 128; + + if (scalar < 2) { + scalar = 2; + } else if (scalar > 126) { + scalar = 126; } - return (i & 0xff80) + i_220_; + + return (hsl & 0xff80) + scalar; } public void method190(int i, SceneCollisionMap[] collisionMaps, int i_263_, Scene scene, byte[] is) { diff --git a/src/main/java/SceneLocTemporary.java b/src/main/java/SceneLocTemporary.java index fdb61b0..21c3f4f 100644 --- a/src/main/java/SceneLocTemporary.java +++ b/src/main/java/SceneLocTemporary.java @@ -9,10 +9,10 @@ public class SceneLocTemporary extends DoublyLinkedList.Node { public int anInt1293; public int anInt1294; public int plane; - public int classID; + public int classId; public int localX; public int localZ; - public int savedLocID; + public int savedLocId; public int savedRotation; public int savedKind; public int anInt1302; diff --git a/src/main/java/SeqFrame.java b/src/main/java/SeqFrame.java index cc0092c..edd8128 100644 --- a/src/main/java/SeqFrame.java +++ b/src/main/java/SeqFrame.java @@ -98,6 +98,7 @@ public class SeqFrame { int baseCount = header.get1U(); int lastBase = -1; int length = 0; + for (int base = 0; base < baseCount; base++) { int flags = tran1.get1U(); @@ -106,6 +107,7 @@ public class SeqFrame { } if (skeleton.baseTypes[base] != SeqSkeleton.OP_BASE) { + // Look for any skipped ORIGIN bases and insert them into this frame. for (int cur = base - 1; cur > lastBase; cur--) { if (skeleton.baseTypes[cur] == SeqSkeleton.OP_BASE) { bases[length] = cur; diff --git a/src/main/java/SeqSkeleton.java b/src/main/java/SeqSkeleton.java index d78bca8..f982045 100644 --- a/src/main/java/SeqSkeleton.java +++ b/src/main/java/SeqSkeleton.java @@ -1,50 +1,54 @@ /** - * A {@link SeqSkeleton} describes the usage and relationship between groups. + * A {@link SeqSkeleton} describes the usage and relationship between groups of vertices. * * @see Model#applySequenceFrame(int) * @see Model#applySequenceFrames(int, int, int[]) */ public class SeqSkeleton { + /** + * A base can be thought of as the origin of a bone. This operator comes first before any other operations occur. + */ + public static final int OP_BASE = 0; + public static final int OP_TRANSLATE = 1; - public static final int OP_BASE = 0; - public static final int OP_TRANSLATE = 1; - public static final int OP_ROTATE = 2; - public static final int OP_SCALE = 3; - public static final int OP_ALPHA = 5; - /** - * A base type determines the operation performed on the labels belonging to it. - * - * @see #OP_BASE - * @see #OP_TRANSLATE - * @see #OP_ROTATE - * @see #OP_SCALE - * @see #OP_ALPHA - */ - public final int[] baseTypes; - /** - * The labels belonging to the base. - */ - public final int[][] baseLabels; + public static final int OP_ROTATE = 2; + public static final int OP_SCALE = 3; + public static final int OP_ALPHA = 5; + /** + * A base type determines the operation performed on the labels belonging to it. + * + * @see #OP_BASE + * @see #OP_TRANSLATE + * @see #OP_ROTATE + * @see #OP_SCALE + * @see #OP_ALPHA + */ + public final int[] baseTypes; + /** + * The labels belonging to the base. + * @see Model#createLabelReferences() + */ + public final int[][] baseLabels; - /** - * Constructs a new {@link SeqSkeleton} read from the provided input. - * - * @param in the input - */ - public SeqSkeleton(Buffer in) { - final int length = in.get1U(); - baseTypes = new int[length]; - baseLabels = new int[length][]; - for (int group = 0; group < length; group++) { - baseTypes[group] = in.get1U(); - } - for (int group = 0; group < length; group++) { - int count = in.get1U(); - baseLabels[group] = new int[count]; - for (int child = 0; child < count; child++) { - baseLabels[group][child] = in.get1U(); - } - } - } + /** + * Constructs a new {@link SeqSkeleton} read from the provided input. + * + * @param in the input + */ + public SeqSkeleton(Buffer in) { + final int length = in.get1U(); + baseTypes = new int[length]; + baseLabels = new int[length][]; + for (int group = 0; group < length; group++) { + baseTypes[group] = in.get1U(); + } + for (int group = 0; group < length; group++) { + int count = in.get1U(); + baseLabels[group] = new int[count]; + for (int child = 0; child < count; child++) { + baseLabels[group][child] = in.get1U(); + } + } + } } diff --git a/src/main/java/SeqType.java b/src/main/java/SeqType.java index 8d02b06..b3aebc5 100644 --- a/src/main/java/SeqType.java +++ b/src/main/java/SeqType.java @@ -31,9 +31,9 @@ public class SeqType { public int speed = -1; public int[] anIntArray357; public boolean aBoolean358 = false; - public int anInt359 = 5; - public int anInt360 = -1; - public int anInt361 = -1; + public int priority = 5; + public int rightHandOverride = -1; + public int leftHandOverride = -1; public int anInt362 = 99; public int anInt363 = -1; public int anInt364 = -1; @@ -88,11 +88,11 @@ public class SeqType { } else if (op == 4) { aBoolean358 = true; } else if (op == 5) { - anInt359 = buffer.get1U(); + priority = buffer.get1U(); } else if (op == 6) { - anInt360 = buffer.get2U(); + rightHandOverride = buffer.get2U(); } else if (op == 7) { - anInt361 = buffer.get2U(); + leftHandOverride = buffer.get2U(); } else if (op == 8) { anInt362 = buffer.get1U(); } else if (op == 9) { diff --git a/src/main/java/SpotAnimEntity.java b/src/main/java/SpotAnimEntity.java index 4b0868b..c3c1255 100644 --- a/src/main/java/SpotAnimEntity.java +++ b/src/main/java/SpotAnimEntity.java @@ -4,67 +4,74 @@ public class SpotAnimEntity extends Entity { - public final int anInt1560; - public final int anInt1561; - public final int anInt1562; - public final int anInt1563; - public final int anInt1564; - public final SpotAnimType aType_1568; - public boolean aBoolean1567 = false; - public int anInt1569; - public int anInt1570; + public final int plane; + public final int x; + public final int z; + public final int y; + public final int startCycle; + public final SpotAnimType type; + public boolean seqComplete = false; + public int seqFrame; + public int seqCycle; - public SpotAnimEntity(int i, int j, int l, int i1, int j1, int k1, int l1) { - aType_1568 = SpotAnimType.instances[i1]; - anInt1560 = i; - anInt1561 = l1; - anInt1562 = k1; - anInt1563 = j1; - anInt1564 = j + l; + public SpotAnimEntity(int plane, int cycle, int delay, int id, int y, int z, int x) { + type = SpotAnimType.instances[id]; + this.plane = plane; + this.x = x; + this.z = z; + this.y = y; + startCycle = cycle + delay; } @Override public Model getModel() { - Model model = aType_1568.method266(); - if (model == null) { + Model base = type.getModel(); + + if (base == null) { return null; } - int j = aType_1568.seq.primaryFrames[anInt1569]; - Model model_1 = new Model(true, SeqFrame.isNull(j), false, model); - if (!aBoolean1567) { - model_1.createLabelReferences(); - model_1.applySequenceFrame(j); - model_1.labelFaces = null; - model_1.labelVertices = null; + + int frame = type.seq.primaryFrames[seqFrame]; + + Model model = new Model(true, SeqFrame.isNull(frame), false, base); + + if (!seqComplete) { + model.createLabelReferences(); + model.applySequenceFrame(frame); + model.labelFaces = null; + model.labelVertices = null; } - if ((aType_1568.anInt410 != 128) || (aType_1568.anInt411 != 128)) { - model_1.scale(aType_1568.anInt410, aType_1568.anInt410, aType_1568.anInt411); + + if ((type.scaleXY != 128) || (type.scaleZ != 128)) { + model.scale(type.scaleXY, type.scaleXY, type.scaleZ); } - if (aType_1568.anInt412 != 0) { - if (aType_1568.anInt412 == 90) { - model_1.rotateY90(); + + if (type.rotation != 0) { + if (type.rotation == 90) { + model.rotateY90(); } - if (aType_1568.anInt412 == 180) { - model_1.rotateY90(); - model_1.rotateY90(); + if (type.rotation == 180) { + model.rotateY90(); + model.rotateY90(); } - if (aType_1568.anInt412 == 270) { - model_1.rotateY90(); - model_1.rotateY90(); - model_1.rotateY90(); + if (type.rotation == 270) { + model.rotateY90(); + model.rotateY90(); + model.rotateY90(); } } - model_1.calculateNormals(64 + aType_1568.anInt413, 850 + aType_1568.anInt414, -30, -50, -30, true); - return model_1; + model.calculateNormals(64 + type.lightAmbient, 850 + type.lightAttenuation, -30, -50, -30, true); + return model; } - public void method454(int i) { - for (anInt1570 += i; anInt1570 > aType_1568.seq.getFrameDelay(anInt1569); ) { - anInt1570 -= aType_1568.seq.getFrameDelay(anInt1569) + 1; - anInt1569++; - if ((anInt1569 >= aType_1568.seq.frameCount) && ((anInt1569 < 0) || (anInt1569 >= aType_1568.seq.frameCount))) { - anInt1569 = 0; - aBoolean1567 = true; + public void update(int delta) { + for (seqCycle += delta; seqCycle > type.seq.getFrameDelay(seqFrame); ) { + seqCycle -= type.seq.getFrameDelay(seqFrame) + 1; + seqFrame++; + + if (seqFrame >= type.seq.frameCount) { + seqFrame = 0; + seqComplete = true; } } } diff --git a/src/main/java/SpotAnimType.java b/src/main/java/SpotAnimType.java index 25d7f85..640fc3c 100644 --- a/src/main/java/SpotAnimType.java +++ b/src/main/java/SpotAnimType.java @@ -15,80 +15,87 @@ public class SpotAnimType { 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); + instances[i].read(buffer); } } - public final int[] anIntArray408 = new int[6]; - public final int[] anIntArray409 = new int[6]; + public final int[] colorSrc = new int[6]; + public final int[] colorDst = new int[6]; public int index; - public int anInt405; + public int modelId; 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 int scaleXY = 128; + public int scaleZ = 128; + public int rotation; + public int lightAmbient; + public int lightAttenuation; public SpotAnimType() { } - public void method265(Buffer buffer) { + public void read(Buffer buffer) { do { int i = buffer.get1U(); if (i == 0) { return; } if (i == 1) { - anInt405 = buffer.get2U(); + modelId = buffer.get2U(); } else if (i == 2) { seqId = buffer.get2U(); if (SeqType.instances != null) { seq = SeqType.instances[seqId]; } } else if (i == 4) { - anInt410 = buffer.get2U(); + scaleXY = buffer.get2U(); } else if (i == 5) { - anInt411 = buffer.get2U(); + scaleZ = buffer.get2U(); } else if (i == 6) { - anInt412 = buffer.get2U(); + rotation = buffer.get2U(); } else if (i == 7) { - anInt413 = buffer.get1U(); + lightAmbient = buffer.get1U(); } else if (i == 8) { - anInt414 = buffer.get1U(); + lightAttenuation = buffer.get1U(); } else if ((i >= 40) && (i < 50)) { - anIntArray408[i - 40] = buffer.get2U(); + colorSrc[i - 40] = buffer.get2U(); } else if ((i >= 50) && (i < 60)) { - anIntArray409[i - 50] = buffer.get2U(); + colorDst[i - 50] = buffer.get2U(); } else { System.out.println("Error unrecognised spotanim config code: " + i); } } while (true); } - public Model method266() { + public Model getModel() { Model model = modelCache.get(index); + if (model != null) { return model; } - model = Model.tryGet(anInt405); + + model = Model.tryGet(modelId); + if (model == null) { return null; } + for (int i = 0; i < 6; i++) { - if (anIntArray408[0] != 0) { - model.recolor(anIntArray408[i], anIntArray409[i]); + if (colorSrc[0] != 0) { + model.recolor(colorSrc[i], colorDst[i]); } } + modelCache.put(index, model); return model; }