diff --git a/src/main/java/Component.java b/src/main/java/Component.java index ab10575..5f09a39 100644 --- a/src/main/java/Component.java +++ b/src/main/java/Component.java @@ -164,14 +164,14 @@ public class Component { if (c.type == 6) { int tmp = in.get1U(); if (tmp != 0) { - c.modelType = 1; - c.modelTypeId = ((tmp - 1) << 8) + in.get1U(); + c.modelCategory = 1; + c.modelID = ((tmp - 1) << 8) + in.get1U(); } tmp = in.get1U(); if (tmp != 0) { - c.activeModelType = 1; - c.activeModelTypeId = ((tmp - 1) << 8) + in.get1U(); + c.activeModelCategory = 1; + c.activeModelID = ((tmp - 1) << 8) + in.get1U(); } tmp = in.get1U(); @@ -269,8 +269,8 @@ public class Component { public int activeColor; public int activeHoverColor; public Image24 activeImage; - public int activeModelType; - public int activeModelTypeId; + public int activeModelCategory; + public int activeModelID; public int activeSeqId; public String activeText; public boolean center; @@ -299,8 +299,8 @@ public class Component { public int[] invSlotY; public boolean invUsable; public int modelEyePitch; - public int modelType; - public int modelTypeId; + public int modelCategory; + public int modelID; public int modelYaw; public int modelZoom; public String option; @@ -341,28 +341,28 @@ public class Component { invSlotAmount[dst] = tmp; } - public Model getModel(int type, int id) { - Model model = modelCache.get(((long) type << 16) + id); + public Model getModel(int category, int id) { + Model model = modelCache.get(((long) category << 16) + id); if (model != null) { return model; } - if (type == 1) { + if (category == 1) { model = Model.tryGet(id); } - if (type == 2) { + if (category == 2) { model = NPCType.get(id).method160(); } - if (type == 3) { - model = Game.self.method453(); + if (category == 3) { + model = Game.localPlayer.method453(); } - if (type == 4) { + if (category == 4) { model = ObjType.get(id).getModelUnlit(50); } - if (type == 5) { + if (category == 5) { model = null; } if (model != null) { - modelCache.put((long) ((type << 16) + id), model); + modelCache.put((long) ((category << 16) + id), model); } return model; } @@ -371,9 +371,9 @@ public class Component { Model model; if (active) { - model = getModel(activeModelType, activeModelTypeId); + model = getModel(activeModelCategory, activeModelID); } else { - model = getModel(modelType, modelTypeId); + model = getModel(modelCategory, modelID); } if (model == null) { diff --git a/src/main/java/Game.java b/src/main/java/Game.java index bc5439a..9fec27a 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -24,7 +24,7 @@ public class Game extends GameShell { public static final BigInteger RSA_MODULUS = new BigInteger("115021795079507343952614936197913546438580135096169635842480712252120509788529535203161526625251797553017433341968661761641695154871087245548928967487006467485383337651405009623296611208539069524887502151216922299338355736930449024798579974392565651281911869750633089962840628929607415810272098208925607905239"); public static final int[] levelExperience; public static final BigInteger RSA_EXPONENT = new BigInteger("65537"); - public static final String aString1162 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"\243$%^&*()-_=+[{]};:'@#~,<.>/?\\| "; + public static final String VALID_CHAT_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"\243$%^&*()-_=+[{]};:'@#~,<.>/?\\| "; public static final int[] BITMASK; public static final int MAX_PLAYER_COUNT = 2048; public static final int LOCAL_PLAYER_INDEX = 2047; @@ -34,7 +34,7 @@ public class Game extends GameShell { public static boolean lowmem; public static boolean started; public static int drawCycle; - public static PlayerEntity self; + public static PlayerEntity localPlayer; public static boolean aBoolean1156; public static int loopCycle; public static boolean aBoolean1205; @@ -156,7 +156,7 @@ public class Game extends GameShell { LocType.lowmem = true; } - public final int[] anIntArray1177 = {0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3}; + public final int[] LOC_KIND_TO_CLASS_ID = {0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3}; /** * A skill's base level is determined by the skill experience and is not [de]buffable. */ @@ -204,7 +204,7 @@ public class Game extends GameShell { 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[] waveId = 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 selfPlayerId = -1; + public int localPlayerID = -1; public boolean menuVisible = false; public int lastHoveredComponentId; public String chatTyped = ""; @@ -310,7 +310,7 @@ public class Game extends GameShell { public int menuWidth; public int menuHeight; public long aLong953; - public boolean aBoolean954 = true; + public boolean _focused = true; public long[] friendName37 = new long[200]; public int nextMusic = -1; public volatile boolean flameThread = false; @@ -501,7 +501,7 @@ public class Game extends GameShell { public String password = ""; public boolean errorHost = false; public int anInt1178 = -1; - public DoublyLinkedList listTemporaryLocs = new DoublyLinkedList(); + public DoublyLinkedList temporaryLocs = new DoublyLinkedList(); public int[] areaChatbackOffsets; public int[] areaInvbackOffsets; public int[] areaViewportOffsets; @@ -529,7 +529,7 @@ public class Game extends GameShell { public int anInt1213; public int[][][] planeHeightmap; public long aLong1215; - public int anInt1216; + public int titleLoginField; public long aLong1220; public int selectedTab = 3; public int hintNPC; @@ -572,8 +572,8 @@ public class Game extends GameShell { public int sceneCycle; public String loginMessage0 = ""; public String loginMessage1 = ""; - public int anInt1268; - public int anInt1269; + public int zoneX; + public int zoneZ; public BitmapFont fontPlain11; public BitmapFont fontPlain12; public BitmapFont fontBold12; @@ -1128,7 +1128,7 @@ public class Game extends GameShell { npcs = null; npcIndices = null; planeObjStacks = null; - listTemporaryLocs = null; + temporaryLocs = null; aList_1013 = null; aList_1056 = null; menuParamA = null; @@ -1472,8 +1472,8 @@ public class Game extends GameShell { String name; - if ((self != null) && (self.name != null)) { - name = self.name; + if ((localPlayer != null) && (localPlayer.name != null)) { + name = localPlayer.name; } else { name = StringUtil.formatName(username); } @@ -1710,25 +1710,25 @@ public class Game extends GameShell { sceneBuilder.method171(collisions, scene); areaViewport.bind(); out.putOp(0); - int k3 = SceneBuilder.anInt145; + int k3 = SceneBuilder.minPlane; if (k3 > currentPlane) { k3 = currentPlane; } if (lowmem) { - scene.setMinPlane(SceneBuilder.anInt145); + scene.setMinPlane(SceneBuilder.minPlane); } else { scene.setMinPlane(0); } - for (int i5 = 0; i5 < 104; i5++) { - for (int i7 = 0; i7 < 104; i7++) { - method25(i5, i7); + for (int x = 0; x < 104; x++) { + for (int z = 0; z < 104; z++) { + sortObjStacks(x, z); } } method63(); } catch (Exception ignored) { } - LocType.modelCache.clear(); + LocType.staticCache.clear(); if (super.frame != null) { out.putOp(210); @@ -1777,8 +1777,8 @@ public class Game extends GameShell { } public void clearCaches() { - LocType.modelCache.clear(); - LocType.aCache_780.clear(); + LocType.staticCache.clear(); + LocType.dynamicCache.clear(); NPCType.modelCache.clear(); ObjType.modelCache.clear(); ObjType.iconCache.clear(); @@ -1807,19 +1807,19 @@ public class Game extends GameShell { } } - int wall = 0xEEEEEE; - int door = 0xEE0000; + int wallRGB = 0xEEEEEE; + int doorRGB = 0xEE0000; imageMinimap.bind(); for (int z = 1; z < 103; z++) { for (int x = 1; x < 103; x++) { if ((planeTileFlags[plane][x][z] & 0x18) == 0) { - drawMinimapLoc(z, wall, x, door, plane); + drawMinimapLoc(z, wallRGB, x, doorRGB, plane); } if ((plane < 3) && ((planeTileFlags[plane + 1][x][z] & 8) != 0)) { - drawMinimapLoc(z, wall, x, door, plane + 1); + drawMinimapLoc(z, wallRGB, x, doorRGB, plane + 1); } } } @@ -1874,7 +1874,7 @@ public class Game extends GameShell { } } - public void method25(int x, int z) { + public void sortObjStacks(int x, int z) { DoublyLinkedList list = planeObjStacks[currentPlane][x][z]; if (list == null) { scene.removeObjStack(currentPlane, x, z); @@ -2357,7 +2357,7 @@ public class Game extends GameShell { PathingEntity e; if (i == -1) { - e = self; + e = localPlayer; } else if (i < playerCount) { e = players[playerIndices[i]]; } else { @@ -2890,7 +2890,7 @@ public class Game extends GameShell { return; } } - if (!s.equals(self.name)) { + if (!s.equals(localPlayer.name)) { friendName[friendCount] = s; friendName37[friendCount] = name37; friendWorld[friendCount] = 0; @@ -2989,13 +2989,13 @@ public class Game extends GameShell { npc.seqTurnLeft = npc.type.seqTurnLeft; npc.seqTurnRight = npc.type.seqTurnRight; npc.seqStand = npc.type.seqStand; - npc.move(self.pathTileX[0] + x, self.pathTileZ[0] + z, j1 == 1); + npc.move(localPlayer.pathTileX[0] + x, localPlayer.pathTileZ[0] + z, j1 == 1); } buffer.accessBytes(); } public void method47(boolean local) { - if (((self.x >> 7) == flagSceneTileX) && ((self.z >> 7) == flagSceneTileZ)) { + if (((localPlayer.x >> 7) == flagSceneTileX) && ((localPlayer.z >> 7) == flagSceneTileZ)) { flagSceneTileX = 0; } @@ -3010,7 +3010,7 @@ public class Game extends GameShell { int index; if (local) { - player = self; + player = localPlayer; index = LOCAL_PLAYER_INDEX << 14; } else { player = players[playerIndices[l]]; @@ -3169,131 +3169,147 @@ public class Game extends GameShell { } } - public void drawMinimapLoc(int i, int k, int l, int i1, int j1) { - int k1 = scene.getWallBitset(j1, l, i); - if (k1 != 0) { - int l1 = scene.getInfo(j1, l, i, k1); - int k2 = (l1 >> 6) & 3; - int i3 = l1 & 0x1f; - int k3 = k; - if (k1 > 0) { - k3 = i1; + public void drawMinimapLoc(int z, int wallRGB, int x, int doorRGB, int plane) { + int bitset = scene.getWallBitset(plane, x, z); + + if (bitset != 0) { + int info = scene.getInfo(plane, x, z, bitset); + int rotation = (info >> 6) & 3; + int kind = info & 0x1f; + int rgb = wallRGB; + + if (bitset > 0) { + rgb = doorRGB; } - int[] ai = imageMinimap.pixels; - int k4 = 24624 + (l * 4) + ((103 - i) * 512 * 4); - int i5 = (k1 >> 14) & 0x7fff; - LocType type_2 = LocType.get(i5); - if (type_2.mapsceneIcon != -1) { - Image8 class30_sub2_sub1_sub2_2 = imageMapscene[type_2.mapsceneIcon]; - if (class30_sub2_sub1_sub2_2 != null) { - int i6 = ((type_2.width * 4) - class30_sub2_sub1_sub2_2.width) / 2; - int j6 = ((type_2.length * 4) - class30_sub2_sub1_sub2_2.height) / 2; - class30_sub2_sub1_sub2_2.blit(48 + (l * 4) + i6, 48 + ((104 - i - type_2.length) * 4) + j6); + + int[] dst = imageMinimap.pixels; + int offset = 24624 + (x * 4) + ((103 - z) * 512 * 4); + + int locID= (bitset >> 14) & 0x7fff; + LocType type = LocType.get(locID); + + if (type.mapsceneIcon != -1) { + Image8 icon = imageMapscene[type.mapsceneIcon]; + if (icon != null) { + int offsetX = ((type.width * 4) - icon.width) / 2; + int offsetY = ((type.length * 4) - icon.height) / 2; + icon.blit(48 + (x * 4) + offsetX, 48 + ((104 - z - type.length) * 4) + offsetY); } } else { - if ((i3 == 0) || (i3 == 2)) { - if (k2 == 0) { - ai[k4] = k3; - ai[k4 + 512] = k3; - ai[k4 + 1024] = k3; - ai[k4 + 1536] = k3; - } else if (k2 == 1) { - ai[k4] = k3; - ai[k4 + 1] = k3; - ai[k4 + 2] = k3; - ai[k4 + 3] = k3; - } else if (k2 == 2) { - ai[k4 + 3] = k3; - ai[k4 + 3 + 512] = k3; - ai[k4 + 3 + 1024] = k3; - ai[k4 + 3 + 1536] = k3; - } else if (k2 == 3) { - ai[k4 + 1536] = k3; - ai[k4 + 1536 + 1] = k3; - ai[k4 + 1536 + 2] = k3; - ai[k4 + 1536 + 3] = k3; + if ((kind == 0) || (kind == 2)) { + if (rotation == 0) { + dst[offset] = rgb; + dst[offset + 512] = rgb; + dst[offset + 1024] = rgb; + dst[offset + 1536] = rgb; + } else if (rotation == 1) { + dst[offset] = rgb; + dst[offset + 1] = rgb; + dst[offset + 2] = rgb; + dst[offset + 3] = rgb; + } else if (rotation == 2) { + dst[offset + 3] = rgb; + dst[offset + 3 + 512] = rgb; + dst[offset + 3 + 1024] = rgb; + dst[offset + 3 + 1536] = rgb; + } else if (rotation == 3) { + dst[offset + 1536] = rgb; + dst[offset + 1536 + 1] = rgb; + dst[offset + 1536 + 2] = rgb; + dst[offset + 1536 + 3] = rgb; } } - if (i3 == 3) { - if (k2 == 0) { - ai[k4] = k3; - } else if (k2 == 1) { - ai[k4 + 3] = k3; - } else if (k2 == 2) { - ai[k4 + 3 + 1536] = k3; - } else if (k2 == 3) { - ai[k4 + 1536] = k3; + if (kind == 3) { + if (rotation == 0) { + dst[offset] = rgb; + } else if (rotation == 1) { + dst[offset + 3] = rgb; + } else if (rotation == 2) { + dst[offset + 3 + 1536] = rgb; + } else if (rotation == 3) { + dst[offset + 1536] = rgb; } } - if (i3 == 2) { - if (k2 == 3) { - ai[k4] = k3; - ai[k4 + 512] = k3; - ai[k4 + 1024] = k3; - ai[k4 + 1536] = k3; - } else if (k2 == 0) { - ai[k4] = k3; - ai[k4 + 1] = k3; - ai[k4 + 2] = k3; - ai[k4 + 3] = k3; - } else if (k2 == 1) { - ai[k4 + 3] = k3; - ai[k4 + 3 + 512] = k3; - ai[k4 + 3 + 1024] = k3; - ai[k4 + 3 + 1536] = k3; - } else if (k2 == 2) { - ai[k4 + 1536] = k3; - ai[k4 + 1536 + 1] = k3; - ai[k4 + 1536 + 2] = k3; - ai[k4 + 1536 + 3] = k3; + if (kind == 2) { + if (rotation == 3) { + dst[offset] = rgb; + dst[offset + 512] = rgb; + dst[offset + 1024] = rgb; + dst[offset + 1536] = rgb; + } else if (rotation == 0) { + dst[offset] = rgb; + dst[offset + 1] = rgb; + dst[offset + 2] = rgb; + dst[offset + 3] = rgb; + } else if (rotation == 1) { + dst[offset + 3] = rgb; + dst[offset + 3 + 512] = rgb; + dst[offset + 3 + 1024] = rgb; + dst[offset + 3 + 1536] = rgb; + } else if (rotation == 2) { + dst[offset + 1536] = rgb; + dst[offset + 1536 + 1] = rgb; + dst[offset + 1536 + 2] = rgb; + dst[offset + 1536 + 3] = rgb; } } } } - k1 = scene.getLocBitset(j1, l, i); - if (k1 != 0) { - int i2 = scene.getInfo(j1, l, i, k1); - int l2 = (i2 >> 6) & 3; - int j3 = i2 & 0x1f; - int l3 = (k1 >> 14) & 0x7fff; - LocType type_1 = LocType.get(l3); - if (type_1.mapsceneIcon != -1) { - Image8 class30_sub2_sub1_sub2_1 = imageMapscene[type_1.mapsceneIcon]; - if (class30_sub2_sub1_sub2_1 != null) { - int j5 = ((type_1.width * 4) - class30_sub2_sub1_sub2_1.width) / 2; - int k5 = ((type_1.length * 4) - class30_sub2_sub1_sub2_1.height) / 2; - class30_sub2_sub1_sub2_1.blit(48 + (l * 4) + j5, 48 + ((104 - i - type_1.length) * 4) + k5); - } - } else if (j3 == 9) { - int l4 = 0xeeeeee; - if (k1 > 0) { - l4 = 0xee0000; - } - int[] ai1 = imageMinimap.pixels; - int l5 = 24624 + (l * 4) + ((103 - i) * 512 * 4); - if ((l2 == 0) || (l2 == 2)) { - ai1[l5 + 1536] = l4; - ai1[l5 + 1024 + 1] = l4; - ai1[l5 + 512 + 2] = l4; - ai1[l5 + 3] = l4; - } else { - ai1[l5] = l4; - ai1[l5 + 512 + 1] = l4; - ai1[l5 + 1024 + 2] = l4; - ai1[l5 + 1536 + 3] = l4; - } - } - } - k1 = scene.getGroundDecorationBitset(j1, l, i); - if (k1 != 0) { - int j2 = (k1 >> 14) & 0x7fff; - LocType type = LocType.get(j2); + + bitset = scene.getLocBitset(plane, x, z); + + if (bitset != 0) { + 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); + if (type.mapsceneIcon != -1) { - Image8 image = imageMapscene[type.mapsceneIcon]; - if (image != null) { - int i4 = ((type.width * 4) - image.width) / 2; - int j4 = ((type.length * 4) - image.height) / 2; - image.blit(48 + (l * 4) + i4, 48 + ((104 - i - type.length) * 4) + j4); + Image8 icon = imageMapscene[type.mapsceneIcon]; + + if (icon != null) { + int offsetX = ((type.width * 4) - icon.width) / 2; + int offsetY = ((type.length * 4) - icon.height) / 2; + icon.blit(48 + (x * 4) + offsetX, 48 + ((104 - z - type.length) * 4) + offsetY); + } + } else if (kind == 9) { + int rgb = 0xEEEEEE; + + if (bitset > 0) { + rgb = 0xEE0000; + } + + int[] dst = imageMinimap.pixels; + int offset = 24624 + (x * 4) + ((103 - z) * 512 * 4); + + if ((rotation == 0) || (rotation == 2)) { + dst[offset + 1536] = rgb; + dst[offset + 1024 + 1] = rgb; + dst[offset + 512 + 2] = rgb; + dst[offset + 3] = rgb; + } else { + dst[offset] = rgb; + dst[offset + 512 + 1] = rgb; + dst[offset + 1024 + 2] = rgb; + dst[offset + 1536 + 3] = rgb; + } + } + } + + bitset = scene.getGroundDecorationBitset(plane, x, z); + + if (bitset != 0) { + int typeID = (bitset >> 14) & 0x7fff; + LocType type = LocType.get(typeID); + + if (type.mapsceneIcon != -1) { + Image8 icon = imageMapscene[type.mapsceneIcon]; + + if (icon != null) { + int offsetX = ((type.width * 4) - icon.width) / 2; + int offsetY = ((type.length * 4) - icon.height) / 2; + icon.blit(48 + (x * 4) + offsetX, 48 + ((104 - z - type.length) * 4) + offsetY); } } } @@ -3460,8 +3476,8 @@ public class Game extends GameShell { if (projectile.anInt1590 < 0) { int j = -projectile.anInt1590 - 1; PlayerEntity player; - if (j == selfPlayerId) { - player = self; + if (j == localPlayerID) { + player = localPlayer; } else { player = players[j]; } @@ -3711,7 +3727,7 @@ public class Game extends GameShell { idleTimeout--; } for (int j = 0; j < 5; j++) { - if (!method145()) { + if (!read()) { break; } } @@ -3826,13 +3842,13 @@ public class Game extends GameShell { out.put2(cameraPitch); out.put2A(cameraYaw); } - if (super.aBoolean17 && !aBoolean954) { - aBoolean954 = true; + if (super.focused && !_focused) { + _focused = true; out.putOp(3); out.put1(1); } - if (!super.aBoolean17 && aBoolean954) { - aBoolean954 = false; + if (!super.focused && _focused) { + _focused = false; out.putOp(3); out.put1(0); } @@ -3943,7 +3959,7 @@ public class Game extends GameShell { if (Scene.anInt470 != -1) { int k = Scene.anInt470; int k1 = Scene.anInt471; - boolean flag = tryMove(0, self.pathTileX[0], self.pathTileZ[0], k, k1, 0, 0, 0, 0, 0, true); + boolean flag = tryMove(0, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], k, k1, 0, 0, 0, 0, 0, true); Scene.anInt470 = -1; if (flag) { crossX = super.mousePressX; @@ -4011,11 +4027,11 @@ public class Game extends GameShell { } public void method63() { - SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.peekFront(); - for (; loc != null; loc = (SceneLocTemporary) listTemporaryLocs.prev()) { + SceneLocTemporary loc = (SceneLocTemporary) temporaryLocs.peekFront(); + for (; loc != null; loc = (SceneLocTemporary) temporaryLocs.prev()) { if (loc.anInt1294 == -1) { loc.anInt1302 = 0; - method89(loc); + storeLoc(loc); } else { loc.unlink(); } @@ -4121,9 +4137,9 @@ public class Game extends GameShell { if (angle != 0) { interactionFlags = ((interactionFlags << angle) & 0xf) + (interactionFlags >> (4 - angle)); } - tryMove(2, self.pathTileX[0], self.pathTileZ[0], x, z, 0, width, length, 0, interactionFlags, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], x, z, 0, width, length, 0, interactionFlags, false); } else { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], x, z, type + 1, 0, 0, angle, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], x, z, type + 1, 0, 0, angle, 0, false); } crossX = super.mousePressX; crossY = super.mousePressY; @@ -4297,7 +4313,7 @@ public class Game extends GameShell { if (action == 582) { NPCEntity npc = npcs[c]; if (npc != null) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], npc.pathTileX[0], npc.pathTileZ[0], 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], npc.pathTileX[0], npc.pathTileZ[0], 0, 1, 1, 0, 0, false); crossX = super.mousePressX; crossY = super.mousePressY; crossMode = 2; @@ -4310,9 +4326,9 @@ public class Game extends GameShell { } } if (action == 234) { - boolean flag1 = tryMove(2, self.pathTileX[0], self.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); + boolean flag1 = tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); if (!flag1) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], a, b, 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 1, 1, 0, 0, false); } crossX = super.mousePressX; crossY = super.mousePressY; @@ -4333,9 +4349,9 @@ public class Game extends GameShell { out.put2(anInt1285); } if (action == 511) { - boolean flag2 = tryMove(2, self.pathTileX[0], self.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); + boolean flag2 = tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); if (!flag2) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], a, b, 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 1, 1, 0, 0, false); } crossX = super.mousePressX; crossY = super.mousePressY; @@ -4379,7 +4395,7 @@ public class Game extends GameShell { if (action == 561) { PlayerEntity player = players[c]; if (player != null) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], player.pathTileX[0], player.pathTileZ[0], 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], player.pathTileX[0], player.pathTileZ[0], 0, 1, 1, 0, 0, false); crossX = super.mousePressX; crossY = super.mousePressY; crossMode = 2; @@ -4391,7 +4407,7 @@ public class Game extends GameShell { if (action == 20) { NPCEntity class30_sub2_sub4_sub1_sub1_1 = npcs[c]; if (class30_sub2_sub4_sub1_sub1_1 != null) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], class30_sub2_sub4_sub1_sub1_1.pathTileX[0], class30_sub2_sub4_sub1_sub1_1.pathTileZ[0], 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], class30_sub2_sub4_sub1_sub1_1.pathTileX[0], class30_sub2_sub4_sub1_sub1_1.pathTileZ[0], 0, 1, 1, 0, 0, false); crossX = super.mousePressX; crossY = super.mousePressY; crossMode = 2; @@ -4403,7 +4419,7 @@ public class Game extends GameShell { if (action == 779) { PlayerEntity class30_sub2_sub4_sub1_sub2_1 = players[c]; if (class30_sub2_sub4_sub1_sub2_1 != null) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], class30_sub2_sub4_sub1_sub2_1.pathTileX[0], class30_sub2_sub4_sub1_sub2_1.pathTileZ[0], 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], class30_sub2_sub4_sub1_sub2_1.pathTileX[0], class30_sub2_sub4_sub1_sub2_1.pathTileZ[0], 0, 1, 1, 0, 0, false); crossX = super.mousePressX; crossY = super.mousePressY; crossMode = 2; @@ -4510,7 +4526,7 @@ public class Game extends GameShell { if ((player_7 == null) || (player_7.name == null) || !player_7.name.equalsIgnoreCase(s7)) { continue; } - tryMove(2, self.pathTileX[0], self.pathTileZ[0], player_7.pathTileX[0], player_7.pathTileZ[0], 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], player_7.pathTileX[0], player_7.pathTileZ[0], 0, 1, 1, 0, 0, false); if (action == 484) { out.putOp(139); out.put2LE(playerIndices[j3]); @@ -4611,7 +4627,7 @@ public class Game extends GameShell { if (action == 27) { PlayerEntity class30_sub2_sub4_sub1_sub2_2 = players[c]; if (class30_sub2_sub4_sub1_sub2_2 != null) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], class30_sub2_sub4_sub1_sub2_2.pathTileX[0], class30_sub2_sub4_sub1_sub2_2.pathTileZ[0], 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], class30_sub2_sub4_sub1_sub2_2.pathTileX[0], class30_sub2_sub4_sub1_sub2_2.pathTileZ[0], 0, 1, 1, 0, 0, false); crossX = super.mousePressX; crossY = super.mousePressY; crossMode = 2; @@ -4621,9 +4637,9 @@ public class Game extends GameShell { } } if (action == 213) { - boolean flag3 = tryMove(2, self.pathTileX[0], self.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); + boolean flag3 = tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); if (!flag3) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], a, b, 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 1, 1, 0, 0, false); } crossX = super.mousePressX; crossY = super.mousePressY; @@ -4667,9 +4683,9 @@ public class Game extends GameShell { } } if (action == 652) { - boolean flag4 = tryMove(2, self.pathTileX[0], self.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); + boolean flag4 = tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); if (!flag4) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], a, b, 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 1, 1, 0, 0, false); } crossX = super.mousePressX; crossY = super.mousePressY; @@ -4681,9 +4697,9 @@ public class Game extends GameShell { out.put2LEA(c); } if (action == 94) { - boolean flag5 = tryMove(2, self.pathTileX[0], self.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); + boolean flag5 = tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); if (!flag5) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], a, b, 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 1, 1, 0, 0, false); } crossX = super.mousePressX; crossY = super.mousePressY; @@ -4711,7 +4727,7 @@ public class Game extends GameShell { if (action == 225) { NPCEntity class30_sub2_sub4_sub1_sub1_2 = npcs[c]; if (class30_sub2_sub4_sub1_sub1_2 != null) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], class30_sub2_sub4_sub1_sub1_2.pathTileX[0], class30_sub2_sub4_sub1_sub1_2.pathTileZ[0], 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], class30_sub2_sub4_sub1_sub1_2.pathTileX[0], class30_sub2_sub4_sub1_sub1_2.pathTileZ[0], 0, 1, 1, 0, 0, false); crossX = super.mousePressX; crossY = super.mousePressY; crossMode = 2; @@ -4723,7 +4739,7 @@ public class Game extends GameShell { if (action == 965) { NPCEntity npc_3 = npcs[c]; if (npc_3 != null) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], npc_3.pathTileX[0], npc_3.pathTileZ[0], 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], npc_3.pathTileX[0], npc_3.pathTileZ[0], 0, 1, 1, 0, 0, false); crossX = super.mousePressX; crossY = super.mousePressY; crossMode = 2; @@ -4735,7 +4751,7 @@ public class Game extends GameShell { if (action == 413) { NPCEntity class30_sub2_sub4_sub1_sub1_4 = npcs[c]; if (class30_sub2_sub4_sub1_sub1_4 != null) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], class30_sub2_sub4_sub1_sub1_4.pathTileX[0], class30_sub2_sub4_sub1_sub1_4.pathTileZ[0], 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], class30_sub2_sub4_sub1_sub1_4.pathTileX[0], class30_sub2_sub4_sub1_sub1_4.pathTileZ[0], 0, 1, 1, 0, 0, false); crossX = super.mousePressX; crossY = super.mousePressY; crossMode = 2; @@ -4776,7 +4792,7 @@ public class Game extends GameShell { if (action == 412) { NPCEntity npc_6 = npcs[c]; if (npc_6 != null) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], npc_6.pathTileX[0], npc_6.pathTileZ[0], 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], npc_6.pathTileX[0], npc_6.pathTileZ[0], 0, 1, 1, 0, 0, false); crossX = super.mousePressX; crossY = super.mousePressY; crossMode = 2; @@ -4788,7 +4804,7 @@ public class Game extends GameShell { if (action == 365) { PlayerEntity player_3 = players[c]; if (player_3 != null) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], player_3.pathTileX[0], player_3.pathTileZ[0], 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], player_3.pathTileX[0], player_3.pathTileZ[0], 0, 1, 1, 0, 0, false); crossX = super.mousePressX; crossY = super.mousePressY; crossMode = 2; @@ -4801,7 +4817,7 @@ public class Game extends GameShell { if (action == 729) { PlayerEntity class30_sub2_sub4_sub1_sub2_4 = players[c]; if (class30_sub2_sub4_sub1_sub2_4 != null) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], class30_sub2_sub4_sub1_sub2_4.pathTileX[0], class30_sub2_sub4_sub1_sub2_4.pathTileZ[0], 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], class30_sub2_sub4_sub1_sub2_4.pathTileX[0], class30_sub2_sub4_sub1_sub2_4.pathTileZ[0], 0, 1, 1, 0, 0, false); crossX = super.mousePressX; crossY = super.mousePressY; crossMode = 2; @@ -4813,7 +4829,7 @@ public class Game extends GameShell { if (action == 577) { PlayerEntity player_5 = players[c]; if (player_5 != null) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], player_5.pathTileX[0], player_5.pathTileZ[0], 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], player_5.pathTileX[0], player_5.pathTileZ[0], 0, 1, 1, 0, 0, false); crossX = super.mousePressX; crossY = super.mousePressY; crossMode = 2; @@ -4830,9 +4846,9 @@ public class Game extends GameShell { out.put2LE((c >> 14) & 0x7fff); } if (action == 567) { - boolean flag6 = tryMove(2, self.pathTileX[0], self.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); + boolean flag6 = tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); if (!flag6) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], a, b, 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 1, 1, 0, 0, false); } crossX = super.mousePressX; crossY = super.mousePressY; @@ -4899,7 +4915,7 @@ public class Game extends GameShell { if (action == 491) { PlayerEntity player_6 = players[c]; if (player_6 != null) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], player_6.pathTileX[0], player_6.pathTileZ[0], 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], player_6.pathTileX[0], player_6.pathTileZ[0], 0, 1, 1, 0, 0, false); crossX = super.mousePressX; crossY = super.mousePressY; crossMode = 2; @@ -4954,7 +4970,7 @@ public class Game extends GameShell { if (action == 478) { NPCEntity npc_7 = npcs[c]; if (npc_7 != null) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], npc_7.pathTileX[0], npc_7.pathTileZ[0], 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], npc_7.pathTileX[0], npc_7.pathTileZ[0], 0, 1, 1, 0, 0, false); crossX = super.mousePressX; crossY = super.mousePressY; crossMode = 2; @@ -5030,9 +5046,9 @@ public class Game extends GameShell { method77(0, "", s10); } if (action == 244) { - boolean flag7 = tryMove(2, self.pathTileX[0], self.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); + boolean flag7 = tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 0, 0, 0, 0, false); if (!flag7) { - tryMove(2, self.pathTileX[0], self.pathTileZ[0], a, b, 0, 1, 1, 0, 0, false); + tryMove(2, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], a, b, 0, 1, 1, 0, 0, false); } crossX = super.mousePressX; crossY = super.mousePressY; @@ -5060,8 +5076,8 @@ public class Game extends GameShell { public void method70() { anInt1251 = 0; - int j = (self.x >> 7) + sceneBaseTileX; - int k = (self.z >> 7) + sceneBaseTileZ; + int j = (localPlayer.x >> 7) + sceneBaseTileX; + int k = (localPlayer.z >> 7) + sceneBaseTileZ; if ((j >= 3053) && (j <= 3156) && (k >= 3056) && (k <= 3136)) { anInt1251 = 1; } @@ -5082,28 +5098,30 @@ public class Game extends GameShell { menuSize++; } int j = -1; - for (int k = 0; k < Model.pickedCount; k++) { - int l = Model.pickedBitsets[k]; - int i1 = l & 0x7f; - int j1 = (l >> 7) & 0x7f; - int k1 = (l >> 29) & 3; - int l1 = (l >> 14) & 0x7fff; - if (l == j) { + for (int i = 0; i < Model.pickedCount; i++) { + int bitset = Model.pickedBitsets[i]; + int i1 = bitset & 0x7f; + int j1 = (bitset >> 7) & 0x7f; + int k1 = (bitset >> 29) & 3; + int locID = (bitset >> 14) & 0x7fff; + if (bitset == j) { continue; } - j = l; - if ((k1 == 2) && (scene.getInfo(currentPlane, i1, j1, l) >= 0)) { - LocType type = LocType.get(l1); - if (type.overrideIds != null) { - type = type.method580(); + j = bitset; + if ((k1 == 2) && (scene.getInfo(currentPlane, i1, j1, bitset) >= 0)) { + LocType type = LocType.get(locID); + + if (type.overrideTypeIDs != null) { + type = type.getOverrideType(); } + if (type == null) { continue; } if (anInt1282 == 1) { menuOption[menuSize] = "Use " + aString1286 + " with @cya@" + type.name; menuAction[menuSize] = 62; - menuParamC[menuSize] = l; + menuParamC[menuSize] = bitset; menuParamA[menuSize] = i1; menuParamB[menuSize] = j1; menuSize++; @@ -5111,7 +5129,7 @@ public class Game extends GameShell { if ((activeSpellFlags & 4) == 4) { menuOption[menuSize] = spellCaption + " @cya@" + type.name; menuAction[menuSize] = 956; - menuParamC[menuSize] = l; + menuParamC[menuSize] = bitset; menuParamA[menuSize] = i1; menuParamB[menuSize] = j1; menuSize++; @@ -5136,7 +5154,7 @@ public class Game extends GameShell { if (i2 == 4) { menuAction[menuSize] = 1062; } - menuParamC[menuSize] = l; + menuParamC[menuSize] = bitset; menuParamA[menuSize] = i1; menuParamB[menuSize] = j1; menuSize++; @@ -5152,7 +5170,7 @@ public class Game extends GameShell { } } if (k1 == 1) { - NPCEntity npc = npcs[l1]; + 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]]; @@ -5167,10 +5185,10 @@ public class Game extends GameShell { } } } - method87(npc.type, l1, j1, i1); + method87(npc.type, locID, j1, i1); } if (k1 == 0) { - PlayerEntity player = players[l1]; + 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]]; @@ -5185,7 +5203,7 @@ public class Game extends GameShell { } } } - method88(i1, l1, player, j1); + method88(i1, locID, player, j1); } if (k1 == 3) { DoublyLinkedList list = planeObjStacks[currentPlane][i1][j1]; @@ -5488,16 +5506,16 @@ public class Game extends GameShell { out.putSize1(out.position - j3); chatTyped = ChatCompression.method527(chatTyped); chatTyped = Censor.method497(chatTyped, 0); - self.chat = chatTyped; - self.chatColor = j2; - self.chatStyle = i3; - self.chatTimer = 150; + localPlayer.chat = chatTyped; + localPlayer.chatColor = j2; + localPlayer.chatStyle = i3; + localPlayer.chatTimer = 150; if (rights == 2) { - method77(2, "@cr2@" + self.name, self.chat); + method77(2, "@cr2@" + localPlayer.name, localPlayer.chat); } else if (rights == 1) { - method77(2, "@cr1@" + self.name, self.chat); + method77(2, "@cr1@" + localPlayer.name, localPlayer.chat); } else { - method77(2, self.name, self.chat); + method77(2, localPlayer.name, localPlayer.chat); } if (publicChatSetting == 2) { publicChatSetting = 3; @@ -5537,7 +5555,7 @@ public class Game extends GameShell { l++; } if (((j1 == 1) || (j1 == 2)) && ((j1 == 1) || (publicChatSetting == 0) || ((publicChatSetting == 1) && isFriend(s)))) { - if ((j > (k1 - 14)) && (j <= k1) && !s.equals(self.name)) { + if ((j > (k1 - 14)) && (j <= k1) && !s.equals(localPlayer.name)) { if (rights >= 1) { menuOption[menuSize] = "Report abuse @whi@" + s; menuAction[menuSize] = 606; @@ -5728,10 +5746,10 @@ public class Game extends GameShell { } } model.createLabelReferences(); - model.applySequenceFrame(SeqType.instances[self.seqStand].primaryFrames[0]); + model.applySequenceFrame(SeqType.instances[localPlayer.seqStand].primaryFrames[0]); model.calculateNormals(64, 850, -30, -50, -30, true); - component.modelType = 5; - component.modelTypeId = 0; + component.modelCategory = 5; + component.modelID = 0; Component.cacheModel(0, 5, model); } return; @@ -6231,8 +6249,8 @@ public class Game extends GameShell { aLong1220 = 0L; anInt1022 = 0; mouseRecorder.anInt810 = 0; - super.aBoolean17 = true; - aBoolean954 = true; + super.focused = true; + _focused = true; ingame = true; out.position = 0; in.position = 0; @@ -6274,7 +6292,7 @@ public class Game extends GameShell { for (int k2 = 0; k2 < 16384; k2++) { npcs[k2] = null; } - self = players[LOCAL_PLAYER_INDEX] = new PlayerEntity(); + localPlayer = players[LOCAL_PLAYER_INDEX] = new PlayerEntity(); aList_1013.clear(); aList_1056.clear(); for (int l2 = 0; l2 < 4; l2++) { @@ -6284,7 +6302,7 @@ public class Game extends GameShell { } } } - listTemporaryLocs = new DoublyLinkedList(); + temporaryLocs = new DoublyLinkedList(); socialState = 0; friendCount = 0; stickyChatbackComponentId = -1; @@ -6768,7 +6786,7 @@ public class Game extends GameShell { } String s = type.name; if (type.anInt61 != 0) { - s = s + method110(self.combatLevel, type.anInt61) + " (level-" + type.anInt61 + ")"; + s = s + method110(localPlayer.combatLevel, type.anInt61) + " (level-" + type.anInt61 + ")"; } if (anInt1282 == 1) { menuOption[menuSize] = "Use " + aString1286 + " with @yel@" + s; @@ -6819,7 +6837,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 > self.combatLevel) { + if (type.anInt61 > localPlayer.combatLevel) { c = '\u07D0'; } menuOption[menuSize] = type.op[i1] + " @yel@" + s; @@ -6855,7 +6873,7 @@ public class Game extends GameShell { } public void method88(int i, int j, PlayerEntity player, int k) { - if (player == self) { + if (player == localPlayer) { return; } if (menuSize >= 400) { @@ -6863,7 +6881,7 @@ public class Game extends GameShell { } String s; if (player.skillLevel == 0) { - s = player.name + method110(self.combatLevel, player.combatLevel) + " (level-" + player.combatLevel + ")"; + s = player.name + method110(localPlayer.combatLevel, player.combatLevel) + " (level-" + player.combatLevel + ")"; } else { s = player.name + " (skill-" + player.skillLevel + ")"; } @@ -6889,11 +6907,11 @@ public class Game extends GameShell { menuOption[menuSize] = aStringArray1127[l] + " @whi@" + s; char c = '\0'; if (aStringArray1127[l].equalsIgnoreCase("attack")) { - if (player.combatLevel > self.combatLevel) { + if (player.combatLevel > localPlayer.combatLevel) { c = '\u07D0'; } - if ((self.team != 0) && (player.team != 0)) { - if (self.team == player.team) { + if ((localPlayer.team != 0) && (player.team != 0)) { + if (localPlayer.team == player.team) { c = '\u07D0'; } else { c = '\0'; @@ -6932,32 +6950,32 @@ public class Game extends GameShell { } } - public void method89(SceneLocTemporary loc) { - int i = 0; - int j = -1; - int k = 0; - int l = 0; - if (loc.anInt1296 == 0) { - i = scene.getWallBitset(loc.anInt1295, loc.sceneTileX, loc.sceneTileZ); + public void storeLoc(SceneLocTemporary loc) { + int bitset = 0; + int locID = -1; + int kind = 0; + int rotation = 0; + if (loc.classID == 0) { + bitset = scene.getWallBitset(loc.plane, loc.localX, loc.localZ); } - if (loc.anInt1296 == 1) { - i = scene.getWallDecorationBitset(loc.anInt1295, loc.sceneTileX, loc.sceneTileZ); + if (loc.classID == 1) { + bitset = scene.getWallDecorationBitset(loc.plane, loc.localX, loc.localZ); } - if (loc.anInt1296 == 2) { - i = scene.getLocBitset(loc.anInt1295, loc.sceneTileX, loc.sceneTileZ); + if (loc.classID == 2) { + bitset = scene.getLocBitset(loc.plane, loc.localX, loc.localZ); } - if (loc.anInt1296 == 3) { - i = scene.getGroundDecorationBitset(loc.anInt1295, loc.sceneTileX, loc.sceneTileZ); + if (loc.classID == 3) { + bitset = scene.getGroundDecorationBitset(loc.plane, loc.localX, loc.localZ); } - if (i != 0) { - int i1 = scene.getInfo(loc.anInt1295, loc.sceneTileX, loc.sceneTileZ, i); - j = (i >> 14) & 0x7fff; - k = i1 & 0x1f; - l = i1 >> 6; + if (bitset != 0) { + int info = scene.getInfo(loc.plane, loc.localX, loc.localZ, bitset); + locID = (bitset >> 14) & 0x7fff; + kind = info & 0x1f; + rotation = info >> 6; } - loc.anInt1299 = j; - loc.anInt1301 = k; - loc.anInt1300 = l; + loc.savedLocID = locID; + loc.savedKind = kind; + loc.savedRotation = rotation; } public void updateAudio() { @@ -6968,12 +6986,12 @@ public class Game extends GameShell { boolean failed = false; try { - if ((waveId[i] == lastWaveId) && (waveLoops[i] == lastWaveLoops)) { + if ((waveIDs[i] == lastWaveId) && (waveLoops[i] == lastWaveLoops)) { if (!wavereplay()) { failed = true; } } else { - Buffer buffer = SoundTrack.generate(waveLoops[i], waveId[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 @@ -6982,7 +7000,7 @@ public class Game extends GameShell { lastWaveStartTime = System.currentTimeMillis(); if (wavesave(buffer.data, buffer.position)) { - lastWaveId = waveId[i]; + lastWaveId = waveIDs[i]; lastWaveLoops = waveLoops[i]; } else { failed = true; @@ -6995,7 +7013,7 @@ public class Game extends GameShell { if (!failed || (waveDelay[i] == -5)) { waveCount--; for (int j = i; j < waveCount; j++) { - waveId[j] = waveId[j + 1]; + waveIDs[j] = waveIDs[j + 1]; waveLoops[j] = waveLoops[j + 1]; waveDelay[j] = waveDelay[j + 1]; } @@ -7047,7 +7065,7 @@ public class Game extends GameShell { if (j1 > 15) { j1 -= 32; } - player.move(self.pathTileX[0] + j1, self.pathTileZ[0] + i1, l == 1); + player.move(localPlayer.pathTileX[0] + j1, localPlayer.pathTileZ[0] + i1, l == 1); } buffer.accessBytes(); } @@ -7069,9 +7087,9 @@ public class Game extends GameShell { j1 = (j1 * (minimapZoom + 256)) >> 8; int k1 = ((j * i1) + (i * j1)) >> 11; int l1 = ((j * j1) - (i * i1)) >> 11; - int i2 = (self.x + k1) >> 7; - int j2 = (self.z - l1) >> 7; - boolean flag1 = tryMove(1, self.pathTileX[0], self.pathTileZ[0], i2, j2, 0, 0, 0, 0, 0, true); + int i2 = (localPlayer.x + k1) >> 7; + int j2 = (localPlayer.z - l1) >> 7; + boolean flag1 = tryMove(1, localPlayer.pathTileX[0], localPlayer.pathTileZ[0], i2, j2, 0, 0, 0, 0, 0, true); if (flag1) { out.put1(i); out.put1(j); @@ -7080,8 +7098,8 @@ public class Game extends GameShell { out.put1(minimapAnticheatAngle); out.put1(minimapZoom); out.put1(89); - out.put2(self.x); - out.put2(self.z); + out.put2(localPlayer.x); + out.put2(localPlayer.z); out.put1(tryMoveNearest); out.put1(63); } @@ -7169,7 +7187,7 @@ public class Game extends GameShell { entity.z = (entity.pathTileZ[0] * 128) + (entity.size * 64); entity.method446(); } - if ((entity == self) && ((entity.x < 1536) || (entity.z < 1536) || (entity.x >= 11776) || (entity.z >= 11776))) { + if ((entity == localPlayer) && ((entity.x < 1536) || (entity.z < 1536) || (entity.x >= 11776) || (entity.z >= 11776))) { entity.anInt1526 = -1; entity.spotanim = -1; entity.forceMoveEndCycle = 0; @@ -7404,7 +7422,7 @@ public class Game extends GameShell { if (e.index >= 32768) { int index = e.index - 32768; - if (index == selfPlayerId) { + if (index == localPlayerID) { index = LOCAL_PLAYER_INDEX; } @@ -7507,7 +7525,7 @@ public class Game extends GameShell { } if (e.anInt1527 >= seq.frameCount) { - e.anInt1527 -= seq.anInt356; + e.anInt1527 -= seq.speed; e.anInt1530++; if (e.anInt1530 >= seq.anInt362) { @@ -8240,7 +8258,7 @@ public class Game extends GameShell { if (player.chat.charAt(0) == '~') { player.chat = player.chat.substring(1); method77(2, player.name, player.chat); - } else if (player == self) { + } else if (player == localPlayer) { method77(2, player.name, player.chat); } player.chatColor = 0; @@ -8326,8 +8344,8 @@ public class Game extends GameShell { } public void method108() { - int focusX = self.x + cameraAnticheatOffsetX; - int focusZ = self.z + cameraAnticheatOffsetZ; + int focusX = localPlayer.x + cameraAnticheatOffsetX; + int focusZ = localPlayer.z + cameraAnticheatOffsetZ; if (((cameraFocusX - focusX) < -500) || ((cameraFocusX - focusX) > 500) || ((cameraFocusZ - focusZ) < -500) || ((cameraFocusZ - focusZ) > 500)) { cameraFocusX = focusX; @@ -8416,7 +8434,7 @@ public class Game extends GameShell { return true; } } - return name.equalsIgnoreCase(self.name); + return name.equalsIgnoreCase(localPlayer.name); } public void method111(int i) { @@ -8525,25 +8543,25 @@ public class Game extends GameShell { public void method115() { if (sceneState == 2) { - for (SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.peekFront(); loc != null; loc = (SceneLocTemporary) listTemporaryLocs.prev()) { + for (SceneLocTemporary loc = (SceneLocTemporary) temporaryLocs.peekFront(); loc != null; loc = (SceneLocTemporary) temporaryLocs.prev()) { if (loc.anInt1294 > 0) { loc.anInt1294--; } if (loc.anInt1294 == 0) { - if ((loc.anInt1299 < 0) || SceneBuilder.method178(loc.anInt1299, loc.anInt1301)) { - method142(loc.sceneTileZ, loc.anInt1295, loc.anInt1300, loc.anInt1301, loc.sceneTileX, loc.anInt1296, loc.anInt1299); + 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 { if (loc.anInt1302 > 0) { loc.anInt1302--; } - if ((loc.anInt1302 == 0) && (loc.sceneTileX >= 1) && (loc.sceneTileZ >= 1) && (loc.sceneTileX <= 102) && (loc.sceneTileZ <= 102) && ((loc.anInt1291 < 0) || SceneBuilder.method178(loc.anInt1291, loc.anInt1293))) { - method142(loc.sceneTileZ, loc.anInt1295, loc.anInt1292, loc.anInt1293, loc.sceneTileX, loc.anInt1296, loc.anInt1291); + 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); loc.anInt1302 = -1; - if ((loc.anInt1291 == loc.anInt1299) && (loc.anInt1299 == -1)) { + if ((loc.anInt1291 == loc.savedLocID) && (loc.savedLocID == -1)) { loc.unlink(); - } else if ((loc.anInt1291 == loc.anInt1299) && (loc.anInt1292 == loc.anInt1300) && (loc.anInt1293 == loc.anInt1301)) { + } else if ((loc.anInt1291 == loc.savedLocID) && (loc.anInt1292 == loc.savedRotation) && (loc.anInt1293 == loc.savedKind)) { loc.unlink(); } } @@ -8639,7 +8657,7 @@ public class Game extends GameShell { } if (k == 1) { int l = buffer.getBits(3); - self.method448(false, l); + localPlayer.method448(false, l); int k1 = buffer.getBits(1); if (k1 == 1) { anIntArray894[anInt893++] = LOCAL_PLAYER_INDEX; @@ -8648,9 +8666,9 @@ public class Game extends GameShell { } if (k == 2) { int i1 = buffer.getBits(3); - self.method448(true, i1); + localPlayer.method448(true, i1); int l1 = buffer.getBits(3); - self.method448(true, l1); + localPlayer.method448(true, l1); int j2 = buffer.getBits(1); if (j2 == 1) { anIntArray894[anInt893++] = LOCAL_PLAYER_INDEX; @@ -8666,7 +8684,7 @@ public class Game extends GameShell { } int k2 = buffer.getBits(7); int l2 = buffer.getBits(7); - self.move(l2, k2, j1 == 1); + localPlayer.move(l2, k2, j1 == 1); } } @@ -8733,7 +8751,7 @@ public class Game extends GameShell { child.seqCycle -= type.getFrameDelay(child.seqFrame) + 1; child.seqFrame++; if (child.seqFrame >= type.frameCount) { - child.seqFrame -= type.anInt356; + child.seqFrame -= type.speed; if ((child.seqFrame < 0) || (child.seqFrame >= type.frameCount)) { child.seqFrame = 0; } @@ -8751,8 +8769,8 @@ public class Game extends GameShell { if (anInt861 < 310) { int k = anInt858 >> 7; int l = anInt860 >> 7; - int i1 = self.x >> 7; - int j1 = self.z >> 7; + int i1 = localPlayer.x >> 7; + int j1 = localPlayer.z >> 7; if ((planeTileFlags[currentPlane][k][l] & 4) != 0) { j = currentPlane; } @@ -8820,7 +8838,7 @@ public class Game extends GameShell { } } } - if ((planeTileFlags[currentPlane][self.x >> 7][self.z >> 7] & 4) != 0) { + if ((planeTileFlags[currentPlane][localPlayer.x >> 7][localPlayer.z >> 7] & 4) != 0) { j = currentPlane; } return j; @@ -8900,7 +8918,7 @@ public class Game extends GameShell { } else if (op == 7) { reg = (variables[script[pos++]] * 100) / 46875; } else if (op == 8) { // load_combat_level - reg = self.combatLevel; + reg = localPlayer.combatLevel; } else if (op == 9) { // load_total_level for (int skill = 0; skill < Skill.COUNT; skill++) { if (Skill.ENABLED[skill]) { @@ -8938,9 +8956,9 @@ public class Game extends GameShell { } else if (op == 17) { // mul nextArithmetic = 3; } else if (op == 18) { // load_world_x - reg = (self.x >> 7) + sceneBaseTileX; + reg = (localPlayer.x >> 7) + sceneBaseTileX; } else if (op == 19) { // load_world_z - reg = (self.z >> 7) + sceneBaseTileZ; + reg = (localPlayer.z >> 7) + sceneBaseTileZ; } else if (op == 20) { // load {value} reg = script[pos++]; } @@ -9003,15 +9021,15 @@ public class Game extends GameShell { } int angle = (cameraYaw + minimapAnticheatAngle) & 0x7ff; - int anchorX = 48 + (self.x / 32); - int anchorY = 464 - (self.z / 32); + int anchorX = 48 + (localPlayer.x / 32); + int anchorY = 464 - (localPlayer.z / 32); imageMinimap.drawRotatedMasked(25, 5, 146, 151, anchorX, anchorY, 256 + minimapZoom, angle, minimapMaskLineLengths, minimapMaskLineOffsets); imageCompass.drawRotatedMasked(0, 0, 33, 33, 25, 25, 256, cameraYaw, compassMaskLineLengths, compassMaskLineOffsets); for (int i = 0; i < activeMapFunctionCount; i++) { - int x = ((activeMapFunctionX[i] * 4) + 2) - (self.x / 32); - int y = ((activeMapFunctionZ[i] * 4) + 2) - (self.z / 32); + int x = ((activeMapFunctionX[i] * 4) + 2) - (localPlayer.x / 32); + int y = ((activeMapFunctionZ[i] * 4) + 2) - (localPlayer.z / 32); drawOnMinimap(activeMapFunctions[i], x, y); } @@ -9020,8 +9038,8 @@ public class Game extends GameShell { DoublyLinkedList stack = planeObjStacks[currentPlane][ltx][ltz]; if (stack != null) { - int x = ((ltx * 4) + 2) - (self.x / 32); - int y = ((ltz * 4) + 2) - (self.z / 32); + int x = ((ltx * 4) + 2) - (localPlayer.x / 32); + int y = ((ltz * 4) + 2) - (localPlayer.z / 32); drawOnMinimap(imageMapdot0, x, y); } } @@ -9037,8 +9055,8 @@ public class Game extends GameShell { type = type.getOverrideType(); } if ((type != null) && type.aBoolean87 && type.aBoolean84) { - int x = (npc.x / 32) - (self.x / 32); - int y = (npc.z / 32) - (self.z / 32); + int x = (npc.x / 32) - (localPlayer.x / 32); + int y = (npc.z / 32) - (localPlayer.z / 32); drawOnMinimap(imageMapdot1, x, y); } } @@ -9050,8 +9068,8 @@ public class Game extends GameShell { continue; } - int x = (player.x / 32) - (self.x / 32); - int y = (player.z / 32) - (self.z / 32); + int x = (player.x / 32) - (localPlayer.x / 32); + int y = (player.z / 32) - (localPlayer.z / 32); boolean friend = false; long name37 = StringUtil.toBase37(player.name); @@ -9063,7 +9081,7 @@ public class Game extends GameShell { break; } - boolean team = (player.team != 0) && (self.team == player.team); + boolean team = (player.team != 0) && (localPlayer.team == player.team); if (friend) { drawOnMinimap(imageMapdot3, x, y); @@ -9078,30 +9096,30 @@ public class Game extends GameShell { if ((hintType == 1) && (hintNPC >= 0) && (hintNPC < npcs.length)) { NPCEntity npc = npcs[hintNPC]; if (npc != null) { - int x = (npc.x / 32) - (self.x / 32); - int y = (npc.z / 32) - (self.z / 32); + int x = (npc.x / 32) - (localPlayer.x / 32); + int y = (npc.z / 32) - (localPlayer.z / 32); drawMinimapHint(imageMapmarker1, x, y); } } if (hintType == 2) { - int x = (((hintTileX - sceneBaseTileX) * 4) + 2) - (self.x / 32); - int y = (((hintTileZ - sceneBaseTileZ) * 4) + 2) - (self.z / 32); + int x = (((hintTileX - sceneBaseTileX) * 4) + 2) - (localPlayer.x / 32); + int y = (((hintTileZ - sceneBaseTileZ) * 4) + 2) - (localPlayer.z / 32); drawMinimapHint(imageMapmarker1, x, y); } if ((hintType == 10) && (hintPlayer >= 0) && (hintPlayer < players.length)) { PlayerEntity player = players[hintPlayer]; if (player != null) { - int x = (player.x / 32) - (self.x / 32); - int z = (player.z / 32) - (self.z / 32); + int x = (player.x / 32) - (localPlayer.x / 32); + int z = (player.z / 32) - (localPlayer.z / 32); drawMinimapHint(imageMapmarker1, x, z); } } } if (flagSceneTileX != 0) { - int j2 = ((flagSceneTileX * 4) + 2) - (self.x / 32); - int l4 = ((flagSceneTileZ * 4) + 2) - (self.z / 32); + int j2 = ((flagSceneTileX * 4) + 2) - (localPlayer.x / 32); + int l4 = ((flagSceneTileZ * 4) + 2) - (localPlayer.z / 32); drawOnMinimap(imageMapmarker0, j2, l4); } Draw2D.fillRect(97, 78, 3, 3, 0xffffff); @@ -9221,23 +9239,23 @@ public class Game extends GameShell { } } - public void method130(int j, int k, int l, int i1, int j1, int k1, int l1, int i2, int j2) { + 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 loc_1 = (SceneLocTemporary) listTemporaryLocs.peekFront(); loc_1 != null; loc_1 = (SceneLocTemporary) listTemporaryLocs.prev()) { - if ((loc_1.anInt1295 != l1) || (loc_1.sceneTileX != i2) || (loc_1.sceneTileZ != j1) || (loc_1.anInt1296 != i1)) { + 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)) { continue; } - loc = loc_1; + loc = other; break; } if (loc == null) { loc = new SceneLocTemporary(); - loc.anInt1295 = l1; - loc.anInt1296 = i1; - loc.sceneTileX = i2; - loc.sceneTileZ = j1; - method89(loc); - listTemporaryLocs.pushBack(loc); + loc.plane = plane; + loc.classID = classID; + loc.localX = x; + loc.localZ = z; + storeLoc(loc); + temporaryLocs.pushBack(loc); } loc.anInt1291 = k; loc.anInt1293 = k1; @@ -9485,10 +9503,10 @@ public class Game extends GameShell { } y += 30; - fontBold12.drawStringTaggable("Username: " + username + ((anInt1216 == 0) & (loopCycle % 40 < 20) ? "@yel@|" : ""), (w / 2) - 90, y, 0xffffff, true); + fontBold12.drawStringTaggable("Username: " + username + ((titleLoginField == 0) & (loopCycle % 40 < 20) ? "@yel@|" : ""), (w / 2) - 90, y, 0xffffff, true); y += 15; - fontBold12.drawStringTaggable("Password: " + StringUtil.toAsterisks(password) + ((anInt1216 == 1) & (loopCycle % 40 < 20) ? "@yel@|" : ""), (w / 2) - 88, y, 0xffffff, true); + fontBold12.drawStringTaggable("Password: " + StringUtil.toAsterisks(password) + ((titleLoginField == 1) & (loopCycle % 40 < 20) ? "@yel@|" : ""), (w / 2) - 88, y, 0xffffff, true); if (!hideButtons) { int x = (w / 2) - 80; @@ -9557,178 +9575,204 @@ public class Game extends GameShell { flameThread = false; } - public void method137(Buffer buffer, int j) { - if (j == 84) { - int k = buffer.get1U(); - int j3 = anInt1268 + ((k >> 4) & 7); - int i6 = anInt1269 + (k & 7); - int l8 = buffer.get2U(); - int k11 = buffer.get2U(); - int l13 = buffer.get2U(); - if ((j3 >= 0) && (i6 >= 0) && (j3 < 104) && (i6 < 104)) { - DoublyLinkedList list_1 = planeObjStacks[currentPlane][j3][i6]; - if (list_1 != null) { - for (ObjStackEntity objStack_3 = (ObjStackEntity) list_1.peekFront(); objStack_3 != null; objStack_3 = (ObjStackEntity) list_1.prev()) { - if ((objStack_3.id != (l8 & 0x7fff)) || (objStack_3.amount != k11)) { + public void readZonePacket(Buffer buffer, int opcode) { + // update obj + if (opcode == 84) { + int pos = buffer.get1U(); + int x = zoneX + ((pos >> 4) & 7); + int z = zoneZ + (pos & 7); + 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)) { continue; } - objStack_3.amount = l13; + stack.amount = newAmount; break; } - method25(j3, i6); + sortObjStacks(x, z); } } return; } - if (j == 105) { - int l = buffer.get1U(); - int k3 = anInt1268 + ((l >> 4) & 7); - int j6 = anInt1269 + (l & 7); - int i9 = buffer.get2U(); - int l11 = buffer.get1U(); - int i14 = (l11 >> 4) & 0xf; - int i16 = l11 & 7; - if ((self.pathTileX[0] >= (k3 - i14)) && (self.pathTileX[0] <= (k3 + i14)) && (self.pathTileZ[0] >= (j6 - i14)) && (self.pathTileZ[0] <= (j6 + i14)) && aBoolean848 && !lowmem && (waveCount < 50)) { - waveId[waveCount] = i9; - waveLoops[waveCount] = i16; - waveDelay[waveCount] = SoundTrack.delays[i9]; + + // emit sound + if (opcode == 105) { + int pos = buffer.get1U(); + int x = zoneX + ((pos >> 4) & 7); + int z = zoneZ + (pos & 7); + 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; + waveLoops[waveCount] = loopCount; + waveDelay[waveCount] = SoundTrack.delays[waveID]; waveCount++; } } - if (j == 215) { - int i1 = buffer.get2UA(); - int l3 = buffer.get1US(); - int k6 = anInt1268 + ((l3 >> 4) & 7); - int j9 = anInt1269 + (l3 & 7); - int i12 = buffer.get2UA(); - int j14 = buffer.get2U(); - if ((k6 >= 0) && (j9 >= 0) && (k6 < 104) && (j9 < 104) && (i12 != selfPlayerId)) { - ObjStackEntity class30_sub2_sub4_sub2_2 = new ObjStackEntity(); - class30_sub2_sub4_sub2_2.id = i1; - class30_sub2_sub4_sub2_2.amount = j14; - if (planeObjStacks[currentPlane][k6][j9] == null) { - planeObjStacks[currentPlane][k6][j9] = new DoublyLinkedList(); + + // reveal obj (this would already be visible to the local player if it belongs to them) + if (opcode == 215) { + int objID = buffer.get2UA(); + int pos = buffer.get1US(); + int x = zoneX + ((pos >> 4) & 7); + int z = zoneZ + (pos & 7); + int ownerID = buffer.get2UA(); + int objAmount = buffer.get2U(); + if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104) && (ownerID != localPlayerID)) { + ObjStackEntity obj = new ObjStackEntity(); + obj.id = objID; + obj.amount = objAmount; + if (planeObjStacks[currentPlane][x][z] == null) { + planeObjStacks[currentPlane][x][z] = new DoublyLinkedList(); } - planeObjStacks[currentPlane][k6][j9].pushBack(class30_sub2_sub4_sub2_2); - method25(k6, j9); + planeObjStacks[currentPlane][x][z].pushBack(obj); + sortObjStacks(x, z); } return; } - if (j == 156) { - int j1 = buffer.get1UA(); - int i4 = anInt1268 + ((j1 >> 4) & 7); - int l6 = anInt1269 + (j1 & 7); - int k9 = buffer.get2U(); - if ((i4 >= 0) && (l6 >= 0) && (i4 < 104) && (l6 < 104)) { - DoublyLinkedList list = planeObjStacks[currentPlane][i4][l6]; + + // remove obj + if (opcode == 156) { + int pos = buffer.get1UA(); + int x = zoneX + ((pos >> 4) & 7); + int z = zoneZ + (pos & 7); + int objID = buffer.get2U(); + if ((x >= 0) && (z >= 0) && (x < 104) && (z < 104)) { + DoublyLinkedList list = planeObjStacks[currentPlane][x][z]; if (list != null) { - for (ObjStackEntity objStack = (ObjStackEntity) list.peekFront(); objStack != null; objStack = (ObjStackEntity) list.prev()) { - if (objStack.id != (k9 & 0x7fff)) { + for (ObjStackEntity obj = (ObjStackEntity) list.peekFront(); obj != null; obj = (ObjStackEntity) list.prev()) { + if (obj.id != (objID & 0x7fff)) { continue; } - objStack.unlink(); + obj.unlink(); break; } if (list.peekFront() == null) { - planeObjStacks[currentPlane][i4][l6] = null; + planeObjStacks[currentPlane][x][z] = null; } - method25(i4, l6); + sortObjStacks(x, z); } } return; } - if (j == 160) { - int k1 = buffer.get1US(); - int j4 = anInt1268 + ((k1 >> 4) & 7); - int i7 = anInt1269 + (k1 & 7); - int l9 = buffer.get1US(); - int j12 = l9 >> 2; - int k14 = l9 & 3; - int j16 = anIntArray1177[j12]; - int j17 = buffer.get2UA(); - if ((j4 >= 0) && (i7 >= 0) && (j4 < 103) && (i7 < 103)) { - int j18 = planeHeightmap[currentPlane][j4][i7]; - int i19 = planeHeightmap[currentPlane][j4 + 1][i7]; - int l19 = planeHeightmap[currentPlane][j4 + 1][i7 + 1]; - int k20 = planeHeightmap[currentPlane][j4][i7 + 1]; - if (j16 == 0) { - SceneWall wall = scene.getWall(currentPlane, j4, i7); - if (wall != null) { - int k21 = (wall.bitset >> 14) & 0x7fff; - if (j12 == 2) { - wall.entity0 = new LocEntity(k21, 4 + k14, 2, i19, l19, j18, k20, j17, false); - wall.entity1 = new LocEntity(k21, (k14 + 1) & 3, 2, i19, l19, j18, k20, j17, false); - } else { - wall.entity0 = new LocEntity(k21, k14, j12, i19, l19, j18, k20, j17, false); - } + + // update loc + if (opcode == 160) { + int pos = buffer.get1US(); + int x = zoneX + ((pos >> 4) & 7); + int z = zoneZ + (pos & 7); + int info = buffer.get1US(); + int kind = info >> 2; + int rotation = info & 3; + int classID = LOC_KIND_TO_CLASS_ID[kind]; + int seqID = buffer.get2UA(); + + if ((x < 0) || (z < 0) || (x >= 103) || (z >= 103)) { + return; + } + + 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]; + + if (classID == 0) { + SceneWall wall = scene.getWall(currentPlane, x, z); + + if (wall != null) { + 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); + } else { + wall.entityA = new LocEntity(locID, rotation, kind, heightmapSE, heightmapNE, heightmapSW, heightmapNW, seqID, false); } } - if (j16 == 1) { - SceneWallDecoration wallDecoration = scene.getWallDecoration(currentPlane, j4, i7); - if (wallDecoration != null) { - wallDecoration.entity = new LocEntity((wallDecoration.bitset >> 14) & 0x7fff, 0, 4, i19, l19, j18, k20, j17, false); - } + } + + 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); } - if (j16 == 2) { - SceneLoc loc = scene.getLoc(currentPlane, j4, i7); - if (j12 == 11) { - j12 = 10; - } - if (loc != null) { - loc.entity = new LocEntity((loc.bitset >> 14) & 0x7fff, k14, j12, i19, l19, j18, k20, j17, false); - } + } + + if (classID == 2) { + SceneLoc loc = scene.getLoc(currentPlane, x, z); + + if (kind == 11) { + kind = 10; } - if (j16 == 3) { - SceneGroundDecoration groundDecoration = scene.getGroundDecoration(i7, j4, currentPlane); - if (groundDecoration != null) { - groundDecoration.entity = new LocEntity((groundDecoration.bitset >> 14) & 0x7fff, k14, 22, i19, l19, j18, k20, j17, false); - } + + if (loc != null) { + loc.entity = new LocEntity((loc.bitset >> 14) & 0x7fff, rotation, kind, heightmapSE, heightmapNE, heightmapSW, heightmapNW, seqID, false); + } + } + + 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); } } return; } - if (j == 147) { - int l1 = buffer.get1US(); - int k4 = anInt1268 + ((l1 >> 4) & 7); - int j7 = anInt1269 + (l1 & 7); - int i10 = buffer.get2U(); + + if (opcode == 147) { + 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 k18 = buffer.get1US(); - int j19 = k18 >> 2; - int i20 = k18 & 3; - int l20 = anIntArray1177[j19]; + 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(); PlayerEntity player; - if (i10 == selfPlayerId) { - player = self; + + if (playerID == localPlayerID) { + player = localPlayer; } else { - player = players[i10]; + player = players[playerID]; } + if (player != null) { LocType type = LocType.get(l21); - int i22 = planeHeightmap[currentPlane][k4][j7]; - int j22 = planeHeightmap[currentPlane][k4 + 1][j7]; - int k22 = planeHeightmap[currentPlane][k4 + 1][j7 + 1]; - int l22 = planeHeightmap[currentPlane][k4][j7 + 1]; - Model model = type.method578(j19, i20, i22, j22, k22, l22, -1); + 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, l20, j7, 0, currentPlane, k4, l14 + 1); + 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; - if ((i20 == 1) || (i20 == 3)) { + if ((rotation == 1) || (rotation == 3)) { i23 = type.length; j23 = type.width; } - player.anInt1711 = (k4 * 128) + (i23 * 64); - player.anInt1713 = (j7 * 128) + (j23 * 64); + 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; @@ -9740,31 +9784,33 @@ public class Game extends GameShell { byte3 = byte1; byte1 = byte5; } - player.minSceneTileX = k4 + byte2; - player.maxSceneTileX = k4 + byte0; - player.minSceneTileZ = j7 + byte3; - player.maxSceneTileZ = j7 + byte1; + player.minSceneTileX = x + byte2; + player.maxSceneTileX = x + byte0; + player.minSceneTileZ = z + byte3; + player.maxSceneTileZ = z + byte1; } } } - if (j == 151) { + + if (opcode == 151) { int i2 = buffer.get1UA(); - int l4 = anInt1268 + ((i2 >> 4) & 7); - int k7 = anInt1269 + (i2 & 7); + int l4 = zoneX + ((i2 >> 4) & 7); + int k7 = zoneZ + (i2 & 7); int j10 = buffer.get2ULE(); int k12 = buffer.get1US(); int i15 = k12 >> 2; int k16 = k12 & 3; - int l17 = anIntArray1177[i15]; + int l17 = LOC_KIND_TO_CLASS_ID[i15]; if ((l4 >= 0) && (k7 >= 0) && (l4 < 104) && (k7 < 104)) { method130(-1, j10, k16, l17, k7, i15, currentPlane, l4, 0); } return; } - if (j == 4) { + + if (opcode == 4) { int j2 = buffer.get1U(); - int i5 = anInt1268 + ((j2 >> 4) & 7); - int l7 = anInt1269 + (j2 & 7); + int i5 = zoneX + ((j2 >> 4) & 7); + int l7 = zoneZ + (j2 & 7); int k10 = buffer.get2U(); int l12 = buffer.get1U(); int j15 = buffer.get2U(); @@ -9776,12 +9822,13 @@ public class Game extends GameShell { } return; } - if (j == 44) { + + if (opcode == 44) { int k2 = buffer.get2ULEA(); int j5 = buffer.get2U(); int i8 = buffer.get1U(); - int l10 = anInt1268 + ((i8 >> 4) & 7); - int i13 = anInt1269 + (i8 & 7); + int l10 = zoneX + ((i8 >> 4) & 7); + int i13 = zoneZ + (i8 & 7); if ((l10 >= 0) && (i13 >= 0) && (l10 < 104) && (i13 < 104)) { ObjStackEntity objStack_1 = new ObjStackEntity(); objStack_1.id = k2; @@ -9790,27 +9837,29 @@ public class Game extends GameShell { planeObjStacks[currentPlane][l10][i13] = new DoublyLinkedList(); } planeObjStacks[currentPlane][l10][i13].pushBack(objStack_1); - method25(l10, i13); + sortObjStacks(l10, i13); } return; } - if (j == 101) { + + if (opcode == 101) { int l2 = buffer.get1UC(); int k5 = l2 >> 2; int j8 = l2 & 3; - int i11 = anIntArray1177[k5]; + int i11 = LOC_KIND_TO_CLASS_ID[k5]; int j13 = buffer.get1U(); - int k15 = anInt1268 + ((j13 >> 4) & 7); - int l16 = anInt1269 + (j13 & 7); + int k15 = zoneX + ((j13 >> 4) & 7); + int l16 = zoneZ + (j13 & 7); if ((k15 >= 0) && (l16 >= 0) && (k15 < 104) && (l16 < 104)) { method130(-1, -1, j8, i11, l16, k5, currentPlane, k15, 0); } return; } - if (j == 117) { + + if (opcode == 117) { int i3 = buffer.get1U(); - int l5 = anInt1268 + ((i3 >> 4) & 7); - int k8 = anInt1269 + (i3 & 7); + int l5 = zoneX + ((i3 >> 4) & 7); + int k8 = zoneZ + (i3 & 7); int j11 = l5 + buffer.get1(); int k13 = k8 + buffer.get1(); int l15 = buffer.get2(); @@ -9886,86 +9935,97 @@ public class Game extends GameShell { } } - @SuppressWarnings("StringConcatenationInLoop") public void updateTitle() { if (titleScreenState == 0) { - int i = (super.screenWidth / 2) - 80; - int l = (super.screenHeight / 2) + 20; - l += 20; - if ((super.mousePressButton == 1) && (super.mousePressX >= (i - 75)) && (super.mousePressX <= (i + 75)) && (super.mousePressY >= (l - 20)) && (super.mousePressY <= (l + 20))) { + int x = (super.screenWidth / 2) - 80; + int y = (super.screenHeight / 2) + 20; + y += 20; + + if ((super.mousePressButton == 1) && (super.mousePressX >= (x - 75)) && (super.mousePressX <= (x + 75)) && (super.mousePressY >= (y - 20)) && (super.mousePressY <= (y + 20))) { titleScreenState = 3; - anInt1216 = 0; + titleLoginField = 0; } - i = (super.screenWidth / 2) + 80; - if ((super.mousePressButton == 1) && (super.mousePressX >= (i - 75)) && (super.mousePressX <= (i + 75)) && (super.mousePressY >= (l - 20)) && (super.mousePressY <= (l + 20))) { + + x = (super.screenWidth / 2) + 80; + + if ((super.mousePressButton == 1) && (super.mousePressX >= (x - 75)) && (super.mousePressX <= (x + 75)) && (super.mousePressY >= (y - 20)) && (super.mousePressY <= (y + 20))) { loginMessage0 = ""; loginMessage1 = "Enter your username & password."; titleScreenState = 2; - anInt1216 = 0; + titleLoginField = 0; } } else { if (titleScreenState == 2) { - int j = (super.screenHeight / 2) - 40; - j += 30; - j += 25; - if ((super.mousePressButton == 1) && (super.mousePressY >= (j - 15)) && (super.mousePressY < j)) { - anInt1216 = 0; + int fieldY = (super.screenHeight / 2) - 40; + fieldY += 30; + fieldY += 25; + if ((super.mousePressButton == 1) && (super.mousePressY >= (fieldY - 15)) && (super.mousePressY < fieldY)) { + titleLoginField = 0; } - j += 15; - if ((super.mousePressButton == 1) && (super.mousePressY >= (j - 15)) && (super.mousePressY < j)) { - anInt1216 = 1; + fieldY += 15; + if ((super.mousePressButton == 1) && (super.mousePressY >= (fieldY - 15)) && (super.mousePressY < fieldY)) { + titleLoginField = 1; } - int i1 = (super.screenWidth / 2) - 80; - int k1 = (super.screenHeight / 2) + 50; - k1 += 20; - if ((super.mousePressButton == 1) && (super.mousePressX >= (i1 - 75)) && (super.mousePressX <= (i1 + 75)) && (super.mousePressY >= (k1 - 20)) && (super.mousePressY <= (k1 + 20))) { + + int buttonX = (super.screenWidth / 2) - 80; + int buttonY = (super.screenHeight / 2) + 50; + buttonY += 20; + + if ((super.mousePressButton == 1) && (super.mousePressX >= (buttonX - 75)) && (super.mousePressX <= (buttonX + 75)) && (super.mousePressY >= (buttonY - 20)) && (super.mousePressY <= (buttonY + 20))) { anInt1038 = 0; login(username, password, false); + if (ingame) { return; } } - i1 = (super.screenWidth / 2) + 80; - if ((super.mousePressButton == 1) && (super.mousePressX >= (i1 - 75)) && (super.mousePressX <= (i1 + 75)) && (super.mousePressY >= (k1 - 20)) && (super.mousePressY <= (k1 + 20))) { + + buttonX = (super.screenWidth / 2) + 80; + + if ((super.mousePressButton == 1) && (super.mousePressX >= (buttonX - 75)) && (super.mousePressX <= (buttonX + 75)) && (super.mousePressY >= (buttonY - 20)) && (super.mousePressY <= (buttonY + 20))) { titleScreenState = 0; username = ""; password = ""; } + do { - int l1 = pollKey(); - if (l1 == -1) { + int key = pollKey(); + + if (key == -1) { break; } - boolean flag1 = false; - for (int i2 = 0; i2 < aString1162.length(); i2++) { - if (l1 != aString1162.charAt(i2)) { + + boolean valid = false; + for (int i = 0; i < VALID_CHAT_CHARACTERS.length(); i++) { + if (key != VALID_CHAT_CHARACTERS.charAt(i)) { continue; } - flag1 = true; + valid = true; break; } - if (anInt1216 == 0) { - if ((l1 == 8) && (username.length() > 0)) { + + if (titleLoginField == 0) { + if ((key == 8) && (username.length() > 0)) { username = username.substring(0, username.length() - 1); } - if ((l1 == 9) || (l1 == 10) || (l1 == 13)) { - anInt1216 = 1; + if ((key == 9) || (key == 10) || (key == 13)) { + titleLoginField = 1; } - if (flag1) { - username += (char) l1; + if (valid) { + username += (char) key; } if (username.length() > 12) { username = username.substring(0, 12); } - } else if (anInt1216 == 1) { - if ((l1 == 8) && (password.length() > 0)) { + } else if (titleLoginField == 1) { + if ((key == 8) && (password.length() > 0)) { password = password.substring(0, password.length() - 1); } - if ((l1 == 9) || (l1 == 10) || (l1 == 13)) { - anInt1216 = 0; + if ((key == 9) || (key == 10) || (key == 13)) { + titleLoginField = 0; } - if (flag1) { - password += (char) l1; + if (valid) { + password += (char) key; } if (password.length() > 20) { password = password.substring(0, 20); @@ -9974,11 +10034,12 @@ public class Game extends GameShell { } while (true); return; } + if (titleScreenState == 3) { - int k = super.screenWidth / 2; - int j1 = (super.screenHeight / 2) + 50; - j1 += 20; - if ((super.mousePressButton == 1) && (super.mousePressX >= (k - 75)) && (super.mousePressX <= (k + 75)) && (super.mousePressY >= (j1 - 20)) && (super.mousePressY <= (j1 + 20))) { + int x = super.screenWidth / 2; + int y = (super.screenHeight / 2) + 50; + y += 20; + if ((super.mousePressButton == 1) && (super.mousePressX >= (x - 75)) && (super.mousePressX <= (x + 75)) && (super.mousePressY >= (y - 20)) && (super.mousePressY <= (y + 20))) { titleScreenState = 0; } } @@ -9988,15 +10049,20 @@ public class Game extends GameShell { public void drawOnMinimap(Image24 image, int dx, int dy) { int angle = (cameraYaw + minimapAnticheatAngle) & 0x7ff; int distance = (dx * dx) + (dy * dy); + if (distance > 6400) { return; } + int sinAngle = Model.sin[angle]; int cosAngle = Model.cos[angle]; + sinAngle = (sinAngle * 256) / (minimapZoom + 256); cosAngle = (cosAngle * 256) / (minimapZoom + 256); + int x = ((dy * sinAngle) + (dx * cosAngle)) >> 16; int y = ((dy * cosAngle) - (dx * sinAngle)) >> 16; + if (distance > 2500) { image.drawMasked(imageMapback, 83 - y - (image.cropH / 2) - 4, ((94 + x) - (image.cropW / 2)) + 4); } else { @@ -10004,65 +10070,83 @@ public class Game extends GameShell { } } - public void method142(int i, int j, int k, int l, int i1, int j1, int k1) { - if ((i1 < 1) || (i < 1) || (i1 > 102) || (i > 102)) { + public void addLoc(int z, int plane, int angle, int kind, int x, int classID, int id) { + if ((x < 1) || (z < 1) || (x > 102) || (z > 102)) { return; } - if (lowmem && (j != currentPlane)) { + + if (lowmem && (plane != currentPlane)) { return; } - int i2 = 0; - if (j1 == 0) { - i2 = scene.getWallBitset(j, i1, i); + + int bitset = 0; + + if (classID == 0) { + bitset = scene.getWallBitset(plane, x, z); } - if (j1 == 1) { - i2 = scene.getWallDecorationBitset(j, i1, i); + + if (classID == 1) { + bitset = scene.getWallDecorationBitset(plane, x, z); } - if (j1 == 2) { - i2 = scene.getLocBitset(j, i1, i); + + if (classID == 2) { + bitset = scene.getLocBitset(plane, x, z); } - if (j1 == 3) { - i2 = scene.getGroundDecorationBitset(j, i1, i); + + if (classID == 3) { + bitset = scene.getGroundDecorationBitset(plane, x, z); } - if (i2 != 0) { - int i3 = scene.getInfo(j, i1, i, i2); - int j2 = (i2 >> 14) & 0x7fff; - int k2 = i3 & 0x1f; - int rotation = i3 >> 6; - if (j1 == 0) { - scene.removeWall(i1, j, i); - LocType type = LocType.get(j2); + + if (bitset != 0) { + int info = scene.getInfo(plane, x, z, bitset); + 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); if (type.solid) { - collisions[j].method215(rotation, k2, type.blocksProjectiles, i1, i); + collisions[plane].remove(otherRotation, otherKind, type.blocksProjectiles, x, z); } } - if (j1 == 1) { - scene.removeWallDecoration(j, i1, i); + + if (classID == 1) { + scene.removeWallDecoration(plane, x, z); } - if (j1 == 2) { - scene.removeLoc(j, i1, i); - LocType type_1 = LocType.get(j2); - if (((i1 + type_1.width) > 103) || ((i + type_1.width) > 103) || ((i1 + type_1.length) > 103) || ((i + type_1.length) > 103)) { + + if (classID == 2) { + scene.removeLoc(plane, x, z); + LocType type = LocType.get(otherID); + + if (((x + type.width) > 103) || ((z + type.width) > 103) || ((x + type.length) > 103) || ((z + type.length) > 103)) { return; } - if (type_1.solid) { - collisions[j].method216(rotation, type_1.width, i1, i, type_1.length, type_1.blocksProjectiles); + + if (type.solid) { + collisions[plane].remove(otherRotation, type.width, x, z, type.length, type.blocksProjectiles); } } - if (j1 == 3) { - scene.removeGroundDecoration(j, i1, i); - LocType type_2 = LocType.get(j2); + + if (classID == 3) { + scene.removeGroundDecoration(plane, x, z); + LocType type_2 = LocType.get(otherID); if (type_2.solid && type_2.interactable) { - collisions[j].method218(i, i1); + collisions[plane].method218(z, x); } } } - if (k1 >= 0) { - int j3 = j; - if ((j3 < 3) && ((planeTileFlags[1][i1][i] & 2) == 2)) { - j3++; + + if (id >= 0) { + // this would be the plane the loc gets its heightmap data from + int truePlane = plane; + + // check for bridged tile + if ((truePlane < 3) && ((planeTileFlags[1][x][z] & 2) == 2)) { + truePlane++; } - SceneBuilder.method188(scene, k, i, l, j3, collisions[j], planeHeightmap, i1, k1, j); + + SceneBuilder.addLoc(scene, angle, z, kind, truePlane, collisions[plane], planeHeightmap, x, id, plane); } } @@ -10118,7 +10202,7 @@ public class Game extends GameShell { anInt862 = j1; } - public boolean method145() { + public boolean read() { if (connection == null) { return false; } @@ -10204,18 +10288,18 @@ public class Game extends GameShell { return true; } if (ptype == 64) { - anInt1268 = in.get1UC(); - anInt1269 = in.get1US(); - for (int j = anInt1268; j < (anInt1268 + 8); j++) { - for (int l9 = anInt1269; l9 < (anInt1269 + 8); l9++) { + zoneX = in.get1UC(); + zoneZ = in.get1US(); + for (int j = zoneX; j < (zoneX + 8); j++) { + for (int l9 = zoneZ; l9 < (zoneZ + 8); l9++) { if (planeObjStacks[currentPlane][j][l9] != null) { planeObjStacks[currentPlane][j][l9] = null; - method25(j, l9); + sortObjStacks(j, l9); } } } - for (SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.peekFront(); loc != null; loc = (SceneLocTemporary) listTemporaryLocs.prev()) { - if ((loc.sceneTileX >= anInt1268) && (loc.sceneTileX < (anInt1268 + 8)) && (loc.sceneTileZ >= anInt1269) && (loc.sceneTileZ < (anInt1269 + 8)) && (loc.anInt1295 == currentPlane)) { + for (SceneLocTemporary loc = (SceneLocTemporary) temporaryLocs.peekFront(); loc != null; loc = (SceneLocTemporary) temporaryLocs.prev()) { + if ((loc.localX >= zoneX) && (loc.localX < (zoneX + 8)) && (loc.localZ >= zoneZ) && (loc.localZ < (zoneZ + 8)) && (loc.plane == currentPlane)) { loc.anInt1294 = 0; } } @@ -10224,11 +10308,11 @@ public class Game extends GameShell { } if (ptype == 185) { int k = in.get2ULEA(); - Component.instances[k].modelType = 3; - if (self.aType_1698 == null) { - Component.instances[k].modelTypeId = (self.anIntArray1700[0] << 25) + (self.anIntArray1700[4] << 20) + (self.appearance[0] << 15) + (self.appearance[8] << 10) + (self.appearance[11] << 5) + self.appearance[1]; + 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]; } else { - Component.instances[k].modelTypeId = (int) (0x12345678L + self.aType_1698.uid); + Component.instances[k].modelID = (int) (0x12345678L + localPlayer.aType_1698.uid); } ptype = -1; return true; @@ -10565,10 +10649,10 @@ public class Game extends GameShell { } } - for (SceneLocTemporary loc = (SceneLocTemporary) listTemporaryLocs.peekFront(); loc != null; loc = (SceneLocTemporary) listTemporaryLocs.prev()) { - loc.sceneTileX -= dtx; - loc.sceneTileZ -= dtz; - if ((loc.sceneTileX < 0) || (loc.sceneTileZ < 0) || (loc.sceneTileX >= 104) || (loc.sceneTileZ >= 104)) { + for (SceneLocTemporary loc = (SceneLocTemporary) temporaryLocs.peekFront(); loc != null; loc = (SceneLocTemporary) temporaryLocs.prev()) { + loc.localX -= dtx; + loc.localZ -= dtz; + if ((loc.localX < 0) || (loc.localZ < 0) || (loc.localX >= 104) || (loc.localZ >= 104)) { loc.unlink(); } } @@ -10599,8 +10683,8 @@ public class Game extends GameShell { if (ptype == 75) { int npcId = in.get2ULEA(); int componentId = in.get2ULEA(); - Component.instances[componentId].modelType = 2; - Component.instances[componentId].modelTypeId = npcId; + Component.instances[componentId].modelCategory = 2; + Component.instances[componentId].modelID = npcId; ptype = -1; return true; } @@ -10610,11 +10694,11 @@ public class Game extends GameShell { return true; } if (ptype == 60) { - anInt1269 = in.get1U(); - anInt1268 = in.get1UC(); + zoneZ = in.get1U(); + zoneX = in.get1UC(); while (in.position < psize) { - int k3 = in.get1U(); - method137(in, k3); + int opcode = in.get1U(); + readZonePacket(in, opcode); } ptype = -1; return true; @@ -10637,7 +10721,7 @@ public class Game extends GameShell { int l11 = in.get1U(); int k17 = in.get2U(); if (aBoolean848 && !lowmem && (waveCount < 50)) { - waveId[waveCount] = i4; + waveIDs[waveCount] = i4; waveLoops[waveCount] = l11; waveDelay[waveCount] = k17 + SoundTrack.delays[i4]; waveCount++; @@ -10913,8 +10997,8 @@ public class Game extends GameShell { return true; } if (ptype == 85) { - anInt1269 = in.get1UC(); - anInt1268 = in.get1UC(); + zoneZ = in.get1UC(); + zoneX = in.get1UC(); ptype = -1; return true; } @@ -10936,11 +11020,11 @@ public class Game extends GameShell { int zoom = in.get2U(); int objId = in.get2U(); if (objId == 65535) { - Component.instances[componentId].modelType = 0; + Component.instances[componentId].modelCategory = 0; } else { ObjType type = ObjType.get(objId); - Component.instances[componentId].modelType = 4; - Component.instances[componentId].modelTypeId = objId; + Component.instances[componentId].modelCategory = 4; + 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; @@ -11009,8 +11093,8 @@ public class Game extends GameShell { if (ptype == 8) { int componentId = in.get2ULEA(); int modelId = in.get2U(); - Component.instances[componentId].modelType = 1; - Component.instances[componentId].modelTypeId = modelId; + Component.instances[componentId].modelCategory = 1; + Component.instances[componentId].modelID = modelId; ptype = -1; return true; } @@ -11094,7 +11178,7 @@ public class Game extends GameShell { } if (ptype == 249) { anInt1046 = in.get1UA(); - selfPlayerId = in.get2ULEA(); + localPlayerID = in.get2ULEA(); ptype = -1; return true; } @@ -11232,7 +11316,7 @@ public class Game extends GameShell { return true; } if ((ptype == 105) || (ptype == 84) || (ptype == 147) || (ptype == 215) || (ptype == 4) || (ptype == 117) || (ptype == 156) || (ptype == 44) || (ptype == 160) || (ptype == 101) || (ptype == 151)) { - method137(in, ptype); + readZonePacket(in, ptype); ptype = -1; return true; } @@ -11263,7 +11347,7 @@ public class Game extends GameShell { } catch (IOException _ex) { tryReconnect(); } catch (Exception exception) { - StringBuilder s2 = new StringBuilder("T2 (Packet Error) - " + ptype + "," + anInt842 + "," + anInt843 + " - " + psize + "," + (sceneBaseTileX + self.pathTileX[0]) + "," + (sceneBaseTileZ + self.pathTileZ[0]) + " - "); + StringBuilder s2 = new StringBuilder("T2 (Packet Error) - " + ptype + "," + anInt842 + "," + anInt843 + " - " + psize + "," + (sceneBaseTileX + localPlayer.pathTileX[0]) + "," + (sceneBaseTileZ + localPlayer.pathTileZ[0]) + " - "); for (int j15 = 0; (j15 < psize) && (j15 < 50); j15++) { s2.append(in.data[j15]).append(","); } @@ -11294,7 +11378,7 @@ public class Game extends GameShell { } int yaw = (cameraYaw + cameraAnticheatAngle) & 0x7ff; - method144(600 + (pitch * 3), pitch, cameraFocusX, getHeightmapY(currentPlane, self.x, self.z) - 50, yaw, cameraFocusZ); + method144(600 + (pitch * 3), pitch, cameraFocusX, getHeightmapY(currentPlane, localPlayer.x, localPlayer.z) - 50, yaw, cameraFocusZ); } int j; if (!aBoolean1160) { diff --git a/src/main/java/GameShell.java b/src/main/java/GameShell.java index 8707b7c..b9cd9ce 100644 --- a/src/main/java/GameShell.java +++ b/src/main/java/GameShell.java @@ -11,7 +11,7 @@ public abstract class GameShell extends JComponent implements Runnable, MouseLis public final long[] otim = new long[10]; public final int[] actionKey = new int[128]; - public final int[] anIntArray31 = new int[128]; + public final int[] keyQueue = new int[128]; public int state; public int deltime = 20; public int mindel = 1; @@ -22,7 +22,7 @@ public abstract class GameShell extends JComponent implements Runnable, MouseLis public Graphics graphics; public GameFrame frame; public boolean refresh = true; - public boolean aBoolean17 = true; + public boolean focused = true; public int idleCycles; public int mouseButton; public int mouseX; @@ -35,8 +35,8 @@ public abstract class GameShell extends JComponent implements Runnable, MouseLis public int mousePressX; public int mousePressY; public long mousePressTime; - public int anInt32; - public int anInt33; + public int keyQueueReadPos; + public int keyQueueWritePos; public void init(int width, int height) { screenWidth = width; @@ -146,7 +146,7 @@ public abstract class GameShell extends JComponent implements Runnable, MouseLis mousePressTime = lastMousePressTime; lastMousePressButton = 0; update(); - anInt32 = anInt33; + keyQueueReadPos = keyQueueWritePos; } count &= 0xff; @@ -293,49 +293,49 @@ public abstract class GameShell extends JComponent implements Runnable, MouseLis public void keyPressed(KeyEvent e) { idleCycles = 0; int code = e.getKeyCode(); - int ch = e.getKeyChar(); + int value = e.getKeyChar(); - if (ch < 30) { - ch = 0; + if (value < 30) { + value = 0; } if (code == KeyEvent.VK_LEFT) { - ch = 1; + value = 1; } else if (code == KeyEvent.VK_RIGHT) { - ch = 2; + value = 2; } else if (code == KeyEvent.VK_UP) { - ch = 3; + value = 3; } else if (code == KeyEvent.VK_DOWN) { - ch = 4; + value = 4; } else if (code == KeyEvent.VK_CONTROL) { - ch = 5; + value = 5; } else if (code == KeyEvent.VK_BACK_SPACE) { - ch = 8; + value = 8; } else if (code == KeyEvent.VK_DELETE) { - ch = 8; + value = 8; } else if (code == KeyEvent.VK_TAB) { - ch = 9; + value = 9; } else if (code == KeyEvent.VK_ENTER) { - ch = 10; + value = 10; } else if ((code >= KeyEvent.VK_F1) && (code <= KeyEvent.VK_F12)) { - ch = (1008 + code) - KeyEvent.VK_F1; + value = (1008 + code) - KeyEvent.VK_F1; } else if (code == KeyEvent.VK_HOME) { - ch = 1000; + value = 1000; } else if (code == KeyEvent.VK_END) { - ch = 1001; + value = 1001; } else if (code == KeyEvent.VK_PAGE_UP) { - ch = 1002; + value = 1002; } else if (code == KeyEvent.VK_PAGE_DOWN) { - ch = 1003; + value = 1003; } - if ((ch > 0) && (ch < 128)) { - actionKey[ch] = 1; + if ((value > 0) && (value < 128)) { + actionKey[value] = 1; } - if (ch > 4) { - anIntArray31[anInt33] = ch; - anInt33 = (anInt33 + 1) & 0x7f; + if (value > 4) { + keyQueue[keyQueueWritePos] = value; + keyQueueWritePos = (keyQueueWritePos + 1) & 0x7f; } } @@ -381,23 +381,23 @@ public abstract class GameShell extends JComponent implements Runnable, MouseLis public int pollKey() { int key = -1; - if (anInt33 != anInt32) { - key = anIntArray31[anInt32]; - anInt32 = (anInt32 + 1) & 0x7f; + if (keyQueueWritePos != keyQueueReadPos) { + key = keyQueue[keyQueueReadPos]; + keyQueueReadPos = (keyQueueReadPos + 1) & 0x7f; } return key; } @Override public void focusGained(FocusEvent e) { - aBoolean17 = true; + focused = true; refresh = true; refresh(); } @Override public void focusLost(FocusEvent e) { - aBoolean17 = false; + focused = false; for (int i = 0; i < 128; i++) { actionKey[i] = 0; } diff --git a/src/main/java/LocEntity.java b/src/main/java/LocEntity.java index f530ddd..87ed4de 100644 --- a/src/main/java/LocEntity.java +++ b/src/main/java/LocEntity.java @@ -5,98 +5,113 @@ public class LocEntity extends Entity { public static Game game; - public final int[] anIntArray1600; - public final int anInt1601; - public final int anInt1602; - public final int anInt1603; - public final int anInt1604; - public final int anInt1605; - public final int anInt1606; - public final int anInt1610; - public final int anInt1611; - public final int anInt1612; - public int anInt1599; - public SeqType aType_1607; - public int anInt1608; + public final int[] overrideTypeIDs; + public final int varbit; + public final int varp; + public final int heightmapSW; + public final int heightmapSE; + public final int heightmapNE; + public final int heightmapNW; + public final int id; + public final int kind; + public final int rotation; + public int seqFrame; + public SeqType seq; + public int seqCycle; - public LocEntity(int i, int j, int k, int l, int i1, int j1, int k1, int l1, boolean flag) { - anInt1610 = i; - anInt1611 = k; - anInt1612 = j; - anInt1603 = j1; - anInt1604 = l; - anInt1605 = i1; - anInt1606 = k1; - if (l1 != -1) { - aType_1607 = SeqType.instances[l1]; - anInt1599 = 0; - anInt1608 = Game.loopCycle; - if (flag && (aType_1607.anInt356 != -1)) { - anInt1599 = (int) (Math.random() * (double) aType_1607.frameCount); - anInt1608 -= (int) (Math.random() * (double) aType_1607.getFrameDelay(anInt1599)); + public LocEntity(int id, int rotation, int kind, int heightmapSE, int heightmapNE, int heightmapSW, int heightmapNW, int seqID, boolean randomFrame) { + this.id = id; + this.kind = kind; + this.rotation = rotation; + this.heightmapSW = heightmapSW; + this.heightmapSE = heightmapSE; + this.heightmapNE = heightmapNE; + this.heightmapNW = heightmapNW; + + if (seqID != -1) { + seq = SeqType.instances[seqID]; + seqFrame = 0; + seqCycle = Game.loopCycle; + + if (randomFrame && (seq.speed != -1)) { + seqFrame = (int) (Math.random() * (double) seq.frameCount); + seqCycle -= (int) (Math.random() * (double) seq.getFrameDelay(seqFrame)); } } - LocType type = LocType.get(anInt1610); - anInt1601 = type.varbit; - anInt1602 = type.varp; - anIntArray1600 = type.overrideIds; + LocType type = LocType.get(this.id); + varbit = type.varbit; + varp = type.varp; + overrideTypeIDs = type.overrideTypeIDs; } @Override public Model getModel() { - int j = -1; - if (aType_1607 != null) { - int k = Game.loopCycle - anInt1608; - if ((k > 100) && (aType_1607.anInt356 > 0)) { - k = 100; + int frame = -1; + + if (seq != null) { + int delta = Game.loopCycle - seqCycle; + + if ((delta > 100) && (seq.speed > 0)) { + delta = 100; } - while (k > aType_1607.getFrameDelay(anInt1599)) { - k -= aType_1607.getFrameDelay(anInt1599); - anInt1599++; - if (anInt1599 < aType_1607.frameCount) { + + while (delta > seq.getFrameDelay(seqFrame)) { + delta -= seq.getFrameDelay(seqFrame); + seqFrame++; + + if (seqFrame < seq.frameCount) { continue; } - anInt1599 -= aType_1607.anInt356; - if ((anInt1599 >= 0) && (anInt1599 < aType_1607.frameCount)) { + + seqFrame -= seq.speed; + + if ((seqFrame >= 0) && (seqFrame < seq.frameCount)) { continue; } - aType_1607 = null; + + seq = null; break; } - anInt1608 = Game.loopCycle - k; - if (aType_1607 != null) { - j = aType_1607.primaryFrames[anInt1599]; + seqCycle = Game.loopCycle - delta; + + if (seq != null) { + frame = seq.primaryFrames[seqFrame]; } } + LocType type; - if (anIntArray1600 != null) { - type = method457(); + + if (overrideTypeIDs != null) { + type = getOverrideType(); } else { - type = LocType.get(anInt1610); + type = LocType.get(id); } + if (type == null) { return null; } else { - return type.method578(anInt1611, anInt1612, anInt1603, anInt1604, anInt1605, anInt1606, j); + return type.getModel(kind, rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, frame); } } - public LocType method457() { - int i = -1; - if (anInt1601 != -1) { - VarbitType varbit = VarbitType.instances[anInt1601]; - int k = varbit.varp; - int l = varbit.lsb; - int i1 = varbit.msb; - int j1 = Game.BITMASK[i1 - l]; - i = (game.variables[k] >> l) & j1; - } else if (anInt1602 != -1) { - i = game.variables[anInt1602]; + public LocType getOverrideType() { + int value = -1; + + if (varbit != -1) { + VarbitType varbit = VarbitType.instances[this.varbit]; + int varp = varbit.varp; + int low = varbit.lsb; + int high = varbit.msb; + int mask = Game.BITMASK[high - low]; + value = (game.variables[varp] >> low) & mask; + } else if (varp != -1) { + value = game.variables[varp]; } - if ((i < 0) || (i >= anIntArray1600.length) || (anIntArray1600[i] == -1)) { + + if ((value < 0) || (value >= overrideTypeIDs.length) || (overrideTypeIDs[value] == -1)) { return null; } else { - return LocType.get(anIntArray1600[i]); + return LocType.get(overrideTypeIDs[value]); } } diff --git a/src/main/java/LocType.java b/src/main/java/LocType.java index 6c2b460..3ad1017 100644 --- a/src/main/java/LocType.java +++ b/src/main/java/LocType.java @@ -8,497 +8,528 @@ import java.io.IOException; public class LocType { - public static final Model[] TMP_MODELS = new Model[4]; - public static boolean lowmem; - public static Buffer dat; - public static int[] offsets; - public static int count; - public static Game game; - public static int anInt771; - public static LRUMap aCache_780 = new LRUMap(30); - public static LocType[] cache; - public static LRUMap modelCache = new LRUMap(500); + public static final Model[] TMP_MODELS = new Model[4]; + public static boolean lowmem; + public static Buffer dat; + public static int[] offsets; + public static int count; + public static Game game; + public static int anInt771; + /** + * This is where dynamically generated models go. + */ + public static LRUMap dynamicCache = new LRUMap(30); + public static LocType[] cache; + /** + * This is where basic models go. + */ + public static LRUMap staticCache = new LRUMap(500); - public static LocType get(int i) { - if (i >= count) { - i = 0; - } - for (int j = 0; j < 20; j++) { - if (cache[j].index == i) { - return cache[j]; - } - } - anInt771 = (anInt771 + 1) % 20; - LocType type = cache[anInt771]; - dat.position = offsets[i]; - type.index = i; - type.reset(); - type.method582(dat); - return type; - } + public static LocType get(int i) { + if (i >= count) { + i = 0; + } + for (int j = 0; j < 20; j++) { + if (cache[j].index == i) { + return cache[j]; + } + } + anInt771 = (anInt771 + 1) % 20; + LocType type = cache[anInt771]; + dat.position = offsets[i]; + type.index = i; + type.reset(); + type.method582(dat); + return type; + } - public static void unload() { - modelCache = null; - aCache_780 = null; - offsets = null; - cache = null; - dat = null; - } + public static void unload() { + staticCache = null; + dynamicCache = null; + offsets = null; + cache = null; + dat = null; + } - public static void unpack(FileArchive archive) throws IOException { - dat = new Buffer(archive.read("loc.dat")); - Buffer buffer = new Buffer(archive.read("loc.idx")); - count = buffer.get2U(); - offsets = new int[count]; - int i = 2; - for (int j = 0; j < count; j++) { - offsets[j] = i; - i += buffer.get2U(); - } - cache = new LocType[20]; - for (int k = 0; k < 20; k++) { - cache[k] = new LocType(); - } - } + public static void unpack(FileArchive archive) throws IOException { + dat = new Buffer(archive.read("loc.dat")); + Buffer buffer = new Buffer(archive.read("loc.idx")); + count = buffer.get2U(); + offsets = new int[count]; + int i = 2; + for (int j = 0; j < count; j++) { + offsets[j] = i; + i += buffer.get2U(); + } + cache = new LocType[20]; + for (int k = 0; k < 20; k++) { + cache[k] = new LocType(); + } + } - public boolean important; - public byte lightAmbient; - public int translateX; - public String name; - public int scaleY; - public byte lightAttenuation; - public int width; - public int translateY; - public int mapfunctionIcon; - public int[] dstColor; - public int scaleX; - public int varp; - public boolean invert; - public int index = -1; - public boolean blocksProjectiles; - public int mapsceneIcon; - public int[] overrideIds; - public int supportsObj; - public int length; - public boolean adjustToTerrain; - public boolean occludes; - public boolean decorative; - public boolean solid; - public int interactionSideFlags; - /** - * Models flagged as dynamic will always copy their models face information by making copyFaces - * equal true. - * - * @see Model#Model(boolean, boolean, Model) - */ - public boolean dynamic; - public int scaleZ; - public int[] modelIds; - public int varbit; - public int decorationPadding; - public int[] modelTypes; - public String description; - public boolean interactable; - public boolean castShadow; - public int seqId; - public int translateZ; - public int[] srcColor; - public String[] actions; + public boolean important; + public byte lightAmbient; + public int translateX; + public String name; + public int scaleY; + public byte lightAttenuation; + public int width; + public int translateY; + public int mapfunctionIcon; + public int[] dstColor; + public int scaleX; + public int varp; + public boolean invert; + public int index = -1; + public boolean blocksProjectiles; + public int mapsceneIcon; + public int[] overrideTypeIDs; + public int supportsObj; + public int length; + public boolean adjustToTerrain; + public boolean occludes; + public boolean decorative; + public boolean solid; + public int interactionSideFlags; + /** + * Models flagged as dynamic will always copy their models face information by making copyFaces + * equal true. + * + * @see Model#Model(boolean, boolean, Model) + */ + public boolean dynamic; + public int scaleZ; + public int[] modelIDs; + public int varbit; + public int decorationPadding; + public int[] modelKinds; + public String description; + public boolean interactable; + public boolean castShadow; + public int seqId; + public int translateZ; + public int[] srcColor; + public String[] actions; - public LocType() { - } + public LocType() { + } - public void reset() { - modelIds = null; - modelTypes = null; - name = null; - description = null; - srcColor = null; - dstColor = null; - width = 1; - length = 1; - solid = true; - blocksProjectiles = true; - interactable = false; - adjustToTerrain = false; - dynamic = false; - occludes = false; - seqId = -1; - decorationPadding = 16; - lightAmbient = 0; - lightAttenuation = 0; - actions = null; - mapfunctionIcon = -1; - mapsceneIcon = -1; - invert = false; - castShadow = true; - scaleX = 128; - scaleZ = 128; - scaleY = 128; - interactionSideFlags = 0; - translateX = 0; - translateY = 0; - translateZ = 0; - important = false; - decorative = false; - supportsObj = -1; - varbit = -1; - varp = -1; - overrideIds = null; - } + public void reset() { + modelIDs = null; + modelKinds = null; + name = null; + description = null; + srcColor = null; + dstColor = null; + width = 1; + length = 1; + solid = true; + blocksProjectiles = true; + interactable = false; + adjustToTerrain = false; + dynamic = false; + occludes = false; + seqId = -1; + decorationPadding = 16; + lightAmbient = 0; + lightAttenuation = 0; + actions = null; + mapfunctionIcon = -1; + mapsceneIcon = -1; + invert = false; + castShadow = true; + scaleX = 128; + scaleZ = 128; + scaleY = 128; + interactionSideFlags = 0; + translateX = 0; + translateY = 0; + translateZ = 0; + important = false; + decorative = false; + supportsObj = -1; + varbit = -1; + varp = -1; + overrideTypeIDs = null; + } - public void method574(OnDemand onDemand) { - if (modelIds == null) { - return; - } - for (int k : modelIds) { - onDemand.method560(k & 0xffff, 0); - } - } + public void method574(OnDemand onDemand) { + if (modelIDs == null) { + return; + } + for (int k : modelIDs) { + onDemand.method560(k & 0xffff, 0); + } + } - public boolean method577(int i) { - if (modelTypes == null) { - if (modelIds == null) { - return true; - } - if (i != 10) { - return true; - } - boolean flag1 = true; - for (int j : modelIds) { - flag1 &= Model.validate(j & 0xffff); - } - return flag1; - } - for (int j = 0; j < modelTypes.length; j++) { - if (modelTypes[j] == i) { - return Model.validate(modelIds[j] & 0xffff); - } - } - return true; - } + public boolean validate(int kind) { + if (modelKinds == null) { + if (modelIDs == null) { + return true; + } + if (kind != 10) { + return true; + } + boolean valid = true; + 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 true; + } - public Model method578(int i, int j, int k, int l, int i1, int j1, int k1) { - Model model = method581(i, k1, j); - if (model == null) { - return null; - } - if (adjustToTerrain || dynamic) { - model = new Model(adjustToTerrain, dynamic, model); - } - if (adjustToTerrain) { - int l1 = (k + l + i1 + j1) / 4; - for (int i2 = 0; i2 < model.vertexCount; i2++) { - int j2 = model.vertexX[i2]; - int k2 = model.vertexZ[i2]; - int l2 = k + (((l - k) * (j2 + 64)) / 128); - int i3 = j1 + (((i1 - j1) * (j2 + 64)) / 128); - int j3 = l2 + (((i3 - l2) * (k2 + 64)) / 128); - model.vertexY[i2] += j3 - l1; - } - model.calculateBoundsY(); - } - return model; - } + public Model getModel(int kind, int rotation, int heightmapSW, int heightmapSE, int heightmapNE, int heightmapNW, int seqFrame) { + Model model = getModel(kind, seqFrame, rotation); - public boolean method579() { - if (modelIds == null) { - return true; - } - boolean flag1 = true; - for (int j : modelIds) { - flag1 &= Model.validate(j & 0xffff); - } - return flag1; - } + if (model == null) { + return null; + } - public LocType method580() { - int i = -1; - if (varbit != -1) { - VarbitType varbit = VarbitType.instances[this.varbit]; - int j = varbit.varp; - int k = varbit.lsb; - int l = varbit.msb; - int i1 = Game.BITMASK[l - k]; - i = (game.variables[j] >> k) & i1; - } else if (varp != -1) { - i = game.variables[varp]; - } - if ((i < 0) || (i >= overrideIds.length) || (overrideIds[i] == -1)) { - return null; - } else { - return get(overrideIds[i]); - } - } + if (adjustToTerrain || dynamic) { + model = new Model(adjustToTerrain, dynamic, model); + } - public Model method581(int type, int seqFrame, int rotation) { - Model model = null; - long bitset; - if (modelTypes == null) { - if (type != 10) { - return null; - } - bitset = ((long) index << 6) + rotation + ((long) (seqFrame + 1) << 32); - Model model_1 = aCache_780.get(bitset); - if (model_1 != null) { - return model_1; - } - if (modelIds == null) { - return null; - } - boolean flip = invert ^ (rotation > 3); - int modelCount = modelIds.length; + if (adjustToTerrain) { + int groundY = (heightmapSW + heightmapSE + heightmapNE + heightmapNW) / 4; + for (int i = 0; i < model.vertexCount; i++) { + int x = model.vertexX[i]; + int z = model.vertexZ[i]; + int heightS = heightmapSW + (((heightmapSE - heightmapSW) * (x + 64)) / 128); + int heightN = heightmapNW + (((heightmapNE - heightmapNW) * (x + 64)) / 128); + int y = heightS + (((heightN - heightS) * (z + 64)) / 128); + model.vertexY[i] += y - groundY; + } + model.calculateBoundsY(); + } + return model; + } - for (int i = 0; i < modelCount; i++) { - int modelId = modelIds[i]; + public boolean method579() { + if (modelIDs == null) { + return true; + } + boolean flag1 = true; + for (int j : modelIDs) { + flag1 &= Model.validate(j & 0xffff); + } + return flag1; + } - if (flip) { - modelId += 0x10000; - } + public LocType getOverrideType() { + int value = -1; - model = modelCache.get(modelId); - if (model == null) { - model = Model.tryGet(modelId & 0xffff); - if (model == null) { - return null; - } - if (flip) { - model.rotateY180(); - } - modelCache.put((long) modelId, model); - } + if (varbit != -1) { + VarbitType varbit = VarbitType.instances[this.varbit]; + int varp = varbit.varp; + int low = varbit.lsb; + int high = varbit.msb; + int mask = Game.BITMASK[high - low]; + value = (game.variables[varp] >> low) & mask; + } else if (varp != -1) { + value = game.variables[varp]; + } - if (modelCount > 1) { - TMP_MODELS[i] = model; - } - } + if ((value < 0) || (value >= overrideTypeIDs.length) || (overrideTypeIDs[value] == -1)) { + return null; + } else { + return get(overrideTypeIDs[value]); + } + } - if (modelCount > 1) { - model = new Model(modelCount, TMP_MODELS); - } - } else { - int typeId = -1; - for (int i = 0; i < modelTypes.length; i++) { - if (modelTypes[i] != type) { - continue; - } - typeId = i; - break; - } + public Model getModel(int kind, int frame, int rotation) { + Model model = null; + long bitset; - if (typeId == -1) { - return null; - } + if (modelKinds == null) { + if (kind != 10) { + return null; + } - bitset = ((long) index << 6) + ((long) typeId << 3) + rotation + ((long) (seqFrame + 1) << 32); + bitset = ((long) index << 6) + rotation + ((long) (frame + 1) << 32); + Model cached = dynamicCache.get(bitset); - Model class30_sub2_sub4_sub6_2 = aCache_780.get(bitset); - if (class30_sub2_sub4_sub6_2 != null) { - return class30_sub2_sub4_sub6_2; - } - int j2 = modelIds[typeId]; - boolean flag3 = invert ^ (rotation > 3); - if (flag3) { - j2 += 0x10000; - } - model = modelCache.get(j2); - if (model == null) { - model = Model.tryGet(j2 & 0xffff); - if (model == null) { - return null; - } - if (flag3) { - model.rotateY180(); - } - modelCache.put((long) j2, model); - } - } + if (cached != null) { + return cached; + } - boolean scaled = (scaleX != 128) || (scaleZ != 128) || (scaleY != 128); - boolean translated = (translateX != 0) || (translateY != 0) || (translateZ != 0); + if (modelIDs == null) { + return null; + } - Model model_3 = new Model(srcColor == null, SeqFrame.isNull(seqFrame), (rotation == 0) && (seqFrame == -1) && !scaled && !translated, model); + boolean flip = invert ^ (rotation > 3); + int modelCount = modelIDs.length; - if (seqFrame != -1) { - model_3.createLabelReferences(); - model_3.applySequenceFrame(seqFrame); - model_3.labelFaces = null; - model_3.labelVertices = null; - } + for (int i = 0; i < modelCount; i++) { + int modelID = modelIDs[i]; - while (rotation-- > 0) { - model_3.rotateY90(); - } - if (srcColor != null) { - for (int k2 = 0; k2 < srcColor.length; k2++) { - model_3.recolor(srcColor[k2], dstColor[k2]); - } - } - if (scaled) { - model_3.scale(scaleX, scaleY, scaleZ); - } - if (translated) { - model_3.translate(translateX, translateY, translateZ); - } - model_3.calculateNormals(64 + lightAmbient, 768 + (lightAttenuation * 5), -50, -10, -50, !dynamic); - if (supportsObj == 1) { - model_3.objRaise = model_3.minY; - } - aCache_780.put(bitset, model_3); - return model_3; - } + if (flip) { + modelID += 0x10000; + } - public void method582(Buffer buffer) { - int i = -1; - label0: - do { - int j; - do { - j = buffer.get1U(); - if (j == 0) { - break label0; - } - if (j == 1) { - int k = buffer.get1U(); - if (k > 0) { - if ((modelIds == null) || lowmem) { - modelTypes = new int[k]; - modelIds = new int[k]; - for (int k1 = 0; k1 < k; k1++) { - modelIds[k1] = buffer.get2U(); - modelTypes[k1] = buffer.get1U(); - } - } else { - buffer.position += k * 3; - } - } - } else if (j == 2) { - name = buffer.getString(); - } else if (j == 3) { - description = buffer.getString(); - } else if (j == 5) { - int l = buffer.get1U(); - if (l > 0) { - if ((modelIds == null) || lowmem) { - modelTypes = null; - modelIds = new int[l]; - for (int l1 = 0; l1 < l; l1++) { - modelIds[l1] = buffer.get2U(); - } - } else { - buffer.position += l * 2; - } - } - } else if (j == 14) { - width = buffer.get1U(); - } else if (j == 15) { - length = buffer.get1U(); - } else if (j == 17) { - solid = false; - } else if (j == 18) { - blocksProjectiles = false; - } else if (j == 19) { - i = buffer.get1U(); - if (i == 1) { - interactable = true; - } - } else if (j == 21) { - adjustToTerrain = true; - } else if (j == 22) { - dynamic = true; - } else if (j == 23) { - occludes = true; - } else if (j == 24) { - seqId = buffer.get2U(); - if (seqId == 65535) { - seqId = -1; - } - } else if (j == 28) { - decorationPadding = buffer.get1U(); - } else if (j == 29) { - lightAmbient = buffer.get1(); - } else if (j == 39) { - lightAttenuation = buffer.get1(); - } else if ((j >= 30) && (j < 39)) { - if (actions == null) { - actions = new String[5]; - } - actions[j - 30] = buffer.getString(); - if (actions[j - 30].equalsIgnoreCase("hidden")) { - actions[j - 30] = null; - } - } else if (j == 40) { - int i1 = buffer.get1U(); - srcColor = new int[i1]; - dstColor = new int[i1]; - for (int i2 = 0; i2 < i1; i2++) { - srcColor[i2] = buffer.get2U(); - dstColor[i2] = buffer.get2U(); - } - } else if (j == 60) { - mapfunctionIcon = buffer.get2U(); - } else if (j == 62) { - invert = true; - } else if (j == 64) { - castShadow = false; - } else if (j == 65) { - scaleX = buffer.get2U(); - } else if (j == 66) { - scaleZ = buffer.get2U(); - } else if (j == 67) { - scaleY = buffer.get2U(); - } else if (j == 68) { - mapsceneIcon = buffer.get2U(); - } else if (j == 69) { - interactionSideFlags = buffer.get1U(); - } else if (j == 70) { - translateX = buffer.get2(); - } else if (j == 71) { - translateY = buffer.get2(); - } else if (j == 72) { - translateZ = buffer.get2(); - } else if (j == 73) { - important = true; - } else if (j == 74) { - decorative = true; - } else { - if (j != 75) { - continue; - } - supportsObj = buffer.get1U(); - } - continue label0; - } while (j != 77); - varbit = buffer.get2U(); - if (varbit == 65535) { - varbit = -1; - } - varp = buffer.get2U(); - if (varp == 65535) { - varp = -1; - } - int j1 = buffer.get1U(); - overrideIds = new int[j1 + 1]; - for (int j2 = 0; j2 <= j1; j2++) { - overrideIds[j2] = buffer.get2U(); - if (overrideIds[j2] == 65535) { - overrideIds[j2] = -1; - } - } - } while (true); - if (i == -1) { - interactable = (modelIds != null) && ((modelTypes == null) || (modelTypes[0] == 10)); - if (actions != null) { - interactable = true; - } - } - if (decorative) { - solid = false; - blocksProjectiles = false; - } - if (supportsObj == -1) { - supportsObj = solid ? 1 : 0; - } - } + model = staticCache.get(modelID); + if (model == null) { + model = Model.tryGet(modelID & 0xffff); + if (model == null) { + return null; + } + if (flip) { + model.rotateY180(); + } + staticCache.put((long) modelID, model); + } + + if (modelCount > 1) { + TMP_MODELS[i] = model; + } + } + + if (modelCount > 1) { + model = new Model(modelCount, TMP_MODELS); + } + } else { + int kindIndex = -1; + + for (int i = 0; i < modelKinds.length; i++) { + if (modelKinds[i] != kind) { + continue; + } + kindIndex = i; + break; + } + + if (kindIndex == -1) { + return null; + } + + bitset = ((long) this.index << 6) + ((long) kindIndex << 3) + rotation + ((long) (frame + 1) << 32); + + Model cached = dynamicCache.get(bitset); + + if (cached != null) { + return cached; + } + + int modelID = modelIDs[kindIndex]; + boolean flip = invert ^ (rotation > 3); + + if (flip) { + modelID += 0x10000; + } + + model = staticCache.get(modelID); + + if (model == null) { + model = Model.tryGet(modelID & 0xffff); + + if (model == null) { + return null; + } + + if (flip) { + model.rotateY180(); + } + + staticCache.put((long) modelID, model); + } + } + + boolean scaled = (scaleX != 128) || (scaleZ != 128) || (scaleY != 128); + boolean translated = (translateX != 0) || (translateY != 0) || (translateZ != 0); + + Model modified = new Model(srcColor == null, SeqFrame.isNull(frame), (rotation == 0) && (frame == -1) && !scaled && !translated, model); + + if (frame != -1) { + modified.createLabelReferences(); + modified.applySequenceFrame(frame); + modified.labelFaces = null; + modified.labelVertices = null; + } + + while (rotation-- > 0) { + modified.rotateY90(); + } + + if (srcColor != null) { + for (int k2 = 0; k2 < srcColor.length; k2++) { + modified.recolor(srcColor[k2], dstColor[k2]); + } + } + + if (scaled) { + modified.scale(scaleX, scaleY, scaleZ); + } + + if (translated) { + modified.translate(translateX, translateY, translateZ); + } + + modified.calculateNormals(64 + lightAmbient, 768 + (lightAttenuation * 5), -50, -10, -50, !dynamic); + + if (supportsObj == 1) { + modified.objRaise = modified.minY; + } + + dynamicCache.put(bitset, modified); + return modified; + } + + public void method582(Buffer buffer) { + int i = -1; + label0: + do { + int j; + do { + j = buffer.get1U(); + if (j == 0) { + break label0; + } + if (j == 1) { + int k = buffer.get1U(); + if (k > 0) { + if ((modelIDs == null) || lowmem) { + modelKinds = new int[k]; + modelIDs = new int[k]; + for (int k1 = 0; k1 < k; k1++) { + modelIDs[k1] = buffer.get2U(); + modelKinds[k1] = buffer.get1U(); + } + } else { + buffer.position += k * 3; + } + } + } else if (j == 2) { + name = buffer.getString(); + } else if (j == 3) { + description = buffer.getString(); + } else if (j == 5) { + int l = buffer.get1U(); + if (l > 0) { + if ((modelIDs == null) || lowmem) { + modelKinds = null; + modelIDs = new int[l]; + for (int l1 = 0; l1 < l; l1++) { + modelIDs[l1] = buffer.get2U(); + } + } else { + buffer.position += l * 2; + } + } + } else if (j == 14) { + width = buffer.get1U(); + } else if (j == 15) { + length = buffer.get1U(); + } else if (j == 17) { + solid = false; + } else if (j == 18) { + blocksProjectiles = false; + } else if (j == 19) { + i = buffer.get1U(); + if (i == 1) { + interactable = true; + } + } else if (j == 21) { + adjustToTerrain = true; + } else if (j == 22) { + dynamic = true; + } else if (j == 23) { + occludes = true; + } else if (j == 24) { + seqId = buffer.get2U(); + if (seqId == 65535) { + seqId = -1; + } + } else if (j == 28) { + decorationPadding = buffer.get1U(); + } else if (j == 29) { + lightAmbient = buffer.get1(); + } else if (j == 39) { + lightAttenuation = buffer.get1(); + } else if ((j >= 30) && (j < 39)) { + if (actions == null) { + actions = new String[5]; + } + actions[j - 30] = buffer.getString(); + if (actions[j - 30].equalsIgnoreCase("hidden")) { + actions[j - 30] = null; + } + } else if (j == 40) { + int i1 = buffer.get1U(); + srcColor = new int[i1]; + dstColor = new int[i1]; + for (int i2 = 0; i2 < i1; i2++) { + srcColor[i2] = buffer.get2U(); + dstColor[i2] = buffer.get2U(); + } + } else if (j == 60) { + mapfunctionIcon = buffer.get2U(); + } else if (j == 62) { + invert = true; + } else if (j == 64) { + castShadow = false; + } else if (j == 65) { + scaleX = buffer.get2U(); + } else if (j == 66) { + scaleZ = buffer.get2U(); + } else if (j == 67) { + scaleY = buffer.get2U(); + } else if (j == 68) { + mapsceneIcon = buffer.get2U(); + } else if (j == 69) { + interactionSideFlags = buffer.get1U(); + } else if (j == 70) { + translateX = buffer.get2(); + } else if (j == 71) { + translateY = buffer.get2(); + } else if (j == 72) { + translateZ = buffer.get2(); + } else if (j == 73) { + important = true; + } else if (j == 74) { + decorative = true; + } else { + if (j != 75) { + continue; + } + supportsObj = buffer.get1U(); + } + continue label0; + } while (j != 77); + varbit = buffer.get2U(); + if (varbit == 65535) { + varbit = -1; + } + varp = buffer.get2U(); + if (varp == 65535) { + varp = -1; + } + int j1 = buffer.get1U(); + overrideTypeIDs = new int[j1 + 1]; + for (int j2 = 0; j2 <= j1; j2++) { + overrideTypeIDs[j2] = buffer.get2U(); + if (overrideTypeIDs[j2] == 65535) { + overrideTypeIDs[j2] = -1; + } + } + } while (true); + if (i == -1) { + interactable = (modelIDs != null) && ((modelKinds == null) || (modelKinds[0] == 10)); + if (actions != null) { + interactable = true; + } + } + if (decorative) { + solid = false; + blocksProjectiles = false; + } + if (supportsObj == -1) { + supportsObj = solid ? 1 : 0; + } + } } diff --git a/src/main/java/Model.java b/src/main/java/Model.java index ff75111..f43bdff 100644 --- a/src/main/java/Model.java +++ b/src/main/java/Model.java @@ -892,7 +892,7 @@ public class Model extends Entity { * @param copyVertexY true to copy model.vertexY. * @param copyFaces true to copy all face data from model. * @param model the model to copy. - * @see LocType#method578(int, int, int, int, int, int, int) + * @see LocType#getModel(int, int, int, int, int, int, int) */ public Model(boolean copyVertexY, boolean copyFaces, Model model) { counter++; diff --git a/src/main/java/Scene.java b/src/main/java/Scene.java index fa65702..7555539 100644 --- a/src/main/java/Scene.java +++ b/src/main/java/Scene.java @@ -329,56 +329,56 @@ public class Scene { planeTiles[plane][stx][stz].objStack = objStack; } - public void addWall(int type0, Entity wall0, int type1, Entity wall1, int plane, int stx, int stz, int y, int bitset, byte info) { - if ((wall0 == null) && (wall1 == null)) { + public void setWall(int occludeA, Entity entityA, int occludeB, Entity entityB, int plane, int localX, int localZ, int y, int bitset, byte info) { + if ((entityA == null) && (entityB == null)) { return; } SceneWall wall = new SceneWall(); wall.bitset = bitset; wall.info = info; - wall.x = (stx * 128) + 64; - wall.z = (stz * 128) + 64; + wall.x = (localX * 128) + 64; + wall.z = (localZ * 128) + 64; wall.y = y; - wall.entity0 = wall0; - wall.entity1 = wall1; - wall.type0 = type0; - wall.type1 = type1; + wall.entityA = entityA; + wall.entityB = entityB; + wall.occludeA = occludeA; + wall.occludeB = occludeB; for (int p = plane; p >= 0; p--) { - if (planeTiles[p][stx][stz] == null) { - planeTiles[p][stx][stz] = new SceneTile(p, stx, stz); + if (planeTiles[p][localX][localZ] == null) { + planeTiles[p][localX][localZ] = new SceneTile(p, localX, localZ); } } - planeTiles[plane][stx][stz].wall = wall; + planeTiles[plane][localX][localZ].wall = wall; } - public void addWallDecoration(int type, Entity entity, int plane, int stx, int stz, int y, int yaw, int offsetX, int offsetZ, int bitset, byte info) { + public void setWallDecoration(int occlude, Entity entity, int plane, int localX, int localZ, int y, int yaw, int offsetX, int offsetZ, int bitset, byte info) { if (entity == null) { return; } - SceneWallDecoration decor = new SceneWallDecoration(); - decor.bitset = bitset; - decor.info = info; - decor.x = (stx * 128) + 64 + offsetX; - decor.z = (stz * 128) + 64 + offsetZ; - decor.y = y; - decor.entity = entity; - decor.type = type; - decor.yaw = yaw; + SceneWallDecoration deco = new SceneWallDecoration(); + deco.bitset = bitset; + deco.info = info; + deco.x = (localX * 128) + 64 + offsetX; + deco.z = (localZ * 128) + 64 + offsetZ; + deco.y = y; + deco.entity = entity; + deco.occlude = occlude; + deco.yaw = yaw; for (int p = plane; p >= 0; p--) { - if (planeTiles[p][stx][stz] == null) { - planeTiles[p][stx][stz] = new SceneTile(p, stx, stz); + if (planeTiles[p][localX][localZ] == null) { + planeTiles[p][localX][localZ] = new SceneTile(p, localX, localZ); } } - planeTiles[plane][stx][stz].wallDecoration = decor; + planeTiles[plane][localX][localZ].wallDecoration = deco; } - public boolean add(Entity entity, int plane, int stx, int stz, int y, int width, int length, int yaw, int bitset, byte info) { + public boolean add(Entity entity, int plane, int localX, int localZ, int y, int width, int length, int yaw, int bitset, byte info) { if (entity == null) { return true; } else { - int x = (stx * 128) + (64 * width); - int z = (stz * 128) + (64 * length); - return add(entity, plane, stx, stz, width, length, x, z, y, yaw, bitset, info, false); + int x = (localX * 128) + (64 * width); + int z = (localZ * 128) + (64 * length); + return add(entity, plane, localX, localZ, width, length, x, z, y, yaw, bitset, info, false); } } @@ -628,8 +628,8 @@ public class Scene { } } - public int getWallBitset(int i, int j, int k) { - SceneTile tile = planeTiles[i][j][k]; + public int getWallBitset(int plane, int x, int z) { + SceneTile tile = planeTiles[plane][x][z]; if ((tile != null) && (tile.wall != null)) { return tile.wall.bitset; } else { @@ -671,21 +671,26 @@ public class Scene { public int getInfo(int plane, int x, int z, int bitset) { SceneTile tile = planeTiles[plane][x][z]; + if (tile == null) { return -1; } + if ((tile.wall != null) && (tile.wall.bitset == bitset)) { return tile.wall.info & 0xff; } + if ((tile.wallDecoration != null) && (tile.wallDecoration.bitset == bitset)) { return tile.wallDecoration.info & 0xff; } + if ((tile.groundDecoration != null) && (tile.groundDecoration.bitset == bitset)) { return tile.groundDecoration.info & 0xff; } - for (int i1 = 0; i1 < tile.locCount; i1++) { - if (tile.locs[i1].bitset == bitset) { - return tile.locs[i1].info & 0xff; + + for (int i = 0; i < tile.locCount; i++) { + if (tile.locs[i].bitset == bitset) { + return tile.locs[i].info & 0xff; } } return -1; @@ -700,14 +705,14 @@ public class Scene { SceneTile tile = planeTiles[l1][i2][j2]; if (tile != null) { SceneWall wall = tile.wall; - if ((wall != null) && (wall.entity0 != null) && (wall.entity0.vertexNormal != null)) { - method307(l1, 1, 1, i2, j2, (Model) wall.entity0); - if ((wall.entity1 != null) && (wall.entity1.vertexNormal != null)) { - method307(l1, 1, 1, i2, j2, (Model) wall.entity1); - method308((Model) wall.entity0, (Model) wall.entity1, 0, 0, 0, false); - ((Model) wall.entity1).applyLighting(j, k1, k, i, i1); + if ((wall != null) && (wall.entityA != null) && (wall.entityA.vertexNormal != null)) { + method307(l1, 1, 1, i2, j2, (Model) wall.entityA); + if ((wall.entityB != null) && (wall.entityB.vertexNormal != null)) { + method307(l1, 1, 1, i2, j2, (Model) wall.entityB); + method308((Model) wall.entityA, (Model) wall.entityB, 0, 0, 0, false); + ((Model) wall.entityB).applyLighting(j, k1, k, i, i1); } - ((Model) wall.entity0).applyLighting(j, k1, k, i, i1); + ((Model) wall.entityA).applyLighting(j, k1, k, i, i1); } for (int k2 = 0; k2 < tile.locCount; k2++) { SceneLoc loc = tile.locs[k2]; @@ -770,11 +775,11 @@ public class Scene { if (tile != null) { int i3 = ((planeHeightmaps[j2][k2][l2] + planeHeightmaps[j2][k2 + 1][l2] + planeHeightmaps[j2][k2][l2 + 1] + planeHeightmaps[j2][k2 + 1][l2 + 1]) / 4) - ((planeHeightmaps[i][l][i1] + planeHeightmaps[i][l + 1][i1] + planeHeightmaps[i][l][i1 + 1] + planeHeightmaps[i][l + 1][i1 + 1]) / 4); SceneWall wall = tile.wall; - if ((wall != null) && (wall.entity0 != null) && (wall.entity0.vertexNormal != null)) { - method308(model, (Model) wall.entity0, ((k2 - l) * 128) + ((1 - j) * 64), i3, ((l2 - i1) * 128) + ((1 - k) * 64), flag); + if ((wall != null) && (wall.entityA != null) && (wall.entityA.vertexNormal != null)) { + method308(model, (Model) wall.entityA, ((k2 - l) * 128) + ((1 - j) * 64), i3, ((l2 - i1) * 128) + ((1 - k) * 64), flag); } - if ((wall != null) && (wall.entity1 != null) && (wall.entity1.vertexNormal != null)) { - method308(model, (Model) wall.entity1, ((k2 - l) * 128) + ((1 - j) * 64), i3, ((l2 - i1) * 128) + ((1 - k) * 64), flag); + if ((wall != null) && (wall.entityB != null) && (wall.entityB.vertexNormal != null)) { + method308(model, (Model) wall.entityB, ((k2 - l) * 128) + ((1 - j) * 64), i3, ((l2 - i1) * 128) + ((1 - k) * 64), flag); } for (int j3 = 0; j3 < tile.locCount; j3++) { SceneLoc loc = tile.locs[j3]; @@ -1154,7 +1159,7 @@ public class Scene { } SceneWall wall = tile_7.wall; if (wall != null) { - wall.entity0.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall.x - eyeX, wall.y - eyeY, wall.z - eyeZ, wall.bitset); + wall.entityA.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall.x - eyeX, wall.y - eyeY, wall.z - eyeZ, wall.bitset); } for (int i2 = 0; i2 < tile_7.locCount; i2++) { SceneLoc loc = tile_7.locs[i2]; @@ -1192,16 +1197,16 @@ public class Scene { tile_1.anInt1328 = anIntArray480[j1]; } if (wall != null) { - if ((wall.type0 & anIntArray479[j1]) != 0) { - if (wall.type0 == 16) { + if ((wall.occludeA & anIntArray479[j1]) != 0) { + if (wall.occludeA == 16) { tile_1.anInt1325 = 3; tile_1.anInt1326 = anIntArray481[j1]; tile_1.anInt1327 = 3 - tile_1.anInt1326; - } else if (wall.type0 == 32) { + } else if (wall.occludeA == 32) { tile_1.anInt1325 = 6; tile_1.anInt1326 = anIntArray482[j1]; tile_1.anInt1327 = 6 - tile_1.anInt1326; - } else if (wall.type0 == 64) { + } else if (wall.occludeA == 64) { tile_1.anInt1325 = 12; tile_1.anInt1326 = anIntArray483[j1]; tile_1.anInt1327 = 12 - tile_1.anInt1326; @@ -1213,17 +1218,17 @@ public class Scene { } else { tile_1.anInt1325 = 0; } - if (((wall.type0 & j2) != 0) && !wallOccluded(l, i, j, wall.type0)) { - wall.entity0.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall.x - eyeX, wall.y - eyeY, wall.z - eyeZ, wall.bitset); + if (((wall.occludeA & j2) != 0) && !wallOccluded(l, i, j, wall.occludeA)) { + wall.entityA.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall.x - eyeX, wall.y - eyeY, wall.z - eyeZ, wall.bitset); } - if (((wall.type1 & j2) != 0) && !wallOccluded(l, i, j, wall.type1)) { - wall.entity1.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall.x - eyeX, wall.y - eyeY, wall.z - eyeZ, wall.bitset); + if (((wall.occludeB & j2) != 0) && !wallOccluded(l, i, j, wall.occludeB)) { + wall.entityB.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall.x - eyeX, wall.y - eyeY, wall.z - eyeZ, wall.bitset); } } if ((decor != null) && !occluded(l, i, j, decor.entity.minY)) { - if ((decor.type & j2) != 0) { + if ((decor.occlude & j2) != 0) { decor.entity.draw(decor.yaw, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, decor.x - eyeX, decor.y - eyeY, decor.z - eyeZ, decor.bitset); - } else if ((decor.type & 0x300) != 0) { + } else if ((decor.occlude & 0x300) != 0) { int j4 = decor.x - eyeX; int l5 = decor.y - eyeY; int k6 = decor.z - eyeZ; @@ -1240,12 +1245,12 @@ public class Scene { } else { k10 = k6; } - if (((decor.type & 0x100) != 0) && (k10 < k9)) { + if (((decor.occlude & 0x100) != 0) && (k10 < k9)) { int i11 = j4 + anIntArray463[i8]; int k11 = k6 + anIntArray464[i8]; decor.entity.draw((i8 * 512) + 256, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, i11, l5, k11, decor.bitset); } - if (((decor.type & 0x200) != 0) && (k10 > k9)) { + if (((decor.occlude & 0x200) != 0) && (k10 > k9)) { int j11 = j4 + anIntArray465[i8]; int l11 = k6 + anIntArray466[i8]; decor.entity.draw(((i8 * 512) + 1280) & 0x7ff, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, j11, l5, l11, decor.bitset); @@ -1309,8 +1314,8 @@ public class Scene { } if (flag2) { SceneWall wall_1 = tile_1.wall; - if (!wallOccluded(l, i, j, wall_1.type0)) { - wall_1.entity0.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall_1.x - eyeX, wall_1.y - eyeY, wall_1.z - eyeZ, wall_1.bitset); + if (!wallOccluded(l, i, j, wall_1.occludeA)) { + wall_1.entityA.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall_1.x - eyeX, wall_1.y - eyeY, wall_1.z - eyeZ, wall_1.bitset); } tile_1.anInt1325 = 0; } @@ -1474,46 +1479,46 @@ public class Scene { } } if (tile_1.anInt1328 != 0) { - SceneWallDecoration wallDecoration = tile_1.wallDecoration; - if ((wallDecoration != null) && !occluded(l, i, j, wallDecoration.entity.minY)) { - if ((wallDecoration.type & tile_1.anInt1328) != 0) { - wallDecoration.entity.draw(wallDecoration.yaw, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wallDecoration.x - eyeX, wallDecoration.y - eyeY, wallDecoration.z - eyeZ, wallDecoration.bitset); - } else if ((wallDecoration.type & 0x300) != 0) { - int l2 = wallDecoration.x - eyeX; - int j3 = wallDecoration.y - eyeY; - int i4 = wallDecoration.z - eyeZ; - int k5 = wallDecoration.yaw; + SceneWallDecoration deco = tile_1.wallDecoration; + if ((deco != null) && !occluded(l, i, j, deco.entity.minY)) { + if ((deco.occlude & tile_1.anInt1328) != 0) { + deco.entity.draw(deco.yaw, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, deco.x - eyeX, deco.y - eyeY, deco.z - eyeZ, deco.bitset); + } else if ((deco.occlude & 0x300) != 0) { + int dx = deco.x - eyeX; + int dy = deco.y - eyeY; + int dz = deco.z - eyeZ; + int rotation = deco.yaw; int j6; - if ((k5 == 1) || (k5 == 2)) { - j6 = -l2; + if ((rotation == 1) || (rotation == 2)) { + j6 = -dx; } else { - j6 = l2; + j6 = dx; } int l7; - if ((k5 == 2) || (k5 == 3)) { - l7 = -i4; + if ((rotation == 2) || (rotation == 3)) { + l7 = -dz; } else { - l7 = i4; + l7 = dz; } - if (((wallDecoration.type & 0x100) != 0) && (l7 >= j6)) { - int i9 = l2 + anIntArray463[k5]; - int i10 = i4 + anIntArray464[k5]; - wallDecoration.entity.draw((k5 * 512) + 256, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, i9, j3, i10, wallDecoration.bitset); + if (((deco.occlude & 0x100) != 0) && (l7 >= j6)) { + int i9 = dx + anIntArray463[rotation]; + int i10 = dz + anIntArray464[rotation]; + deco.entity.draw((rotation * 512) + 256, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, i9, dy, i10, deco.bitset); } - if (((wallDecoration.type & 0x200) != 0) && (l7 <= j6)) { - int j9 = l2 + anIntArray465[k5]; - int j10 = i4 + anIntArray466[k5]; - wallDecoration.entity.draw(((k5 * 512) + 1280) & 0x7ff, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, j9, j3, j10, wallDecoration.bitset); + if (((deco.occlude & 0x200) != 0) && (l7 <= j6)) { + int j9 = dx + anIntArray465[rotation]; + int j10 = dz + anIntArray466[rotation]; + deco.entity.draw(((rotation * 512) + 1280) & 0x7ff, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, j9, dy, j10, deco.bitset); } } } SceneWall wall_2 = tile_1.wall; if (wall_2 != null) { - if (((wall_2.type1 & tile_1.anInt1328) != 0) && !wallOccluded(l, i, j, wall_2.type1)) { - wall_2.entity1.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall_2.x - eyeX, wall_2.y - eyeY, wall_2.z - eyeZ, wall_2.bitset); + if (((wall_2.occludeB & tile_1.anInt1328) != 0) && !wallOccluded(l, i, j, wall_2.occludeB)) { + wall_2.entityB.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall_2.x - eyeX, wall_2.y - eyeY, wall_2.z - eyeZ, wall_2.bitset); } - if (((wall_2.type0 & tile_1.anInt1328) != 0) && !wallOccluded(l, i, j, wall_2.type0)) { - wall_2.entity0.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall_2.x - eyeX, wall_2.y - eyeY, wall_2.z - eyeZ, wall_2.bitset); + if (((wall_2.occludeA & tile_1.anInt1328) != 0) && !wallOccluded(l, i, j, wall_2.occludeA)) { + wall_2.entityA.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall_2.x - eyeX, wall_2.y - eyeY, wall_2.z - eyeZ, wall_2.bitset); } } } diff --git a/src/main/java/SceneBuilder.java b/src/main/java/SceneBuilder.java index 856bd83..3ec16c7 100644 --- a/src/main/java/SceneBuilder.java +++ b/src/main/java/SceneBuilder.java @@ -4,1277 +4,1342 @@ public class SceneBuilder { - public static final int[] anIntArray137 = {1, 0, -1, 0}; - public static final int[] WALL_TYPE_1 = {16, 32, 64, 128}; - public static final int[] anIntArray144 = {0, -1, 0, 1}; - public static final int[] WALL_TYPE_0 = {1, 2, 4, 8}; - public static int anInt123 = (int) (Math.random() * 17.0) - 8; - public static int anInt131; - public static int anInt133 = (int) (Math.random() * 33.0) - 16; - public static int anInt145 = 99; - public static boolean lowmem = true; + public static final int[] anIntArray137 = {1, 0, -1, 0}; + public static final int[] WALL_ROTATION_OCCLUDE_TYPE_1 = {16, 32, 64, 128}; + public static final int[] anIntArray144 = {0, -1, 0, 1}; + public static final int[] WALL_ROTATION_OCCLUDE_TYPE = {1, 2, 4, 8}; + public static int anInt123 = (int) (Math.random() * 17.0) - 8; + public static int anInt131; + public static int anInt133 = (int) (Math.random() * 33.0) - 16; + public static int minPlane = 99; + public static boolean lowmem = true; - public static int method170(int i, int i_3_) { - int i_4_ = i + (i_3_ * 57); - i_4_ = (i_4_ << 13) ^ i_4_; - int i_5_ = ((i_4_ * ((i_4_ * i_4_ * 15731) + 789221)) + 1376312589) & 0x7fffffff; - return (i_5_ >> 19) & 0xff; - } + public static int method170(int i, int i_3_) { + int i_4_ = i + (i_3_ * 57); + i_4_ = (i_4_ << 13) ^ i_4_; + int i_5_ = ((i_4_ * ((i_4_ * i_4_ * 15731) + 789221)) + 1376312589) & 0x7fffffff; + return (i_5_ >> 19) & 0xff; + } - 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)); - i_109_ = (int) ((double) i_109_ * 0.3) + 35; - if (i_109_ < 10) { - i_109_ = 10; - } else if (i_109_ > 60) { - i_109_ = 60; - } - return i_109_; - } + 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)); + i_109_ = (int) ((double) i_109_ * 0.3) + 35; + if (i_109_ < 10) { + i_109_ = 10; + } else if (i_109_ > 60) { + i_109_ = 60; + } + return i_109_; + } - public static void method173(Buffer buffer, OnDemand onDemand) { - int i_110_ = -1; - for (; ; ) { - int i_111_ = buffer.getSmartU(); - if (i_111_ == 0) { - break; - } - i_110_ += i_111_; - LocType type = LocType.get(i_110_); - type.method574(onDemand); - for (; ; ) { - int i_112_ = buffer.getSmartU(); - if (i_112_ == 0) { - break; - } - buffer.get1U(); - } - } - } + public static void method173(Buffer buffer, OnDemand onDemand) { + int i_110_ = -1; + for (; ; ) { + int i_111_ = buffer.getSmartU(); + if (i_111_ == 0) { + break; + } + i_110_ += i_111_; + LocType type = LocType.get(i_110_); + type.method574(onDemand); + for (; ; ) { + int i_112_ = buffer.getSmartU(); + if (i_112_ == 0) { + break; + } + buffer.get1U(); + } + } + } - public static int method176(int i, int i_144_, int i_145_) { - int i_146_ = i / i_145_; - int i_147_ = i & (i_145_ - 1); - int i_148_ = i_144_ / i_145_; - int i_149_ = i_144_ & (i_145_ - 1); - int i_150_ = method186(i_146_, i_148_); - int i_151_ = method186(i_146_ + 1, i_148_); - int i_152_ = method186(i_146_, i_148_ + 1); - int i_153_ = method186(i_146_ + 1, i_148_ + 1); - int i_154_ = method184(i_150_, i_151_, i_147_, i_145_); - int i_155_ = method184(i_152_, i_153_, i_147_, i_145_); - return method184(i_154_, i_155_, i_149_, i_145_); - } + public static int method176(int i, int i_144_, int i_145_) { + int i_146_ = i / i_145_; + int i_147_ = i & (i_145_ - 1); + int i_148_ = i_144_ / i_145_; + int i_149_ = i_144_ & (i_145_ - 1); + int i_150_ = method186(i_146_, i_148_); + int i_151_ = method186(i_146_ + 1, i_148_); + int i_152_ = method186(i_146_, i_148_ + 1); + int i_153_ = method186(i_146_ + 1, i_148_ + 1); + int i_154_ = method184(i_150_, i_151_, i_147_, i_145_); + int i_155_ = method184(i_152_, i_153_, i_147_, i_145_); + return method184(i_154_, i_155_, i_149_, i_145_); + } - public static boolean method178(int i, int i_159_) { - LocType type = LocType.get(i); - if (i_159_ == 11) { - i_159_ = 10; - } - if ((i_159_ >= 5) && (i_159_ <= 8)) { - i_159_ = 4; - } - return type.method577(i_159_); - } + /** + * Used to determine if a LocType's models have been loaded. + * + * @param locID the loc type id. + * @param kind the loc kind. + * @return true if the loc models are ready. + */ + public static boolean isLocReady(int locID, int kind) { + LocType type = LocType.get(locID); + if (kind == 11) { + kind = 10; + } + if ((kind >= 5) && (kind <= 8)) { + kind = 4; + } + return type.validate(kind); + } - 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); - return ((i * (65536 - i_219_)) >> 16) + ((i_216_ * i_219_) >> 16); - } + 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); + 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_224_ = method170(i, i_221_); - return (i_222_ / 16) + (i_223_ / 8) + (i_224_ / 4); - } + 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_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) { - return 12345678; - } - i_225_ = (i_225_ * (i & 0x7f)) / 128; - if (i_225_ < 2) { - i_225_ = 2; - } else if (i_225_ > 126) { - i_225_ = 126; - } - return (i & 0xff80) + i_225_; - } + public static int method187(int i, int i_225_) { + if (i == -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; + } + return (i & 0xff80) + i_225_; + } - public static void method188(Scene scene, int angle, int stz, int type, int groundPlane, SceneCollisionMap collisionMap, int[][][] planeHeightmap, int stx, int locId, int locPlane) { - int y00 = planeHeightmap[groundPlane][stx][stz]; - int y10 = planeHeightmap[groundPlane][stx + 1][stz]; - int y11 = planeHeightmap[groundPlane][stx + 1][stz + 1]; - int y01 = planeHeightmap[groundPlane][stx][stz + 1]; - int y = (y00 + y10 + y11 + y01) >> 2; + public static void addLoc(Scene scene, int rotation, int z, int kind, int plane, SceneCollisionMap collision, int[][][] planeHeightmap, int x, int locID, int dataPlane) { + int heightSW = planeHeightmap[plane][x][z]; + int heightSE = planeHeightmap[plane][x + 1][z]; + int heightNE = planeHeightmap[plane][x + 1][z + 1]; + int heightNW = planeHeightmap[plane][x][z + 1]; + int y = (heightSW + heightSE + heightNE + heightNW) >> 2; - LocType loc = LocType.get(locId); - int bitset = stx + (stz << 7) + (locId << 14) + 1073741824; + LocType loc = LocType.get(locID); + int bitset = x + (z << 7) + (locID << 14) + 1073741824; - if (!loc.interactable) { - bitset += -2147483648; - } + if (!loc.interactable) { + bitset += 0x80000000; + } - byte info = (byte) ((angle << 6) + type); + byte info = (byte) ((rotation << 6) + kind); - if (type == 22) { - Entity entity; + if (kind == 22) { + Entity entity; - if ((loc.seqId == -1) && (loc.overrideIds == null)) { - entity = loc.method578(22, angle, y00, y10, y11, y01, -1); - } else { - entity = new LocEntity(locId, angle, 22, y10, y11, y00, y01, loc.seqId, true); - } + if ((loc.seqId == -1) && (loc.overrideTypeIDs == null)) { + entity = loc.getModel(22, rotation, heightSW, heightSE, heightNE, heightNW, -1); + } else { + entity = new LocEntity(locID, rotation, 22, heightSE, heightNE, heightSW, heightNW, loc.seqId, true); + } - scene.addGroundDecoration(entity, locPlane, stx, stz, y, bitset, info); + scene.addGroundDecoration(entity, dataPlane, x, z, y, bitset, info); - if (loc.solid && loc.interactable) { - collisionMap.method213(stz, stx); - } - } else if ((type == 10) || (type == 11)) { - Entity entity; + if (loc.solid && loc.interactable) { + collision.addSolid(z, x); + } + } else if ((kind == 10) || (kind == 11)) { + Entity entity; - if ((loc.seqId == -1) && (loc.overrideIds == null)) { - entity = loc.method578(10, angle, y00, y10, y11, y01, -1); - } else { - entity = new LocEntity(locId, angle, 10, y10, y11, y00, y01, loc.seqId, true); - } + if ((loc.seqId == -1) && (loc.overrideTypeIDs == null)) { + entity = loc.getModel(10, rotation, heightSW, heightSE, heightNE, heightNW, -1); + } else { + entity = new LocEntity(locID, rotation, 10, heightSE, heightNE, heightSW, heightNW, loc.seqId, true); + } - if (entity != null) { - int i_240_ = 0; + if (entity != null) { + int angle = 0; - if (type == 11) { - i_240_ += 256; - } + if (kind == 11) { + angle += 256; + } - int i_241_; - int i_242_; + int width; + int length; - if ((angle == 1) || (angle == 3)) { - i_241_ = loc.length; - i_242_ = loc.width; - } else { - i_241_ = loc.width; - i_242_ = loc.length; - } + if ((rotation == 1) || (rotation == 3)) { + width = loc.length; + length = loc.width; + } else { + width = loc.width; + length = loc.length; + } - scene.add(entity, locPlane, stx, stz, y, i_241_, i_242_, i_240_, bitset, info); - } - if (loc.solid) { - collisionMap.method212(loc.blocksProjectiles, loc.width, loc.length, stx, stz, angle); - } - } else if (type >= 12) { - Entity entity; - if ((loc.seqId == -1) && (loc.overrideIds == null)) { - entity = loc.method578(type, angle, y00, y10, y11, y01, -1); - } else { - entity = new LocEntity(locId, angle, type, y10, y11, y00, y01, loc.seqId, true); - } - scene.add(entity, locPlane, stx, stz, y, 1, 1, 0, bitset, info); - if (loc.solid) { - collisionMap.method212(loc.blocksProjectiles, loc.width, loc.length, stx, stz, angle); - } - } else if (type == 0) { - Entity entity; - if ((loc.seqId == -1) && (loc.overrideIds == null)) { - entity = loc.method578(0, angle, y00, y10, y11, y01, -1); - } else { - entity = new LocEntity(locId, angle, 0, y10, y11, y00, y01, loc.seqId, true); - } - scene.addWall(WALL_TYPE_0[angle], entity, 0, null, locPlane, stx, stz, y, bitset, info); - if (loc.solid) { - collisionMap.method211(stz, angle, stx, type, loc.blocksProjectiles); - } - } else if (type == 1) { - Entity entity; - if ((loc.seqId == -1) && (loc.overrideIds == null)) { - entity = loc.method578(1, angle, y00, y10, y11, y01, -1); - } else { - entity = new LocEntity(locId, angle, 1, y10, y11, y00, y01, loc.seqId, true); - } - scene.addWall(WALL_TYPE_1[angle], entity, 0, null, locPlane, stx, stz, y, bitset, info); - if (loc.solid) { - collisionMap.method211(stz, angle, stx, type, loc.blocksProjectiles); - } - } else if (type == 2) { - int i_243_ = (angle + 1) & 0x3; - Entity entity; - Entity entity_244_; - if ((loc.seqId == -1) && (loc.overrideIds == null)) { - entity = loc.method578(2, 4 + angle, y00, y10, y11, y01, -1); - entity_244_ = loc.method578(2, i_243_, y00, y10, y11, y01, -1); - } else { - entity = new LocEntity(locId, 4 + angle, 2, y10, y11, y00, y01, loc.seqId, true); - entity_244_ = new LocEntity(locId, i_243_, 2, y10, y11, y00, y01, loc.seqId, true); - } - scene.addWall(WALL_TYPE_0[angle], entity, WALL_TYPE_0[i_243_], entity_244_, locPlane, stx, stz, y, bitset, info); - if (loc.solid) { - collisionMap.method211(stz, angle, stx, type, loc.blocksProjectiles); - } - } else if (type == 3) { - Entity entity; - if ((loc.seqId == -1) && (loc.overrideIds == null)) { - entity = loc.method578(3, angle, y00, y10, y11, y01, -1); - } else { - entity = new LocEntity(locId, angle, 3, y10, y11, y00, y01, loc.seqId, true); - } - scene.addWall(WALL_TYPE_1[angle], entity, 0, null, locPlane, stx, stz, y, bitset, info); - if (loc.solid) { - collisionMap.method211(stz, angle, stx, type, loc.blocksProjectiles); - } - } else if (type == 9) { - Entity entity; - if ((loc.seqId == -1) && (loc.overrideIds == null)) { - entity = loc.method578(type, angle, y00, y10, y11, y01, -1); - } else { - entity = new LocEntity(locId, angle, type, y10, y11, y00, y01, loc.seqId, true); - } - scene.add(entity, locPlane, stx, stz, y, 1, 1, 0, bitset, info); - if (loc.solid) { - collisionMap.method212(loc.blocksProjectiles, loc.width, loc.length, stx, stz, angle); - } - } else { - if (loc.adjustToTerrain) { - if (angle == 1) { - int i_245_ = y01; - y01 = y11; - y11 = y10; - y10 = y00; - y00 = i_245_; - } else if (angle == 2) { - int i_246_ = y01; - y01 = y10; - y10 = i_246_; - i_246_ = y11; - y11 = y00; - y00 = i_246_; - } else if (angle == 3) { - int i_247_ = y01; - y01 = y00; - y00 = y10; - y10 = y11; - y11 = i_247_; - } - } - if (type == 4) { - Entity entity; - if ((loc.seqId == -1) && (loc.overrideIds == null)) { - entity = loc.method578(4, 0, y00, y10, y11, y01, -1); - } else { - entity = new LocEntity(locId, 0, 4, y10, y11, y00, y01, loc.seqId, true); - } - scene.addWallDecoration(WALL_TYPE_0[angle], entity, locPlane, stx, stz, y, angle * 512, 0, 0, bitset, info); - } else if (type == 5) { - int i_248_ = 16; - int i_249_ = scene.getWallBitset(locPlane, stx, stz); - if (i_249_ > 0) { - i_248_ = LocType.get((i_249_ >> 14) & 0x7fff).decorationPadding; - } - Entity entity; - if ((loc.seqId == -1) && (loc.overrideIds == null)) { - entity = loc.method578(4, 0, y00, y10, y11, y01, -1); - } else { - entity = new LocEntity(locId, 0, 4, y10, y11, y00, y01, loc.seqId, true); - } - scene.addWallDecoration(WALL_TYPE_0[angle], entity, locPlane, stx, stz, y, angle * 512, anIntArray137[angle] * i_248_, anIntArray144[angle] * i_248_, bitset, info); - } else if (type == 6) { - Entity entity; - if ((loc.seqId == -1) && (loc.overrideIds == null)) { - entity = loc.method578(4, 0, y00, y10, y11, y01, -1); - } else { - entity = new LocEntity(locId, 0, 4, y10, y11, y00, y01, loc.seqId, true); - } - scene.addWallDecoration(256, entity, locPlane, stx, stz, y, angle, 0, 0, bitset, info); - } else if (type == 7) { - Entity entity; - if ((loc.seqId == -1) && (loc.overrideIds == null)) { - entity = loc.method578(4, 0, y00, y10, y11, y01, -1); - } else { - entity = new LocEntity(locId, 0, 4, y10, y11, y00, y01, loc.seqId, true); - } - scene.addWallDecoration(512, entity, locPlane, stx, stz, y, angle, 0, 0, bitset, info); - } else if (type == 8) { - Entity entity; - if ((loc.seqId == -1) && (loc.overrideIds == null)) { - entity = loc.method578(4, 0, y00, y10, y11, y01, -1); - } else { - entity = new LocEntity(locId, 0, 4, y10, y11, y00, y01, loc.seqId, true); - } - scene.addWallDecoration(768, entity, locPlane, stx, stz, y, angle, 0, 0, bitset, info); - } - } - } + scene.add(entity, dataPlane, x, z, y, width, length, angle, bitset, info); + } + if (loc.solid) { + collision.add(loc.blocksProjectiles, loc.width, loc.length, x, z, rotation); + } + } else if (kind >= 12) { + Entity entity; + if ((loc.seqId == -1) && (loc.overrideTypeIDs == null)) { + entity = loc.getModel(kind, rotation, heightSW, heightSE, heightNE, heightNW, -1); + } else { + entity = new LocEntity(locID, rotation, kind, heightSE, heightNE, heightSW, heightNW, loc.seqId, true); + } - public static boolean method189(int i, byte[] is, int i_250_) { - boolean bool = true; - Buffer buffer = new Buffer(is); - int i_252_ = -1; - for (; ; ) { - int i_253_ = buffer.getSmartU(); - if (i_253_ == 0) { - break; - } - i_252_ += i_253_; - int i_254_ = 0; - boolean bool_255_ = false; - for (; ; ) { - if (bool_255_) { - int i_256_ = buffer.getSmartU(); - if (i_256_ == 0) { - break; - } - buffer.get1U(); - } else { - int i_257_ = buffer.getSmartU(); - if (i_257_ == 0) { - break; - } - i_254_ += i_257_ - 1; - int i_258_ = i_254_ & 0x3f; - int i_259_ = (i_254_ >> 6) & 0x3f; - int i_260_ = buffer.get1U() >> 2; - int i_261_ = i_259_ + i; - int i_262_ = i_258_ + i_250_; - if ((i_261_ > 0) && (i_262_ > 0) && (i_261_ < 103) && (i_262_ < 103)) { - LocType type = LocType.get(i_252_); - if ((i_260_ != 22) || !lowmem || type.interactable || type.important) { - bool &= type.method579(); - bool_255_ = true; - } - } - } - } - } - return bool; - } + scene.add(entity, dataPlane, x, z, y, 1, 1, 0, bitset, info); - public final int[] anIntArray124; - public final int[] anIntArray125; - public final int[] anIntArray126; - public final int[] anIntArray127; - public final int[] anIntArray128; - public final int[][][] planeHeightmap; - public final byte[][][] aByteArrayArrayArray130; - public final byte[][][] aByteArrayArrayArray134; - public final int[][][] anIntArrayArrayArray135; - public final byte[][][] aByteArrayArrayArray136; - public final int[][] anIntArrayArray139; - public final byte[][][] aByteArrayArrayArray142; - public final int maxTileX; - public final int maxTileZ; - public final byte[][][] aByteArrayArrayArray148; - public final byte[][][] planeTileFlags; + if (loc.solid) { + collision.add(loc.blocksProjectiles, loc.width, loc.length, x, z, rotation); + } + } else if (kind == 0) { + Entity entity; - public SceneBuilder(byte[][][] planeTileFlags, int maxTileZ, int maxTileX, int[][][] planeHeightmap) { - anInt145 = 99; - this.maxTileX = maxTileX; - this.maxTileZ = maxTileZ; - this.planeHeightmap = planeHeightmap; - this.planeTileFlags = planeTileFlags; - aByteArrayArrayArray142 = new byte[4][this.maxTileX][this.maxTileZ]; - aByteArrayArrayArray130 = new byte[4][this.maxTileX][this.maxTileZ]; - aByteArrayArrayArray136 = new byte[4][this.maxTileX][this.maxTileZ]; - aByteArrayArrayArray148 = new byte[4][this.maxTileX][this.maxTileZ]; - anIntArrayArrayArray135 = new int[4][this.maxTileX + 1][this.maxTileZ + 1]; - aByteArrayArrayArray134 = new byte[4][this.maxTileX + 1][this.maxTileZ + 1]; - anIntArrayArray139 = new int[this.maxTileX + 1][this.maxTileZ + 1]; - anIntArray124 = new int[this.maxTileZ]; - anIntArray125 = new int[this.maxTileZ]; - anIntArray126 = new int[this.maxTileZ]; - anIntArray127 = new int[this.maxTileZ]; - anIntArray128 = new int[this.maxTileZ]; - } + if ((loc.seqId == -1) && (loc.overrideTypeIDs == null)) { + entity = loc.getModel(0, rotation, heightSW, heightSE, heightNE, heightNW, -1); + } else { + entity = new LocEntity(locID, rotation, 0, heightSE, heightNE, heightSW, heightNW, loc.seqId, true); + } - 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_--; - } - if (i_9_ >= 0) { - collisionMaps[i_9_].method213(i_8_, i_7_); - } - } - } - } - } - 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 = aByteArrayArrayArray134[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_; - } - } - 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 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_]++; - } - } - 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_]--; - } - } - } - if ((i_29_ >= 1) && (i_29_ < (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_]; - } - 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_]; - } - 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 (plane < anInt145) { - anInt145 = 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_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; - } - i_54_ = method177(i_55_, i_56_, i_57_); - } - if (plane > 0) { - boolean bool = true; - if ((i_43_ == 0) && ((aByteArrayArrayArray136[plane][i_29_][i_40_]) != 0)) { - bool = false; - } - if ((i_44_ > 0) && !(FloType.instances[i_44_ - 1].aBoolean393)) { - bool = false; - } - if (bool && (i_45_ == i_46_) && (i_45_ == i_47_) && (i_45_ == i_48_)) { - anIntArrayArrayArray135[plane][i_29_][i_40_] |= 0x924; - } - } - int i_58_ = 0; - if (i_53_ != -1) { - i_58_ = (Draw3D.palette[method187(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); - } 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_; - if (textureId >= 0) { - i_62_ = Draw3D.getAverageTextureRGB(textureId); - i_63_ = -1; - } else if (type.anInt390 == 16711935) { - i_62_ = 0; - i_63_ = -2; - textureId = -1; - } else { - i_63_ = method177(type.anInt394, type.anInt395, type.anInt396); - i_62_ = (Draw3D.palette[method185(type.anInt399, 96)]); - } - scene.method279(plane, i_29_, i_40_, i_59_, i_60_, 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_); - } - } - } - } - } - } - 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_); - } - } - } - int i_68_ = 1; - int i_69_ = 2; - int i_70_ = 4; - for (int i_71_ = 0; i_71_ < 4; i_71_++) { - if (i_71_ > 0) { - i_68_ <<= 3; - i_69_ <<= 3; - i_70_ <<= 3; - } - for (int i_72_ = 0; i_72_ <= i_71_; i_72_++) { - for (int i_73_ = 0; i_73_ <= maxTileZ; i_73_++) { - for (int i_74_ = 0; i_74_ <= maxTileX; i_74_++) { - if ((anIntArrayArrayArray135[i_72_][i_74_][i_73_] & i_68_) != 0) { - int i_75_ = i_73_; - int i_76_ = i_73_; - int i_77_ = i_72_; - int i_78_ = i_72_; - for (/**/; i_75_ > 0; i_75_--) { - if (((anIntArrayArrayArray135[i_72_][i_74_][i_75_ - 1]) & i_68_) == 0) { - break; - } - } - for (/**/; i_76_ < maxTileZ; i_76_++) { - if (((anIntArrayArrayArray135[i_72_][i_74_][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 (((anIntArrayArrayArray135[i_77_ - 1][i_74_][i_79_]) & i_68_) == 0) { - break while_0_; - } - } - } - while_1_: - for (/**/; i_78_ < i_71_; i_78_++) { - for (int i_80_ = i_75_; i_80_ <= i_76_; i_80_++) { - if (((anIntArrayArrayArray135[i_78_ + 1][i_74_][i_80_]) & i_68_) == 0) { - break while_1_; - } - } - } - 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_][i_74_][i_75_] - i_82_); - int i_84_ = planeHeightmap[i_77_][i_74_][i_75_]; - Scene.method277(i_71_, i_74_ * 128, i_84_, i_74_ * 128, (i_76_ * 128) + 128, i_83_, i_75_ * 128, 1); - for (int i_85_ = i_77_; i_85_ <= i_78_; i_85_++) { - for (int i_86_ = i_75_; i_86_ <= i_76_; i_86_++) { - anIntArrayArrayArray135[i_85_][i_74_][i_86_] &= ~i_68_; - } - } - } - } - if ((anIntArrayArrayArray135[i_72_][i_74_][i_73_] & i_69_) != 0) { - int i_87_ = i_74_; - int i_88_ = i_74_; - int i_89_ = i_72_; - int i_90_ = i_72_; - for (/**/; i_87_ > 0; i_87_--) { - if (((anIntArrayArrayArray135[i_72_][i_87_ - 1][i_73_]) & i_69_) == 0) { - break; - } - } - for (/**/; i_88_ < maxTileX; i_88_++) { - if (((anIntArrayArrayArray135[i_72_][i_88_ + 1][i_73_]) & 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 (((anIntArrayArrayArray135[i_89_ - 1][i_91_][i_73_]) & i_69_) == 0) { - break while_2_; - } - } - } - while_3_: - for (/**/; i_90_ < i_71_; i_90_++) { - for (int i_92_ = i_87_; i_92_ <= i_88_; i_92_++) { - if (((anIntArrayArrayArray135[i_90_ + 1][i_92_][i_73_]) & i_69_) == 0) { - break while_3_; - } - } - } - 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_][i_73_] - i_94_); - int i_96_ = planeHeightmap[i_89_][i_87_][i_73_]; - Scene.method277(i_71_, i_87_ * 128, i_96_, (i_88_ * 128) + 128, i_73_ * 128, i_95_, i_73_ * 128, 2); - for (int i_97_ = i_89_; i_97_ <= i_90_; i_97_++) { - for (int i_98_ = i_87_; i_98_ <= i_88_; i_98_++) { - anIntArrayArrayArray135[i_97_][i_98_][i_73_] &= ~i_69_; - } - } - } - } - if ((anIntArrayArrayArray135[i_72_][i_74_][i_73_] & i_70_) != 0) { - int i_99_ = i_74_; - int i_100_ = i_74_; - int i_101_ = i_73_; - int i_102_ = i_73_; - for (/**/; i_101_ > 0; i_101_--) { - if (((anIntArrayArrayArray135[i_72_][i_74_][i_101_ - 1]) & i_70_) == 0) { - break; - } - } - for (/**/; i_102_ < maxTileZ; i_102_++) { - if (((anIntArrayArrayArray135[i_72_][i_74_][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 (((anIntArrayArrayArray135[i_72_][i_99_ - 1][i_103_]) & i_70_) == 0) { - break while_4_; - } - } - } - while_5_: - for (/**/; i_100_ < maxTileX; i_100_++) { - for (int i_104_ = i_101_; i_104_ <= i_102_; i_104_++) { - if (((anIntArrayArrayArray135[i_72_][i_100_ + 1][i_104_]) & i_70_) == 0) { - break while_5_; - } - } - } - if ((((i_100_ - i_99_) + 1) * ((i_102_ - i_101_) + 1)) >= 4) { - int i_105_ = planeHeightmap[i_72_][i_99_][i_101_]; - Scene.method277(i_71_, i_99_ * 128, i_105_, (i_100_ * 128) + 128, (i_102_ * 128) + 128, i_105_, i_101_ * 128, 4); - for (int i_106_ = i_99_; i_106_ <= i_100_; i_106_++) { - for (int i_107_ = i_101_; i_107_ <= i_102_; i_107_++) { - anIntArrayArrayArray135[i_72_][i_106_][i_107_] &= ~i_70_; - } - } - } - } - } - } - } - } - } + scene.setWall(WALL_ROTATION_OCCLUDE_TYPE[rotation], entity, 0, null, dataPlane, x, z, y, bitset, info); - public void method174(int i, int i_113_, int i_115_, int i_116_) { - for (int i_117_ = i; i_117_ <= (i + i_113_); i_117_++) { - for (int i_118_ = i_116_; i_118_ <= (i_116_ + i_115_); i_118_++) { - if ((i_118_ >= 0) && (i_118_ < maxTileX) && (i_117_ >= 0) && (i_117_ < maxTileZ)) { - aByteArrayArrayArray134[0][i_118_][i_117_] = (byte) 127; - if ((i_118_ == i_116_) && (i_118_ > 0)) { - planeHeightmap[0][i_118_][i_117_] = planeHeightmap[0][i_118_ - 1][i_117_]; - } - if ((i_118_ == (i_116_ + i_115_)) && (i_118_ < (maxTileX - 1))) { - planeHeightmap[0][i_118_][i_117_] = planeHeightmap[0][i_118_ + 1][i_117_]; - } - if ((i_117_ == i) && (i_117_ > 0)) { - planeHeightmap[0][i_118_][i_117_] = planeHeightmap[0][i_118_][i_117_ - 1]; - } - if ((i_117_ == (i + i_113_)) && (i_117_ < (maxTileZ - 1))) { - planeHeightmap[0][i_118_][i_117_] = planeHeightmap[0][i_118_][i_117_ + 1]; - } - } - } - } - } + if (loc.solid) { + collision.addWall(z, rotation, x, kind, loc.blocksProjectiles); + } + } else if (kind == 1) { + Entity entity; - public void method175(int i, Scene scene, SceneCollisionMap collisionMap, int i_119_, int i_120_, int i_121_, int i_122_, boolean bool, int i_123_) { - if (lowmem && ((planeTileFlags[0][i_121_][i] & 0x2) == 0) && (((planeTileFlags[i_120_][i_121_][i] & 0x10) != 0) || (getDrawPlane(i_120_, i_121_, i) != anInt131))) { - return; - } - if (i_120_ < anInt145) { - anInt145 = i_120_; - } - int i_124_ = planeHeightmap[i_120_][i_121_][i]; - int i_125_ = planeHeightmap[i_120_][i_121_ + 1][i]; - int i_126_ = planeHeightmap[i_120_][i_121_ + 1][i + 1]; - int i_127_ = planeHeightmap[i_120_][i_121_][i + 1]; - int i_128_ = (i_124_ + i_125_ + i_126_ + i_127_) >> 2; - LocType type = LocType.get(i_122_); - int i_129_ = i_121_ + (i << 7) + (i_122_ << 14) + 1073741824; - if (!type.interactable) { - i_129_ += -2147483648; - } - byte i_130_ = (byte) ((i_123_ << 6) + i_119_); - if (!bool) { - if (i_119_ == 22) { - if (!lowmem || type.interactable || type.important) { - Entity entity; - if ((type.seqId == -1) && (type.overrideIds == null)) { - entity = type.method578(22, i_123_, i_124_, i_125_, i_126_, i_127_, -1); - } else { - entity = new LocEntity(i_122_, i_123_, 22, i_125_, i_126_, i_124_, i_127_, type.seqId, true); - } - scene.addGroundDecoration(entity, i_120_, i_121_, i, i_128_, i_129_, i_130_); - if (type.solid && type.interactable && (collisionMap != null)) { - collisionMap.method213(i, i_121_); - } - } - } else if ((i_119_ == 10) || (i_119_ == 11)) { - Entity entity; - if ((type.seqId == -1) && (type.overrideIds == null)) { - entity = type.method578(10, i_123_, i_124_, i_125_, i_126_, i_127_, -1); - } else { - entity = new LocEntity(i_122_, i_123_, 10, i_125_, i_126_, i_124_, i_127_, type.seqId, true); - } - if (entity != null) { - int i_131_ = 0; - if (i_119_ == 11) { - i_131_ += 256; - } - int i_132_; - int i_133_; - if ((i_123_ == 1) || (i_123_ == 3)) { - i_132_ = type.length; - i_133_ = type.width; - } else { - i_132_ = type.width; - i_133_ = type.length; - } - if (scene.add(entity, i_120_, i_121_, i, i_128_, i_132_, i_133_, i_131_, i_129_, i_130_) && type.castShadow) { - Model model; - if (entity instanceof Model) { - model = (Model) entity; - } else { - model = type.method578(10, i_123_, i_124_, i_125_, i_126_, i_127_, -1); - } - if (model != null) { - for (int i_134_ = 0; i_134_ <= i_132_; i_134_++) { - for (int i_135_ = 0; i_135_ <= i_133_; i_135_++) { - int i_136_ = model.radius / 4; - if (i_136_ > 30) { - i_136_ = 30; - } - if (i_136_ > (aByteArrayArrayArray134[i_120_][i_121_ + i_134_][i + i_135_])) { - aByteArrayArrayArray134[i_120_][i_121_ + i_134_][i + i_135_] = (byte) i_136_; - } - } - } - } - } - } - if (type.solid && (collisionMap != null)) { - collisionMap.method212(type.blocksProjectiles, type.width, type.length, i_121_, i, i_123_); - } - } else if (i_119_ >= 12) { - Entity entity; - if ((type.seqId == -1) && (type.overrideIds == null)) { - entity = type.method578(i_119_, i_123_, i_124_, i_125_, i_126_, i_127_, -1); - } else { - entity = new LocEntity(i_122_, i_123_, i_119_, i_125_, i_126_, i_124_, i_127_, type.seqId, true); - } - scene.add(entity, i_120_, i_121_, i, i_128_, 1, 1, 0, i_129_, i_130_); - if ((i_119_ >= 12) && (i_119_ <= 17) && (i_119_ != 13) && (i_120_ > 0)) { - anIntArrayArrayArray135[i_120_][i_121_][i] |= 0x924; - } - if (type.solid && (collisionMap != null)) { - collisionMap.method212(type.blocksProjectiles, type.width, type.length, i_121_, i, i_123_); - } - } else if (i_119_ == 0) { - Entity entity; - if ((type.seqId == -1) && (type.overrideIds == null)) { - entity = type.method578(0, i_123_, i_124_, i_125_, i_126_, i_127_, -1); - } else { - entity = new LocEntity(i_122_, i_123_, 0, i_125_, i_126_, i_124_, i_127_, type.seqId, true); - } - scene.addWall(WALL_TYPE_0[i_123_], entity, 0, null, i_120_, i_121_, i, i_128_, i_129_, i_130_); - if (i_123_ == 0) { - if (type.castShadow) { - aByteArrayArrayArray134[i_120_][i_121_][i] = (byte) 50; - aByteArrayArrayArray134[i_120_][i_121_][i + 1] = (byte) 50; - } - if (type.occludes) { - anIntArrayArrayArray135[i_120_][i_121_][i] |= 0x249; - } - } else if (i_123_ == 1) { - if (type.castShadow) { - aByteArrayArrayArray134[i_120_][i_121_][i + 1] = (byte) 50; - aByteArrayArrayArray134[i_120_][i_121_ + 1][i + 1] = (byte) 50; - } - if (type.occludes) { - anIntArrayArrayArray135[i_120_][i_121_][i + 1] |= 0x492; - } - } else if (i_123_ == 2) { - if (type.castShadow) { - aByteArrayArrayArray134[i_120_][i_121_ + 1][i] = (byte) 50; - aByteArrayArrayArray134[i_120_][i_121_ + 1][i + 1] = (byte) 50; - } - if (type.occludes) { - anIntArrayArrayArray135[i_120_][i_121_ + 1][i] |= 0x249; - } - } else if (i_123_ == 3) { - if (type.castShadow) { - aByteArrayArrayArray134[i_120_][i_121_][i] = (byte) 50; - aByteArrayArrayArray134[i_120_][i_121_ + 1][i] = (byte) 50; - } - if (type.occludes) { - anIntArrayArrayArray135[i_120_][i_121_][i] |= 0x492; - } - } - if (type.solid && (collisionMap != null)) { - collisionMap.method211(i, i_123_, i_121_, i_119_, type.blocksProjectiles); - } - if (type.decorationPadding != 16) { - scene.setWallDecorationOffset(i_120_, i_121_, i, type.decorationPadding); - } - } else if (i_119_ == 1) { - Entity entity; - if ((type.seqId == -1) && (type.overrideIds == null)) { - entity = type.method578(1, i_123_, i_124_, i_125_, i_126_, i_127_, -1); - } else { - entity = new LocEntity(i_122_, i_123_, 1, i_125_, i_126_, i_124_, i_127_, type.seqId, true); - } - scene.addWall(WALL_TYPE_1[i_123_], entity, 0, null, i_120_, i_121_, i, i_128_, i_129_, i_130_); - if (type.castShadow) { - if (i_123_ == 0) { - aByteArrayArrayArray134[i_120_][i_121_][i + 1] = (byte) 50; - } else if (i_123_ == 1) { - aByteArrayArrayArray134[i_120_][i_121_ + 1][i + 1] = (byte) 50; - } else if (i_123_ == 2) { - aByteArrayArrayArray134[i_120_][i_121_ + 1][i] = (byte) 50; - } else if (i_123_ == 3) { - aByteArrayArrayArray134[i_120_][i_121_][i] = (byte) 50; - } - } - if (type.solid && (collisionMap != null)) { - collisionMap.method211(i, i_123_, i_121_, i_119_, type.blocksProjectiles); - } - } else if (i_119_ == 2) { - int i_137_ = (i_123_ + 1) & 0x3; - Entity entity; - Entity entity_138_; - if ((type.seqId == -1) && (type.overrideIds == null)) { - entity = type.method578(2, 4 + i_123_, i_124_, i_125_, i_126_, i_127_, -1); - entity_138_ = type.method578(2, i_137_, i_124_, i_125_, i_126_, i_127_, -1); - } else { - entity = new LocEntity(i_122_, 4 + i_123_, 2, i_125_, i_126_, i_124_, i_127_, type.seqId, true); - entity_138_ = new LocEntity(i_122_, i_137_, 2, i_125_, i_126_, i_124_, i_127_, type.seqId, true); - } - scene.addWall(WALL_TYPE_0[i_123_], entity, WALL_TYPE_0[i_137_], entity_138_, i_120_, i_121_, i, i_128_, i_129_, i_130_); - if (type.occludes) { - if (i_123_ == 0) { - anIntArrayArrayArray135[i_120_][i_121_][i] |= 0x249; - anIntArrayArrayArray135[i_120_][i_121_][i + 1] |= 0x492; - } else if (i_123_ == 1) { - anIntArrayArrayArray135[i_120_][i_121_][i + 1] |= 0x492; - anIntArrayArrayArray135[i_120_][i_121_ + 1][i] |= 0x249; - } else if (i_123_ == 2) { - anIntArrayArrayArray135[i_120_][i_121_ + 1][i] |= 0x249; - anIntArrayArrayArray135[i_120_][i_121_][i] |= 0x492; - } else if (i_123_ == 3) { - anIntArrayArrayArray135[i_120_][i_121_][i] |= 0x492; - anIntArrayArrayArray135[i_120_][i_121_][i] |= 0x249; - } - } - if (type.solid && (collisionMap != null)) { - collisionMap.method211(i, i_123_, i_121_, i_119_, type.blocksProjectiles); - } - if (type.decorationPadding != 16) { - scene.setWallDecorationOffset(i_120_, i_121_, i, type.decorationPadding); - } - } else if (i_119_ == 3) { - Entity entity; - if ((type.seqId == -1) && (type.overrideIds == null)) { - entity = type.method578(3, i_123_, i_124_, i_125_, i_126_, i_127_, -1); - } else { - entity = new LocEntity(i_122_, i_123_, 3, i_125_, i_126_, i_124_, i_127_, type.seqId, true); - } - scene.addWall(WALL_TYPE_1[i_123_], entity, 0, null, i_120_, i_121_, i, i_128_, i_129_, i_130_); - if (type.castShadow) { - if (i_123_ == 0) { - aByteArrayArrayArray134[i_120_][i_121_][i + 1] = (byte) 50; - } else if (i_123_ == 1) { - aByteArrayArrayArray134[i_120_][i_121_ + 1][i + 1] = (byte) 50; - } else if (i_123_ == 2) { - aByteArrayArrayArray134[i_120_][i_121_ + 1][i] = (byte) 50; - } else if (i_123_ == 3) { - aByteArrayArrayArray134[i_120_][i_121_][i] = (byte) 50; - } - } - if (type.solid && (collisionMap != null)) { - collisionMap.method211(i, i_123_, i_121_, i_119_, type.blocksProjectiles); - } - } else if (i_119_ == 9) { - Entity entity; - if ((type.seqId == -1) && (type.overrideIds == null)) { - entity = type.method578(i_119_, i_123_, i_124_, i_125_, i_126_, i_127_, -1); - } else { - entity = new LocEntity(i_122_, i_123_, i_119_, i_125_, i_126_, i_124_, i_127_, type.seqId, true); - } - scene.add(entity, i_120_, i_121_, i, i_128_, 1, 1, 0, i_129_, i_130_); - if (type.solid && (collisionMap != null)) { - collisionMap.method212(type.blocksProjectiles, type.width, type.length, i_121_, i, i_123_); - } - } else { - if (type.adjustToTerrain) { - if (i_123_ == 1) { - int i_139_ = i_127_; - i_127_ = i_126_; - i_126_ = i_125_; - i_125_ = i_124_; - i_124_ = i_139_; - } else if (i_123_ == 2) { - int i_140_ = i_127_; - i_127_ = i_125_; - i_125_ = i_140_; - i_140_ = i_126_; - i_126_ = i_124_; - i_124_ = i_140_; - } else if (i_123_ == 3) { - int i_141_ = i_127_; - i_127_ = i_124_; - i_124_ = i_125_; - i_125_ = i_126_; - i_126_ = i_141_; - } - } - if (i_119_ == 4) { - Entity entity; - if ((type.seqId == -1) && (type.overrideIds == null)) { - entity = type.method578(4, 0, i_124_, i_125_, i_126_, i_127_, -1); - } else { - entity = new LocEntity(i_122_, 0, 4, i_125_, i_126_, i_124_, i_127_, type.seqId, true); - } - scene.addWallDecoration(WALL_TYPE_0[i_123_], entity, i_120_, i_121_, i, i_128_, i_123_ * 512, 0, 0, i_129_, i_130_); - } else if (i_119_ == 5) { - int i_142_ = 16; - int i_143_ = scene.getWallBitset(i_120_, i_121_, i); - if (i_143_ > 0) { - i_142_ = LocType.get((i_143_ >> 14) & 0x7fff).decorationPadding; - } - Entity entity; - if ((type.seqId == -1) && (type.overrideIds == null)) { - entity = type.method578(4, 0, i_124_, i_125_, i_126_, i_127_, -1); - } else { - entity = new LocEntity(i_122_, 0, 4, i_125_, i_126_, i_124_, i_127_, type.seqId, true); - } - scene.addWallDecoration(WALL_TYPE_0[i_123_], entity, i_120_, i_121_, i, i_128_, i_123_ * 512, anIntArray137[i_123_] * i_142_, anIntArray144[i_123_] * i_142_, i_129_, i_130_); - } else if (i_119_ == 6) { - Entity entity; - if ((type.seqId == -1) && (type.overrideIds == null)) { - entity = type.method578(4, 0, i_124_, i_125_, i_126_, i_127_, -1); - } else { - entity = new LocEntity(i_122_, 0, 4, i_125_, i_126_, i_124_, i_127_, type.seqId, true); - } - scene.addWallDecoration(256, entity, i_120_, i_121_, i, i_128_, i_123_, 0, 0, i_129_, i_130_); - } else if (i_119_ == 7) { - Entity entity; - if ((type.seqId == -1) && (type.overrideIds == null)) { - entity = type.method578(4, 0, i_124_, i_125_, i_126_, i_127_, -1); - } else { - entity = new LocEntity(i_122_, 0, 4, i_125_, i_126_, i_124_, i_127_, type.seqId, true); - } - scene.addWallDecoration(512, entity, i_120_, i_121_, i, i_128_, i_123_, 0, 0, i_129_, i_130_); - } else if (i_119_ == 8) { - Entity entity; - if ((type.seqId == -1) && (type.overrideIds == null)) { - entity = type.method578(4, 0, i_124_, i_125_, i_126_, i_127_, -1); - } else { - entity = new LocEntity(i_122_, 0, 4, i_125_, i_126_, i_124_, i_127_, type.seqId, true); - } - scene.addWallDecoration(768, entity, i_120_, i_121_, i, i_128_, i_123_, 0, 0, i_129_, i_130_); - } - } - } - } + if ((loc.seqId == -1) && (loc.overrideTypeIDs == null)) { + entity = loc.getModel(1, rotation, heightSW, heightSE, heightNE, heightNW, -1); + } else { + entity = new LocEntity(locID, rotation, 1, heightSE, heightNE, heightSW, heightNW, loc.seqId, true); + } - public int method177(int i, int i_156_, int i_157_) { - if (i_157_ > 179) { - i_156_ /= 2; - } - if (i_157_ > 192) { - i_156_ /= 2; - } - if (i_157_ > 217) { - i_156_ /= 2; - } - if (i_157_ > 243) { - i_156_ /= 2; - } - return ((i / 4) << 10) + ((i_156_ / 32) << 7) + (i_157_ / 2); - } + scene.setWall(WALL_ROTATION_OCCLUDE_TYPE_1[rotation], entity, 0, null, dataPlane, x, z, y, bitset, info); - 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; - } - } - } - Buffer buffer = new Buffer(is); - for (int i_172_ = 0; i_172_ < 4; i_172_++) { - for (int i_173_ = 0; i_173_ < 64; i_173_++) { - for (int i_174_ = 0; i_174_ < 64; i_174_++) { - if ((i_172_ == i) && (i_173_ >= i_165_) && (i_173_ < (i_165_ + 8)) && (i_174_ >= i_166_) && (i_174_ < (i_166_ + 8))) { - method181(i_168_ + ZoneUtil.method156(i_174_ & 0x7, i_162_, i_173_ & 0x7), 0, buffer, i_164_ + ZoneUtil.method155(i_162_, i_174_ & 0x7, i_173_ & 0x7), i_167_, i_162_, 0); - } else { - method181(-1, 0, buffer, -1, 0, 0, 0); - } - } - } - } - } + if (loc.solid) { + collision.addWall(z, rotation, x, kind, loc.blocksProjectiles); + } + } else if (kind == 2) { + int nextRotation = (rotation + 1) & 0x3; + Entity locA; + Entity locB; - public void method180(byte[] is, int i, int i_175_, int i_176_, int i_177_, SceneCollisionMap[] collisionMaps) { - for (int i_179_ = 0; i_179_ < 4; i_179_++) { - for (int i_180_ = 0; i_180_ < 64; i_180_++) { - for (int i_181_ = 0; i_181_ < 64; i_181_++) { - if (((i_175_ + i_180_) > 0) && ((i_175_ + i_180_) < 103) && ((i + i_181_) > 0) && ((i + i_181_) < 103)) { - collisionMaps[i_179_].flags[i_175_ + i_180_][i + i_181_] &= ~0x1000000; - } - } - } - } - Buffer buffer = new Buffer(is); - for (int i_182_ = 0; i_182_ < 4; i_182_++) { - for (int i_183_ = 0; i_183_ < 64; i_183_++) { - for (int i_184_ = 0; i_184_ < 64; i_184_++) { - method181(i_184_ + i, i_177_, buffer, i_183_ + i_175_, i_182_, 0, i_176_); - } - } - } - } + if ((loc.seqId == -1) && (loc.overrideTypeIDs == null)) { + locA = loc.getModel(2, 4 + rotation, heightSW, heightSE, heightNE, heightNW, -1); + locB = loc.getModel(2, nextRotation, heightSW, heightSE, heightNE, heightNW, -1); + } else { + locA = new LocEntity(locID, 4 + rotation, 2, heightSE, heightNE, heightSW, heightNW, loc.seqId, true); + locB = new LocEntity(locID, nextRotation, 2, heightSE, heightNE, heightSW, heightNW, loc.seqId, true); + } - public void method181(int i, int i_185_, Buffer buffer, int i_186_, int i_187_, int i_188_, int i_190_) { - if ((i_186_ >= 0) && (i_186_ < 104) && (i >= 0) && (i < 104)) { - planeTileFlags[i_187_][i_186_][i] = (byte) 0; - for (; ; ) { - int i_191_ = buffer.get1U(); - if (i_191_ == 0) { - if (i_187_ == 0) { - planeHeightmap[0][i_186_][i] = -method172(932731 + i_186_ + i_190_, 556238 + i + i_185_) * 8; - } else { - planeHeightmap[i_187_][i_186_][i] = planeHeightmap[i_187_ - 1][i_186_][i] - 240; - break; - } - break; - } - if (i_191_ == 1) { - int i_192_ = buffer.get1U(); - if (i_192_ == 1) { - i_192_ = 0; - } - 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)); - break; - } - break; - } - if (i_191_ <= 49) { - aByteArrayArrayArray130[i_187_][i_186_][i] = buffer.get1(); - aByteArrayArrayArray136[i_187_][i_186_][i] = (byte) ((i_191_ - 2) / 4); - aByteArrayArrayArray148[i_187_][i_186_][i] = (byte) (((i_191_ - 2) + i_188_) & 0x3); - } else if (i_191_ <= 81) { - planeTileFlags[i_187_][i_186_][i] = (byte) (i_191_ - 49); - } else { - aByteArrayArrayArray142[i_187_][i_186_][i] = (byte) (i_191_ - 81); - } - } - } else { - for (; ; ) { - int i_193_ = buffer.get1U(); - if (i_193_ == 0) { - break; - } - if (i_193_ == 1) { - buffer.get1U(); - break; - } - if (i_193_ <= 49) { - buffer.get1U(); - } - } - } - } + scene.setWall(WALL_ROTATION_OCCLUDE_TYPE[rotation], locA, WALL_ROTATION_OCCLUDE_TYPE[nextRotation], locB, dataPlane, x, z, y, bitset, info); - public int getDrawPlane(int plane, int stx, int stz) { - if ((planeTileFlags[plane][stx][stz] & 0x8) != 0) { - return 0; - } - if ((plane > 0) && ((planeTileFlags[1][stx][stz] & 0x2) != 0)) { - return plane - 1; - } - return plane; - } + if (loc.solid) { + collision.addWall(z, rotation, x, kind, loc.blocksProjectiles); + } + } else if (kind == 3) { + Entity entity; - public void method183(SceneCollisionMap[] collisionMaps, Scene scene, int i, int i_197_, int i_198_, int i_199_, byte[] is, int i_200_, int i_201_, int i_202_) { - Buffer buffer = new Buffer(is); - int i_203_ = -1; - for (; ; ) { - int i_204_ = buffer.getSmartU(); - if (i_204_ == 0) { - break; - } - i_203_ += i_204_; - int i_205_ = 0; - for (; ; ) { - int i_206_ = buffer.getSmartU(); - if (i_206_ == 0) { - break; - } - i_205_ += i_206_ - 1; - int i_207_ = i_205_ & 0x3f; - int i_208_ = (i_205_ >> 6) & 0x3f; - int i_209_ = i_205_ >> 12; - int i_210_ = buffer.get1U(); - int i_211_ = i_210_ >> 2; - int i_212_ = i_210_ & 0x3; - if ((i_209_ == i) && (i_208_ >= i_200_) && (i_208_ < (i_200_ + 8)) && (i_207_ >= i_198_) && (i_207_ < (i_198_ + 8))) { - LocType type = LocType.get(i_203_); - int i_213_ = i_197_ + ZoneUtil.method157(i_201_, type.length, i_208_ & 0x7, i_207_ & 0x7, type.width); - int i_214_ = i_202_ + ZoneUtil.method158(i_207_ & 0x7, type.length, i_201_, type.width, i_208_ & 0x7); - if ((i_213_ > 0) && (i_214_ > 0) && (i_213_ < 103) && (i_214_ < 103)) { - int i_215_ = i_209_; - if ((planeTileFlags[1][i_213_][i_214_] & 0x2) == 2) { - i_215_--; - } - SceneCollisionMap collisionMap = null; - if (i_215_ >= 0) { - collisionMap = collisionMaps[i_215_]; - } - method175(i_214_, scene, collisionMap, i_211_, i_199_, i_213_, i_203_, false, (i_212_ + i_201_) & 0x3); - } - } - } - } - } + if ((loc.seqId == -1) && (loc.overrideTypeIDs == null)) { + entity = loc.getModel(3, rotation, heightSW, heightSE, heightNE, heightNW, -1); + } else { + entity = new LocEntity(locID, rotation, 3, heightSE, heightNE, heightSW, heightNW, loc.seqId, true); + } - public int method185(int i, int i_220_) { - if (i == -2) { - return 12345678; - } - if (i == -1) { - if (i_220_ < 0) { - i_220_ = 0; - } else if (i_220_ > 127) { - i_220_ = 127; - } - i_220_ = 127 - i_220_; - return i_220_; - } - i_220_ = (i_220_ * (i & 0x7f)) / 128; - if (i_220_ < 2) { - i_220_ = 2; - } else if (i_220_ > 126) { - i_220_ = 126; - } - return (i & 0xff80) + i_220_; - } + scene.setWall(WALL_ROTATION_OCCLUDE_TYPE_1[rotation], entity, 0, null, dataPlane, x, z, y, bitset, info); - public void method190(int i, SceneCollisionMap[] collisionMaps, int i_263_, Scene scene, byte[] is) { - Buffer buffer = new Buffer(is); - int i_265_ = -1; - for (; ; ) { - int i_266_ = buffer.getSmartU(); - if (i_266_ == 0) { - break; - } - i_265_ += i_266_; - int i_267_ = 0; - for (; ; ) { - int i_268_ = buffer.getSmartU(); - if (i_268_ == 0) { - break; - } - i_267_ += i_268_ - 1; - int i_269_ = i_267_ & 0x3f; - int i_270_ = (i_267_ >> 6) & 0x3f; - int i_271_ = i_267_ >> 12; - int i_272_ = buffer.get1U(); - int i_273_ = i_272_ >> 2; - int i_274_ = i_272_ & 0x3; - int i_275_ = i_270_ + i; - int i_276_ = i_269_ + i_263_; - if ((i_275_ > 0) && (i_276_ > 0) && (i_275_ < 103) && (i_276_ < 103)) { - int i_277_ = i_271_; - if ((planeTileFlags[1][i_275_][i_276_] & 0x2) == 2) { - i_277_--; - } - SceneCollisionMap collisionMap = null; - if (i_277_ >= 0) { - collisionMap = collisionMaps[i_277_]; - } - method175(i_276_, scene, collisionMap, i_273_, i_271_, i_275_, i_265_, false, i_274_); - } - } - } - } + if (loc.solid) { + collision.addWall(z, rotation, x, kind, loc.blocksProjectiles); + } + } else if (kind == 9) { + Entity entity; + + if ((loc.seqId == -1) && (loc.overrideTypeIDs == null)) { + entity = loc.getModel(kind, rotation, heightSW, heightSE, heightNE, heightNW, -1); + } else { + entity = new LocEntity(locID, rotation, kind, heightSE, heightNE, heightSW, heightNW, loc.seqId, true); + } + + scene.add(entity, dataPlane, x, z, y, 1, 1, 0, bitset, info); + + if (loc.solid) { + collision.add(loc.blocksProjectiles, loc.width, loc.length, x, z, rotation); + } + } else { + if (loc.adjustToTerrain) { + if (rotation == 1) { + int tmp = heightNW; + heightNW = heightNE; + heightNE = heightSE; + heightSE = heightSW; + heightSW = tmp; + } else if (rotation == 2) { + int tmp = heightNW; + heightNW = heightSE; + heightSE = tmp; + tmp = heightNE; + heightNE = heightSW; + heightSW = tmp; + } else if (rotation == 3) { + int tmp = heightNW; + heightNW = heightSW; + heightSW = heightSE; + heightSE = heightNE; + heightNE = tmp; + } + } + + if (kind == 4) { + Entity entity; + + if ((loc.seqId == -1) && (loc.overrideTypeIDs == null)) { + entity = loc.getModel(4, 0, heightSW, heightSE, heightNE, heightNW, -1); + } else { + entity = new LocEntity(locID, 0, 4, heightSE, heightNE, heightSW, heightNW, loc.seqId, true); + } + + scene.setWallDecoration(WALL_ROTATION_OCCLUDE_TYPE[rotation], entity, dataPlane, x, z, y, rotation * 512, 0, 0, bitset, info); + } else if (kind == 5) { + int padding = 16; + int wallBitset = scene.getWallBitset(dataPlane, x, z); + + if (wallBitset > 0) { + padding = LocType.get((wallBitset >> 14) & 0x7fff).decorationPadding; + } + + Entity entity; + + if ((loc.seqId == -1) && (loc.overrideTypeIDs == null)) { + entity = loc.getModel(4, 0, heightSW, heightSE, heightNE, heightNW, -1); + } else { + entity = new LocEntity(locID, 0, 4, heightSE, heightNE, heightSW, heightNW, loc.seqId, true); + } + + scene.setWallDecoration(WALL_ROTATION_OCCLUDE_TYPE[rotation], entity, dataPlane, x, z, y, rotation * 512, anIntArray137[rotation] * padding, anIntArray144[rotation] * padding, bitset, info); + } else if (kind == 6) { + Entity entity; + + if ((loc.seqId == -1) && (loc.overrideTypeIDs == null)) { + entity = loc.getModel(4, 0, heightSW, heightSE, heightNE, heightNW, -1); + } else { + entity = new LocEntity(locID, 0, 4, heightSE, heightNE, heightSW, heightNW, loc.seqId, true); + } + + scene.setWallDecoration(256, entity, dataPlane, x, z, y, rotation, 0, 0, bitset, info); + } else if (kind == 7) { + Entity entity; + + if ((loc.seqId == -1) && (loc.overrideTypeIDs == null)) { + entity = loc.getModel(4, 0, heightSW, heightSE, heightNE, heightNW, -1); + } else { + entity = new LocEntity(locID, 0, 4, heightSE, heightNE, heightSW, heightNW, loc.seqId, true); + } + + scene.setWallDecoration(512, entity, dataPlane, x, z, y, rotation, 0, 0, bitset, info); + } else if (kind == 8) { + Entity entity; + + if ((loc.seqId == -1) && (loc.overrideTypeIDs == null)) { + entity = loc.getModel(4, 0, heightSW, heightSE, heightNE, heightNW, -1); + } else { + entity = new LocEntity(locID, 0, 4, heightSE, heightNE, heightSW, heightNW, loc.seqId, true); + } + + scene.setWallDecoration(768, entity, dataPlane, x, z, y, rotation, 0, 0, bitset, info); + } + } + } + + public static boolean method189(int i, byte[] is, int i_250_) { + boolean bool = true; + Buffer buffer = new Buffer(is); + int i_252_ = -1; + for (; ; ) { + int i_253_ = buffer.getSmartU(); + if (i_253_ == 0) { + break; + } + i_252_ += i_253_; + int i_254_ = 0; + boolean bool_255_ = false; + for (; ; ) { + if (bool_255_) { + int i_256_ = buffer.getSmartU(); + if (i_256_ == 0) { + break; + } + buffer.get1U(); + } else { + int i_257_ = buffer.getSmartU(); + if (i_257_ == 0) { + break; + } + i_254_ += i_257_ - 1; + int i_258_ = i_254_ & 0x3f; + int i_259_ = (i_254_ >> 6) & 0x3f; + int i_260_ = buffer.get1U() >> 2; + int i_261_ = i_259_ + i; + int i_262_ = i_258_ + i_250_; + if ((i_261_ > 0) && (i_262_ > 0) && (i_261_ < 103) && (i_262_ < 103)) { + LocType type = LocType.get(i_252_); + if ((i_260_ != 22) || !lowmem || type.interactable || type.important) { + bool &= type.method579(); + bool_255_ = true; + } + } + } + } + } + return bool; + } + + public final int[] anIntArray124; + public final int[] anIntArray125; + public final int[] anIntArray126; + public final int[] anIntArray127; + public final int[] anIntArray128; + public final int[][][] planeHeightmap; + public final byte[][][] aByteArrayArrayArray130; + public final byte[][][] planeShademap; + public final int[][][] planeOccludemap; + public final byte[][][] aByteArrayArrayArray136; + public final int[][] anIntArrayArray139; + public final byte[][][] aByteArrayArrayArray142; + public final int maxTileX; + public final int maxTileZ; + public final byte[][][] aByteArrayArrayArray148; + public final byte[][][] planeTileFlags; + + public SceneBuilder(byte[][][] planeTileFlags, int maxTileZ, int maxTileX, int[][][] planeHeightmap) { + minPlane = 99; + this.maxTileX = maxTileX; + this.maxTileZ = maxTileZ; + this.planeHeightmap = planeHeightmap; + this.planeTileFlags = planeTileFlags; + aByteArrayArrayArray142 = new byte[4][this.maxTileX][this.maxTileZ]; + aByteArrayArrayArray130 = new byte[4][this.maxTileX][this.maxTileZ]; + aByteArrayArrayArray136 = new byte[4][this.maxTileX][this.maxTileZ]; + 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]; + anIntArray124 = new int[this.maxTileZ]; + anIntArray125 = new int[this.maxTileZ]; + anIntArray126 = new int[this.maxTileZ]; + anIntArray127 = new int[this.maxTileZ]; + 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_--; + } + if (i_9_ >= 0) { + collisionMaps[i_9_].addSolid(i_8_, i_7_); + } + } + } + } + } + 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_; + } + } + 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 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_]++; + } + } + 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_]--; + } + } + } + if ((i_29_ >= 1) && (i_29_ < (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_]; + } + 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_]; + } + 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 (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_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; + } + i_54_ = method177(i_55_, i_56_, i_57_); + } + if (plane > 0) { + boolean bool = true; + if ((i_43_ == 0) && ((aByteArrayArrayArray136[plane][i_29_][i_40_]) != 0)) { + bool = false; + } + if ((i_44_ > 0) && !(FloType.instances[i_44_ - 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; + } + } + int i_58_ = 0; + if (i_53_ != -1) { + i_58_ = (Draw3D.palette[method187(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); + } 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_; + if (textureId >= 0) { + i_62_ = Draw3D.getAverageTextureRGB(textureId); + i_63_ = -1; + } else if (type.anInt390 == 16711935) { + i_62_ = 0; + i_63_ = -2; + textureId = -1; + } else { + i_63_ = method177(type.anInt394, type.anInt395, type.anInt396); + i_62_ = (Draw3D.palette[method185(type.anInt399, 96)]); + } + scene.method279(plane, i_29_, i_40_, i_59_, i_60_, 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_); + } + } + } + } + } + } + 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_); + } + } + } + int i_68_ = 1; + int i_69_ = 2; + int i_70_ = 4; + for (int i_71_ = 0; i_71_ < 4; i_71_++) { + if (i_71_ > 0) { + i_68_ <<= 3; + i_69_ <<= 3; + i_70_ <<= 3; + } + for (int plane = 0; plane <= i_71_; plane++) { + for (int z = 0; z <= maxTileZ; z++) { + for (int x = 0; x <= maxTileX; x++) { + if ((planeOccludemap[plane][x][z] & i_68_) != 0) { + int i_75_ = z; + int i_76_ = z; + int i_77_ = plane; + int i_78_ = plane; + for (/**/; i_75_ > 0; i_75_--) { + 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) { + 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) { + break while_0_; + } + } + } + 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) { + break while_1_; + } + } + } + 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_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_++) { + for (int i_86_ = i_75_; i_86_ <= i_76_; i_86_++) { + planeOccludemap[i_85_][x][i_86_] &= ~i_68_; + } + } + } + } + if ((planeOccludemap[plane][x][z] & i_69_) != 0) { + int i_87_ = x; + int i_88_ = x; + int i_89_ = plane; + int i_90_ = plane; + for (/**/; i_87_ > 0; i_87_--) { + 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) { + 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) { + break while_2_; + } + } + } + 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) { + break while_3_; + } + } + } + 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_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_++) { + for (int i_98_ = i_87_; i_98_ <= i_88_; i_98_++) { + planeOccludemap[i_97_][i_98_][z] &= ~i_69_; + } + } + } + } + if ((planeOccludemap[plane][x][z] & i_70_) != 0) { + int i_99_ = x; + int i_100_ = x; + int i_101_ = z; + int i_102_ = z; + for (/**/; i_101_ > 0; i_101_--) { + 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) { + 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) { + break while_4_; + } + } + } + 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) { + break while_5_; + } + } + } + if ((((i_100_ - i_99_) + 1) * ((i_102_ - i_101_) + 1)) >= 4) { + int i_105_ = planeHeightmap[plane][i_99_][i_101_]; + Scene.method277(i_71_, i_99_ * 128, i_105_, (i_100_ * 128) + 128, (i_102_ * 128) + 128, i_105_, i_101_ * 128, 4); + for (int i_106_ = i_99_; i_106_ <= i_100_; i_106_++) { + for (int i_107_ = i_101_; i_107_ <= i_102_; i_107_++) { + planeOccludemap[plane][i_106_][i_107_] &= ~i_70_; + } + } + } + } + } + } + } + } + } + + public void method174(int i, int i_113_, int i_115_, int i_116_) { + for (int i_117_ = i; i_117_ <= (i + i_113_); i_117_++) { + for (int i_118_ = i_116_; i_118_ <= (i_116_ + i_115_); i_118_++) { + if ((i_118_ >= 0) && (i_118_ < maxTileX) && (i_117_ >= 0) && (i_117_ < maxTileZ)) { + planeShademap[0][i_118_][i_117_] = (byte) 127; + if ((i_118_ == i_116_) && (i_118_ > 0)) { + planeHeightmap[0][i_118_][i_117_] = planeHeightmap[0][i_118_ - 1][i_117_]; + } + if ((i_118_ == (i_116_ + i_115_)) && (i_118_ < (maxTileX - 1))) { + planeHeightmap[0][i_118_][i_117_] = planeHeightmap[0][i_118_ + 1][i_117_]; + } + if ((i_117_ == i) && (i_117_ > 0)) { + planeHeightmap[0][i_118_][i_117_] = planeHeightmap[0][i_118_][i_117_ - 1]; + } + if ((i_117_ == (i + i_113_)) && (i_117_ < (maxTileZ - 1))) { + planeHeightmap[0][i_118_][i_117_] = planeHeightmap[0][i_118_][i_117_ + 1]; + } + } + } + } + } + + public void method175(int z, Scene scene, SceneCollisionMap collision, int kind, int plane, int x, int locID, int rotation) { + if (lowmem && ((planeTileFlags[0][x][z] & 0x2) == 0) && (((planeTileFlags[plane][x][z] & 0x10) != 0) || (getDrawPlane(plane, x, z) != anInt131))) { + return; + } + if (plane < minPlane) { + minPlane = plane; + } + int heightmapSW = planeHeightmap[plane][x][z]; + int heightmapSE = planeHeightmap[plane][x + 1][z]; + int heightmapNE = planeHeightmap[plane][x + 1][z + 1]; + int heightmapNW = planeHeightmap[plane][x][z + 1]; + int heightmapAverage = (heightmapSW + heightmapSE + heightmapNE + heightmapNW) >> 2; + LocType type = LocType.get(locID); + int bitset = x + (z << 7) + (locID << 14) + 0x40000000; + + if (!type.interactable) { + bitset += 0x80000000; + } + + byte info = (byte) ((rotation << 6) + kind); + + if (kind == 22) { + if (!lowmem || type.interactable || type.important) { + Entity entity; + + if ((type.seqId == -1) && (type.overrideTypeIDs == null)) { + entity = type.getModel(22, rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, -1); + } else { + entity = new LocEntity(locID, rotation, 22, heightmapSE, heightmapNE, heightmapSW, heightmapNW, type.seqId, true); + } + + scene.addGroundDecoration(entity, plane, x, z, heightmapAverage, bitset, info); + + if (type.solid && type.interactable && (collision != null)) { + collision.addSolid(z, x); + } + } + } else if ((kind == 10) || (kind == 11)) { + Entity entity; + + if ((type.seqId == -1) && (type.overrideTypeIDs == null)) { + entity = type.getModel(10, rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, -1); + } else { + entity = new LocEntity(locID, rotation, 10, heightmapSE, heightmapNE, heightmapSW, heightmapNW, type.seqId, true); + } + + if (entity != null) { + int yaw = 0; + + if (kind == 11) { + yaw += 256; + } + + int width; + int height; + + if ((rotation == 1) || (rotation == 3)) { + width = type.length; + height = type.width; + } else { + width = type.width; + height = type.length; + } + + if (scene.add(entity, plane, x, z, heightmapAverage, width, height, yaw, bitset, info) && type.castShadow) { + Model model; + + if (entity instanceof Model) { + model = (Model) entity; + } else { + model = type.getModel(10, rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, -1); + } + + if (model != null) { + for (int dx = 0; dx <= width; dx++) { + for (int dz = 0; dz <= height; dz++) { + int shade = model.radius / 4; + + if (shade > 30) { + shade = 30; + } + + if (shade > (planeShademap[plane][x + dx][z + dz])) { + planeShademap[plane][x + dx][z + dz] = (byte) shade; + } + } + } + } + } + } + + if (type.solid && (collision != null)) { + collision.add(type.blocksProjectiles, type.width, type.length, x, z, rotation); + } + } else if (kind >= 12) { + Entity entity; + + if ((type.seqId == -1) && (type.overrideTypeIDs == null)) { + entity = type.getModel(kind, rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, -1); + } else { + entity = new LocEntity(locID, rotation, kind, heightmapSE, heightmapNE, heightmapSW, heightmapNW, type.seqId, true); + } + + scene.add(entity, plane, x, z, heightmapAverage, 1, 1, 0, bitset, info); + + if ((kind >= 12) && (kind <= 17) && (kind != 13) && (plane > 0)) { + planeOccludemap[plane][x][z] |= 0x924; + } + + if (type.solid && (collision != null)) { + collision.add(type.blocksProjectiles, type.width, type.length, x, z, rotation); + } + } else if (kind == 0) { + Entity entity; + + if ((type.seqId == -1) && (type.overrideTypeIDs == null)) { + entity = type.getModel(0, rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, -1); + } else { + entity = new LocEntity(locID, rotation, 0, heightmapSE, heightmapNE, heightmapSW, heightmapNW, type.seqId, true); + } + + scene.setWall(WALL_ROTATION_OCCLUDE_TYPE[rotation], entity, 0, null, plane, x, z, heightmapAverage, bitset, info); + + if (rotation == 0) { + if (type.castShadow) { + planeShademap[plane][x][z] = (byte) 50; + planeShademap[plane][x][z + 1] = (byte) 50; + } + if (type.occludes) { + planeOccludemap[plane][x][z] |= 0x249; + } + } else if (rotation == 1) { + if (type.castShadow) { + planeShademap[plane][x][z + 1] = (byte) 50; + planeShademap[plane][x + 1][z + 1] = (byte) 50; + } + if (type.occludes) { + planeOccludemap[plane][x][z + 1] |= 0x492; + } + } else if (rotation == 2) { + if (type.castShadow) { + planeShademap[plane][x + 1][z] = (byte) 50; + planeShademap[plane][x + 1][z + 1] = (byte) 50; + } + if (type.occludes) { + planeOccludemap[plane][x + 1][z] |= 0x249; + } + } else if (rotation == 3) { + if (type.castShadow) { + planeShademap[plane][x][z] = (byte) 50; + planeShademap[plane][x + 1][z] = (byte) 50; + } + if (type.occludes) { + planeOccludemap[plane][x][z] |= 0x492; + } + } + + if (type.solid && (collision != null)) { + collision.addWall(z, rotation, x, kind, type.blocksProjectiles); + } + + if (type.decorationPadding != 16) { + scene.setWallDecorationOffset(plane, x, z, type.decorationPadding); + } + } else if (kind == 1) { + Entity entity; + + if ((type.seqId == -1) && (type.overrideTypeIDs == null)) { + entity = type.getModel(1, rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, -1); + } else { + entity = new LocEntity(locID, rotation, 1, heightmapSE, heightmapNE, heightmapSW, heightmapNW, type.seqId, true); + } + + scene.setWall(WALL_ROTATION_OCCLUDE_TYPE_1[rotation], entity, 0, null, plane, x, z, heightmapAverage, bitset, info); + + if (type.castShadow) { + if (rotation == 0) { + planeShademap[plane][x][z + 1] = (byte) 50; + } else if (rotation == 1) { + planeShademap[plane][x + 1][z + 1] = (byte) 50; + } else if (rotation == 2) { + planeShademap[plane][x + 1][z] = (byte) 50; + } else if (rotation == 3) { + planeShademap[plane][x][z] = (byte) 50; + } + } + + if (type.solid && (collision != null)) { + collision.addWall(z, rotation, x, kind, type.blocksProjectiles); + } + } else if (kind == 2) { + int i_137_ = (rotation + 1) & 0x3; + Entity entity; + Entity entity_138_; + if ((type.seqId == -1) && (type.overrideTypeIDs == null)) { + entity = type.getModel(2, 4 + rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, -1); + entity_138_ = type.getModel(2, i_137_, heightmapSW, heightmapSE, heightmapNE, heightmapNW, -1); + } else { + entity = new LocEntity(locID, 4 + rotation, 2, heightmapSE, heightmapNE, heightmapSW, heightmapNW, type.seqId, true); + entity_138_ = new LocEntity(locID, i_137_, 2, heightmapSE, heightmapNE, heightmapSW, heightmapNW, type.seqId, true); + } + scene.setWall(WALL_ROTATION_OCCLUDE_TYPE[rotation], entity, WALL_ROTATION_OCCLUDE_TYPE[i_137_], entity_138_, plane, x, z, heightmapAverage, bitset, info); + if (type.occludes) { + if (rotation == 0) { + planeOccludemap[plane][x][z] |= 0x249; + planeOccludemap[plane][x][z + 1] |= 0x492; + } else if (rotation == 1) { + planeOccludemap[plane][x][z + 1] |= 0x492; + planeOccludemap[plane][x + 1][z] |= 0x249; + } else if (rotation == 2) { + planeOccludemap[plane][x + 1][z] |= 0x249; + planeOccludemap[plane][x][z] |= 0x492; + } else if (rotation == 3) { + planeOccludemap[plane][x][z] |= 0x492; + planeOccludemap[plane][x][z] |= 0x249; + } + } + if (type.solid && (collision != null)) { + collision.addWall(z, rotation, x, kind, type.blocksProjectiles); + } + if (type.decorationPadding != 16) { + scene.setWallDecorationOffset(plane, x, z, type.decorationPadding); + } + } else if (kind == 3) { + Entity entity; + if ((type.seqId == -1) && (type.overrideTypeIDs == null)) { + entity = type.getModel(3, rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, -1); + } else { + entity = new LocEntity(locID, rotation, 3, heightmapSE, heightmapNE, heightmapSW, heightmapNW, type.seqId, true); + } + scene.setWall(WALL_ROTATION_OCCLUDE_TYPE_1[rotation], entity, 0, null, plane, x, z, heightmapAverage, bitset, info); + if (type.castShadow) { + if (rotation == 0) { + planeShademap[plane][x][z + 1] = (byte) 50; + } else if (rotation == 1) { + planeShademap[plane][x + 1][z + 1] = (byte) 50; + } else if (rotation == 2) { + planeShademap[plane][x + 1][z] = (byte) 50; + } else if (rotation == 3) { + planeShademap[plane][x][z] = (byte) 50; + } + } + if (type.solid && (collision != null)) { + collision.addWall(z, rotation, x, kind, type.blocksProjectiles); + } + } else if (kind == 9) { + Entity entity; + if ((type.seqId == -1) && (type.overrideTypeIDs == null)) { + entity = type.getModel(kind, rotation, heightmapSW, heightmapSE, heightmapNE, heightmapNW, -1); + } else { + entity = new LocEntity(locID, rotation, kind, heightmapSE, heightmapNE, heightmapSW, heightmapNW, type.seqId, true); + } + scene.add(entity, plane, x, z, heightmapAverage, 1, 1, 0, bitset, info); + if (type.solid && (collision != null)) { + collision.add(type.blocksProjectiles, type.width, type.length, x, z, rotation); + } + } else { + if (type.adjustToTerrain) { + if (rotation == 1) { + int i_139_ = heightmapNW; + heightmapNW = heightmapNE; + heightmapNE = heightmapSE; + heightmapSE = heightmapSW; + heightmapSW = i_139_; + } else if (rotation == 2) { + int i_140_ = heightmapNW; + heightmapNW = heightmapSE; + heightmapSE = i_140_; + i_140_ = heightmapNE; + heightmapNE = heightmapSW; + heightmapSW = i_140_; + } else if (rotation == 3) { + int i_141_ = heightmapNW; + heightmapNW = heightmapSW; + heightmapSW = heightmapSE; + heightmapSE = heightmapNE; + heightmapNE = i_141_; + } + } + if (kind == 4) { + Entity entity; + if ((type.seqId == -1) && (type.overrideTypeIDs == null)) { + entity = type.getModel(4, 0, heightmapSW, heightmapSE, heightmapNE, heightmapNW, -1); + } else { + entity = new LocEntity(locID, 0, 4, heightmapSE, heightmapNE, heightmapSW, heightmapNW, type.seqId, true); + } + scene.setWallDecoration(WALL_ROTATION_OCCLUDE_TYPE[rotation], entity, plane, x, z, heightmapAverage, rotation * 512, 0, 0, bitset, info); + } else if (kind == 5) { + int i_142_ = 16; + int i_143_ = scene.getWallBitset(plane, x, z); + if (i_143_ > 0) { + i_142_ = LocType.get((i_143_ >> 14) & 0x7fff).decorationPadding; + } + Entity entity; + if ((type.seqId == -1) && (type.overrideTypeIDs == null)) { + entity = type.getModel(4, 0, heightmapSW, heightmapSE, heightmapNE, heightmapNW, -1); + } else { + entity = new LocEntity(locID, 0, 4, heightmapSE, heightmapNE, heightmapSW, heightmapNW, type.seqId, true); + } + scene.setWallDecoration(WALL_ROTATION_OCCLUDE_TYPE[rotation], entity, plane, x, z, heightmapAverage, rotation * 512, anIntArray137[rotation] * i_142_, anIntArray144[rotation] * i_142_, bitset, info); + } else if (kind == 6) { + Entity entity; + if ((type.seqId == -1) && (type.overrideTypeIDs == null)) { + entity = type.getModel(4, 0, heightmapSW, heightmapSE, heightmapNE, heightmapNW, -1); + } else { + entity = new LocEntity(locID, 0, 4, heightmapSE, heightmapNE, heightmapSW, heightmapNW, type.seqId, true); + } + scene.setWallDecoration(256, entity, plane, x, z, heightmapAverage, rotation, 0, 0, bitset, info); + } else if (kind == 7) { + Entity entity; + if ((type.seqId == -1) && (type.overrideTypeIDs == null)) { + entity = type.getModel(4, 0, heightmapSW, heightmapSE, heightmapNE, heightmapNW, -1); + } else { + entity = new LocEntity(locID, 0, 4, heightmapSE, heightmapNE, heightmapSW, heightmapNW, type.seqId, true); + } + scene.setWallDecoration(512, entity, plane, x, z, heightmapAverage, rotation, 0, 0, bitset, info); + } else if (kind == 8) { + Entity entity; + if ((type.seqId == -1) && (type.overrideTypeIDs == null)) { + entity = type.getModel(4, 0, heightmapSW, heightmapSE, heightmapNE, heightmapNW, -1); + } else { + entity = new LocEntity(locID, 0, 4, heightmapSE, heightmapNE, heightmapSW, heightmapNW, type.seqId, true); + } + scene.setWallDecoration(768, entity, plane, x, z, heightmapAverage, rotation, 0, 0, bitset, info); + } + } + } + + public int method177(int i, int i_156_, int i_157_) { + if (i_157_ > 179) { + i_156_ /= 2; + } + if (i_157_ > 192) { + i_156_ /= 2; + } + if (i_157_ > 217) { + i_156_ /= 2; + } + if (i_157_ > 243) { + i_156_ /= 2; + } + return ((i / 4) << 10) + ((i_156_ / 32) << 7) + (i_157_ / 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; + } + } + } + Buffer buffer = new Buffer(is); + for (int i_172_ = 0; i_172_ < 4; i_172_++) { + for (int i_173_ = 0; i_173_ < 64; i_173_++) { + for (int i_174_ = 0; i_174_ < 64; i_174_++) { + if ((i_172_ == i) && (i_173_ >= i_165_) && (i_173_ < (i_165_ + 8)) && (i_174_ >= i_166_) && (i_174_ < (i_166_ + 8))) { + method181(i_168_ + ZoneUtil.method156(i_174_ & 0x7, i_162_, i_173_ & 0x7), 0, buffer, i_164_ + ZoneUtil.method155(i_162_, i_174_ & 0x7, i_173_ & 0x7), i_167_, i_162_, 0); + } else { + method181(-1, 0, buffer, -1, 0, 0, 0); + } + } + } + } + } + + public void method180(byte[] is, int i, int i_175_, int i_176_, int i_177_, SceneCollisionMap[] collisionMaps) { + for (int i_179_ = 0; i_179_ < 4; i_179_++) { + for (int i_180_ = 0; i_180_ < 64; i_180_++) { + for (int i_181_ = 0; i_181_ < 64; i_181_++) { + if (((i_175_ + i_180_) > 0) && ((i_175_ + i_180_) < 103) && ((i + i_181_) > 0) && ((i + i_181_) < 103)) { + collisionMaps[i_179_].flags[i_175_ + i_180_][i + i_181_] &= ~0x1000000; + } + } + } + } + Buffer buffer = new Buffer(is); + for (int i_182_ = 0; i_182_ < 4; i_182_++) { + for (int i_183_ = 0; i_183_ < 64; i_183_++) { + for (int i_184_ = 0; i_184_ < 64; i_184_++) { + method181(i_184_ + i, i_177_, buffer, i_183_ + i_175_, i_182_, 0, i_176_); + } + } + } + } + + public void method181(int i, int i_185_, Buffer buffer, int i_186_, int i_187_, int i_188_, int i_190_) { + if ((i_186_ >= 0) && (i_186_ < 104) && (i >= 0) && (i < 104)) { + planeTileFlags[i_187_][i_186_][i] = (byte) 0; + for (; ; ) { + int i_191_ = buffer.get1U(); + if (i_191_ == 0) { + if (i_187_ == 0) { + planeHeightmap[0][i_186_][i] = -method172(932731 + i_186_ + i_190_, 556238 + i + i_185_) * 8; + } else { + planeHeightmap[i_187_][i_186_][i] = planeHeightmap[i_187_ - 1][i_186_][i] - 240; + break; + } + break; + } + if (i_191_ == 1) { + int i_192_ = buffer.get1U(); + if (i_192_ == 1) { + i_192_ = 0; + } + 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)); + break; + } + break; + } + if (i_191_ <= 49) { + aByteArrayArrayArray130[i_187_][i_186_][i] = buffer.get1(); + aByteArrayArrayArray136[i_187_][i_186_][i] = (byte) ((i_191_ - 2) / 4); + aByteArrayArrayArray148[i_187_][i_186_][i] = (byte) (((i_191_ - 2) + i_188_) & 0x3); + } else if (i_191_ <= 81) { + planeTileFlags[i_187_][i_186_][i] = (byte) (i_191_ - 49); + } else { + aByteArrayArrayArray142[i_187_][i_186_][i] = (byte) (i_191_ - 81); + } + } + } else { + for (; ; ) { + int i_193_ = buffer.get1U(); + if (i_193_ == 0) { + break; + } + if (i_193_ == 1) { + buffer.get1U(); + break; + } + if (i_193_ <= 49) { + buffer.get1U(); + } + } + } + } + + public int getDrawPlane(int plane, int stx, int stz) { + if ((planeTileFlags[plane][stx][stz] & 0x8) != 0) { + return 0; + } + if ((plane > 0) && ((planeTileFlags[1][stx][stz] & 0x2) != 0)) { + return plane - 1; + } + return plane; + } + + public void method183(SceneCollisionMap[] collisionMaps, Scene scene, int i, int i_197_, int i_198_, int i_199_, byte[] is, int i_200_, int i_201_, int i_202_) { + Buffer buffer = new Buffer(is); + int i_203_ = -1; + for (; ; ) { + int i_204_ = buffer.getSmartU(); + if (i_204_ == 0) { + break; + } + i_203_ += i_204_; + int i_205_ = 0; + for (; ; ) { + int i_206_ = buffer.getSmartU(); + if (i_206_ == 0) { + break; + } + i_205_ += i_206_ - 1; + int i_207_ = i_205_ & 0x3f; + int i_208_ = (i_205_ >> 6) & 0x3f; + int i_209_ = i_205_ >> 12; + int i_210_ = buffer.get1U(); + int i_211_ = i_210_ >> 2; + int i_212_ = i_210_ & 0x3; + if ((i_209_ == i) && (i_208_ >= i_200_) && (i_208_ < (i_200_ + 8)) && (i_207_ >= i_198_) && (i_207_ < (i_198_ + 8))) { + LocType type = LocType.get(i_203_); + int i_213_ = i_197_ + ZoneUtil.method157(i_201_, type.length, i_208_ & 0x7, i_207_ & 0x7, type.width); + int i_214_ = i_202_ + ZoneUtil.method158(i_207_ & 0x7, type.length, i_201_, type.width, i_208_ & 0x7); + if ((i_213_ > 0) && (i_214_ > 0) && (i_213_ < 103) && (i_214_ < 103)) { + int i_215_ = i_209_; + if ((planeTileFlags[1][i_213_][i_214_] & 0x2) == 2) { + i_215_--; + } + SceneCollisionMap collisionMap = null; + if (i_215_ >= 0) { + collisionMap = collisionMaps[i_215_]; + } + method175(i_214_, scene, collisionMap, i_211_, i_199_, i_213_, i_203_, (i_212_ + i_201_) & 0x3); + } + } + } + } + } + + public int method185(int i, int i_220_) { + if (i == -2) { + return 12345678; + } + if (i == -1) { + if (i_220_ < 0) { + i_220_ = 0; + } else if (i_220_ > 127) { + i_220_ = 127; + } + i_220_ = 127 - i_220_; + return i_220_; + } + i_220_ = (i_220_ * (i & 0x7f)) / 128; + if (i_220_ < 2) { + i_220_ = 2; + } else if (i_220_ > 126) { + i_220_ = 126; + } + return (i & 0xff80) + i_220_; + } + + public void method190(int i, SceneCollisionMap[] collisionMaps, int i_263_, Scene scene, byte[] is) { + Buffer buffer = new Buffer(is); + int i_265_ = -1; + for (; ; ) { + int i_266_ = buffer.getSmartU(); + if (i_266_ == 0) { + break; + } + i_265_ += i_266_; + int i_267_ = 0; + for (; ; ) { + int i_268_ = buffer.getSmartU(); + if (i_268_ == 0) { + break; + } + i_267_ += i_268_ - 1; + int i_269_ = i_267_ & 0x3f; + int i_270_ = (i_267_ >> 6) & 0x3f; + int i_271_ = i_267_ >> 12; + int i_272_ = buffer.get1U(); + int i_273_ = i_272_ >> 2; + int i_274_ = i_272_ & 0x3; + int i_275_ = i_270_ + i; + int i_276_ = i_269_ + i_263_; + if ((i_275_ > 0) && (i_276_ > 0) && (i_275_ < 103) && (i_276_ < 103)) { + int i_277_ = i_271_; + if ((planeTileFlags[1][i_275_][i_276_] & 0x2) == 2) { + i_277_--; + } + SceneCollisionMap collisionMap = null; + if (i_277_ >= 0) { + collisionMap = collisionMaps[i_277_]; + } + method175(i_276_, scene, collisionMap, i_273_, i_271_, i_275_, i_265_, i_274_); + } + } + } + } } diff --git a/src/main/java/SceneCollisionMap.java b/src/main/java/SceneCollisionMap.java index b83eef3..d47171b 100644 --- a/src/main/java/SceneCollisionMap.java +++ b/src/main/java/SceneCollisionMap.java @@ -29,157 +29,160 @@ public class SceneCollisionMap { } } - public void method211(int i, int j, int k, int l, boolean flag) { - if (l == 0) { - if (j == 0) { - method214(k, i, 128); - method214(k - 1, i, 8); + public void addWall(int i, int rotation, int k, int kind, boolean blocksProjectiles) { + if (kind == 0) { + if (rotation == 0) { + add(k, i, 128); + add(k - 1, i, 8); } - if (j == 1) { - method214(k, i, 2); - method214(k, i + 1, 32); + if (rotation == 1) { + add(k, i, 2); + add(k, i + 1, 32); } - if (j == 2) { - method214(k, i, 8); - method214(k + 1, i, 128); + if (rotation == 2) { + add(k, i, 8); + add(k + 1, i, 128); } - if (j == 3) { - method214(k, i, 32); - method214(k, i - 1, 2); + if (rotation == 3) { + add(k, i, 32); + add(k, i - 1, 2); } } - if ((l == 1) || (l == 3)) { - if (j == 0) { - method214(k, i, 1); - method214(k - 1, i + 1, 16); + if ((kind == 1) || (kind == 3)) { + if (rotation == 0) { + add(k, i, 1); + add(k - 1, i + 1, 16); } - if (j == 1) { - method214(k, i, 4); - method214(k + 1, i + 1, 64); + if (rotation == 1) { + add(k, i, 4); + add(k + 1, i + 1, 64); } - if (j == 2) { - method214(k, i, 16); - method214(k + 1, i - 1, 1); + if (rotation == 2) { + add(k, i, 16); + add(k + 1, i - 1, 1); } - if (j == 3) { - method214(k, i, 64); - method214(k - 1, i - 1, 4); + if (rotation == 3) { + add(k, i, 64); + add(k - 1, i - 1, 4); } } - if (l == 2) { - if (j == 0) { - method214(k, i, 130); - method214(k - 1, i, 8); - method214(k, i + 1, 32); + if (kind == 2) { + if (rotation == 0) { + add(k, i, 130); + add(k - 1, i, 8); + add(k, i + 1, 32); } - if (j == 1) { - method214(k, i, 10); - method214(k, i + 1, 32); - method214(k + 1, i, 128); + if (rotation == 1) { + add(k, i, 10); + add(k, i + 1, 32); + add(k + 1, i, 128); } - if (j == 2) { - method214(k, i, 40); - method214(k + 1, i, 128); - method214(k, i - 1, 2); + if (rotation == 2) { + add(k, i, 40); + add(k + 1, i, 128); + add(k, i - 1, 2); } - if (j == 3) { - method214(k, i, 160); - method214(k, i - 1, 2); - method214(k - 1, i, 8); + if (rotation == 3) { + add(k, i, 160); + add(k, i - 1, 2); + add(k - 1, i, 8); } } - if (flag) { - if (l == 0) { - if (j == 0) { - method214(k, i, 0x10000); - method214(k - 1, i, 4096); + if (blocksProjectiles) { + if (kind == 0) { + if (rotation == 0) { + add(k, i, 0x10000); + add(k - 1, i, 4096); } - if (j == 1) { - method214(k, i, 1024); - method214(k, i + 1, 16384); + if (rotation == 1) { + add(k, i, 1024); + add(k, i + 1, 16384); } - if (j == 2) { - method214(k, i, 4096); - method214(k + 1, i, 0x10000); + if (rotation == 2) { + add(k, i, 4096); + add(k + 1, i, 0x10000); } - if (j == 3) { - method214(k, i, 16384); - method214(k, i - 1, 1024); + if (rotation == 3) { + add(k, i, 16384); + add(k, i - 1, 1024); } } - if ((l == 1) || (l == 3)) { - if (j == 0) { - method214(k, i, 512); - method214(k - 1, i + 1, 8192); + if ((kind == 1) || (kind == 3)) { + if (rotation == 0) { + add(k, i, 512); + add(k - 1, i + 1, 8192); } - if (j == 1) { - method214(k, i, 2048); - method214(k + 1, i + 1, 32768); + if (rotation == 1) { + add(k, i, 2048); + add(k + 1, i + 1, 32768); } - if (j == 2) { - method214(k, i, 8192); - method214(k + 1, i - 1, 512); + if (rotation == 2) { + add(k, i, 8192); + add(k + 1, i - 1, 512); } - if (j == 3) { - method214(k, i, 32768); - method214(k - 1, i - 1, 2048); + if (rotation == 3) { + add(k, i, 32768); + add(k - 1, i - 1, 2048); } } - if (l == 2) { - if (j == 0) { - method214(k, i, 0x10400); - method214(k - 1, i, 4096); - method214(k, i + 1, 16384); + if (kind == 2) { + if (rotation == 0) { + add(k, i, 0x10400); + add(k - 1, i, 4096); + add(k, i + 1, 16384); } - if (j == 1) { - method214(k, i, 5120); - method214(k, i + 1, 16384); - method214(k + 1, i, 0x10000); + if (rotation == 1) { + add(k, i, 5120); + add(k, i + 1, 16384); + add(k + 1, i, 0x10000); } - if (j == 2) { - method214(k, i, 20480); - method214(k + 1, i, 0x10000); - method214(k, i - 1, 1024); + if (rotation == 2) { + add(k, i, 20480); + add(k + 1, i, 0x10000); + add(k, i - 1, 1024); } - if (j == 3) { - method214(k, i, 0x14000); - method214(k, i - 1, 1024); - method214(k - 1, i, 4096); + if (rotation == 3) { + add(k, i, 0x14000); + add(k, i - 1, 1024); + add(k - 1, i, 4096); } } } } - public void method212(boolean flag, int j, int k, int l, int i1, int j1) { - int k1 = 256; - if (flag) { - k1 += 0x20000; + public void add(boolean blocksProjectiles, int width, int length, int x, int z, int rotation) { + int flags = 256; + + if (blocksProjectiles) { + flags += 0x20000; } - if ((j1 == 1) || (j1 == 3)) { - int l1 = j; - j = k; - k = l1; + + if ((rotation == 1) || (rotation == 3)) { + int tmp = width; + width = length; + length = tmp; } - for (int i2 = l; i2 < (l + j); i2++) { - if ((i2 >= 0) && (i2 < anInt292)) { - for (int j2 = i1; j2 < (i1 + k); j2++) { - if ((j2 >= 0) && (j2 < anInt293)) { - method214(i2, j2, k1); + + for (int tx = x; tx < (x + width); tx++) { + if ((tx >= 0) && (tx < anInt292)) { + for (int tz = z; tz < (z + length); tz++) { + if ((tz >= 0) && (tz < anInt293)) { + add(tx, tz, flags); } } } } } - public void method213(int i, int k) { - flags[k][i] |= 0x200000; + public void addSolid(int z, int x) { + flags[x][z] |= 0x200000; } - public void method214(int i, int j, int k) { - flags[i][j] |= k; + public void add(int x, int z, int k) { + flags[x][z] |= k; } - public void method215(int i, int j, boolean flag, int k, int l) { + public void remove(int i, int j, boolean flag, int k, int l) { if (j == 0) { if (i == 0) { method217(128, k, l); @@ -300,7 +303,7 @@ public class SceneCollisionMap { } } - public void method216(int rotation, int width, int x0, int z0, int length, boolean flag) { + public void remove(int rotation, int width, int x0, int z0, int length, boolean flag) { int flags = 256; if (flag) { flags += 0x20000; diff --git a/src/main/java/SceneLocTemporary.java b/src/main/java/SceneLocTemporary.java index bd3e70c..fdb61b0 100644 --- a/src/main/java/SceneLocTemporary.java +++ b/src/main/java/SceneLocTemporary.java @@ -8,13 +8,13 @@ public class SceneLocTemporary extends DoublyLinkedList.Node { public int anInt1292; public int anInt1293; public int anInt1294; - public int anInt1295; - public int anInt1296; - public int sceneTileX; - public int sceneTileZ; - public int anInt1299; - public int anInt1300; - public int anInt1301; + public int plane; + public int classID; + public int localX; + public int localZ; + public int savedLocID; + public int savedRotation; + public int savedKind; public int anInt1302; public SceneLocTemporary() { diff --git a/src/main/java/SceneWall.java b/src/main/java/SceneWall.java index 317ebeb..76707b4 100644 --- a/src/main/java/SceneWall.java +++ b/src/main/java/SceneWall.java @@ -7,10 +7,10 @@ public class SceneWall { public int y; public int x; public int z; - public int type0; - public int type1; - public Entity entity0; - public Entity entity1; + public int occludeA; + public int occludeB; + public Entity entityA; + public Entity entityB; public int bitset; public byte info; diff --git a/src/main/java/SceneWallDecoration.java b/src/main/java/SceneWallDecoration.java index 142065b..55395be 100644 --- a/src/main/java/SceneWallDecoration.java +++ b/src/main/java/SceneWallDecoration.java @@ -3,7 +3,7 @@ public class SceneWallDecoration { public int y; public int x; public int z; - public int type; + public int occlude; public int yaw; public Entity entity; public int bitset; diff --git a/src/main/java/SeqType.java b/src/main/java/SeqType.java index beeb00d..8d02b06 100644 --- a/src/main/java/SeqType.java +++ b/src/main/java/SeqType.java @@ -28,7 +28,7 @@ public class SeqType { public int[] primaryFrames; public int[] secondaryFrames; public int[] frameDelays; - public int anInt356 = -1; + public int speed = -1; public int[] anIntArray357; public boolean aBoolean358 = false; public int anInt359 = 5; @@ -77,7 +77,7 @@ public class SeqType { frameDelays[j] = buffer.get2U(); } } else if (op == 2) { - anInt356 = buffer.get2U(); + speed = buffer.get2U(); } else if (op == 3) { int k = buffer.get1U(); anIntArray357 = new int[k + 1]; diff --git a/src/main/java/SoundEnvelope.java b/src/main/java/SoundEnvelope.java index e590790..42b9a1b 100644 --- a/src/main/java/SoundEnvelope.java +++ b/src/main/java/SoundEnvelope.java @@ -6,60 +6,60 @@ */ public class SoundEnvelope { - public int length; - public int[] shapeDelta; - public int[] shapePeak; - public int start; - public int end; - public int form; - public int threshold; - public int position; - public int delta; - public int amplitude; - public int ticks; + public int length; + public int[] shapeDelta; + public int[] shapePeak; + public int start; + public int end; + public int form; + public int threshold; + public int position; + public int delta; + public int amplitude; + public int ticks; - public SoundEnvelope() { - } + public SoundEnvelope() { + } - public void read(Buffer buffer) { - form = buffer.get1U(); - start = buffer.get4(); - end = buffer.get4(); - readShape(buffer); - } + public void read(Buffer buffer) { + form = buffer.get1U(); + start = buffer.get4(); + end = buffer.get4(); + readShape(buffer); + } - public void readShape(Buffer buffer) { - length = buffer.get1U(); - shapeDelta = new int[length]; - shapePeak = new int[length]; - for (int i = 0; i < length; i++) { - shapeDelta[i] = buffer.get2U(); - shapePeak[i] = buffer.get2U(); - } - } + public void readShape(Buffer buffer) { + length = buffer.get1U(); + shapeDelta = new int[length]; + shapePeak = new int[length]; + for (int i = 0; i < length; i++) { + shapeDelta[i] = buffer.get2U(); + shapePeak[i] = buffer.get2U(); + } + } - public void reset() { - threshold = 0; - position = 0; - delta = 0; - amplitude = 0; - ticks = 0; - } + public void reset() { + threshold = 0; + position = 0; + delta = 0; + amplitude = 0; + ticks = 0; + } - public int evaluate(int delta) { - if (ticks >= threshold) { - amplitude = shapePeak[position++] << 15; - if (position >= length) { - position = length - 1; - } - threshold = (int) (((double) shapeDelta[position] / 65536D) * (double) delta); - if (threshold > ticks) { - this.delta = ((shapePeak[position] << 15) - amplitude) / (threshold - ticks); - } - } - amplitude += this.delta; - ticks++; - return (amplitude - this.delta) >> 15; - } + public int evaluate(int delta) { + if (ticks >= threshold) { + amplitude = shapePeak[position++] << 15; + if (position >= length) { + position = length - 1; + } + threshold = (int) (((double) shapeDelta[position] / 65536D) * (double) delta); + if (threshold > ticks) { + this.delta = ((shapePeak[position] << 15) - amplitude) / (threshold - ticks); + } + } + amplitude += this.delta; + ticks++; + return (amplitude - this.delta) >> 15; + } }