From 626e6395eaa1633f2fdbbcb73f461d903d259663 Mon Sep 17 00:00:00 2001 From: thedaneeffect Date: Tue, 16 Mar 2021 05:49:56 -0400 Subject: [PATCH] Scene --- .idea/inspectionProfiles/Project_Default.xml | 9 +- src/main/java/Component.java | 4 +- src/main/java/Draw3D.java | 4 +- src/main/java/Game.java | 2362 ++++++++++-------- src/main/java/Image24.java | 595 +++-- src/main/java/Image8.java | 90 +- src/main/java/LocEntity.java | 30 +- src/main/java/LocType.java | 16 +- src/main/java/NPCEntity.java | 28 +- src/main/java/NPCType.java | 163 +- src/main/java/ObjType.java | 64 +- src/main/java/PathingEntity.java | 127 +- src/main/java/PlayerEntity.java | 102 +- src/main/java/ProjectileEntity.java | 12 +- src/main/java/Scene.java | 1429 ++++++----- src/main/java/SceneBuilder.java | 498 ++-- src/main/java/SceneCollisionMap.java | 88 +- src/main/java/SceneGroundDecoration.java | 12 +- src/main/java/SceneLoc.java | 28 +- src/main/java/SceneObjStack.java | 16 +- src/main/java/SceneOccluder.java | 2 +- src/main/java/SceneTile.java | 24 +- src/main/java/SceneWall.java | 18 +- src/main/java/SceneWallDecoration.java | 20 +- src/main/java/SeqType.java | 114 +- src/main/java/SpotAnimEntity.java | 8 +- src/main/java/SpotAnimType.java | 4 +- src/main/java/VarbitType.java | 65 +- src/main/java/VarpType.java | 36 +- 29 files changed, 3105 insertions(+), 2863 deletions(-) diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 427cfa4..2e03685 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -1,10 +1,11 @@ \ No newline at end of file diff --git a/src/main/java/Component.java b/src/main/java/Component.java index b0d6628..561f123 100644 --- a/src/main/java/Component.java +++ b/src/main/java/Component.java @@ -322,10 +322,10 @@ public class Component { model = Model.tryGet(j); } if (i == 2) { - model = NPCType.method159(j).method160(); + model = NPCType.get(j).method160(); } if (i == 3) { - model = Game.aPlayer_1126.method453(); + model = Game.self.method453(); } if (i == 4) { model = ObjType.method198(j).method202(50); diff --git a/src/main/java/Draw3D.java b/src/main/java/Draw3D.java index 812a13f..cad0ba5 100644 --- a/src/main/java/Draw3D.java +++ b/src/main/java/Draw3D.java @@ -135,7 +135,7 @@ public class Draw3D { /** * Nullifies the texel pool. {@link #initPool(int)} must be called again if textured triangles are drawn. */ - public static void disposePool() { + public static void clearTexels() { texelPool = null; for (int j = 0; j < 50; j++) { activeTexels[j] = null; @@ -261,7 +261,7 @@ public class Draw3D { } } else { // scale 64x64 textures up to 128x128 - if (texture.anInt1452 == 64) { + if (texture.width == 64) { for (int y = 0; y < 128; y++) { for (int x = 0; x < 128; x++) { texels[x + (y << 7)] = palette[texture.pixels[(x >> 1) + ((y >> 1) << 6)]]; diff --git a/src/main/java/Game.java b/src/main/java/Game.java index d0849b4..cb6edeb 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -26,7 +26,7 @@ public class Game extends GameShell { public static final int[] levelExperience; public static final BigInteger RSA_PUBLIC_KEY = new BigInteger("58778699976184461502525193738213253649000149147835990136706041084440742975821"); public static final String aString1162 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"\243$%^&*()-_=+[{]};:'@#~,<.>/?\\| "; - public static final int[] anIntArray1232; + public static final int[] BITMASK; public static final int MAX_PLAYER_COUNT = 2048; public static final int LOCAL_PLAYER_INDEX = 2047; public static int nodeId = 10; @@ -35,7 +35,7 @@ public class Game extends GameShell { public static boolean lowmem; public static boolean started; public static int drawCycle; - public static PlayerEntity aPlayer_1126; + public static PlayerEntity self; public static boolean aBoolean1156; public static int loopCycle; public static boolean aBoolean1205; @@ -49,10 +49,10 @@ public class Game extends GameShell { i += i1; levelExperience[j] = i / 4; } - anIntArray1232 = new int[32]; + BITMASK = new int[32]; i = 2; for (int k = 0; k < 32; k++) { - anIntArray1232[k] = i - 1; + BITMASK[k] = i - 1; i += i; } } @@ -170,8 +170,8 @@ public class Game extends GameShell { public final String[] aStringArray943 = new String[100]; public final String[] aStringArray944 = new String[100]; public final int[] anIntArray965 = {0xffff00, 0xff0000, 65280, 65535, 0xff00ff, 0xffffff}; - public final int[] anIntArray968 = new int[33]; - public final int[] anIntArray969 = new int[256]; + public final int[] compassMaskLineOffsets = new int[33]; + public final int[] flameLineOffset = new int[256]; public final FileStore[] filestores = new FileStore[5]; public final int anInt975 = 50; public final int[] anIntArray976 = new int[anInt975]; @@ -187,8 +187,8 @@ public class Game extends GameShell { public final int[] anIntArray1030 = new int[5]; public final int[] anIntArray1044 = new int[SkillConstants.anInt733]; public final int[] anIntArray1045 = new int[2000]; - public final int[] anIntArray1052 = new int[151]; - public final int[] anIntArray1057 = new int[33]; + public final int[] minimapMaskLineOffsets = new int[151]; + public final int[] compassMaskLineLengths = new int[33]; public final Component aComponent_1059 = new Component(); public final int anInt1063 = 0x4d4233; public final int[] anIntArray1065 = new int[7]; @@ -200,7 +200,7 @@ public class Game extends GameShell { public final int[] anIntArray1203 = new int[5]; public final int[] anIntArray1207 = new int[50]; public final Image8[] aImageArray1219 = new Image8[2]; - public final int[] anIntArray1229 = new int[151]; + public final int[] minimapMaskLineLengths = new int[151]; public final int[] anIntArray1240 = new int[100]; public final int[] anIntArray1241 = new int[50]; public final int[] anIntArray1250 = new int[50]; @@ -209,9 +209,9 @@ public class Game extends GameShell { public int[][] anIntArrayArray825 = new int[104][104]; public int[] anIntArray826 = new int[200]; public DoublyLinkedList[][][] aListArrayArrayArray827 = new DoublyLinkedList[4][104][104]; - public int[] anIntArray828; - public int[] anIntArray829; - public volatile boolean aBoolean831 = false; + public int[] flameBuffer3; + public int[] flameBuffer2; + public volatile boolean flameActive = false; public Socket aSocket832; public int anInt833; public Buffer aBuffer_834 = new Buffer(new byte[5000]); @@ -227,10 +227,10 @@ public class Game extends GameShell { public int anInt845; public Buffer aBuffer_847 = Buffer.create(1); public boolean aBoolean848 = true; - public int[] anIntArray850; - public int[] anIntArray851; - public int[] anIntArray852; - public int[] anIntArray853; + public int[] flameGradient; + public int[] flameGradient0; + public int[] flameGradient1; + public int[] flameGradient2; public int anInt855; public int anInt857 = -1; public int anInt858; @@ -252,7 +252,7 @@ public class Game extends GameShell { public MouseRecorder aMouseRecorder_879; public volatile boolean aBoolean880 = false; public String aString881 = ""; - public int anInt884 = -1; + public int selfPlayerId = -1; public boolean aBoolean885 = false; public int anInt886; public String aString887 = ""; @@ -281,7 +281,7 @@ public class Game extends GameShell { public int anInt915; public int anInt916; public int anInt917; - public int anInt918; + public int currentPlane; public boolean aBoolean926 = false; public int[][] anIntArrayArray929 = new int[104][104]; public Image24 aImage_931; @@ -304,16 +304,16 @@ public class Game extends GameShell { public boolean aBoolean954 = true; public long[] aLongArray955 = new long[200]; public int anInt956 = -1; - public volatile boolean aBoolean962 = false; + public volatile boolean flameThread = false; public int anInt963 = -1; public int anInt964 = -1; - public Image8 aImage_966; - public Image8 aImage_967; + public Image8 imageTitlebox; + public Image8 imageTitlebutton; public int[] anIntArray971 = new int[2000]; public boolean aBoolean972 = false; public int anInt974; public int anInt984; - public int anInt985 = -1; + public int minimapPlane = -1; public Image24[] imageHitmarks = new Image24[20]; public int anInt989; public int anInt992; @@ -337,7 +337,7 @@ public class Game extends GameShell { public int anInt1016; public boolean aBoolean1017 = false; public int anInt1018 = -1; - public int anInt1021; + public int minimapState; public int anInt1022; public int sceneState; public Image8 imageScrollbar0; @@ -354,8 +354,8 @@ public class Game extends GameShell { public int scenePrevBaseTileZ; public int anInt1038; public int anInt1039; - public int anInt1040; - public int anInt1041; + public int flameGradientCycle0; + public int flameGradientCycle1; public int anInt1042 = -1; public int anInt1046; public boolean aBoolean1047 = true; @@ -373,9 +373,9 @@ public class Game extends GameShell { public OnDemand ondemand; public int sceneCenterZoneX; public int sceneCenterZoneZ; - public int anInt1071; - public int[] anIntArray1072 = new int[1000]; - public int[] anIntArray1073 = new int[1000]; + public int activeMapFunctionCount; + public int[] activeMapFunctionX = new int[1000]; + public int[] activeMapFunctionZ = new int[1000]; public Image24 imageMapdot0; public Image24 imageMapdot1; public Image24 imageMapdot2; @@ -403,15 +403,15 @@ public class Game extends GameShell { public int anInt1102; public boolean aBoolean1103 = false; public int anInt1104; - public DrawArea aArea_1107; - public DrawArea aArea_1108; - public DrawArea aArea_1109; - public DrawArea aArea_1110; - public DrawArea aArea_1111; - public DrawArea aArea_1112; - public DrawArea aArea_1113; - public DrawArea aArea_1114; - public DrawArea aArea_1115; + public DrawArea imageTitle2; + public DrawArea imageTitle3; + public DrawArea imageTitle4; + public DrawArea imageTitle0; + public DrawArea imageTitle1; + public DrawArea imageTitle5; + public DrawArea imageTitle6; + public DrawArea imageTitle7; + public DrawArea imageTitle8; public int anInt1120; public String aString1121 = ""; public Image24 imageCompass; @@ -424,7 +424,7 @@ public class Game extends GameShell { public int anInt1137; public int anInt1138; public String aString1139; - public Image24[] aImageArray1140 = new Image24[1000]; + public Image24[] activeMapFunctions = new Image24[1000]; public boolean withinTutorialIsland = false; public Image8 imageRedstone1; public Image8 imageRedstone2; @@ -435,7 +435,7 @@ public class Game extends GameShell { public boolean aBoolean1149 = false; public Image24[] imageCrosses = new Image24[8]; public boolean aBoolean1151 = true; - public Image8[] aImageArray1152; + public Image8[] imageRunes; public boolean aBoolean1153 = false; public int anInt1154; public boolean ingame = false; @@ -449,7 +449,7 @@ public class Game extends GameShell { public int anInt1167; public Connection connection; public int anInt1169; - public int anInt1170; + public int minimapZoom; public long aLong1172; public String aString1173 = ""; public String aString1174 = ""; @@ -465,8 +465,8 @@ public class Game extends GameShell { public int anInt1186; public int anInt1187; public int anInt1189 = -1; - public int[] anIntArray1190; - public int[] anIntArray1191; + public int[] flameBuffer0; + public int[] flameBuffer1; public Buffer aBuffer_1192 = Buffer.create(1); public int anInt1193; public int anInt1195; @@ -474,8 +474,8 @@ public class Game extends GameShell { public Image8 imageMapback; public Image8 imageChatback; public String[] aStringArray1199 = new String[500]; - public Image24 aImage_1201; - public Image24 aImage_1202; + public Image24 imageFlamesLeft; + public Image24 imageFlamesRight; public int flameCycle; public int anInt1209; public int anInt1211 = 78; @@ -512,7 +512,7 @@ public class Game extends GameShell { public boolean aBoolean1255 = false; public boolean aBoolean1256 = false; public int anInt1257; - public byte[][][] aByteArrayArrayArray1258; + public byte[][][] planeTileFlags; public int anInt1259; public int anInt1261; public int anInt1262; @@ -527,7 +527,7 @@ public class Game extends GameShell { public BitmapFont fontPlain12; public BitmapFont fontBold12; public BitmapFont fontQuill8; - public int anInt1275; + public int flameCycle0; public int anInt1276 = -1; public int anInt1278; public int[] anIntArray1280 = new int[4000]; @@ -662,8 +662,8 @@ public class Game extends GameShell { fontBold12 = new BitmapFont(archiveTitle, "b12_full", false); fontQuill8 = new BitmapFont(archiveTitle, "q8_full", true); - method56(); - method51(); + createTitleBackground(); + createTitleImages(); FileArchive archiveConfig = loadArchive(2, "config", "config", archiveChecksum[2], 30); FileArchive archiveInterface = loadArchive(3, "interface", "interface", archiveChecksum[3], 35); @@ -672,7 +672,7 @@ public class Game extends GameShell { FileArchive archiveWordenc = loadArchive(7, "chat system", "wordenc", archiveChecksum[7], 50); FileArchive archiveSounds = loadArchive(8, "sound effects", "sounds", archiveChecksum[8], 55); - aByteArrayArrayArray1258 = new byte[4][104][104]; + planeTileFlags = new byte[4][104][104]; anIntArrayArrayArray1214 = new int[4][105][105]; scene = new Scene(104, 104, anIntArrayArrayArray1214, 4); @@ -916,32 +916,32 @@ public class Game extends GameShell { aImageArray1219[l4] = new Image8(archiveMedia, "mod_icons", l4); } Image24 image = new Image24(archiveMedia, "backleft1", 0); - aArea_903 = new DrawArea(image.anInt1440, image.anInt1441, getComponent()); - image.method346(0, 0); + aArea_903 = new DrawArea(image.width, image.height, getComponent()); + image.blitOpaque(0, 0); image = new Image24(archiveMedia, "backleft2", 0); - aArea_904 = new DrawArea(image.anInt1440, image.anInt1441, getComponent()); - image.method346(0, 0); + aArea_904 = new DrawArea(image.width, image.height, getComponent()); + image.blitOpaque(0, 0); image = new Image24(archiveMedia, "backright1", 0); - aArea_905 = new DrawArea(image.anInt1440, image.anInt1441, getComponent()); - image.method346(0, 0); + aArea_905 = new DrawArea(image.width, image.height, getComponent()); + image.blitOpaque(0, 0); image = new Image24(archiveMedia, "backright2", 0); - aArea_906 = new DrawArea(image.anInt1440, image.anInt1441, getComponent()); - image.method346(0, 0); + aArea_906 = new DrawArea(image.width, image.height, getComponent()); + image.blitOpaque(0, 0); image = new Image24(archiveMedia, "backtop1", 0); - aArea_907 = new DrawArea(image.anInt1440, image.anInt1441, getComponent()); - image.method346(0, 0); + aArea_907 = new DrawArea(image.width, image.height, getComponent()); + image.blitOpaque(0, 0); image = new Image24(archiveMedia, "backvmid1", 0); - aArea_908 = new DrawArea(image.anInt1440, image.anInt1441, getComponent()); - image.method346(0, 0); + aArea_908 = new DrawArea(image.width, image.height, getComponent()); + image.blitOpaque(0, 0); image = new Image24(archiveMedia, "backvmid2", 0); - aArea_909 = new DrawArea(image.anInt1440, image.anInt1441, getComponent()); - image.method346(0, 0); + aArea_909 = new DrawArea(image.width, image.height, getComponent()); + image.blitOpaque(0, 0); image = new Image24(archiveMedia, "backvmid3", 0); - aArea_910 = new DrawArea(image.anInt1440, image.anInt1441, getComponent()); - image.method346(0, 0); + aArea_910 = new DrawArea(image.width, image.height, getComponent()); + image.blitOpaque(0, 0); image = new Image24(archiveMedia, "backhmid2", 0); - aArea_911 = new DrawArea(image.anInt1440, image.anInt1441, getComponent()); - image.method346(0, 0); + aArea_911 = new DrawArea(image.width, image.height, getComponent()); + image.blitOpaque(0, 0); int i5 = (int) (Math.random() * 21D) - 10; int j5 = (int) (Math.random() * 21D) - 10; int k5 = (int) (Math.random() * 21D) - 10; @@ -983,7 +983,7 @@ public class Game extends GameShell { int k6 = 999; int i7 = 0; for (int k7 = 0; k7 < 34; k7++) { - if (imageMapback.pixels[k7 + (j6 * imageMapback.anInt1452)] == 0) { + if (imageMapback.pixels[k7 + (j6 * imageMapback.width)] == 0) { if (k6 == 999) { k6 = k7; } @@ -995,14 +995,14 @@ public class Game extends GameShell { i7 = k7; break; } - anIntArray968[j6] = k6; - anIntArray1057[j6] = i7 - k6; + compassMaskLineOffsets[j6] = k6; + compassMaskLineLengths[j6] = i7 - k6; } for (int l6 = 5; l6 < 156; l6++) { int j7 = 999; int l7 = 0; for (int j8 = 25; j8 < 172; j8++) { - if ((imageMapback.pixels[j8 + (l6 * imageMapback.anInt1452)] == 0) && ((j8 > 34) || (l6 > 34))) { + if ((imageMapback.pixels[j8 + (l6 * imageMapback.width)] == 0) && ((j8 > 34) || (l6 > 34))) { if (j7 == 999) { j7 = j8; } @@ -1014,8 +1014,8 @@ public class Game extends GameShell { l7 = j8; break; } - anIntArray1052[l6 - 5] = j7 - 25; - anIntArray1229[l6 - 5] = l7 - j7; + minimapMaskLineOffsets[l6 - 5] = j7 - 25; + minimapMaskLineLengths[l6 - 5] = l7 - j7; } Draw3D.init3D(479, 96); anIntArray1180 = Draw3D.lineOffset; @@ -1034,9 +1034,9 @@ public class Game extends GameShell { Censor.method487(archiveWordenc); aMouseRecorder_879 = new MouseRecorder(this); startThread(aMouseRecorder_879, 10); - LocEntity.aGame1609 = this; - LocType.aGame765 = this; - NPCType.aGame82 = this; + LocEntity.game = this; + LocType.game = this; + NPCType.game = this; return; } catch (Exception exception) { Signlink.reporterror("loaderror " + aString1049 + " " + anInt1079); @@ -1088,7 +1088,7 @@ public class Game extends GameShell { sceneMapLandFile = null; sceneMapLocFile = null; anIntArrayArrayArray1214 = null; - aByteArrayArrayArray1258 = null; + planeTileFlags = null; scene = null; collisions = null; anIntArrayArray901 = null; @@ -1158,22 +1158,22 @@ public class Game extends GameShell { anIntArray1094 = null; aStringArray1199 = null; anIntArray971 = null; - anIntArray1072 = null; - anIntArray1073 = null; - aImageArray1140 = null; + activeMapFunctionX = null; + activeMapFunctionZ = null; + activeMapFunctions = null; imageMinimap = null; aStringArray1082 = null; aLongArray955 = null; anIntArray826 = null; - aArea_1110 = null; - aArea_1111 = null; - aArea_1107 = null; - aArea_1108 = null; - aArea_1109 = null; - aArea_1112 = null; - aArea_1113 = null; - aArea_1114 = null; - aArea_1115 = null; + imageTitle0 = null; + imageTitle1 = null; + imageTitle2 = null; + imageTitle3 = null; + imageTitle4 = null; + imageTitle5 = null; + imageTitle6 = null; + imageTitle7 = null; + imageTitle8 = null; method118(); LocType.unload(); NPCType.unload(); @@ -1246,7 +1246,7 @@ public class Game extends GameShell { super.showProgress(percent, message); return; } - aArea_1109.bind(); + imageTitle4.bind(); char c = '\u0168'; char c1 = '\310'; byte byte1 = 20; @@ -1257,19 +1257,19 @@ public class Game extends GameShell { Draw2D.fillRect((c / 2) - 150, j + 2, percent * 3, 30, 0x8c1111); Draw2D.fillRect(((c / 2) - 150) + (percent * 3), j + 2, 300 - (percent * 3), 30, 0); fontBold12.drawStringCenter(message, c / 2, ((c1 / 2) + 5) - byte1, 0xffffff); - aArea_1109.draw(super.graphics, 202, 171); + imageTitle4.draw(super.graphics, 202, 171); if (aBoolean1255) { aBoolean1255 = false; - if (!aBoolean831) { - aArea_1110.draw(super.graphics, 0, 0); - aArea_1111.draw(super.graphics, 637, 0); + if (!flameActive) { + imageTitle0.draw(super.graphics, 0, 0); + imageTitle1.draw(super.graphics, 637, 0); } - aArea_1107.draw(super.graphics, 128, 0); - aArea_1108.draw(super.graphics, 202, 371); - aArea_1112.draw(super.graphics, 0, 265); - aArea_1113.draw(super.graphics, 562, 265); - aArea_1114.draw(super.graphics, 128, 171); - aArea_1115.draw(super.graphics, 562, 171); + imageTitle2.draw(super.graphics, 128, 0); + imageTitle3.draw(super.graphics, 202, 371); + imageTitle5.draw(super.graphics, 0, 265); + imageTitle6.draw(super.graphics, 562, 265); + imageTitle7.draw(super.graphics, 128, 171); + imageTitle8.draw(super.graphics, 562, 171); } } @@ -1352,7 +1352,7 @@ public class Game extends GameShell { public void method18() { aArea_1166.bind(); Draw3D.lineOffset = anIntArray1180; - imageChatback.method361(0, 0); + imageChatback.blit(0, 0); if (aBoolean1256) { fontBold12.drawStringCenter(aString1121, 239, 40, 0); @@ -1398,11 +1398,11 @@ public class Game extends GameShell { if ((i1 > 0) && (i1 < 110)) { int j1 = 4; if (byte0 == 1) { - aImageArray1219[0].method361(j1, i1 - 12); + aImageArray1219[0].blit(j1, i1 - 12); j1 += 14; } if (byte0 == 2) { - aImageArray1219[1].method361(j1, i1 - 12); + aImageArray1219[1].blit(j1, i1 - 12); j1 += 14; } font.drawString(s1 + ":", j1, i1, 0); @@ -1417,11 +1417,11 @@ public class Game extends GameShell { font.drawString("From", k1, i1, 0); k1 += font.stringWidthTaggable("From "); if (byte0 == 1) { - aImageArray1219[0].method361(k1, i1 - 12); + aImageArray1219[0].blit(k1, i1 - 12); k1 += 14; } if (byte0 == 2) { - aImageArray1219[1].method361(k1, i1 - 12); + aImageArray1219[1].blit(k1, i1 - 12); k1 += 14; } font.drawString(s1 + ":", k1, i1, 0); @@ -1464,8 +1464,8 @@ public class Game extends GameShell { } method30(77, anInt1211 - anInt1089 - 77, 0, 463, anInt1211); String s; - if ((aPlayer_1126 != null) && (aPlayer_1126.aString1703 != null)) { - s = aPlayer_1126.aString1703; + if ((self != null) && (self.aString1703 != null)) { + s = self.aString1703; } else { s = StringUtil.formatName(aString1173); } @@ -1603,12 +1603,12 @@ public class Game extends GameShell { public void method22() { try { - anInt985 = -1; + minimapPlane = -1; aList_1056.clear(); aList_1013.clear(); - Draw3D.disposePool(); - method23(); - scene.method274(); + Draw3D.clearTexels(); + clearCaches(); + scene.clear(); System.gc(); for (int i = 0; i < 4; i++) { collisions[i].method210(); @@ -1616,11 +1616,11 @@ public class Game extends GameShell { for (int l = 0; l < 4; l++) { for (int k1 = 0; k1 < 104; k1++) { for (int j2 = 0; j2 < 104; j2++) { - aByteArrayArrayArray1258[l][k1][j2] = 0; + planeTileFlags[l][k1][j2] = 0; } } } - SceneBuilder sceneBuilder = new SceneBuilder(aByteArrayArrayArray1258, 104, 104, anIntArrayArrayArray1214); + SceneBuilder sceneBuilder = new SceneBuilder(planeTileFlags, 104, 104, anIntArrayArrayArray1214); int k2 = sceneMapLandData.length; aBuffer_1192.putOp(0); if (!sceneInstanced) { @@ -1708,15 +1708,13 @@ public class Game extends GameShell { areaViewport.bind(); aBuffer_1192.putOp(0); int k3 = SceneBuilder.anInt145; - if (k3 > anInt918) { - k3 = anInt918; - } - if (k3 < (anInt918 - 1)) { + if (k3 > currentPlane) { + k3 = currentPlane; } if (lowmem) { - scene.method275(SceneBuilder.anInt145); + scene.setMinPlane(SceneBuilder.anInt145); } else { - scene.method275(0); + scene.setMinPlane(0); } for (int i5 = 0; i5 < 104; i5++) { for (int i7 = 0; i7 < 104; i7++) { @@ -1773,7 +1771,7 @@ public class Game extends GameShell { } } - public void method23() { + public void clearCaches() { LocType.aCache_785.clear(); LocType.aCache_780.clear(); NPCType.modelCache.clear(); @@ -1783,117 +1781,142 @@ public class Game extends GameShell { SpotAnimType.modelCache.clear(); } - public void method24(int i) { - int[] ai = imageMinimap.anIntArray1439; - int j = ai.length; - for (int k = 0; k < j; k++) { - ai[k] = 0; - } - for (int l = 1; l < 103; l++) { - int i1 = 24628 + ((103 - l) * 512 * 4); - for (int k1 = 1; k1 < 103; k1++) { - if ((aByteArrayArrayArray1258[i][k1][l] & 0x18) == 0) { - scene.method309(ai, i1, 512, i, k1, l); + public void createMinimap(int plane) { + int[] pixels = imageMinimap.pixels; + + Arrays.fill(pixels,0); + + for (int z = 1; z < 103; z++) { + int offset = 24628 + ((103 - z) * 512 * 4); + + for (int x = 1; x < 103; x++) { + if ((planeTileFlags[plane][x][z] & 0x18) == 0) { + scene.drawMinimapTile(pixels, offset, 512, plane, x, z); } - if ((i < 3) && ((aByteArrayArrayArray1258[i + 1][k1][l] & 8) != 0)) { - scene.method309(ai, i1, 512, i + 1, k1, l); + + if ((plane < 3) && ((planeTileFlags[plane + 1][x][z] & 8) != 0)) { + scene.drawMinimapTile(pixels, offset, 512, plane + 1, x, z); } - i1 += 4; + + offset += 4; } } + int j1 = (((238 + (int) (Math.random() * 20D)) - 10) << 16) + (((238 + (int) (Math.random() * 20D)) - 10) << 8) + ((238 + (int) (Math.random() * 20D)) - 10); int l1 = ((238 + (int) (Math.random() * 20D)) - 10) << 16; - imageMinimap.method343(); - for (int i2 = 1; i2 < 103; i2++) { - for (int j2 = 1; j2 < 103; j2++) { - if ((aByteArrayArrayArray1258[i][j2][i2] & 0x18) == 0) { - method50(i2, j1, j2, l1, i); + + imageMinimap.bind(); + + for (int z = 1; z < 103; z++) { + for (int x = 1; x < 103; x++) { + if ((planeTileFlags[plane][x][z] & 0x18) == 0) { + drawMinimapLoc(z, j1, x, l1, plane); } - if ((i < 3) && ((aByteArrayArrayArray1258[i + 1][j2][i2] & 8) != 0)) { - method50(i2, j1, j2, l1, i + 1); + + if ((plane < 3) && ((planeTileFlags[plane + 1][x][z] & 8) != 0)) { + drawMinimapLoc(z, j1, x, l1, plane + 1); } } } + areaViewport.bind(); - anInt1071 = 0; - for (int k2 = 0; k2 < 104; k2++) { - for (int l2 = 0; l2 < 104; l2++) { - int i3 = scene.method303(anInt918, k2, l2); - if (i3 != 0) { - i3 = (i3 >> 14) & 0x7fff; - int j3 = LocType.method572(i3).anInt746; - if (j3 >= 0) { - int k3 = k2; - int l3 = l2; - if ((j3 != 22) && (j3 != 29) && (j3 != 34) && (j3 != 36) && (j3 != 46) && (j3 != 47) && (j3 != 48)) { - byte byte0 = 104; - byte byte1 = 104; - int[][] ai1 = collisions[anInt918].anIntArrayArray294; - for (int i4 = 0; i4 < 10; i4++) { - int j4 = (int) (Math.random() * 4D); - if ((j4 == 0) && (k3 > 0) && (k3 > (k2 - 3)) && ((ai1[k3 - 1][l3] & 0x1280108) == 0)) { - k3--; - } - if ((j4 == 1) && (k3 < (byte0 - 1)) && (k3 < (k2 + 3)) && ((ai1[k3 + 1][l3] & 0x1280180) == 0)) { - k3++; - } - if ((j4 == 2) && (l3 > 0) && (l3 > (l2 - 3)) && ((ai1[k3][l3 - 1] & 0x1280102) == 0)) { - l3--; - } - if ((j4 == 3) && (l3 < (byte1 - 1)) && (l3 < (l2 + 3)) && ((ai1[k3][l3 + 1] & 0x1280120) == 0)) { - l3++; - } - } + activeMapFunctionCount = 0; + + for (int x = 0; x < 104; x++) { + for (int z = 0; z < 104; z++) { + int bitset = scene.getGroundDecorationBitset(currentPlane, x, z); + + if (bitset == 0) { + continue; + } + + bitset = (bitset >> 14) & 0x7fff; + + int j3 = LocType.method572(bitset).anInt746; + + if (j3 < 0) { + continue; + } + + int stx = x; + int stz = z; + + if ((j3 != 22) && (j3 != 29) && (j3 != 34) && (j3 != 36) && (j3 != 46) && (j3 != 47) && (j3 != 48)) { + byte byte0 = 104; + byte byte1 = 104; + int[][] flags = collisions[currentPlane].flags; + for (int i4 = 0; i4 < 10; i4++) { + int j4 = (int) (Math.random() * 4D); + if ((j4 == 0) && (stx > 0) && (stx > (x - 3)) && ((flags[stx - 1][stz] & 0x1280108) == 0)) { + stx--; + } + if ((j4 == 1) && (stx < (byte0 - 1)) && (stx < (x + 3)) && ((flags[stx + 1][stz] & 0x1280180) == 0)) { + stx++; + } + if ((j4 == 2) && (stz > 0) && (stz > (z - 3)) && ((flags[stx][stz - 1] & 0x1280102) == 0)) { + stz--; + } + if ((j4 == 3) && (stz < (byte1 - 1)) && (stz < (z + 3)) && ((flags[stx][stz + 1] & 0x1280120) == 0)) { + stz++; } - aImageArray1140[anInt1071] = imageMapfunction[j3]; - anIntArray1072[anInt1071] = k3; - anIntArray1073[anInt1071] = l3; - anInt1071++; } } + activeMapFunctions[activeMapFunctionCount] = imageMapfunction[j3]; + activeMapFunctionX[activeMapFunctionCount] = stx; + activeMapFunctionZ[activeMapFunctionCount] = stz; + activeMapFunctionCount++; } } } - public void method25(int i, int j) { - DoublyLinkedList list = aListArrayArrayArray827[anInt918][i][j]; + public void method25(int x, int z) { + DoublyLinkedList list = aListArrayArrayArray827[currentPlane][x][z]; if (list == null) { - scene.method295(anInt918, i, j); + scene.removeObjStack(currentPlane, x, z); return; } - int k = 0xfa0a1f01; - ObjStackEntity obj = null; - for (ObjStackEntity objStack = (ObjStackEntity) list.peekFront(); objStack != null; objStack = (ObjStackEntity) list.prev()) { - ObjType type = ObjType.method198(objStack.anInt1558); + + int k = -99999999; + + ObjStackEntity stack0 = null; + ObjStackEntity stack1 = null; + ObjStackEntity stack2 = null; + + for (ObjStackEntity stack = (ObjStackEntity) list.peekFront(); stack != null; stack = (ObjStackEntity) list.prev()) { + ObjType type = ObjType.method198(stack.anInt1558); + int l = type.anInt155; + if (type.aBoolean176) { - l *= objStack.anInt1559 + 1; + l *= stack.anInt1559 + 1; } + if (l > k) { k = l; - obj = objStack; + stack0 = stack; } } - list.pushFront(obj); - ObjStackEntity obj1 = null; - Entity obj2 = null; - for (ObjStackEntity objStack_1 = (ObjStackEntity) list.peekFront(); objStack_1 != null; objStack_1 = (ObjStackEntity) list.prev()) { - if ((objStack_1.anInt1558 != obj.anInt1558) && (obj1 == null)) { - obj1 = objStack_1; + + list.pushFront(stack0); + + for (ObjStackEntity stack = (ObjStackEntity) list.peekFront(); stack != null; stack = (ObjStackEntity) list.prev()) { + if ((stack.anInt1558 != stack0.anInt1558) && (stack1 == null)) { + stack1 = stack; } - if ((objStack_1.anInt1558 != obj.anInt1558) && (objStack_1.anInt1558 != obj1.anInt1558) && (obj2 == null)) { - obj2 = objStack_1; + if ((stack.anInt1558 != stack0.anInt1558) && (stack.anInt1558 != stack1.anInt1558) && (stack2 == null)) { + stack2 = stack; } } - int i1 = i + (j << 7) + 0x60000000; - scene.method281(i, i1, obj1, method42(anInt918, (j * 128) + 64, (i * 128) + 64), obj2, obj, anInt918, j); + + int bitset = x + (z << 7) + 0x60000000; + scene.addObjStack(stack0, stack1, stack2, currentPlane, x, z, getHeightmapY(currentPlane, (x * 128) + 64, (z * 128) + 64), bitset); } public void method26(boolean flag) { for (int j = 0; j < anInt836; j++) { NPCEntity npc = npcs[anIntArray837[j]]; int k = 0x20000000 + (anIntArray837[j] << 14); - if ((npc == null) || !npc.method449() || (npc.aType_1696.aBoolean93 != flag)) { + if ((npc == null) || !npc.method449() || (npc.type.aBoolean93 != flag)) { continue; } int l = npc.x >> 7; @@ -1901,16 +1924,16 @@ public class Game extends GameShell { if ((l < 0) || (l >= 104) || (i1 < 0) || (i1 >= 104)) { continue; } - if ((npc.anInt1540 == 1) && ((npc.x & 0x7f) == 64) && ((npc.z & 0x7f) == 64)) { + if ((npc.size == 1) && ((npc.x & 0x7f) == 64) && ((npc.z & 0x7f) == 64)) { if (anIntArrayArray929[l][i1] == anInt1265) { continue; } anIntArrayArray929[l][i1] = anInt1265; } - if (!npc.aType_1696.aBoolean84) { + if (!npc.type.aBoolean84) { k += 0x80000000; } - scene.method285(anInt918, npc.anInt1552, method42(anInt918, npc.z, npc.x), k, npc.z, ((npc.anInt1540 - 1) * 64) + 60, npc.x, npc, npc.aBoolean1541); + scene.addTemporary(npc, currentPlane, npc.x, npc.z, getHeightmapY(currentPlane, npc.x, npc.z), npc.yaw, k, npc.aBoolean1541, ((npc.size - 1) * 64) + 60); } } @@ -2137,8 +2160,8 @@ public class Game extends GameShell { } public void method30(int j, int k, int l, int i1, int j1) { - imageScrollbar0.method361(i1, l); - imageScrollbar1.method361(i1, (l + j) - 16); + imageScrollbar0.blit(i1, l); + imageScrollbar1.blit(i1, (l + j) - 16); Draw2D.fillRect(i1, l + 16, 16, j - 32, anInt1002); int k1 = ((j - 32) * j) / j1; if (k1 < 8) { @@ -2165,7 +2188,7 @@ public class Game extends GameShell { for (int k = 0; k < anInt839; k++) { int l = anIntArray840[k]; if (npcs[l].anInt1537 != loopCycle) { - npcs[l].aType_1696 = null; + npcs[l].type = null; npcs[l] = null; } } @@ -2324,7 +2347,7 @@ public class Game extends GameShell { for (int j = -1; j < (anInt891 + anInt836); j++) { PathingEntity obj; if (j == -1) { - obj = aPlayer_1126; + obj = self; } else if (j < anInt891) { obj = players[anIntArray892[j]]; } else { @@ -2334,9 +2357,9 @@ public class Game extends GameShell { continue; } if (obj instanceof NPCEntity) { - NPCType type = ((NPCEntity) obj).aType_1696; - if (type.anIntArray88 != null) { - type = type.method161(); + NPCType type = ((NPCEntity) obj).type; + if (type.overrides != null) { + type = type.getOverrideType(); } if (type == null) { continue; @@ -2350,7 +2373,7 @@ public class Game extends GameShell { if (anInt963 > -1) { for (int i2 = 0; i2 < 8; i2++) { if ((player.anInt1706 & (1 << i2)) != 0) { - imageHeadicons[i2].method348(anInt963 - 12, anInt964 - l); + imageHeadicons[i2].draw(anInt963 - 12, anInt964 - l); l -= 25; } } @@ -2359,21 +2382,21 @@ public class Game extends GameShell { if ((j >= 0) && (anInt855 == 10) && (anInt933 == anIntArray892[j])) { method127(obj, obj.anInt1507 + 15); if (anInt963 > -1) { - imageHeadicons[7].method348(anInt963 - 12, anInt964 - l); + imageHeadicons[7].draw(anInt963 - 12, anInt964 - l); } } } else { - NPCType type_1 = ((NPCEntity) obj).aType_1696; + NPCType type_1 = ((NPCEntity) obj).type; if ((type_1.anInt75 >= 0) && (type_1.anInt75 < imageHeadicons.length)) { method127(obj, obj.anInt1507 + 15); if (anInt963 > -1) { - imageHeadicons[type_1.anInt75].method348(anInt963 - 12, anInt964 - 30); + imageHeadicons[type_1.anInt75].draw(anInt963 - 12, anInt964 - 30); } } if ((anInt855 == 1) && (anInt1222 == anIntArray837[j - anInt891]) && ((loopCycle % 20) < 10)) { method127(obj, obj.anInt1507 + 15); if (anInt963 > -1) { - imageHeadicons[2].method348(anInt963 - 12, anInt964 - 28); + imageHeadicons[2].draw(anInt963 - 12, anInt964 - 28); } } } @@ -2426,7 +2449,7 @@ public class Game extends GameShell { anInt963 += 15; anInt964 -= 10; } - imageHitmarks[obj.anIntArray1515[j1]].method348(anInt963 - 12, anInt964 - 12); + imageHitmarks[obj.anIntArray1515[j1]].draw(anInt963 - 12, anInt964 - 12); fontPlain11.drawStringCenter(String.valueOf(obj.anIntArray1514[j1]), anInt963, anInt964 + 4, 0); fontPlain11.drawStringCenter(String.valueOf(obj.anIntArray1514[j1]), anInt963 - 1, anInt964 + 3, 0xffffff); } @@ -2563,7 +2586,7 @@ public class Game extends GameShell { public void method36() { aArea_1163.bind(); Draw3D.lineOffset = anIntArray1181; - imageInvback.method361(0, 0); + imageInvback.blit(0, 0); if (anInt1189 != -1) { method105(0, 0, Component.instances[anInt1189], 0); } else if (anIntArray1130[anInt1221] != -1) { @@ -2581,8 +2604,8 @@ public class Game extends GameShell { if (!lowmem) { if (Draw3D.textureCycle[17] >= j) { Image8 image = Draw3D.textures[17]; - int k = (image.anInt1452 * image.anInt1453) - 1; - int j1 = image.anInt1452 * anInt945 * 2; + int k = (image.width * image.height) - 1; + int j1 = image.width * anInt945 * 2; byte[] abyte0 = image.pixels; byte[] abyte3 = aByteArray912; for (int i2 = 0; i2 <= k; i2++) { @@ -2594,8 +2617,8 @@ public class Game extends GameShell { } if (Draw3D.textureCycle[24] >= j) { Image8 class30_sub2_sub1_sub2_1 = Draw3D.textures[24]; - int l = (class30_sub2_sub1_sub2_1.anInt1452 * class30_sub2_sub1_sub2_1.anInt1453) - 1; - int k1 = class30_sub2_sub1_sub2_1.anInt1452 * anInt945 * 2; + int l = (class30_sub2_sub1_sub2_1.width * class30_sub2_sub1_sub2_1.height) - 1; + int k1 = class30_sub2_sub1_sub2_1.width * anInt945 * 2; byte[] abyte1 = class30_sub2_sub1_sub2_1.pixels; byte[] abyte4 = aByteArray912; for (int j2 = 0; j2 <= l; j2++) { @@ -2607,8 +2630,8 @@ public class Game extends GameShell { } if (Draw3D.textureCycle[34] >= j) { Image8 class30_sub2_sub1_sub2_2 = Draw3D.textures[34]; - int i1 = (class30_sub2_sub1_sub2_2.anInt1452 * class30_sub2_sub1_sub2_2.anInt1453) - 1; - int l1 = class30_sub2_sub1_sub2_2.anInt1452 * anInt945 * 2; + int i1 = (class30_sub2_sub1_sub2_2.width * class30_sub2_sub1_sub2_2.height) - 1; + int l1 = class30_sub2_sub1_sub2_2.width * anInt945 * 2; byte[] abyte2 = class30_sub2_sub1_sub2_2.pixels; byte[] abyte5 = aByteArray912; for (int k2 = 0; k2 <= i1; k2++) { @@ -2652,7 +2675,7 @@ public class Game extends GameShell { public void method39() { int i = (anInt1098 * 128) + 64; int j = (anInt1099 * 128) + 64; - int k = method42(anInt918, j, i) - anInt1100; + int k = getHeightmapY(currentPlane, i, j) - anInt1100; if (anInt858 < i) { anInt858 += anInt1101 + (((i - anInt858) * anInt1102) / 1000); if (anInt858 > i) { @@ -2691,7 +2714,7 @@ public class Game extends GameShell { } i = (anInt995 * 128) + 64; j = (anInt996 * 128) + 64; - k = method42(anInt918, j, i) - anInt997; + k = getHeightmapY(currentPlane, i, j) - anInt997; int l = i - anInt858; int i1 = k - anInt859; int j1 = j - anInt860; @@ -2802,7 +2825,7 @@ public class Game extends GameShell { return; } } - if (!s.equals(aPlayer_1126.aString1703)) { + if (!s.equals(self.aString1703)) { aStringArray1082[anInt899] = s; aLongArray955[anInt899] = l; anIntArray826[anInt899] = 0; @@ -2813,21 +2836,21 @@ public class Game extends GameShell { } } - public int method42(int i, int j, int k) { - int l = k >> 7; - int i1 = j >> 7; - if ((l < 0) || (i1 < 0) || (l > 103) || (i1 > 103)) { + public int getHeightmapY(int plane, int x, int z) { + int stx = x >> 7; + int stz = z >> 7; + if ((stx < 0) || (stz < 0) || (stx > 103) || (stz > 103)) { return 0; } - int j1 = i; - if ((j1 < 3) && ((aByteArrayArrayArray1258[1][l][i1] & 2) == 2)) { - j1++; + int p = plane; + if ((p < 3) && ((planeTileFlags[1][stx][stz] & 2) == 2)) { + p++; } - int k1 = k & 0x7f; - int l1 = j & 0x7f; - int i2 = ((anIntArrayArrayArray1214[j1][l][i1] * (128 - k1)) + (anIntArrayArrayArray1214[j1][l + 1][i1] * k1)) >> 7; - int j2 = ((anIntArrayArrayArray1214[j1][l][i1 + 1] * (128 - k1)) + (anIntArrayArrayArray1214[j1][l + 1][i1 + 1] * k1)) >> 7; - return ((i2 * (128 - l1)) + (j2 * l1)) >> 7; + int ltx = x & 0x7f; + int ltz = z & 0x7f; + int y00 = ((anIntArrayArrayArray1214[p][stx][stz] * (128 - ltx)) + (anIntArrayArrayArray1214[p][stx + 1][stz] * ltx)) >> 7; + int y11 = ((anIntArrayArrayArray1214[p][stx][stz + 1] * (128 - ltx)) + (anIntArrayArrayArray1214[p][stx + 1][stz + 1] * ltx)) >> 7; + return ((y00 * (128 - ltz)) + (y11 * ltz)) >> 7; } public void method44() { @@ -2842,8 +2865,8 @@ public class Game extends GameShell { anInt833 = 0; aString1173 = ""; aString1174 = ""; - method23(); - scene.method274(); + clearCaches(); + scene.clear(); for (int i = 0; i < 4; i++) { collisions[i].method210(); } @@ -2880,73 +2903,84 @@ public class Game extends GameShell { NPCEntity npc = npcs[k]; anIntArray837[anInt836++] = k; npc.anInt1537 = loopCycle; - int l = buffer.getBits(5); - if (l > 15) { - l -= 32; + int z = buffer.getBits(5); + if (z > 15) { + z -= 32; } - int i1 = buffer.getBits(5); - if (i1 > 15) { - i1 -= 32; + int x = buffer.getBits(5); + if (x > 15) { + x -= 32; } int j1 = buffer.getBits(1); - npc.aType_1696 = NPCType.method159(buffer.getBits(12)); + npc.type = NPCType.get(buffer.getBits(12)); int k1 = buffer.getBits(1); if (k1 == 1) { anIntArray894[anInt893++] = k; } - npc.anInt1540 = npc.aType_1696.aByte68; - npc.anInt1504 = npc.aType_1696.anInt79; - npc.anInt1554 = npc.aType_1696.anInt67; - npc.anInt1555 = npc.aType_1696.anInt58; - npc.anInt1556 = npc.aType_1696.anInt83; - npc.anInt1557 = npc.aType_1696.anInt55; - npc.anInt1511 = npc.aType_1696.anInt77; - npc.method445(aPlayer_1126.moveQueueTileX[0] + i1, aPlayer_1126.moveQueueTileZ[0] + l, j1 == 1); + npc.size = npc.type.size; + npc.turnSpeed = npc.type.turnSpeed; + npc.seqWalk = npc.type.seqWalk; + npc.seqTurnAround = npc.type.seqTurnAround; + 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); } buffer.accessBytes(); } - public void method47(boolean flag) { - if (((aPlayer_1126.x >> 7) == anInt1261) && ((aPlayer_1126.z >> 7) == anInt1262)) { + public void method47(boolean local) { + if (((self.x >> 7) == anInt1261) && ((self.z >> 7) == anInt1262)) { anInt1261 = 0; } + int j = anInt891; - if (flag) { + + if (local) { j = 1; } + for (int l = 0; l < j; l++) { PlayerEntity player; - int i1; - if (flag) { - player = aPlayer_1126; - i1 = LOCAL_PLAYER_INDEX << 14; + int index; + + if (local) { + player = self; + index = LOCAL_PLAYER_INDEX << 14; } else { player = players[anIntArray892[l]]; - i1 = anIntArray892[l] << 14; + index = anIntArray892[l] << 14; } + if ((player == null) || !player.method449()) { continue; } - player.aBoolean1699 = ((lowmem && (anInt891 > 50)) || (anInt891 > 200)) && !flag && (player.anInt1517 == player.anInt1511); - int j1 = player.x >> 7; - int k1 = player.z >> 7; - if ((j1 < 0) || (j1 >= 104) || (k1 < 0) || (k1 >= 104)) { + + player.aBoolean1699 = ((lowmem && (anInt891 > 50)) || (anInt891 > 200)) && !local && (player.seqCurrent == player.seqStand); + + int stx = player.x >> 7; + int stz = player.z >> 7; + + if ((stx < 0) || (stx >= 104) || (stz < 0) || (stz >= 104)) { continue; } - if ((player.aModel_1714 != null) && (loopCycle >= player.anInt1707) && (loopCycle < player.anInt1708)) { + + if ((player.model != null) && (loopCycle >= player.anInt1707) && (loopCycle < player.anInt1708)) { player.aBoolean1699 = false; - player.anInt1709 = method42(anInt918, player.z, player.x); - scene.method286(anInt918, player.z, player, player.anInt1552, player.anInt1722, player.x, player.anInt1709, player.anInt1719, player.anInt1721, i1, player.anInt1720); + player.y = getHeightmapY(currentPlane, player.x, player.z); + scene.addTemporary(player, currentPlane, player.minSceneTileX, player.minSceneTileZ, player.maxSceneTileX, player.maxSceneTileZ, player.x, player.z, player.y, player.yaw, index); continue; } + if (((player.x & 0x7f) == 64) && ((player.z & 0x7f) == 64)) { - if (anIntArrayArray929[j1][k1] == anInt1265) { + if (anIntArrayArray929[stx][stz] == anInt1265) { continue; } - anIntArrayArray929[j1][k1] = anInt1265; + anIntArrayArray929[stx][stz] = anInt1265; } - player.anInt1709 = method42(anInt918, player.z, player.x); - scene.method285(anInt918, player.anInt1552, player.anInt1709, i1, player.z, 60, player.x, player, player.aBoolean1541); + + player.y = getHeightmapY(currentPlane, player.x, player.z); + scene.addTemporary(player, currentPlane, player.x, player.z, player.y, player.yaw, index, player.aBoolean1541, 60); } } @@ -3063,26 +3097,26 @@ public class Game extends GameShell { } } - public void method50(int i, int k, int l, int i1, int j1) { - int k1 = scene.method300(j1, l, i); + 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.method304(j1, l, i, k1); + 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; } - int[] ai = imageMinimap.anIntArray1439; + int[] ai = imageMinimap.pixels; int k4 = 24624 + (l * 4) + ((103 - i) * 512 * 4); int i5 = (k1 >> 14) & 0x7fff; LocType type_2 = LocType.method572(i5); if (type_2.anInt758 != -1) { Image8 class30_sub2_sub1_sub2_2 = imageMapscene[type_2.anInt758]; if (class30_sub2_sub1_sub2_2 != null) { - int i6 = ((type_2.anInt744 * 4) - class30_sub2_sub1_sub2_2.anInt1452) / 2; - int j6 = ((type_2.anInt761 * 4) - class30_sub2_sub1_sub2_2.anInt1453) / 2; - class30_sub2_sub1_sub2_2.method361(48 + (l * 4) + i6, 48 + ((104 - i - type_2.anInt761) * 4) + j6); + int i6 = ((type_2.anInt744 * 4) - class30_sub2_sub1_sub2_2.width) / 2; + int j6 = ((type_2.anInt761 * 4) - class30_sub2_sub1_sub2_2.height) / 2; + class30_sub2_sub1_sub2_2.blit(48 + (l * 4) + i6, 48 + ((104 - i - type_2.anInt761) * 4) + j6); } } else { if ((i3 == 0) || (i3 == 2)) { @@ -3144,9 +3178,9 @@ public class Game extends GameShell { } } } - k1 = scene.method302(j1, l, i); + k1 = scene.getLocBitset(j1, l, i); if (k1 != 0) { - int i2 = scene.method304(j1, l, i, k1); + int i2 = scene.getInfo(j1, l, i, k1); int l2 = (i2 >> 6) & 3; int j3 = i2 & 0x1f; int l3 = (k1 >> 14) & 0x7fff; @@ -3154,16 +3188,16 @@ public class Game extends GameShell { if (type_1.anInt758 != -1) { Image8 class30_sub2_sub1_sub2_1 = imageMapscene[type_1.anInt758]; if (class30_sub2_sub1_sub2_1 != null) { - int j5 = ((type_1.anInt744 * 4) - class30_sub2_sub1_sub2_1.anInt1452) / 2; - int k5 = ((type_1.anInt761 * 4) - class30_sub2_sub1_sub2_1.anInt1453) / 2; - class30_sub2_sub1_sub2_1.method361(48 + (l * 4) + j5, 48 + ((104 - i - type_1.anInt761) * 4) + k5); + int j5 = ((type_1.anInt744 * 4) - class30_sub2_sub1_sub2_1.width) / 2; + int k5 = ((type_1.anInt761 * 4) - class30_sub2_sub1_sub2_1.height) / 2; + class30_sub2_sub1_sub2_1.blit(48 + (l * 4) + j5, 48 + ((104 - i - type_1.anInt761) * 4) + k5); } } else if (j3 == 9) { int l4 = 0xeeeeee; if (k1 > 0) { l4 = 0xee0000; } - int[] ai1 = imageMinimap.anIntArray1439; + int[] ai1 = imageMinimap.pixels; int l5 = 24624 + (l * 4) + ((103 - i) * 512 * 4); if ((l2 == 0) || (l2 == 2)) { ai1[l5 + 1536] = l4; @@ -3178,102 +3212,110 @@ public class Game extends GameShell { } } } - k1 = scene.method303(j1, l, i); + k1 = scene.getGroundDecorationBitset(j1, l, i); if (k1 != 0) { int j2 = (k1 >> 14) & 0x7fff; LocType type = LocType.method572(j2); if (type.anInt758 != -1) { Image8 image = imageMapscene[type.anInt758]; if (image != null) { - int i4 = ((type.anInt744 * 4) - image.anInt1452) / 2; - int j4 = ((type.anInt761 * 4) - image.anInt1453) / 2; - image.method361(48 + (l * 4) + i4, 48 + ((104 - i - type.anInt761) * 4) + j4); + int i4 = ((type.anInt744 * 4) - image.width) / 2; + int j4 = ((type.anInt761 * 4) - image.height) / 2; + image.blit(48 + (l * 4) + i4, 48 + ((104 - i - type.anInt761) * 4) + j4); } } } } - public void method51() throws IOException { - aImage_966 = new Image8(archiveTitle, "titlebox", 0); - aImage_967 = new Image8(archiveTitle, "titlebutton", 0); - aImageArray1152 = new Image8[12]; - int j = 0; + public void createTitleImages() throws IOException { + imageTitlebox = new Image8(archiveTitle, "titlebox", 0); + imageTitlebutton = new Image8(archiveTitle, "titlebutton", 0); + imageRunes = new Image8[12]; + int icon = 0; + try { - j = Integer.parseInt(getParameter("fl_icon")); + icon = Integer.parseInt(getParameter("fl_icon")); } catch (Exception ignored) { } - if (j == 0) { - for (int k = 0; k < 12; k++) { - aImageArray1152[k] = new Image8(archiveTitle, "runes", k); + + if (icon == 0) { + for (int i = 0; i < 12; i++) { + imageRunes[i] = new Image8(archiveTitle, "runes", i); } } else { - for (int l = 0; l < 12; l++) { - aImageArray1152[l] = new Image8(archiveTitle, "runes", 12 + (l & 3)); + for (int i = 0; i < 12; i++) { + imageRunes[i] = new Image8(archiveTitle, "runes", 12 + (i & 3)); } } - aImage_1201 = new Image24(128, 265); - aImage_1202 = new Image24(128, 265); - for (int i1 = 0; i1 < 33920; i1++) { - aImage_1201.anIntArray1439[i1] = aArea_1110.pixels[i1]; + + imageFlamesLeft = new Image24(128, 265); + imageFlamesRight = new Image24(128, 265); + + System.arraycopy(imageTitle0.pixels, 0, imageFlamesLeft.pixels, 0, 33920); + System.arraycopy(imageTitle1.pixels, 0, imageFlamesRight.pixels, 0, 33920); + + flameGradient0 = new int[256]; + + for (int i = 0; i < 64; i++) { + flameGradient0[i] = i * 0x40000; } - for (int j1 = 0; j1 < 33920; j1++) { - aImage_1202.anIntArray1439[j1] = aArea_1111.pixels[j1]; + for (int i = 0; i < 64; i++) { + flameGradient0[i + 64] = 0xff0000 + (0x400 * i); } - anIntArray851 = new int[256]; - for (int k1 = 0; k1 < 64; k1++) { - anIntArray851[k1] = k1 * 0x40000; + for (int i = 0; i < 64; i++) { + flameGradient0[i + 128] = 0xffff00 + (0x4 * i); } - for (int l1 = 0; l1 < 64; l1++) { - anIntArray851[l1 + 64] = 0xff0000 + (1024 * l1); + for (int i = 0; i < 64; i++) { + flameGradient0[i + 192] = 0xffffff; } - for (int i2 = 0; i2 < 64; i2++) { - anIntArray851[i2 + 128] = 0xffff00 + (4 * i2); + + flameGradient1 = new int[256]; + + for (int i = 0; i < 64; i++) { + flameGradient1[i] = i * 1024; } - for (int j2 = 0; j2 < 64; j2++) { - anIntArray851[j2 + 192] = 0xffffff; + for (int i = 0; i < 64; i++) { + flameGradient1[i + 64] = 65280 + (4 * i); } - anIntArray852 = new int[256]; - for (int k2 = 0; k2 < 64; k2++) { - anIntArray852[k2] = k2 * 1024; + for (int i = 0; i < 64; i++) { + flameGradient1[i + 128] = 65535 + (0x40000 * i); } - for (int l2 = 0; l2 < 64; l2++) { - anIntArray852[l2 + 64] = 65280 + (4 * l2); + for (int i = 0; i < 64; i++) { + flameGradient1[i + 192] = 0xffffff; } - for (int i3 = 0; i3 < 64; i3++) { - anIntArray852[i3 + 128] = 65535 + (0x40000 * i3); - } - for (int j3 = 0; j3 < 64; j3++) { - anIntArray852[j3 + 192] = 0xffffff; - } - anIntArray853 = new int[256]; + + flameGradient2 = new int[256]; + for (int k3 = 0; k3 < 64; k3++) { - anIntArray853[k3] = k3 * 4; + flameGradient2[k3] = k3 * 4; } for (int l3 = 0; l3 < 64; l3++) { - anIntArray853[l3 + 64] = 255 + (0x40000 * l3); + flameGradient2[l3 + 64] = 255 + (0x40000 * l3); } for (int i4 = 0; i4 < 64; i4++) { - anIntArray853[i4 + 128] = 0xff00ff + (1024 * i4); + flameGradient2[i4 + 128] = 0xff00ff + (1024 * i4); } for (int j4 = 0; j4 < 64; j4++) { - anIntArray853[j4 + 192] = 0xffffff; + flameGradient2[j4 + 192] = 0xffffff; } - anIntArray850 = new int[256]; - anIntArray1190 = new int[32768]; - anIntArray1191 = new int[32768]; + + flameGradient = new int[256]; + flameBuffer0 = new int[32768]; + flameBuffer1 = new int[32768]; method106(null); - anIntArray828 = new int[32768]; - anIntArray829 = new int[32768]; + flameBuffer3 = new int[32768]; + flameBuffer2 = new int[32768]; showProgress(10, "Connecting to fileserver"); - if (!aBoolean831) { + + if (!flameActive) { aBoolean880 = true; - aBoolean831 = true; + flameActive = true; startThread(this, 2); } } public void method53() { - if (lowmem && (sceneState == 2) && (SceneBuilder.anInt131 != anInt918)) { + if (lowmem && (sceneState == 2) && (SceneBuilder.anInt131 != currentPlane)) { areaViewport.bind(); fontPlain12.drawStringCenter("Loading - please wait.", 257, 151, 0); fontPlain12.drawStringCenter("Loading - please wait.", 256, 150, 0xffffff); @@ -3284,13 +3326,13 @@ public class Game extends GameShell { if (sceneState == 1) { int j = method54(); if ((j != 0) && ((System.currentTimeMillis() - sceneLoadStartTime) > 0x57e40L)) { - Signlink.reporterror(aString1173 + " glcfb " + aLong1215 + "," + j + "," + lowmem + "," + filestores[0] + "," + ondemand.remaining() + "," + anInt918 + "," + sceneCenterZoneX + "," + sceneCenterZoneZ); + Signlink.reporterror(aString1173 + " glcfb " + aLong1215 + "," + j + "," + lowmem + "," + filestores[0] + "," + ondemand.remaining() + "," + currentPlane + "," + sceneCenterZoneX + "," + sceneCenterZoneZ); sceneLoadStartTime = System.currentTimeMillis(); } } - if ((sceneState == 2) && (anInt918 != anInt985)) { - anInt985 = anInt918; - method24(anInt918); + if ((sceneState == 2) && (currentPlane != minimapPlane)) { + minimapPlane = currentPlane; + createMinimap(currentPlane); } } @@ -3325,7 +3367,7 @@ public class Game extends GameShell { return -4; } else { sceneState = 2; - SceneBuilder.anInt131 = anInt918; + SceneBuilder.anInt131 = currentPlane; method22(); aBuffer_1192.putOp(121); return 0; @@ -3334,84 +3376,103 @@ public class Game extends GameShell { public void method55() { for (ProjectileEntity projectile = (ProjectileEntity) aList_1013.peekFront(); projectile != null; projectile = (ProjectileEntity) aList_1013.prev()) { - if ((projectile.anInt1597 != anInt918) || (loopCycle > projectile.anInt1572)) { + if ((projectile.anInt1597 != currentPlane) || (loopCycle > projectile.anInt1572)) { projectile.unlink(); } else if (loopCycle >= projectile.anInt1571) { if (projectile.anInt1590 > 0) { NPCEntity npc = npcs[projectile.anInt1590 - 1]; if ((npc != null) && (npc.x >= 0) && (npc.x < 13312) && (npc.z >= 0) && (npc.z < 13312)) { - projectile.method455(loopCycle, npc.z, method42(projectile.anInt1597, npc.z, npc.x) - projectile.anInt1583, npc.x); + projectile.method455(loopCycle, npc.z, getHeightmapY(projectile.anInt1597, npc.x, npc.z) - projectile.anInt1583, npc.x); } } if (projectile.anInt1590 < 0) { int j = -projectile.anInt1590 - 1; PlayerEntity player; - if (j == anInt884) { - player = aPlayer_1126; + if (j == selfPlayerId) { + player = self; } else { player = players[j]; } if ((player != null) && (player.x >= 0) && (player.x < 13312) && (player.z >= 0) && (player.z < 13312)) { - projectile.method455(loopCycle, player.z, method42(projectile.anInt1597, player.z, player.x) - projectile.anInt1583, player.x); + projectile.method455(loopCycle, player.z, getHeightmapY(projectile.anInt1597, player.x, player.z) - projectile.anInt1583, player.x); } } projectile.method456(anInt945); - scene.method285(anInt918, projectile.anInt1595, (int) projectile.aDouble1587, -1, (int) projectile.aDouble1586, 60, (int) projectile.aDouble1585, projectile, false); + scene.addTemporary(projectile, currentPlane, (int) projectile.aDouble1585, (int) projectile.aDouble1586, (int) projectile.aDouble1587, projectile.anInt1595, -1, false, 60); } } } - public void method56() throws IOException { - byte[] abyte0 = archiveTitle.read("title.dat"); - Image24 image = new Image24(abyte0, this); - aArea_1110.bind(); - image.method346(0, 0); - aArea_1111.bind(); - image.method346(-637, 0); - aArea_1107.bind(); - image.method346(-128, 0); - aArea_1108.bind(); - image.method346(-202, -371); - aArea_1109.bind(); - image.method346(-202, -171); - aArea_1112.bind(); - image.method346(0, -265); - aArea_1113.bind(); - image.method346(-562, -265); - aArea_1114.bind(); - image.method346(-128, -171); - aArea_1115.bind(); - image.method346(-562, -171); - int[] ai = new int[image.anInt1440]; - for (int j = 0; j < image.anInt1441; j++) { - for (int k = 0; k < image.anInt1440; k++) { - ai[k] = image.anIntArray1439[(image.anInt1440 - k - 1) + (image.anInt1440 * j)]; - } - for (int l = 0; l < image.anInt1440; l++) { - image.anIntArray1439[l + (image.anInt1440 * j)] = ai[l]; + public void createTitleBackground() throws IOException { + Image24 image = new Image24(archiveTitle.read("title.dat"), this); + + imageTitle0.bind(); + image.blitOpaque(0, 0); + + imageTitle1.bind(); + image.blitOpaque(-637, 0); + + imageTitle2.bind(); + image.blitOpaque(-128, 0); + + imageTitle3.bind(); + image.blitOpaque(-202, -371); + + imageTitle4.bind(); + image.blitOpaque(-202, -171); + + imageTitle5.bind(); + image.blitOpaque(0, -265); + + imageTitle6.bind(); + image.blitOpaque(-562, -265); + + imageTitle7.bind(); + image.blitOpaque(-128, -171); + + imageTitle8.bind(); + image.blitOpaque(-562, -171); + + // Flips the title background horizontally + int[] tmp = new int[image.width]; + for (int y = 0; y < image.height; y++) { + for (int x = 0; x < image.width; x++) { + tmp[x] = image.pixels[(image.width - x - 1) + (image.width * y)]; } + System.arraycopy(tmp, 0, image.pixels, image.width * y, image.width); } - aArea_1110.bind(); - image.method346(382, 0); - aArea_1111.bind(); - image.method346(-255, 0); - aArea_1107.bind(); - image.method346(254, 0); - aArea_1108.bind(); - image.method346(180, -371); - aArea_1109.bind(); - image.method346(180, -171); - aArea_1112.bind(); - image.method346(382, -265); - aArea_1113.bind(); - image.method346(-180, -265); - aArea_1114.bind(); - image.method346(254, -171); - aArea_1115.bind(); - image.method346(-180, -171); + + imageTitle0.bind(); + image.blitOpaque(382, 0); + + imageTitle1.bind(); + image.blitOpaque(-255, 0); + + imageTitle2.bind(); + image.blitOpaque(254, 0); + + imageTitle3.bind(); + image.blitOpaque(180, -371); + + imageTitle4.bind(); + image.blitOpaque(180, -171); + + imageTitle5.bind(); + image.blitOpaque(382, -265); + + imageTitle6.bind(); + image.blitOpaque(-180, -265); + + imageTitle7.bind(); + image.blitOpaque(254, -171); + + imageTitle8.bind(); + image.blitOpaque(-180, -171); + image = new Image24(archiveTitle, "logo", 0); - aArea_1107.bind(); - image.method348(382 - (image.anInt1440 / 2) - 128, 18); + imageTitle2.bind(); + image.draw(382 - (image.width / 2) - 128, 18); + System.gc(); } @@ -3466,59 +3527,72 @@ public class Game extends GameShell { } while (true); } - public void method58() { - char c = '\u0100'; - for (int j = 10; j < 117; j++) { - int k = (int) (Math.random() * 100D); - if (k < 50) { - anIntArray828[j + ((c - 2) << 7)] = 255; + public void updateFlames() { + int height = 256; + + // add fuel to the bottom + for (int x = 10; x < 117; x++) { + if ((int) (Math.random() * 100.0) < 50) { + flameBuffer3[x + ((height - 2) << 7)] = 255; } } + + // add sparkles of fuel everywhere for (int l = 0; l < 100; l++) { - int i1 = (int) (Math.random() * 124D) + 2; - int k1 = (int) (Math.random() * 128D) + 128; - int k2 = i1 + (k1 << 7); - anIntArray828[k2] = 192; + int x = (int) (Math.random() * 124D) + 2; + int y = (int) (Math.random() * 128D) + 128; + flameBuffer3[x + (y << 7)] = 192; } - for (int j1 = 1; j1 < (c - 1); j1++) { - for (int l1 = 1; l1 < 127; l1++) { - int l2 = l1 + (j1 << 7); - anIntArray829[l2] = (anIntArray828[l2 - 1] + anIntArray828[l2 + 1] + anIntArray828[l2 - 128] + anIntArray828[l2 + 128]) / 4; + + // blur that fuel + for (int y = 1; y < (height - 1); y++) { + for (int x = 1; x < 127; x++) { + int pos = x + (y << 7); + flameBuffer2[pos] = (flameBuffer3[pos - 1] + flameBuffer3[pos + 1] + flameBuffer3[pos - 128] + flameBuffer3[pos + 128]) / 4; } } - anInt1275 += 128; - if (anInt1275 > anIntArray1190.length) { - anInt1275 -= anIntArray1190.length; - int i2 = (int) (Math.random() * 12D); - method106(aImageArray1152[i2]); + + flameCycle0 += 128; + + if (flameCycle0 > flameBuffer0.length) { + flameCycle0 -= flameBuffer0.length; + method106(imageRunes[(int) (Math.random() * 12D)]); } - for (int j2 = 1; j2 < (c - 1); j2++) { - for (int i3 = 1; i3 < 127; i3++) { - int k3 = i3 + (j2 << 7); - int i4 = anIntArray829[k3 + 128] - (anIntArray1190[(k3 + anInt1275) & (anIntArray1190.length - 1)] / 5); - if (i4 < 0) { - i4 = 0; + + // flamebuffer0 is being used to dilute the fuel + for (int y = 1; y < (height - 1); y++) { + for (int x = 1; x < 127; x++) { + int pos = x + (y << 7); + int intensity = flameBuffer2[pos + 128] - (flameBuffer0[(pos + flameCycle0) & (flameBuffer0.length - 1)] / 5); + + if (intensity < 0) { + intensity = 0; } - anIntArray828[k3] = i4; + + flameBuffer3[pos] = intensity; } } - for (int j3 = 0; j3 < (c - 1); j3++) { - anIntArray969[j3] = anIntArray969[j3 + 1]; + + for (int y = 0; y < (height - 1); y++) { + flameLineOffset[y] = flameLineOffset[y + 1]; } - anIntArray969[c - 1] = (int) ((Math.sin((double) loopCycle / 14D) * 16D) + (Math.sin((double) loopCycle / 15D) * 14D) + (Math.sin((double) loopCycle / 16D) * 12D)); - if (anInt1040 > 0) { - anInt1040 -= 4; + + flameLineOffset[height - 1] = (int) ((Math.sin((double) loopCycle / 14D) * 16D) + (Math.sin((double) loopCycle / 15D) * 14D) + (Math.sin((double) loopCycle / 16D) * 12D)); + + if (flameGradientCycle0 > 0) { + flameGradientCycle0 -= 4; } - if (anInt1041 > 0) { - anInt1041 -= 4; + + if (flameGradientCycle1 > 0) { + flameGradientCycle1 -= 4; } - if ((anInt1040 == 0) && (anInt1041 == 0)) { - int l3 = (int) (Math.random() * 2000D); - if (l3 == 0) { - anInt1040 = 1024; - } - if (l3 == 1) { - anInt1041 = 1024; + + if ((flameGradientCycle0 == 0) && (flameGradientCycle1 == 0)) { + int rng = (int) (Math.random() * 2000D); + if (rng == 0) { + flameGradientCycle0 = 1024; + } else if (rng == 1) { + flameGradientCycle1 = 1024; } } } @@ -3552,7 +3626,7 @@ public class Game extends GameShell { } method128(((anInt934 - sceneBaseTileX) << 7) + anInt937, anInt936 * 2, ((anInt935 - sceneBaseTileZ) << 7) + anInt938); if ((anInt963 > -1) && ((loopCycle % 20) < 10)) { - imageHeadicons[2].method348(anInt963 - 12, anInt964 - 28); + imageHeadicons[2].draw(anInt963 - 12, anInt964 - 28); } } @@ -3782,7 +3856,7 @@ public class Game extends GameShell { if (Scene.anInt470 != -1) { int k = Scene.anInt470; int k1 = Scene.anInt471; - boolean flag = method85(0, 0, 0, 0, aPlayer_1126.moveQueueTileZ[0], 0, 0, k1, aPlayer_1126.moveQueueTileX[0], true, k); + boolean flag = method85(0, 0, 0, 0, self.pathTileZ[0], 0, 0, k1, self.pathTileX[0], true, k); Scene.anInt470 = -1; if (flag) { anInt914 = super.mousePressX; @@ -3849,7 +3923,7 @@ public class Game extends GameShell { } public void method64() throws IOException { - if (aArea_1107 != null) { + if (imageTitle2 != null) { return; } aArea_1166 = null; @@ -3859,27 +3933,27 @@ public class Game extends GameShell { aArea_1123 = null; aArea_1124 = null; aArea_1125 = null; - aArea_1110 = new DrawArea(128, 265, getComponent()); + imageTitle0 = new DrawArea(128, 265, getComponent()); Draw2D.clear(); - aArea_1111 = new DrawArea(128, 265, getComponent()); + imageTitle1 = new DrawArea(128, 265, getComponent()); Draw2D.clear(); - aArea_1107 = new DrawArea(509, 171, getComponent()); + imageTitle2 = new DrawArea(509, 171, getComponent()); Draw2D.clear(); - aArea_1108 = new DrawArea(360, 132, getComponent()); + imageTitle3 = new DrawArea(360, 132, getComponent()); Draw2D.clear(); - aArea_1109 = new DrawArea(360, 200, getComponent()); + imageTitle4 = new DrawArea(360, 200, getComponent()); Draw2D.clear(); - aArea_1112 = new DrawArea(202, 238, getComponent()); + imageTitle5 = new DrawArea(202, 238, getComponent()); Draw2D.clear(); - aArea_1113 = new DrawArea(203, 238, getComponent()); + imageTitle6 = new DrawArea(203, 238, getComponent()); Draw2D.clear(); - aArea_1114 = new DrawArea(74, 94, getComponent()); + imageTitle7 = new DrawArea(74, 94, getComponent()); Draw2D.clear(); - aArea_1115 = new DrawArea(75, 94, getComponent()); + imageTitle8 = new DrawArea(75, 94, getComponent()); Draw2D.clear(); if (archiveTitle != null) { - method56(); - method51(); + createTitleBackground(); + createTitleImages(); } aBoolean1255 = true; } @@ -3918,7 +3992,7 @@ public class Game extends GameShell { public boolean method66(int i, int j, int k) { int i1 = (i >> 14) & 0x7fff; - int j1 = scene.method304(anInt918, k, j, i); + int j1 = scene.getInfo(currentPlane, k, j, i); if (j1 == -1) { return false; } @@ -3939,9 +4013,9 @@ public class Game extends GameShell { if (l1 != 0) { k2 = ((k2 << l1) & 0xf) + (k2 >> (4 - l1)); } - method85(2, 0, j2, 0, aPlayer_1126.moveQueueTileZ[0], i2, k2, j, aPlayer_1126.moveQueueTileX[0], false, k); + method85(2, 0, j2, 0, self.pathTileZ[0], i2, k2, j, self.pathTileX[0], false, k); } else { - method85(2, l1, 0, k1 + 1, aPlayer_1126.moveQueueTileZ[0], 0, 0, j, aPlayer_1126.moveQueueTileX[0], false, k); + method85(2, l1, 0, k1 + 1, self.pathTileZ[0], 0, 0, j, self.pathTileX[0], false, k); } anInt914 = super.mousePressX; anInt915 = super.mousePressY; @@ -4080,7 +4154,7 @@ public class Game extends GameShell { fontPlain12.drawStringCenter("Please wait - attempting to reestablish", 257, 159, 0); fontPlain12.drawStringCenter("Please wait - attempting to reestablish", 256, 158, 0xffffff); areaViewport.draw(super.graphics, 4, 4); - anInt1021 = 0; + minimapState = 0; anInt1261 = 0; Connection connection = this.connection; ingame = false; @@ -4113,7 +4187,7 @@ public class Game extends GameShell { if (l == 582) { NPCEntity npc = npcs[i1]; if (npc != null) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, npc.moveQueueTileZ[0], aPlayer_1126.moveQueueTileX[0], false, npc.moveQueueTileX[0]); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, npc.pathTileZ[0], self.pathTileX[0], false, npc.pathTileX[0]); anInt914 = super.mousePressX; anInt915 = super.mousePressY; anInt917 = 2; @@ -4126,9 +4200,9 @@ public class Game extends GameShell { } } if (l == 234) { - boolean flag1 = method85(2, 0, 0, 0, aPlayer_1126.moveQueueTileZ[0], 0, 0, k, aPlayer_1126.moveQueueTileX[0], false, j); + boolean flag1 = method85(2, 0, 0, 0, self.pathTileZ[0], 0, 0, k, self.pathTileX[0], false, j); if (!flag1) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, k, aPlayer_1126.moveQueueTileX[0], false, j); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, k, self.pathTileX[0], false, j); } anInt914 = super.mousePressX; anInt915 = super.mousePressY; @@ -4149,9 +4223,9 @@ public class Game extends GameShell { aBuffer_1192.put2(anInt1285); } if (l == 511) { - boolean flag2 = method85(2, 0, 0, 0, aPlayer_1126.moveQueueTileZ[0], 0, 0, k, aPlayer_1126.moveQueueTileX[0], false, j); + boolean flag2 = method85(2, 0, 0, 0, self.pathTileZ[0], 0, 0, k, self.pathTileX[0], false, j); if (!flag2) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, k, aPlayer_1126.moveQueueTileX[0], false, j); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, k, self.pathTileX[0], false, j); } anInt914 = super.mousePressX; anInt915 = super.mousePressY; @@ -4195,7 +4269,7 @@ public class Game extends GameShell { if (l == 561) { PlayerEntity player = players[i1]; if (player != null) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, player.moveQueueTileZ[0], aPlayer_1126.moveQueueTileX[0], false, player.moveQueueTileX[0]); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, player.pathTileZ[0], self.pathTileX[0], false, player.pathTileX[0]); anInt914 = super.mousePressX; anInt915 = super.mousePressY; anInt917 = 2; @@ -4207,7 +4281,7 @@ public class Game extends GameShell { if (l == 20) { NPCEntity class30_sub2_sub4_sub1_sub1_1 = npcs[i1]; if (class30_sub2_sub4_sub1_sub1_1 != null) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, class30_sub2_sub4_sub1_sub1_1.moveQueueTileZ[0], aPlayer_1126.moveQueueTileX[0], false, class30_sub2_sub4_sub1_sub1_1.moveQueueTileX[0]); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, class30_sub2_sub4_sub1_sub1_1.pathTileZ[0], self.pathTileX[0], false, class30_sub2_sub4_sub1_sub1_1.pathTileX[0]); anInt914 = super.mousePressX; anInt915 = super.mousePressY; anInt917 = 2; @@ -4219,7 +4293,7 @@ public class Game extends GameShell { if (l == 779) { PlayerEntity class30_sub2_sub4_sub1_sub2_1 = players[i1]; if (class30_sub2_sub4_sub1_sub2_1 != null) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, class30_sub2_sub4_sub1_sub2_1.moveQueueTileZ[0], aPlayer_1126.moveQueueTileX[0], false, class30_sub2_sub4_sub1_sub2_1.moveQueueTileX[0]); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, class30_sub2_sub4_sub1_sub2_1.pathTileZ[0], self.pathTileX[0], false, class30_sub2_sub4_sub1_sub2_1.pathTileX[0]); anInt914 = super.mousePressX; anInt915 = super.mousePressY; anInt917 = 2; @@ -4326,7 +4400,7 @@ public class Game extends GameShell { if ((player_7 == null) || (player_7.aString1703 == null) || !player_7.aString1703.equalsIgnoreCase(s7)) { continue; } - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, player_7.moveQueueTileZ[0], aPlayer_1126.moveQueueTileX[0], false, player_7.moveQueueTileX[0]); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, player_7.pathTileZ[0], self.pathTileX[0], false, player_7.pathTileX[0]); if (l == 484) { aBuffer_1192.putOp(139); aBuffer_1192.put2LE(anIntArray892[j3]); @@ -4420,7 +4494,7 @@ public class Game extends GameShell { if (l == 27) { PlayerEntity class30_sub2_sub4_sub1_sub2_2 = players[i1]; if (class30_sub2_sub4_sub1_sub2_2 != null) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, class30_sub2_sub4_sub1_sub2_2.moveQueueTileZ[0], aPlayer_1126.moveQueueTileX[0], false, class30_sub2_sub4_sub1_sub2_2.moveQueueTileX[0]); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, class30_sub2_sub4_sub1_sub2_2.pathTileZ[0], self.pathTileX[0], false, class30_sub2_sub4_sub1_sub2_2.pathTileX[0]); anInt914 = super.mousePressX; anInt915 = super.mousePressY; anInt917 = 2; @@ -4430,9 +4504,9 @@ public class Game extends GameShell { } } if (l == 213) { - boolean flag3 = method85(2, 0, 0, 0, aPlayer_1126.moveQueueTileZ[0], 0, 0, k, aPlayer_1126.moveQueueTileX[0], false, j); + boolean flag3 = method85(2, 0, 0, 0, self.pathTileZ[0], 0, 0, k, self.pathTileX[0], false, j); if (!flag3) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, k, aPlayer_1126.moveQueueTileX[0], false, j); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, k, self.pathTileX[0], false, j); } anInt914 = super.mousePressX; anInt915 = super.mousePressY; @@ -4476,9 +4550,9 @@ public class Game extends GameShell { } } if (l == 652) { - boolean flag4 = method85(2, 0, 0, 0, aPlayer_1126.moveQueueTileZ[0], 0, 0, k, aPlayer_1126.moveQueueTileX[0], false, j); + boolean flag4 = method85(2, 0, 0, 0, self.pathTileZ[0], 0, 0, k, self.pathTileX[0], false, j); if (!flag4) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, k, aPlayer_1126.moveQueueTileX[0], false, j); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, k, self.pathTileX[0], false, j); } anInt914 = super.mousePressX; anInt915 = super.mousePressY; @@ -4490,9 +4564,9 @@ public class Game extends GameShell { aBuffer_1192.put2LEA(i1); } if (l == 94) { - boolean flag5 = method85(2, 0, 0, 0, aPlayer_1126.moveQueueTileZ[0], 0, 0, k, aPlayer_1126.moveQueueTileX[0], false, j); + boolean flag5 = method85(2, 0, 0, 0, self.pathTileZ[0], 0, 0, k, self.pathTileX[0], false, j); if (!flag5) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, k, aPlayer_1126.moveQueueTileX[0], false, j); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, k, self.pathTileX[0], false, j); } anInt914 = super.mousePressX; anInt915 = super.mousePressY; @@ -4520,7 +4594,7 @@ public class Game extends GameShell { if (l == 225) { NPCEntity class30_sub2_sub4_sub1_sub1_2 = npcs[i1]; if (class30_sub2_sub4_sub1_sub1_2 != null) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, class30_sub2_sub4_sub1_sub1_2.moveQueueTileZ[0], aPlayer_1126.moveQueueTileX[0], false, class30_sub2_sub4_sub1_sub1_2.moveQueueTileX[0]); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, class30_sub2_sub4_sub1_sub1_2.pathTileZ[0], self.pathTileX[0], false, class30_sub2_sub4_sub1_sub1_2.pathTileX[0]); anInt914 = super.mousePressX; anInt915 = super.mousePressY; anInt917 = 2; @@ -4532,7 +4606,7 @@ public class Game extends GameShell { if (l == 965) { NPCEntity npc_3 = npcs[i1]; if (npc_3 != null) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, npc_3.moveQueueTileZ[0], aPlayer_1126.moveQueueTileX[0], false, npc_3.moveQueueTileX[0]); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, npc_3.pathTileZ[0], self.pathTileX[0], false, npc_3.pathTileX[0]); anInt914 = super.mousePressX; anInt915 = super.mousePressY; anInt917 = 2; @@ -4544,7 +4618,7 @@ public class Game extends GameShell { if (l == 413) { NPCEntity class30_sub2_sub4_sub1_sub1_4 = npcs[i1]; if (class30_sub2_sub4_sub1_sub1_4 != null) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, class30_sub2_sub4_sub1_sub1_4.moveQueueTileZ[0], aPlayer_1126.moveQueueTileX[0], false, class30_sub2_sub4_sub1_sub1_4.moveQueueTileX[0]); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, class30_sub2_sub4_sub1_sub1_4.pathTileZ[0], self.pathTileX[0], false, class30_sub2_sub4_sub1_sub1_4.pathTileX[0]); anInt914 = super.mousePressX; anInt915 = super.mousePressY; anInt917 = 2; @@ -4560,9 +4634,9 @@ public class Game extends GameShell { if (l == 1025) { NPCEntity npc_5 = npcs[i1]; if (npc_5 != null) { - NPCType type = npc_5.aType_1696; - if (type.anIntArray88 != null) { - type = type.method161(); + NPCType type = npc_5.type; + if (type.overrides != null) { + type = type.getOverrideType(); } if (type != null) { String s9; @@ -4585,7 +4659,7 @@ public class Game extends GameShell { if (l == 412) { NPCEntity npc_6 = npcs[i1]; if (npc_6 != null) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, npc_6.moveQueueTileZ[0], aPlayer_1126.moveQueueTileX[0], false, npc_6.moveQueueTileX[0]); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, npc_6.pathTileZ[0], self.pathTileX[0], false, npc_6.pathTileX[0]); anInt914 = super.mousePressX; anInt915 = super.mousePressY; anInt917 = 2; @@ -4597,7 +4671,7 @@ public class Game extends GameShell { if (l == 365) { PlayerEntity player_3 = players[i1]; if (player_3 != null) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, player_3.moveQueueTileZ[0], aPlayer_1126.moveQueueTileX[0], false, player_3.moveQueueTileX[0]); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, player_3.pathTileZ[0], self.pathTileX[0], false, player_3.pathTileX[0]); anInt914 = super.mousePressX; anInt915 = super.mousePressY; anInt917 = 2; @@ -4610,7 +4684,7 @@ public class Game extends GameShell { if (l == 729) { PlayerEntity class30_sub2_sub4_sub1_sub2_4 = players[i1]; if (class30_sub2_sub4_sub1_sub2_4 != null) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, class30_sub2_sub4_sub1_sub2_4.moveQueueTileZ[0], aPlayer_1126.moveQueueTileX[0], false, class30_sub2_sub4_sub1_sub2_4.moveQueueTileX[0]); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, class30_sub2_sub4_sub1_sub2_4.pathTileZ[0], self.pathTileX[0], false, class30_sub2_sub4_sub1_sub2_4.pathTileX[0]); anInt914 = super.mousePressX; anInt915 = super.mousePressY; anInt917 = 2; @@ -4622,7 +4696,7 @@ public class Game extends GameShell { if (l == 577) { PlayerEntity player_5 = players[i1]; if (player_5 != null) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, player_5.moveQueueTileZ[0], aPlayer_1126.moveQueueTileX[0], false, player_5.moveQueueTileX[0]); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, player_5.pathTileZ[0], self.pathTileX[0], false, player_5.pathTileX[0]); anInt914 = super.mousePressX; anInt915 = super.mousePressY; anInt917 = 2; @@ -4639,9 +4713,9 @@ public class Game extends GameShell { aBuffer_1192.put2LE((i1 >> 14) & 0x7fff); } if (l == 567) { - boolean flag6 = method85(2, 0, 0, 0, aPlayer_1126.moveQueueTileZ[0], 0, 0, k, aPlayer_1126.moveQueueTileX[0], false, j); + boolean flag6 = method85(2, 0, 0, 0, self.pathTileZ[0], 0, 0, k, self.pathTileX[0], false, j); if (!flag6) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, k, aPlayer_1126.moveQueueTileX[0], false, j); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, k, self.pathTileX[0], false, j); } anInt914 = super.mousePressX; anInt915 = super.mousePressY; @@ -4708,7 +4782,7 @@ public class Game extends GameShell { if (l == 491) { PlayerEntity player_6 = players[i1]; if (player_6 != null) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, player_6.moveQueueTileZ[0], aPlayer_1126.moveQueueTileX[0], false, player_6.moveQueueTileX[0]); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, player_6.pathTileZ[0], self.pathTileX[0], false, player_6.pathTileX[0]); anInt914 = super.mousePressX; anInt915 = super.mousePressY; anInt917 = 2; @@ -4763,7 +4837,7 @@ public class Game extends GameShell { if (l == 478) { NPCEntity npc_7 = npcs[i1]; if (npc_7 != null) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, npc_7.moveQueueTileZ[0], aPlayer_1126.moveQueueTileX[0], false, npc_7.moveQueueTileX[0]); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, npc_7.pathTileZ[0], self.pathTileX[0], false, npc_7.pathTileX[0]); anInt914 = super.mousePressX; anInt915 = super.mousePressY; anInt917 = 2; @@ -4839,9 +4913,9 @@ public class Game extends GameShell { method77(0, "", s10); } if (l == 244) { - boolean flag7 = method85(2, 0, 0, 0, aPlayer_1126.moveQueueTileZ[0], 0, 0, k, aPlayer_1126.moveQueueTileX[0], false, j); + boolean flag7 = method85(2, 0, 0, 0, self.pathTileZ[0], 0, 0, k, self.pathTileX[0], false, j); if (!flag7) { - method85(2, 0, 1, 0, aPlayer_1126.moveQueueTileZ[0], 1, 0, k, aPlayer_1126.moveQueueTileX[0], false, j); + method85(2, 0, 1, 0, self.pathTileZ[0], 1, 0, k, self.pathTileX[0], false, j); } anInt914 = super.mousePressX; anInt915 = super.mousePressY; @@ -4869,8 +4943,8 @@ public class Game extends GameShell { public void method70() { anInt1251 = 0; - int j = (aPlayer_1126.x >> 7) + sceneBaseTileX; - int k = (aPlayer_1126.z >> 7) + sceneBaseTileZ; + int j = (self.x >> 7) + sceneBaseTileX; + int k = (self.z >> 7) + sceneBaseTileZ; if ((j >= 3053) && (j <= 3156) && (k >= 3056) && (k <= 3136)) { anInt1251 = 1; } @@ -4901,7 +4975,7 @@ public class Game extends GameShell { continue; } j = l; - if ((k1 == 2) && (scene.method304(anInt918, i1, j1, l) >= 0)) { + if ((k1 == 2) && (scene.getInfo(currentPlane, i1, j1, l) >= 0)) { LocType type = LocType.method572(l1); if (type.anIntArray759 != null) { type = type.method580(); @@ -4962,11 +5036,11 @@ public class Game extends GameShell { } if (k1 == 1) { NPCEntity npc = npcs[l1]; - if ((npc.aType_1696.aByte68 == 1) && ((npc.x & 0x7f) == 64) && ((npc.z & 0x7f) == 64)) { + if ((npc.type.size == 1) && ((npc.x & 0x7f) == 64) && ((npc.z & 0x7f) == 64)) { for (int j2 = 0; j2 < anInt836; j2++) { NPCEntity class30_sub2_sub4_sub1_sub1_1 = npcs[anIntArray837[j2]]; - if ((class30_sub2_sub4_sub1_sub1_1 != null) && (class30_sub2_sub4_sub1_sub1_1 != npc) && (class30_sub2_sub4_sub1_sub1_1.aType_1696.aByte68 == 1) && (class30_sub2_sub4_sub1_sub1_1.x == npc.x) && (class30_sub2_sub4_sub1_sub1_1.z == npc.z)) { - method87(class30_sub2_sub4_sub1_sub1_1.aType_1696, anIntArray837[j2], j1, i1); + if ((class30_sub2_sub4_sub1_sub1_1 != null) && (class30_sub2_sub4_sub1_sub1_1 != npc) && (class30_sub2_sub4_sub1_sub1_1.type.size == 1) && (class30_sub2_sub4_sub1_sub1_1.x == npc.x) && (class30_sub2_sub4_sub1_sub1_1.z == npc.z)) { + method87(class30_sub2_sub4_sub1_sub1_1.type, anIntArray837[j2], j1, i1); } } for (int l2 = 0; l2 < anInt891; l2++) { @@ -4976,15 +5050,15 @@ public class Game extends GameShell { } } } - method87(npc.aType_1696, l1, j1, i1); + method87(npc.type, l1, j1, i1); } if (k1 == 0) { PlayerEntity player = players[l1]; if (((player.x & 0x7f) == 64) && ((player.z & 0x7f) == 64)) { for (int k2 = 0; k2 < anInt836; k2++) { NPCEntity class30_sub2_sub4_sub1_sub1_2 = npcs[anIntArray837[k2]]; - if ((class30_sub2_sub4_sub1_sub1_2 != null) && (class30_sub2_sub4_sub1_sub1_2.aType_1696.aByte68 == 1) && (class30_sub2_sub4_sub1_sub1_2.x == player.x) && (class30_sub2_sub4_sub1_sub1_2.z == player.z)) { - method87(class30_sub2_sub4_sub1_sub1_2.aType_1696, anIntArray837[k2], j1, i1); + if ((class30_sub2_sub4_sub1_sub1_2 != null) && (class30_sub2_sub4_sub1_sub1_2.type.size == 1) && (class30_sub2_sub4_sub1_sub1_2.x == player.x) && (class30_sub2_sub4_sub1_sub1_2.z == player.z)) { + method87(class30_sub2_sub4_sub1_sub1_2.type, anIntArray837[k2], j1, i1); } } for (int i3 = 0; i3 < anInt891; i3++) { @@ -4997,7 +5071,7 @@ public class Game extends GameShell { method88(i1, l1, player, j1); } if (k1 == 3) { - DoublyLinkedList list = aListArrayArrayArray827[anInt918][i1][j1]; + DoublyLinkedList list = aListArrayArrayArray827[currentPlane][i1][j1]; if (list != null) { for (ObjStackEntity objStack = (ObjStackEntity) list.peekBack(); objStack != null; objStack = (ObjStackEntity) list.next()) { ObjType type = ObjType.method198(objStack.anInt1558); @@ -5217,7 +5291,7 @@ public class Game extends GameShell { for (int k1 = 0; k1 < 4; k1++) { for (int i2 = 1; i2 < 103; i2++) { for (int k2 = 1; k2 < 103; k2++) { - collisions[k1].anIntArrayArray294[i2][k2] = 0; + collisions[k1].flags[i2][k2] = 0; } } } @@ -5296,16 +5370,16 @@ public class Game extends GameShell { aBuffer_1192.putSize1(aBuffer_1192.position - j3); aString887 = ChatCompression.method527(aString887); aString887 = Censor.method497(aString887, 0); - aPlayer_1126.aString1506 = aString887; - aPlayer_1126.anInt1513 = j2; - aPlayer_1126.anInt1531 = i3; - aPlayer_1126.anInt1535 = 150; + self.aString1506 = aString887; + self.anInt1513 = j2; + self.anInt1531 = i3; + self.anInt1535 = 150; if (rights == 2) { - method77(2, "@cr2@" + aPlayer_1126.aString1703, aPlayer_1126.aString1506); + method77(2, "@cr2@" + self.aString1703, self.aString1506); } else if (rights == 1) { - method77(2, "@cr1@" + aPlayer_1126.aString1703, aPlayer_1126.aString1506); + method77(2, "@cr1@" + self.aString1703, self.aString1506); } else { - method77(2, aPlayer_1126.aString1703, aPlayer_1126.aString1506); + method77(2, self.aString1703, self.aString1506); } if (anInt1287 == 2) { anInt1287 = 3; @@ -5345,7 +5419,7 @@ public class Game extends GameShell { l++; } if (((j1 == 1) || (j1 == 2)) && ((j1 == 1) || (anInt1287 == 0) || ((anInt1287 == 1) && method109(s)))) { - if ((j > (k1 - 14)) && (j <= k1) && !s.equals(aPlayer_1126.aString1703)) { + if ((j > (k1 - 14)) && (j <= k1) && !s.equals(self.aString1703)) { if (rights >= 1) { aStringArray1199[anInt1133] = "Report abuse @whi@" + s; anIntArray1093[anInt1133] = 606; @@ -5530,7 +5604,7 @@ public class Game extends GameShell { } } model.createLabelReferences(); - model.applySequenceFrame(SeqType.instances[aPlayer_1126.anInt1511].anIntArray353[0]); + model.applySequenceFrame(SeqType.instances[self.seqStand].primaryFrames[0]); model.calculateNormals(64, 850, -30, -50, -30, true); component.anInt233 = 5; component.anInt234 = 0; @@ -5693,11 +5767,11 @@ public class Game extends GameShell { font.drawString("From", k1, l - 1, 65535); k1 += font.stringWidthTaggable("From "); if (byte1 == 1) { - aImageArray1219[0].method361(k1, l - 12); + aImageArray1219[0].blit(k1, l - 12); k1 += 14; } if (byte1 == 2) { - aImageArray1219[1].method361(k1, l - 12); + aImageArray1219[1].blit(k1, l - 12); k1 += 14; } font.drawString(s + ": " + aStringArray944[j], k1, l, 0); @@ -5824,19 +5898,19 @@ public class Game extends GameShell { return; } method118(); - aArea_1107 = null; - aArea_1108 = null; - aArea_1109 = null; - aArea_1110 = null; - aArea_1111 = null; - aArea_1112 = null; - aArea_1113 = null; - aArea_1114 = null; - aArea_1115 = null; + imageTitle2 = null; + imageTitle3 = null; + imageTitle4 = null; + imageTitle0 = null; + imageTitle1 = null; + imageTitle5 = null; + imageTitle6 = null; + imageTitle7 = null; + imageTitle8 = null; aArea_1166 = new DrawArea(479, 96, getComponent()); aArea_1164 = new DrawArea(172, 156, getComponent()); Draw2D.clear(); - imageMapback.method361(0, 0); + imageMapback.blit(0, 0); aArea_1163 = new DrawArea(190, 261, getComponent()); areaViewport = new DrawArea(512, 334, getComponent()); Draw2D.clear(); @@ -5863,14 +5937,14 @@ public class Game extends GameShell { int i1 = (anInt1185 + anInt1209) & 0x7ff; int j1 = Model.sin[i1]; int k1 = Model.cos[i1]; - j1 = (j1 * 256) / (anInt1170 + 256); - k1 = (k1 * 256) / (anInt1170 + 256); + j1 = (j1 * 256) / (minimapZoom + 256); + k1 = (k1 * 256) / (minimapZoom + 256); int l1 = ((j * j1) + (k * k1)) >> 16; int i2 = ((j * k1) - (k * j1)) >> 16; double d = Math.atan2(l1, i2); int j2 = (int) (Math.sin(d) * 63D); int k2 = (int) (Math.cos(d) * 57D); - imageMapedge.method353(83 - k2 - 20, 15, 20, 15, 256, 20, d, (94 + j2 + 4) - 10); + imageMapedge.drawRotated((94 + j2 + 4) - 10, 83 - k2 - 20, 20, 20, 15, 15, d, 256); } else { method141(image, k, j); } @@ -5945,9 +6019,9 @@ public class Game extends GameShell { } } - public int method83(int i, int j, int k) { - int l = 256 - k; - return (((((i & 0xff00ff) * l) + ((j & 0xff00ff) * k)) & 0xff00ff00) + ((((i & 0xff00) * l) + ((j & 0xff00) * k)) & 0xff0000)) >> 8; + public int mix(int src, int dst, int alpha) { + int invAlpha = 256 - alpha; + return (((((src & 0xff00ff) * invAlpha) + ((dst & 0xff00ff) * alpha)) & 0xff00ff00) + ((((src & 0xff00) * invAlpha) + ((dst & 0xff00) * alpha)) & 0xff0000)) >> 8; } public void method84(String s, String s1, boolean flag) { @@ -6055,10 +6129,10 @@ public class Game extends GameShell { anInt1131 = (int) (Math.random() * 110D) - 55; anInt896 = (int) (Math.random() * 80D) - 40; anInt1209 = (int) (Math.random() * 120D) - 60; - anInt1170 = (int) (Math.random() * 30D) - 20; + minimapZoom = (int) (Math.random() * 30D) - 20; anInt1185 = ((int) (Math.random() * 20D) - 10) & 0x7ff; - anInt1021 = 0; - anInt985 = -1; + minimapState = 0; + minimapPlane = -1; anInt1261 = 0; anInt1262 = 0; anInt891 = 0; @@ -6070,7 +6144,7 @@ public class Game extends GameShell { for (int k2 = 0; k2 < 16384; k2++) { npcs[k2] = null; } - aPlayer_1126 = players[LOCAL_PLAYER_INDEX] = new PlayerEntity(); + self = players[LOCAL_PLAYER_INDEX] = new PlayerEntity(); aList_1013.clear(); aList_1056.clear(); for (int l2 = 0; l2 < 4; l2++) { @@ -6260,7 +6334,7 @@ public class Game extends GameShell { anIntArray1281[l3++] = j1; boolean flag1 = false; int j4 = anIntArray1280.length; - int[][] ai = collisions[anInt918].anIntArrayArray294; + int[][] ai = collisions[currentPlane].flags; while (i4 != l3) { j3 = anIntArray1280[i4]; k3 = anIntArray1281[i4]; @@ -6270,16 +6344,16 @@ public class Game extends GameShell { break; } if (i1 != 0) { - if (((i1 < 5) || (i1 == 10)) && collisions[anInt918].method219(k2, j3, k3, j, i1 - 1, i2)) { + if (((i1 < 5) || (i1 == 10)) && collisions[currentPlane].method219(k2, j3, k3, j, i1 - 1, i2)) { flag1 = true; break; } - if ((i1 < 10) && collisions[anInt918].method220(k2, i2, k3, i1 - 1, j, j3)) { + if ((i1 < 10) && collisions[currentPlane].method220(k2, i2, k3, i1 - 1, j, j3)) { flag1 = true; break; } } - if ((k1 != 0) && (k != 0) && collisions[anInt918].method221(i2, k2, j3, k, l1, k1, k3)) { + if ((k1 != 0) && (k != 0) && collisions[currentPlane].method221(i2, k2, j3, k, l1, k1, k3)) { flag1 = true; break; } @@ -6451,7 +6525,7 @@ public class Game extends GameShell { npc.anInt1528 = 0; npc.anInt1529 = i2; npc.anInt1530 = 0; - npc.anInt1542 = npc.anInt1525; + npc.anInt1542 = npc.pathRemaining; } } if ((l & 8) != 0) { @@ -6463,23 +6537,23 @@ public class Game extends GameShell { npc.anInt1534 = buffer.get1U(); } if ((l & 0x80) != 0) { - npc.anInt1520 = buffer.get2U(); + npc.spotanim = buffer.get2U(); int k1 = buffer.get4(); npc.anInt1524 = k1 >> 16; npc.anInt1523 = loopCycle + (k1 & 0xffff); - npc.anInt1521 = 0; - npc.anInt1522 = 0; + npc.spotanimFrame = 0; + npc.spotanimCycle = 0; if (npc.anInt1523 > loopCycle) { - npc.anInt1521 = -1; + npc.spotanimFrame = -1; } - if (npc.anInt1520 == 65535) { - npc.anInt1520 = -1; + if (npc.spotanim == 65535) { + npc.spotanim = -1; } } if ((l & 0x20) != 0) { - npc.anInt1502 = buffer.get2U(); - if (npc.anInt1502 == 65535) { - npc.anInt1502 = -1; + npc.index = buffer.get2U(); + if (npc.index == 65535) { + npc.index = -1; } } if ((l & 1) != 0) { @@ -6495,18 +6569,18 @@ public class Game extends GameShell { npc.anInt1534 = buffer.get1UC(); } if ((l & 2) != 0) { - npc.aType_1696 = NPCType.method159(buffer.get2ULEA()); - npc.anInt1540 = npc.aType_1696.aByte68; - npc.anInt1504 = npc.aType_1696.anInt79; - npc.anInt1554 = npc.aType_1696.anInt67; - npc.anInt1555 = npc.aType_1696.anInt58; - npc.anInt1556 = npc.aType_1696.anInt83; - npc.anInt1557 = npc.aType_1696.anInt55; - npc.anInt1511 = npc.aType_1696.anInt77; + npc.type = NPCType.get(buffer.get2ULEA()); + npc.size = npc.type.size; + npc.turnSpeed = npc.type.turnSpeed; + npc.seqWalk = npc.type.seqWalk; + npc.seqTurnAround = npc.type.seqTurnAround; + npc.seqTurnLeft = npc.type.seqTurnLeft; + npc.seqTurnRight = npc.type.seqTurnRight; + npc.seqStand = npc.type.seqStand; } if ((l & 4) != 0) { - npc.anInt1538 = buffer.get2ULE(); - npc.anInt1539 = buffer.get2ULE(); + npc.faceTileX = buffer.get2ULE(); + npc.faceTileZ = buffer.get2ULE(); } } } @@ -6515,8 +6589,8 @@ public class Game extends GameShell { if (anInt1133 >= 400) { return; } - if (type.anIntArray88 != null) { - type = type.method161(); + if (type.overrides != null) { + type = type.getOverrideType(); } if (type == null) { return; @@ -6526,7 +6600,7 @@ public class Game extends GameShell { } String s = type.aString65; if (type.anInt61 != 0) { - s = s + method110(aPlayer_1126.anInt1705, type.anInt61) + " (level-" + type.anInt61 + ")"; + s = s + method110(self.anInt1705, type.anInt61) + " (level-" + type.anInt61 + ")"; } if (anInt1282 == 1) { aStringArray1199[anInt1133] = "Use " + aString1286 + " with @yel@" + s; @@ -6577,7 +6651,7 @@ public class Game extends GameShell { for (int i1 = 4; i1 >= 0; i1--) { if ((type.aStringArray66[i1] != null) && type.aStringArray66[i1].equalsIgnoreCase("attack")) { char c = '\0'; - if (type.anInt61 > aPlayer_1126.anInt1705) { + if (type.anInt61 > self.anInt1705) { c = '\u07D0'; } aStringArray1199[anInt1133] = type.aStringArray66[i1] + " @yel@" + s; @@ -6613,7 +6687,7 @@ public class Game extends GameShell { } public void method88(int i, int j, PlayerEntity player, int k) { - if (player == aPlayer_1126) { + if (player == self) { return; } if (anInt1133 >= 400) { @@ -6621,7 +6695,7 @@ public class Game extends GameShell { } String s; if (player.anInt1723 == 0) { - s = player.aString1703 + method110(aPlayer_1126.anInt1705, player.anInt1705) + " (level-" + player.anInt1705 + ")"; + s = player.aString1703 + method110(self.anInt1705, player.anInt1705) + " (level-" + player.anInt1705 + ")"; } else { s = player.aString1703 + " (skill-" + player.anInt1723 + ")"; } @@ -6647,11 +6721,11 @@ public class Game extends GameShell { aStringArray1199[anInt1133] = aStringArray1127[l] + " @whi@" + s; char c = '\0'; if (aStringArray1127[l].equalsIgnoreCase("attack")) { - if (player.anInt1705 > aPlayer_1126.anInt1705) { + if (player.anInt1705 > self.anInt1705) { c = '\u07D0'; } - if ((aPlayer_1126.anInt1701 != 0) && (player.anInt1701 != 0)) { - if (aPlayer_1126.anInt1701 == player.anInt1701) { + if ((self.anInt1701 != 0) && (player.anInt1701 != 0)) { + if (self.anInt1701 == player.anInt1701) { c = '\u07D0'; } else { c = '\0'; @@ -6696,19 +6770,19 @@ public class Game extends GameShell { int k = 0; int l = 0; if (loc.anInt1296 == 0) { - i = scene.method300(loc.anInt1295, loc.sceneTileX, loc.sceneTileZ); + i = scene.getWallBitset(loc.anInt1295, loc.sceneTileX, loc.sceneTileZ); } if (loc.anInt1296 == 1) { - i = scene.method301(loc.anInt1295, loc.sceneTileX, loc.sceneTileZ); + i = scene.getWallDecorationBitset(loc.anInt1295, loc.sceneTileX, loc.sceneTileZ); } if (loc.anInt1296 == 2) { - i = scene.method302(loc.anInt1295, loc.sceneTileX, loc.sceneTileZ); + i = scene.getLocBitset(loc.anInt1295, loc.sceneTileX, loc.sceneTileZ); } if (loc.anInt1296 == 3) { - i = scene.method303(loc.anInt1295, loc.sceneTileX, loc.sceneTileZ); + i = scene.getGroundDecorationBitset(loc.anInt1295, loc.sceneTileX, loc.sceneTileZ); } if (i != 0) { - int i1 = scene.method304(loc.anInt1295, loc.sceneTileX, loc.sceneTileZ, i); + int i1 = scene.getInfo(loc.anInt1295, loc.sceneTileX, loc.sceneTileZ, i); j = (i >> 14) & 0x7fff; k = i1 & 0x1f; l = i1 >> 6; @@ -6798,13 +6872,13 @@ public class Game extends GameShell { if (j1 > 15) { j1 -= 32; } - player.method445(aPlayer_1126.moveQueueTileX[0] + j1, aPlayer_1126.moveQueueTileZ[0] + i1, l == 1); + player.move(self.pathTileX[0] + j1, self.pathTileZ[0] + i1, l == 1); } buffer.accessBytes(); } public void method92() { - if (anInt1021 != 0) { + if (minimapState != 0) { return; } if (super.mousePressButton == 1) { @@ -6816,23 +6890,23 @@ public class Game extends GameShell { int k = (anInt1185 + anInt1209) & 0x7ff; int i1 = Draw3D.sin[k]; int j1 = Draw3D.cos[k]; - i1 = (i1 * (anInt1170 + 256)) >> 8; - j1 = (j1 * (anInt1170 + 256)) >> 8; + i1 = (i1 * (minimapZoom + 256)) >> 8; + j1 = (j1 * (minimapZoom + 256)) >> 8; int k1 = ((j * i1) + (i * j1)) >> 11; int l1 = ((j * j1) - (i * i1)) >> 11; - int i2 = (aPlayer_1126.x + k1) >> 7; - int j2 = (aPlayer_1126.z - l1) >> 7; - boolean flag1 = method85(1, 0, 0, 0, aPlayer_1126.moveQueueTileZ[0], 0, 0, j2, aPlayer_1126.moveQueueTileX[0], true, i2); + int i2 = (self.x + k1) >> 7; + int j2 = (self.z - l1) >> 7; + boolean flag1 = method85(1, 0, 0, 0, self.pathTileZ[0], 0, 0, j2, self.pathTileX[0], true, i2); if (flag1) { aBuffer_1192.put1(i); aBuffer_1192.put1(j); aBuffer_1192.put2(anInt1185); aBuffer_1192.put1(57); aBuffer_1192.put1(anInt1209); - aBuffer_1192.put1(anInt1170); + aBuffer_1192.put1(minimapZoom); aBuffer_1192.put1(89); - aBuffer_1192.put2(aPlayer_1126.x); - aBuffer_1192.put2(aPlayer_1126.z); + aBuffer_1192.put2(self.x); + aBuffer_1192.put2(self.z); aBuffer_1192.put1(anInt1264); aBuffer_1192.put1(63); } @@ -6854,7 +6928,7 @@ public class Game extends GameShell { g.fillRect(0, 0, 765, 503); setFrameRate(1); if (aBoolean926) { - aBoolean831 = false; + flameActive = false; g.setFont(new java.awt.Font("Helvetica", java.awt.Font.BOLD, 16)); g.setColor(Color.yellow); int k = 35; @@ -6876,7 +6950,7 @@ public class Game extends GameShell { g.drawString("5: Try selecting a different version of Java from the play-game menu", 30, k); } if (errInvalidHost) { - aBoolean831 = false; + flameActive = false; g.setFont(new java.awt.Font("Helvetica", java.awt.Font.BOLD, 20)); g.setColor(Color.white); g.drawString("Error - unable to load game!", 50, 50); @@ -6884,7 +6958,7 @@ public class Game extends GameShell { g.drawString("http://www.runescape.com", 50, 150); } if (errAlreadyStarted) { - aBoolean831 = false; + flameActive = false; g.setColor(Color.yellow); int l = 35; g.drawString("Error a copy of RuneScape already appears to be loaded", 30, l); @@ -6913,25 +6987,25 @@ public class Game extends GameShell { public void method96(PathingEntity entity) { if ((entity.x < 128) || (entity.z < 128) || (entity.x >= 13184) || (entity.z >= 13184)) { entity.anInt1526 = -1; - entity.anInt1520 = -1; - entity.anInt1547 = 0; - entity.anInt1548 = 0; - entity.x = (entity.moveQueueTileX[0] * 128) + (entity.anInt1540 * 64); - entity.z = (entity.moveQueueTileZ[0] * 128) + (entity.anInt1540 * 64); + entity.spotanim = -1; + entity.forceMoveEndCycle = 0; + entity.forceMoveStartCycle = 0; + entity.x = (entity.pathTileX[0] * 128) + (entity.size * 64); + entity.z = (entity.pathTileZ[0] * 128) + (entity.size * 64); entity.method446(); } - if ((entity == aPlayer_1126) && ((entity.x < 1536) || (entity.z < 1536) || (entity.x >= 11776) || (entity.z >= 11776))) { + if ((entity == self) && ((entity.x < 1536) || (entity.z < 1536) || (entity.x >= 11776) || (entity.z >= 11776))) { entity.anInt1526 = -1; - entity.anInt1520 = -1; - entity.anInt1547 = 0; - entity.anInt1548 = 0; - entity.x = (entity.moveQueueTileX[0] * 128) + (entity.anInt1540 * 64); - entity.z = (entity.moveQueueTileZ[0] * 128) + (entity.anInt1540 * 64); + entity.spotanim = -1; + entity.forceMoveEndCycle = 0; + entity.forceMoveStartCycle = 0; + entity.x = (entity.pathTileX[0] * 128) + (entity.size * 64); + entity.z = (entity.pathTileZ[0] * 128) + (entity.size * 64); entity.method446(); } - if (entity.anInt1547 > loopCycle) { + if (entity.forceMoveEndCycle > loopCycle) { method97(entity); - } else if (entity.anInt1548 >= loopCycle) { + } else if (entity.forceMoveStartCycle >= loopCycle) { method98(entity); } else { method99(entity); @@ -6941,275 +7015,335 @@ public class Game extends GameShell { } public void method97(PathingEntity entity) { - int i = entity.anInt1547 - loopCycle; - int j = (entity.anInt1543 * 128) + (entity.anInt1540 * 64); - int k = (entity.anInt1545 * 128) + (entity.anInt1540 * 64); - entity.x += (j - entity.x) / i; - entity.z += (k - entity.z) / i; + int delta = entity.forceMoveEndCycle - loopCycle; + int dstX = (entity.forceMoveStartSceneTileX * 128) + (entity.size * 64); + int dstZ = (entity.forceMoveStartSceneTileZ * 128) + (entity.size * 64); + + entity.x += (dstX - entity.x) / delta; + entity.z += (dstZ - entity.z) / delta; + entity.anInt1503 = 0; - if (entity.anInt1549 == 0) { - entity.anInt1510 = 1024; + + if (entity.forceMoveFaceDirection == 0) { + entity.dstYaw = 1024; } - if (entity.anInt1549 == 1) { - entity.anInt1510 = 1536; + if (entity.forceMoveFaceDirection == 1) { + entity.dstYaw = 1536; } - if (entity.anInt1549 == 2) { - entity.anInt1510 = 0; + if (entity.forceMoveFaceDirection == 2) { + entity.dstYaw = 0; } - if (entity.anInt1549 == 3) { - entity.anInt1510 = 512; + if (entity.forceMoveFaceDirection == 3) { + entity.dstYaw = 512; } } public void method98(PathingEntity entity) { - if ((entity.anInt1548 == loopCycle) || (entity.anInt1526 == -1) || (entity.anInt1529 != 0) || ((entity.anInt1528 + 1) > SeqType.instances[entity.anInt1526].method258(entity.anInt1527))) { - int i = entity.anInt1548 - entity.anInt1547; - int j = loopCycle - entity.anInt1547; - int k = (entity.anInt1543 * 128) + (entity.anInt1540 * 64); - int l = (entity.anInt1545 * 128) + (entity.anInt1540 * 64); - int i1 = (entity.anInt1544 * 128) + (entity.anInt1540 * 64); - int j1 = (entity.anInt1546 * 128) + (entity.anInt1540 * 64); - entity.x = ((k * (i - j)) + (i1 * j)) / i; - entity.z = ((l * (i - j)) + (j1 * j)) / i; + if ((entity.forceMoveStartCycle == loopCycle) || (entity.anInt1526 == -1) || (entity.anInt1529 != 0) || ((entity.anInt1528 + 1) > SeqType.instances[entity.anInt1526].getFrameDelay(entity.anInt1527))) { + int duration = entity.forceMoveStartCycle - entity.forceMoveEndCycle; + int delta = loopCycle - entity.forceMoveEndCycle; + int dx0 = (entity.forceMoveStartSceneTileX * 128) + (entity.size * 64); + int dz0 = (entity.forceMoveStartSceneTileZ * 128) + (entity.size * 64); + int dx1 = (entity.forceMoveEndSceneTileX * 128) + (entity.size * 64); + int dz1 = (entity.forceMoveEndSceneTileZ * 128) + (entity.size * 64); + entity.x = ((dx0 * (duration - delta)) + (dx1 * delta)) / duration; + entity.z = ((dz0 * (duration - delta)) + (dz1 * delta)) / duration; } + entity.anInt1503 = 0; - if (entity.anInt1549 == 0) { - entity.anInt1510 = 1024; + + if (entity.forceMoveFaceDirection == 0) { + entity.dstYaw = 1024; } - if (entity.anInt1549 == 1) { - entity.anInt1510 = 1536; + if (entity.forceMoveFaceDirection == 1) { + entity.dstYaw = 1536; } - if (entity.anInt1549 == 2) { - entity.anInt1510 = 0; + if (entity.forceMoveFaceDirection == 2) { + entity.dstYaw = 0; } - if (entity.anInt1549 == 3) { - entity.anInt1510 = 512; + if (entity.forceMoveFaceDirection == 3) { + entity.dstYaw = 512; } - entity.anInt1552 = entity.anInt1510; + entity.yaw = entity.dstYaw; } public void method99(PathingEntity entity) { - entity.anInt1517 = entity.anInt1511; - if (entity.anInt1525 == 0) { + entity.seqCurrent = entity.seqStand; + + if (entity.pathRemaining == 0) { entity.anInt1503 = 0; return; } + if ((entity.anInt1526 != -1) && (entity.anInt1529 == 0)) { SeqType type = SeqType.instances[entity.anInt1526]; + if ((entity.anInt1542 > 0) && (type.anInt363 == 0)) { entity.anInt1503++; return; } + if ((entity.anInt1542 <= 0) && (type.anInt364 == 0)) { entity.anInt1503++; return; } } - int i = entity.x; - int j = entity.z; - int k = (entity.moveQueueTileX[entity.anInt1525 - 1] * 128) + (entity.anInt1540 * 64); - int l = (entity.moveQueueTileZ[entity.anInt1525 - 1] * 128) + (entity.anInt1540 * 64); - if (((k - i) > 256) || ((k - i) < -256) || ((l - j) > 256) || ((l - j) < -256)) { - entity.x = k; - entity.z = l; + + int x = entity.x; + int z = entity.z; + int dstX = (entity.pathTileX[entity.pathRemaining - 1] * 128) + (entity.size * 64); + int dstZ = (entity.pathTileZ[entity.pathRemaining - 1] * 128) + (entity.size * 64); + + if (((dstX - x) > 256) || ((dstX - x) < -256) || ((dstZ - z) > 256) || ((dstZ - z) < -256)) { + entity.x = dstX; + entity.z = dstZ; return; } - if (i < k) { - if (j < l) { - entity.anInt1510 = 1280; - } else if (j > l) { - entity.anInt1510 = 1792; + + if (x < dstX) { + if (z < dstZ) { + entity.dstYaw = 1280; + } else if (z > dstZ) { + entity.dstYaw = 1792; } else { - entity.anInt1510 = 1536; + entity.dstYaw = 1536; } - } else if (i > k) { - if (j < l) { - entity.anInt1510 = 768; - } else if (j > l) { - entity.anInt1510 = 256; + } else if (x > dstX) { + if (z < dstZ) { + entity.dstYaw = 768; + } else if (z > dstZ) { + entity.dstYaw = 256; } else { - entity.anInt1510 = 512; + entity.dstYaw = 512; } - } else if (j < l) { - entity.anInt1510 = 1024; + } else if (z < dstZ) { + entity.dstYaw = 1024; } else { - entity.anInt1510 = 0; + entity.dstYaw = 0; } - int i1 = (entity.anInt1510 - entity.anInt1552) & 0x7ff; - if (i1 > 1024) { - i1 -= 2048; + + int remainingYaw = (entity.dstYaw - entity.yaw) & 0x7ff; + + if (remainingYaw > 1024) { + remainingYaw -= 2048; } - int j1 = entity.anInt1555; - if ((i1 >= -256) && (i1 <= 256)) { - j1 = entity.anInt1554; - } else if ((i1 >= 256) && (i1 < 768)) { - j1 = entity.anInt1557; - } else if ((i1 >= -768) && (i1 <= -256)) { - j1 = entity.anInt1556; + + int seq = entity.seqTurnAround; + + // yaw >= -45 deg && yaw <= 45 deg + if ((remainingYaw >= -256) && (remainingYaw <= 256)) { + seq = entity.seqWalk; } - if (j1 == -1) { - j1 = entity.anInt1554; + // yaw >= 45 deg && yaw <= 135 deg + else if ((remainingYaw >= 256) && (remainingYaw < 768)) { + seq = entity.seqTurnRight; } - entity.anInt1517 = j1; - int k1 = 4; - if ((entity.anInt1552 != entity.anInt1510) && (entity.anInt1502 == -1) && (entity.anInt1504 != 0)) { - k1 = 2; + // yaw >= -135 deg && yaw <= -45 deg + else if ((remainingYaw >= -768) && (remainingYaw <= -256)) { + seq = entity.seqTurnLeft; } - if (entity.anInt1525 > 2) { - k1 = 6; + + if (seq == -1) { + seq = entity.seqWalk; } - if (entity.anInt1525 > 3) { - k1 = 8; + + entity.seqCurrent = seq; + + int moveSpeed = 4; + + if ((entity.yaw != entity.dstYaw) && (entity.index == -1) && (entity.turnSpeed != 0)) { + moveSpeed = 2; } - if ((entity.anInt1503 > 0) && (entity.anInt1525 > 1)) { - k1 = 8; + + if (entity.pathRemaining > 2) { + moveSpeed = 6; + } + + if (entity.pathRemaining > 3) { + moveSpeed = 8; + } + + if ((entity.anInt1503 > 0) && (entity.pathRemaining > 1)) { + moveSpeed = 8; entity.anInt1503--; } - if (entity.aBooleanArray1553[entity.anInt1525 - 1]) { - k1 <<= 1; + + if (entity.pathRunning[entity.pathRemaining - 1]) { + moveSpeed <<= 1; } - if ((k1 >= 8) && (entity.anInt1517 == entity.anInt1554) && (entity.anInt1505 != -1)) { - entity.anInt1517 = entity.anInt1505; + + if ((moveSpeed >= 8) && (entity.seqCurrent == entity.seqWalk) && (entity.seqRun != -1)) { + entity.seqCurrent = entity.seqRun; } - if (i < k) { - entity.x += k1; - if (entity.x > k) { - entity.x = k; + + if (x < dstX) { + entity.x += moveSpeed; + if (entity.x > dstX) { + entity.x = dstX; } - } else if (i > k) { - entity.x -= k1; - if (entity.x < k) { - entity.x = k; + } else if (x > dstX) { + entity.x -= moveSpeed; + if (entity.x < dstX) { + entity.x = dstX; } } - if (j < l) { - entity.z += k1; - if (entity.z > l) { - entity.z = l; + if (z < dstZ) { + entity.z += moveSpeed; + if (entity.z > dstZ) { + entity.z = dstZ; } - } else if (j > l) { - entity.z -= k1; - if (entity.z < l) { - entity.z = l; + } else if (z > dstZ) { + entity.z -= moveSpeed; + if (entity.z < dstZ) { + entity.z = dstZ; } } - if ((entity.x == k) && (entity.z == l)) { - entity.anInt1525--; + if ((entity.x == dstX) && (entity.z == dstZ)) { + entity.pathRemaining--; if (entity.anInt1542 > 0) { entity.anInt1542--; } } } - public void method100(PathingEntity entity) { - if (entity.anInt1504 == 0) { + public void method100(PathingEntity e) { + if (e.turnSpeed == 0) { return; } - if ((entity.anInt1502 != -1) && (entity.anInt1502 < 32768)) { - NPCEntity npc = npcs[entity.anInt1502]; + + if ((e.index != -1) && (e.index < 32768)) { + NPCEntity npc = npcs[e.index]; + if (npc != null) { - int i1 = entity.x - npc.x; - int k1 = entity.z - npc.z; - if ((i1 != 0) || (k1 != 0)) { - entity.anInt1510 = (int) (Math.atan2(i1, k1) * 325.94900000000001D) & 0x7ff; + int dstX = e.x - npc.x; + int dstZ = e.z - npc.z; + + if ((dstX != 0) || (dstZ != 0)) { + e.dstYaw = (int) (Math.atan2(dstX, dstZ) * 325.94900000000001D) & 0x7ff; } } } - if (entity.anInt1502 >= 32768) { - int j = entity.anInt1502 - 32768; - if (j == anInt884) { - j = LOCAL_PLAYER_INDEX; + if (e.index >= 32768) { + int index = e.index - 32768; + + if (index == selfPlayerId) { + index = LOCAL_PLAYER_INDEX; } - PlayerEntity player = players[j]; + + PlayerEntity player = players[index]; + if (player != null) { - int l1 = entity.x - player.x; - int i2 = entity.z - player.z; - if ((l1 != 0) || (i2 != 0)) { - entity.anInt1510 = (int) (Math.atan2(l1, i2) * 325.94900000000001D) & 0x7ff; + int dstX = e.x - player.x; + int dstZ = e.z - player.z; + + if ((dstX != 0) || (dstZ != 0)) { + e.dstYaw = (int) (Math.atan2(dstX, dstZ) * 325.94900000000001D) & 0x7ff; } } } - if (((entity.anInt1538 != 0) || (entity.anInt1539 != 0)) && ((entity.anInt1525 == 0) || (entity.anInt1503 > 0))) { - int k = entity.x - ((entity.anInt1538 - sceneBaseTileX - sceneBaseTileX) * 64); - int j1 = entity.z - ((entity.anInt1539 - sceneBaseTileZ - sceneBaseTileZ) * 64); - if ((k != 0) || (j1 != 0)) { - entity.anInt1510 = (int) (Math.atan2(k, j1) * 325.94900000000001D) & 0x7ff; + + if (((e.faceTileX != 0) || (e.faceTileZ != 0)) && ((e.pathRemaining == 0) || (e.anInt1503 > 0))) { + int dstX = e.x - ((e.faceTileX - sceneBaseTileX - sceneBaseTileX) * 64); + int dstZ = e.z - ((e.faceTileZ - sceneBaseTileZ - sceneBaseTileZ) * 64); + + if ((dstX != 0) || (dstZ != 0)) { + e.dstYaw = (int) (Math.atan2(dstX, dstZ) * 325.94900000000001D) & 0x7ff; } - entity.anInt1538 = 0; - entity.anInt1539 = 0; + + e.faceTileX = 0; + e.faceTileZ = 0; } - int l = (entity.anInt1510 - entity.anInt1552) & 0x7ff; - if (l != 0) { - if ((l < entity.anInt1504) || (l > (2048 - entity.anInt1504))) { - entity.anInt1552 = entity.anInt1510; - } else if (l > 1024) { - entity.anInt1552 -= entity.anInt1504; + + int remainingYaw = (e.dstYaw - e.yaw) & 0x7ff; + + if (remainingYaw != 0) { + if ((remainingYaw < e.turnSpeed) || (remainingYaw > (2048 - e.turnSpeed))) { + e.yaw = e.dstYaw; + } else if (remainingYaw > 1024) { + e.yaw -= e.turnSpeed; } else { - entity.anInt1552 += entity.anInt1504; + e.yaw += e.turnSpeed; } - entity.anInt1552 &= 0x7ff; - if ((entity.anInt1517 == entity.anInt1511) && (entity.anInt1552 != entity.anInt1510)) { - if (entity.anInt1512 != -1) { - entity.anInt1517 = entity.anInt1512; + + e.yaw &= 0x7ff; + + if ((e.seqCurrent == e.seqStand) && (e.yaw != e.dstYaw)) { + if (e.seqTurn != -1) { + e.seqCurrent = e.seqTurn; return; } - entity.anInt1517 = entity.anInt1554; + + e.seqCurrent = e.seqWalk; } } } - public void method101(PathingEntity entity) { - entity.aBoolean1541 = false; - if (entity.anInt1517 != -1) { - SeqType type = SeqType.instances[entity.anInt1517]; - entity.anInt1519++; - if ((entity.anInt1518 < type.anInt352) && (entity.anInt1519 > type.method258(entity.anInt1518))) { - entity.anInt1519 = 0; - entity.anInt1518++; + public void method101(PathingEntity e) { + e.aBoolean1541 = false; + + if (e.seqCurrent != -1) { + SeqType seq = SeqType.instances[e.seqCurrent]; + e.seqCycle++; + + if ((e.seqFrame < seq.frameCount) && (e.seqCycle > seq.getFrameDelay(e.seqFrame))) { + e.seqCycle = 0; + e.seqFrame++; } - if (entity.anInt1518 >= type.anInt352) { - entity.anInt1519 = 0; - entity.anInt1518 = 0; + + if (e.seqFrame >= seq.frameCount) { + e.seqCycle = 0; + e.seqFrame = 0; } } - if ((entity.anInt1520 != -1) && (loopCycle >= entity.anInt1523)) { - if (entity.anInt1521 < 0) { - entity.anInt1521 = 0; + + if ((e.spotanim != -1) && (loopCycle >= e.anInt1523)) { + if (e.spotanimFrame < 0) { + e.spotanimFrame = 0; } - SeqType type_1 = SpotAnimType.instances[entity.anInt1520].aType_407; - for (entity.anInt1522++; (entity.anInt1521 < type_1.anInt352) && (entity.anInt1522 > type_1.method258(entity.anInt1521)); entity.anInt1521++) { - entity.anInt1522 -= type_1.method258(entity.anInt1521); + + SeqType seq = SpotAnimType.instances[e.spotanim].seq; + + for (e.spotanimCycle++; (e.spotanimFrame < seq.frameCount) && (e.spotanimCycle > seq.getFrameDelay(e.spotanimFrame)); e.spotanimFrame++) { + e.spotanimCycle -= seq.getFrameDelay(e.spotanimFrame); } - if ((entity.anInt1521 >= type_1.anInt352) && ((entity.anInt1521 < 0) || (entity.anInt1521 >= type_1.anInt352))) { - entity.anInt1520 = -1; + + if ((e.spotanimFrame >= seq.frameCount) && ((e.spotanimFrame < 0) || (e.spotanimFrame >= seq.frameCount))) { + e.spotanim = -1; } } - if ((entity.anInt1526 != -1) && (entity.anInt1529 <= 1)) { - SeqType type_2 = SeqType.instances[entity.anInt1526]; - if ((type_2.anInt363 == 1) && (entity.anInt1542 > 0) && (entity.anInt1547 <= loopCycle) && (entity.anInt1548 < loopCycle)) { - entity.anInt1529 = 1; + + if ((e.anInt1526 != -1) && (e.anInt1529 <= 1)) { + SeqType seq = SeqType.instances[e.anInt1526]; + + if ((seq.anInt363 == 1) && (e.anInt1542 > 0) && (e.forceMoveEndCycle <= loopCycle) && (e.forceMoveStartCycle < loopCycle)) { + e.anInt1529 = 1; return; } } - if ((entity.anInt1526 != -1) && (entity.anInt1529 == 0)) { - SeqType type_3 = SeqType.instances[entity.anInt1526]; - for (entity.anInt1528++; (entity.anInt1527 < type_3.anInt352) && (entity.anInt1528 > type_3.method258(entity.anInt1527)); entity.anInt1527++) { - entity.anInt1528 -= type_3.method258(entity.anInt1527); + + if ((e.anInt1526 != -1) && (e.anInt1529 == 0)) { + SeqType seq = SeqType.instances[e.anInt1526]; + + for (e.anInt1528++; (e.anInt1527 < seq.frameCount) && (e.anInt1528 > seq.getFrameDelay(e.anInt1527)); e.anInt1527++) { + e.anInt1528 -= seq.getFrameDelay(e.anInt1527); } - if (entity.anInt1527 >= type_3.anInt352) { - entity.anInt1527 -= type_3.anInt356; - entity.anInt1530++; - if (entity.anInt1530 >= type_3.anInt362) { - entity.anInt1526 = -1; + + if (e.anInt1527 >= seq.frameCount) { + e.anInt1527 -= seq.anInt356; + e.anInt1530++; + + if (e.anInt1530 >= seq.anInt362) { + e.anInt1526 = -1; } - if ((entity.anInt1527 < 0) || (entity.anInt1527 >= type_3.anInt352)) { - entity.anInt1526 = -1; + if ((e.anInt1527 < 0) || (e.anInt1527 >= seq.frameCount)) { + e.anInt1526 = -1; } } - entity.aBoolean1541 = type_3.aBoolean358; + e.aBoolean1541 = seq.aBoolean358; } - if (entity.anInt1529 > 0) { - entity.anInt1529--; + + if (e.anInt1529 > 0) { + e.anInt1529--; } } @@ -7310,97 +7444,97 @@ public class Game extends GameShell { } aBoolean1103 = false; aArea_1125.bind(); - imageBackhmid1.method361(0, 0); + imageBackhmid1.blit(0, 0); if (anInt1189 == -1) { if (anIntArray1130[anInt1221] != -1) { if (anInt1221 == 0) { - imageRedstone1.method361(22, 10); + imageRedstone1.blit(22, 10); } if (anInt1221 == 1) { - imageRedstone2.method361(54, 8); + imageRedstone2.blit(54, 8); } if (anInt1221 == 2) { - imageRedstone2.method361(82, 8); + imageRedstone2.blit(82, 8); } if (anInt1221 == 3) { - imageRedstone3.method361(110, 8); + imageRedstone3.blit(110, 8); } if (anInt1221 == 4) { - aImage_1147.method361(153, 8); + aImage_1147.blit(153, 8); } if (anInt1221 == 5) { - aImage_1147.method361(181, 8); + aImage_1147.blit(181, 8); } if (anInt1221 == 6) { - aImage_1146.method361(209, 9); + aImage_1146.blit(209, 9); } } if ((anIntArray1130[0] != -1) && ((anInt1054 != 0) || ((loopCycle % 20) < 10))) { - imageSideicons[0].method361(29, 13); + imageSideicons[0].blit(29, 13); } if ((anIntArray1130[1] != -1) && ((anInt1054 != 1) || ((loopCycle % 20) < 10))) { - imageSideicons[1].method361(53, 11); + imageSideicons[1].blit(53, 11); } if ((anIntArray1130[2] != -1) && ((anInt1054 != 2) || ((loopCycle % 20) < 10))) { - imageSideicons[2].method361(82, 11); + imageSideicons[2].blit(82, 11); } if ((anIntArray1130[3] != -1) && ((anInt1054 != 3) || ((loopCycle % 20) < 10))) { - imageSideicons[3].method361(115, 12); + imageSideicons[3].blit(115, 12); } if ((anIntArray1130[4] != -1) && ((anInt1054 != 4) || ((loopCycle % 20) < 10))) { - imageSideicons[4].method361(153, 13); + imageSideicons[4].blit(153, 13); } if ((anIntArray1130[5] != -1) && ((anInt1054 != 5) || ((loopCycle % 20) < 10))) { - imageSideicons[5].method361(180, 11); + imageSideicons[5].blit(180, 11); } if ((anIntArray1130[6] != -1) && ((anInt1054 != 6) || ((loopCycle % 20) < 10))) { - imageSideicons[6].method361(208, 13); + imageSideicons[6].blit(208, 13); } } aArea_1125.draw(super.graphics, 516, 160); aArea_1124.bind(); - imageBackbase2.method361(0, 0); + imageBackbase2.blit(0, 0); if (anInt1189 == -1) { if (anIntArray1130[anInt1221] != -1) { if (anInt1221 == 7) { - aImage_865.method361(42, 0); + aImage_865.blit(42, 0); } if (anInt1221 == 8) { - aImage_866.method361(74, 0); + aImage_866.blit(74, 0); } if (anInt1221 == 9) { - aImage_866.method361(102, 0); + aImage_866.blit(102, 0); } if (anInt1221 == 10) { - aImage_867.method361(130, 1); + aImage_867.blit(130, 1); } if (anInt1221 == 11) { - aImage_869.method361(173, 0); + aImage_869.blit(173, 0); } if (anInt1221 == 12) { - aImage_869.method361(201, 0); + aImage_869.blit(201, 0); } if (anInt1221 == 13) { - aImage_868.method361(229, 0); + aImage_868.blit(229, 0); } } if ((anIntArray1130[8] != -1) && ((anInt1054 != 8) || ((loopCycle % 20) < 10))) { - imageSideicons[7].method361(74, 2); + imageSideicons[7].blit(74, 2); } if ((anIntArray1130[9] != -1) && ((anInt1054 != 9) || ((loopCycle % 20) < 10))) { - imageSideicons[8].method361(102, 3); + imageSideicons[8].blit(102, 3); } if ((anIntArray1130[10] != -1) && ((anInt1054 != 10) || ((loopCycle % 20) < 10))) { - imageSideicons[9].method361(137, 4); + imageSideicons[9].blit(137, 4); } if ((anIntArray1130[11] != -1) && ((anInt1054 != 11) || ((loopCycle % 20) < 10))) { - imageSideicons[10].method361(174, 2); + imageSideicons[10].blit(174, 2); } if ((anIntArray1130[12] != -1) && ((anInt1054 != 12) || ((loopCycle % 20) < 10))) { - imageSideicons[11].method361(201, 2); + imageSideicons[11].blit(201, 2); } if ((anIntArray1130[13] != -1) && ((anInt1054 != 13) || ((loopCycle % 20) < 10))) { - imageSideicons[12].method361(226, 2); + imageSideicons[12].blit(226, 2); } } aArea_1124.draw(super.graphics, 496, 466); @@ -7409,7 +7543,7 @@ public class Game extends GameShell { if (aBoolean1233) { aBoolean1233 = false; aArea_1123.bind(); - imageBackbase1.method361(0, 0); + imageBackbase1.blit(0, 0); fontPlain12.drawStringTaggableCenter("Public chat", 55, 28, 0xffffff, true); if (anInt1287 == 0) { fontPlain12.drawStringTaggableCenter("On", 55, 41, 65280, true); @@ -7483,14 +7617,14 @@ public class Game extends GameShell { public void method104() { SpotAnimEntity spotAnim = (SpotAnimEntity) aList_1056.peekFront(); for (; spotAnim != null; spotAnim = (SpotAnimEntity) aList_1056.prev()) { - if ((spotAnim.anInt1560 != anInt918) || spotAnim.aBoolean1567) { + if ((spotAnim.anInt1560 != currentPlane) || spotAnim.aBoolean1567) { spotAnim.unlink(); } else if (loopCycle >= spotAnim.anInt1564) { spotAnim.method454(anInt945); if (spotAnim.aBoolean1567) { spotAnim.unlink(); } else { - scene.method285(spotAnim.anInt1560, 0, spotAnim.anInt1563, -1, spotAnim.anInt1562, 60, spotAnim.anInt1561, spotAnim, false); + scene.addTemporary(spotAnim, spotAnim.anInt1560, spotAnim.anInt1561, spotAnim.anInt1562, spotAnim.anInt1563, 0, -1, false, 60); } } } @@ -7564,7 +7698,7 @@ public class Game extends GameShell { k6 = 0; j7 = 0; } - class30_sub2_sub1_sub1_2.method350(k5 + k6, j6 + j7, 128); + class30_sub2_sub1_sub1_2.draw(k5 + k6, j6 + j7, 128); if (((j6 + j7) < Draw2D.top) && (component.anInt224 > 0)) { int i10 = (anInt945 * (Draw2D.top - j6 - j7)) / 3; if (i10 > (anInt945 * 10)) { @@ -7588,11 +7722,11 @@ public class Game extends GameShell { anInt1088 -= j10; } } else if ((anInt1246 != 0) && (anInt1245 == i3) && (anInt1244 == component_1.anInt250)) { - class30_sub2_sub1_sub1_2.method350(k5, j6, 128); + class30_sub2_sub1_sub1_2.draw(k5, j6, 128); } else { - class30_sub2_sub1_sub1_2.method348(k5, j6); + class30_sub2_sub1_sub1_2.draw(k5, j6); } - if ((class30_sub2_sub1_sub1_2.anInt1444 == 33) || (component_1.anIntArray252[i3] != 1)) { + if ((class30_sub2_sub1_sub1_2.cropW == 33) || (component_1.anIntArray252[i3] != 1)) { int k10 = component_1.anIntArray252[i3]; fontPlain11.drawString(method43(k10), k5 + 1 + k6, j6 + 10 + j7, 0); fontPlain11.drawString(method43(k10), k5 + k6, j6 + 9 + j7, 0xffff00); @@ -7602,7 +7736,7 @@ public class Game extends GameShell { } else if ((component_1.aImageArray209 != null) && (i3 < 20)) { Image24 class30_sub2_sub1_sub1_1 = component_1.aImageArray209[i3]; if (class30_sub2_sub1_sub1_1 != null) { - class30_sub2_sub1_sub1_1.method348(k5, j6); + class30_sub2_sub1_sub1_1.draw(k5, j6); } } i3++; @@ -7731,7 +7865,7 @@ public class Game extends GameShell { image = component_1.aImage_207; } if (image != null) { - image.method348(k2, l2); + image.draw(k2, l2); } } else if (component_1.anInt262 == 6) { int k3 = Draw3D.centerX; @@ -7752,7 +7886,7 @@ public class Game extends GameShell { model = component_1.method209(-1, -1, flag2); } else { SeqType type = SeqType.instances[i7]; - model = component_1.method209(type.anIntArray354[component_1.anInt246], type.anIntArray353[component_1.anInt246], flag2); + model = component_1.method209(type.secondaryFrames[component_1.anInt246], type.primaryFrames[component_1.anInt246], flag2); } if (model != null) { model.drawSimple(0, component_1.anInt271, 0, component_1.anInt270, 0, i5, l5); @@ -7788,32 +7922,33 @@ public class Game extends GameShell { } public void method106(Image8 image) { - int j = 256; - Arrays.fill(anIntArray1190, 0); + Arrays.fill(flameBuffer0, 0); + for (int l = 0; l < 5000; l++) { - int i1 = (int) (Math.random() * 128D * (double) j); - anIntArray1190[i1] = (int) (Math.random() * 256D); + flameBuffer0[(int) (Math.random() * 128.0 * 256.0)] = (int) (Math.random() * 256D); } - for (int j1 = 0; j1 < 20; j1++) { - for (int k1 = 1; k1 < (j - 1); k1++) { - for (int i2 = 1; i2 < 127; i2++) { - int k2 = i2 + (k1 << 7); - anIntArray1191[k2] = (anIntArray1190[k2 - 1] + anIntArray1190[k2 + 1] + anIntArray1190[k2 - 128] + anIntArray1190[k2 + 128]) / 4; + + for (int i = 0; i < 20; i++) { + for (int y = 1; y < 255; y++) { + for (int x = 1; x < 127; x++) { + int pos = x + (y << 7); + flameBuffer1[pos] = (flameBuffer0[pos - 1] + flameBuffer0[pos + 1] + flameBuffer0[pos - 128] + flameBuffer0[pos + 128]) / 4; } } - int[] ai = anIntArray1190; - anIntArray1190 = anIntArray1191; - anIntArray1191 = ai; + + int[] tmp = flameBuffer0; + flameBuffer0 = flameBuffer1; + flameBuffer1 = tmp; } + if (image != null) { - int l1 = 0; - for (int j2 = 0; j2 < image.anInt1453; j2++) { - for (int l2 = 0; l2 < image.anInt1452; l2++) { - if (image.pixels[l1++] != 0) { - int i3 = l2 + 16 + image.anInt1454; - int j3 = j2 + 16 + image.anInt1455; - int k3 = i3 + (j3 << 7); - anIntArray1190[k3] = 0; + int offset = 0; + for (int y = 0; y < image.height; y++) { + for (int x = 0; x < image.width; x++) { + if (image.pixels[offset++] != 0) { + int dstX = x + 16 + image.anInt1454; + int dstY = y + 16 + image.anInt1455; + flameBuffer0[dstX + (dstY << 7)] = 0; } } } @@ -7822,27 +7957,27 @@ public class Game extends GameShell { public void method107(int i, int j, Buffer buffer, PlayerEntity player) { if ((i & 0x400) != 0) { - player.anInt1543 = buffer.get1US(); - player.anInt1545 = buffer.get1US(); - player.anInt1544 = buffer.get1US(); - player.anInt1546 = buffer.get1US(); - player.anInt1547 = buffer.get2ULEA() + loopCycle; - player.anInt1548 = buffer.get2UA() + loopCycle; - player.anInt1549 = buffer.get1US(); + player.forceMoveStartSceneTileX = buffer.get1US(); + player.forceMoveStartSceneTileZ = buffer.get1US(); + player.forceMoveEndSceneTileX = buffer.get1US(); + player.forceMoveEndSceneTileZ = buffer.get1US(); + player.forceMoveEndCycle = buffer.get2ULEA() + loopCycle; + player.forceMoveStartCycle = buffer.get2UA() + loopCycle; + player.forceMoveFaceDirection = buffer.get1US(); player.method446(); } if ((i & 0x100) != 0) { - player.anInt1520 = buffer.get2ULE(); + player.spotanim = buffer.get2ULE(); int k = buffer.get4(); player.anInt1524 = k >> 16; player.anInt1523 = loopCycle + (k & 0xffff); - player.anInt1521 = 0; - player.anInt1522 = 0; + player.spotanimFrame = 0; + player.spotanimCycle = 0; if (player.anInt1523 > loopCycle) { - player.anInt1521 = -1; + player.spotanimFrame = -1; } - if (player.anInt1520 == 65535) { - player.anInt1520 = -1; + if (player.spotanim == 65535) { + player.spotanim = -1; } } if ((i & 8) != 0) { @@ -7868,7 +8003,7 @@ public class Game extends GameShell { player.anInt1528 = 0; player.anInt1529 = i2; player.anInt1530 = 0; - player.anInt1542 = player.anInt1525; + player.anInt1542 = player.pathRemaining; } } if ((i & 4) != 0) { @@ -7876,7 +8011,7 @@ public class Game extends GameShell { if (player.aString1506.charAt(0) == '~') { player.aString1506 = player.aString1506.substring(1); method77(2, player.aString1703, player.aString1506); - } else if (player == aPlayer_1126) { + } else if (player == self) { method77(2, player.aString1703, player.aString1506); } player.anInt1513 = 0; @@ -7926,9 +8061,9 @@ public class Game extends GameShell { buffer.position = k3 + j3; } if ((i & 1) != 0) { - player.anInt1502 = buffer.get2ULE(); - if (player.anInt1502 == 65535) { - player.anInt1502 = -1; + player.index = buffer.get2ULE(); + if (player.index == 65535) { + player.index = -1; } } if ((i & 0x10) != 0) { @@ -7940,8 +8075,8 @@ public class Game extends GameShell { player.method451(buffer_1); } if ((i & 2) != 0) { - player.anInt1538 = buffer.get2ULEA(); - player.anInt1539 = buffer.get2ULE(); + player.faceTileX = buffer.get2ULEA(); + player.faceTileZ = buffer.get2ULE(); } if ((i & 0x20) != 0) { int k1 = buffer.get1U(); @@ -7962,8 +8097,8 @@ public class Game extends GameShell { } public void method108() { - int j = aPlayer_1126.x + anInt1278; - int k = aPlayer_1126.z + anInt1131; + int j = self.x + anInt1278; + int k = self.z + anInt1131; if (((anInt1014 - j) < -500) || ((anInt1014 - j) > 500) || ((anInt1015 - k) < -500) || ((anInt1015 - k) > 500)) { anInt1014 = j; anInt1015 = k; @@ -7998,13 +8133,13 @@ public class Game extends GameShell { } int l = anInt1014 >> 7; int i1 = anInt1015 >> 7; - int j1 = method42(anInt918, anInt1015, anInt1014); + int j1 = getHeightmapY(currentPlane, anInt1014, anInt1015); int k1 = 0; if ((l > 3) && (i1 > 3) && (l < 100) && (i1 < 100)) { for (int l1 = l - 4; l1 <= (l + 4); l1++) { for (int k2 = i1 - 4; k2 <= (i1 + 4); k2++) { - int l2 = anInt918; - if ((l2 < 3) && ((aByteArrayArrayArray1258[1][l1][k2] & 2) == 2)) { + int l2 = currentPlane; + if ((l2 < 3) && ((planeTileFlags[1][l1][k2] & 2) == 2)) { l2++; } int i3 = j1 - anIntArrayArrayArray1214[l2][l1][k2]; @@ -8039,7 +8174,7 @@ public class Game extends GameShell { return true; } } - return s.equalsIgnoreCase(aPlayer_1126.aString1703); + return s.equalsIgnoreCase(self.aString1703); } public void method111(int i) { @@ -8049,10 +8184,10 @@ public class Game extends GameShell { public void method112() { method76(); if (anInt917 == 1) { - imageCrosses[anInt916 / 100].method348(anInt914 - 8 - 4, anInt915 - 8 - 4); + imageCrosses[anInt916 / 100].draw(anInt914 - 8 - 4, anInt915 - 8 - 4); } if (anInt917 == 2) { - imageCrosses[4 + (anInt916 / 100)].method348(anInt914 - 8 - 4, anInt915 - 8 - 4); + imageCrosses[4 + (anInt916 / 100)].draw(anInt914 - 8 - 4, anInt915 - 8 - 4); } if (anInt1018 != -1) { method119(anInt945, anInt1018); @@ -8070,7 +8205,7 @@ public class Game extends GameShell { method40(); } if (anInt1055 == 1) { - imageHeadicons[1].method348(472, 296); + imageHeadicons[1].draw(472, 296); } if (aBoolean1156) { char c = '\u01FB'; @@ -8257,7 +8392,7 @@ public class Game extends GameShell { } if (k == 1) { int l = buffer.getBits(3); - aPlayer_1126.method448(false, l); + self.method448(false, l); int k1 = buffer.getBits(1); if (k1 == 1) { anIntArray894[anInt893++] = LOCAL_PLAYER_INDEX; @@ -8266,9 +8401,9 @@ public class Game extends GameShell { } if (k == 2) { int i1 = buffer.getBits(3); - aPlayer_1126.method448(true, i1); + self.method448(true, i1); int l1 = buffer.getBits(3); - aPlayer_1126.method448(true, l1); + self.method448(true, l1); int j2 = buffer.getBits(1); if (j2 == 1) { anIntArray894[anInt893++] = LOCAL_PLAYER_INDEX; @@ -8276,7 +8411,7 @@ public class Game extends GameShell { return; } if (k == 3) { - anInt918 = buffer.getBits(2); + currentPlane = buffer.getBits(2); int j1 = buffer.getBits(1); int i2 = buffer.getBits(1); if (i2 == 1) { @@ -8284,32 +8419,32 @@ public class Game extends GameShell { } int k2 = buffer.getBits(7); int l2 = buffer.getBits(7); - aPlayer_1126.method445(l2, k2, j1 == 1); + self.move(l2, k2, j1 == 1); } } public void method118() { - aBoolean831 = false; - while (aBoolean962) { - aBoolean831 = false; + flameActive = false; + while (flameThread) { + flameActive = false; try { Thread.sleep(50L); } catch (Exception ignored) { } } - aImage_966 = null; - aImage_967 = null; - aImageArray1152 = null; - anIntArray850 = null; - anIntArray851 = null; - anIntArray852 = null; - anIntArray853 = null; - anIntArray1190 = null; - anIntArray1191 = null; - anIntArray828 = null; - anIntArray829 = null; - aImage_1201 = null; - aImage_1202 = null; + imageTitlebox = null; + imageTitlebutton = null; + imageRunes = null; + flameGradient = null; + flameGradient0 = null; + flameGradient1 = null; + flameGradient2 = null; + flameBuffer0 = null; + flameBuffer1 = null; + flameBuffer3 = null; + flameBuffer2 = null; + imageFlamesLeft = null; + imageFlamesRight = null; } public boolean method119(int i, int j) { @@ -8333,12 +8468,12 @@ public class Game extends GameShell { } if (l != -1) { SeqType type = SeqType.instances[l]; - for (component_1.anInt208 += i; component_1.anInt208 > type.method258(component_1.anInt246); ) { - component_1.anInt208 -= type.method258(component_1.anInt246) + 1; + for (component_1.anInt208 += i; component_1.anInt208 > type.getFrameDelay(component_1.anInt246); ) { + component_1.anInt208 -= type.getFrameDelay(component_1.anInt246) + 1; component_1.anInt246++; - if (component_1.anInt246 >= type.anInt352) { + if (component_1.anInt246 >= type.frameCount) { component_1.anInt246 -= type.anInt356; - if ((component_1.anInt246 < 0) || (component_1.anInt246 >= type.anInt352)) { + if ((component_1.anInt246 < 0) || (component_1.anInt246 >= type.frameCount)) { component_1.anInt246 = 0; } } @@ -8355,10 +8490,10 @@ public class Game extends GameShell { if (anInt861 < 310) { int k = anInt858 >> 7; int l = anInt860 >> 7; - int i1 = aPlayer_1126.x >> 7; - int j1 = aPlayer_1126.z >> 7; - if ((aByteArrayArrayArray1258[anInt918][k][l] & 4) != 0) { - j = anInt918; + int i1 = self.x >> 7; + int j1 = self.z >> 7; + if ((planeTileFlags[currentPlane][k][l] & 4) != 0) { + j = currentPlane; } int k1; if (i1 > k) { @@ -8381,8 +8516,8 @@ public class Game extends GameShell { } else if (k > i1) { k--; } - if ((aByteArrayArrayArray1258[anInt918][k][l] & 4) != 0) { - j = anInt918; + if ((planeTileFlags[currentPlane][k][l] & 4) != 0) { + j = currentPlane; } k2 += i2; if (k2 >= 0x10000) { @@ -8392,8 +8527,8 @@ public class Game extends GameShell { } else if (l > j1) { l--; } - if ((aByteArrayArrayArray1258[anInt918][k][l] & 4) != 0) { - j = anInt918; + if ((planeTileFlags[currentPlane][k][l] & 4) != 0) { + j = currentPlane; } } } @@ -8406,8 +8541,8 @@ public class Game extends GameShell { } else if (l > j1) { l--; } - if ((aByteArrayArrayArray1258[anInt918][k][l] & 4) != 0) { - j = anInt918; + if ((planeTileFlags[currentPlane][k][l] & 4) != 0) { + j = currentPlane; } l2 += j2; if (l2 >= 0x10000) { @@ -8417,23 +8552,23 @@ public class Game extends GameShell { } else if (k > i1) { k--; } - if ((aByteArrayArrayArray1258[anInt918][k][l] & 4) != 0) { - j = anInt918; + if ((planeTileFlags[currentPlane][k][l] & 4) != 0) { + j = currentPlane; } } } } } - if ((aByteArrayArrayArray1258[anInt918][aPlayer_1126.x >> 7][aPlayer_1126.z >> 7] & 4) != 0) { - j = anInt918; + if ((planeTileFlags[currentPlane][self.x >> 7][self.z >> 7] & 4) != 0) { + j = currentPlane; } return j; } public int method121() { - int j = method42(anInt918, anInt860, anInt858); - if (((j - anInt859) < 800) && ((aByteArrayArrayArray1258[anInt918][anInt858 >> 7][anInt860 >> 7] & 4) != 0)) { - return anInt918; + int j = getHeightmapY(currentPlane, anInt858, anInt860); + if (((j - anInt859) < 800) && ((planeTileFlags[currentPlane][anInt858 >> 7][anInt860 >> 7] & 4) != 0)) { + return currentPlane; } else { return 3; } @@ -8510,7 +8645,7 @@ public class Game extends GameShell { k1 = (anIntArray971[ai[l++]] * 100) / 46875; } if (j1 == 8) { - k1 = aPlayer_1126.anInt1705; + k1 = self.anInt1705; } if (j1 == 9) { for (int l1 = 0; l1 < SkillConstants.anInt733; l1++) { @@ -8545,11 +8680,11 @@ public class Game extends GameShell { } if (j1 == 14) { int j2 = ai[l++]; - VarbitType varbit = VarbitType.aVarbitArray646[j2]; - int l3 = varbit.anInt648; - int i4 = varbit.anInt649; - int j4 = varbit.anInt650; - int k4 = anIntArray1232[j4 - i4]; + VarbitType varbit = VarbitType.instances[j2]; + int l3 = varbit.varp; + int i4 = varbit.lsb; + int j4 = varbit.msb; + int k4 = BITMASK[j4 - i4]; k1 = (anIntArray971[l3] >> i4) & k4; } if (j1 == 15) { @@ -8562,10 +8697,10 @@ public class Game extends GameShell { byte0 = 3; } if (j1 == 18) { - k1 = (aPlayer_1126.x >> 7) + sceneBaseTileX; + k1 = (self.x >> 7) + sceneBaseTileX; } if (j1 == 19) { - k1 = (aPlayer_1126.z >> 7) + sceneBaseTileZ; + k1 = (self.z >> 7) + sceneBaseTileZ; } if (j1 == 20) { k1 = ai[l++]; @@ -8613,35 +8748,39 @@ public class Game extends GameShell { public void method126() { aArea_1164.bind(); - if (anInt1021 == 2) { - byte[] abyte0 = imageMapback.pixels; - int[] ai = Draw2D.pixels; - int k2 = abyte0.length; - for (int i5 = 0; i5 < k2; i5++) { - if (abyte0[i5] == 0) { - ai[i5] = 0; + + if (minimapState == 2) { + byte[] mapback = imageMapback.pixels; + int[] pixels = Draw2D.pixels; + for (int i = 0; i < mapback.length; i++) { + if (mapback[i] == 0) { + pixels[i] = 0; } } - imageCompass.method352(33, anInt1185, anIntArray1057, 256, anIntArray968, 25, 0, 0, 33, 25); + imageCompass.drawRotatedMasked(0, 0, 33, 33, 25, 25, 256, anInt1185, compassMaskLineLengths, compassMaskLineOffsets); areaViewport.bind(); return; } + int i = (anInt1185 + anInt1209) & 0x7ff; - int j = 48 + (aPlayer_1126.x / 32); - int l2 = 464 - (aPlayer_1126.z / 32); - imageMinimap.method352(151, i, anIntArray1229, 256 + anInt1170, anIntArray1052, l2, 5, 25, 146, j); - imageCompass.method352(33, anInt1185, anIntArray1057, 256, anIntArray968, 25, 0, 0, 33, 25); - for (int j5 = 0; j5 < anInt1071; j5++) { - int k = ((anIntArray1072[j5] * 4) + 2) - (aPlayer_1126.x / 32); - int i3 = ((anIntArray1073[j5] * 4) + 2) - (aPlayer_1126.z / 32); - method141(aImageArray1140[j5], k, i3); + int j = 48 + (self.x / 32); + int l2 = 464 - (self.z / 32); + + imageMinimap.drawRotatedMasked(25, 5, 146, 151, j, l2, 256 + minimapZoom, i, minimapMaskLineLengths, minimapMaskLineOffsets); + imageCompass.drawRotatedMasked(0, 0, 33, 33, 25, 25, 256, anInt1185, compassMaskLineLengths, compassMaskLineOffsets); + + for (int j5 = 0; j5 < activeMapFunctionCount; j5++) { + int k = ((activeMapFunctionX[j5] * 4) + 2) - (self.x / 32); + int i3 = ((activeMapFunctionZ[j5] * 4) + 2) - (self.z / 32); + method141(activeMapFunctions[j5], k, i3); } + for (int k5 = 0; k5 < 104; k5++) { for (int l5 = 0; l5 < 104; l5++) { - DoublyLinkedList list = aListArrayArrayArray827[anInt918][k5][l5]; + DoublyLinkedList list = aListArrayArrayArray827[currentPlane][k5][l5]; if (list != null) { - int l = ((k5 * 4) + 2) - (aPlayer_1126.x / 32); - int j3 = ((l5 * 4) + 2) - (aPlayer_1126.z / 32); + int l = ((k5 * 4) + 2) - (self.x / 32); + int j3 = ((l5 * 4) + 2) - (self.z / 32); method141(imageMapdot0, l, j3); } } @@ -8649,13 +8788,13 @@ public class Game extends GameShell { for (int i6 = 0; i6 < anInt836; i6++) { NPCEntity npc = npcs[anIntArray837[i6]]; if ((npc != null) && npc.method449()) { - NPCType type = npc.aType_1696; - if (type.anIntArray88 != null) { - type = type.method161(); + NPCType type = npc.type; + if (type.overrides != null) { + type = type.getOverrideType(); } if ((type != null) && type.aBoolean87 && type.aBoolean84) { - int i1 = (npc.x / 32) - (aPlayer_1126.x / 32); - int k3 = (npc.z / 32) - (aPlayer_1126.z / 32); + int i1 = (npc.x / 32) - (self.x / 32); + int k3 = (npc.z / 32) - (self.z / 32); method141(imageMapdot1, i1, k3); } } @@ -8663,8 +8802,8 @@ public class Game extends GameShell { for (int j6 = 0; j6 < anInt891; j6++) { PlayerEntity player = players[anIntArray892[j6]]; if ((player != null) && player.method449()) { - int j1 = (player.x / 32) - (aPlayer_1126.x / 32); - int l3 = (player.z / 32) - (aPlayer_1126.z / 32); + int j1 = (player.x / 32) - (self.x / 32); + int l3 = (player.z / 32) - (self.z / 32); boolean flag1 = false; long l6 = StringUtil.toBase37(player.aString1703); for (int k6 = 0; k6 < anInt899; k6++) { @@ -8675,7 +8814,7 @@ public class Game extends GameShell { break; } boolean flag2 = false; - if ((player.anInt1701 != 0) && (aPlayer_1126.anInt1701 == player.anInt1701)) { + if ((player.anInt1701 != 0) && (self.anInt1701 == player.anInt1701)) { flag2 = true; } if (flag1) { @@ -8691,28 +8830,28 @@ public class Game extends GameShell { if ((anInt855 == 1) && (anInt1222 >= 0) && (anInt1222 < npcs.length)) { NPCEntity class30_sub2_sub4_sub1_sub1_1 = npcs[anInt1222]; if (class30_sub2_sub4_sub1_sub1_1 != null) { - int k1 = (class30_sub2_sub4_sub1_sub1_1.x / 32) - (aPlayer_1126.x / 32); - int i4 = (class30_sub2_sub4_sub1_sub1_1.z / 32) - (aPlayer_1126.z / 32); + int k1 = (class30_sub2_sub4_sub1_sub1_1.x / 32) - (self.x / 32); + int i4 = (class30_sub2_sub4_sub1_sub1_1.z / 32) - (self.z / 32); method81(imageMapmarker1, i4, k1); } } if (anInt855 == 2) { - int l1 = (((anInt934 - sceneBaseTileX) * 4) + 2) - (aPlayer_1126.x / 32); - int j4 = (((anInt935 - sceneBaseTileZ) * 4) + 2) - (aPlayer_1126.z / 32); + int l1 = (((anInt934 - sceneBaseTileX) * 4) + 2) - (self.x / 32); + int j4 = (((anInt935 - sceneBaseTileZ) * 4) + 2) - (self.z / 32); method81(imageMapmarker1, j4, l1); } if ((anInt855 == 10) && (anInt933 >= 0) && (anInt933 < players.length)) { PlayerEntity class30_sub2_sub4_sub1_sub2_1 = players[anInt933]; if (class30_sub2_sub4_sub1_sub2_1 != null) { - int i2 = (class30_sub2_sub4_sub1_sub2_1.x / 32) - (aPlayer_1126.x / 32); - int k4 = (class30_sub2_sub4_sub1_sub2_1.z / 32) - (aPlayer_1126.z / 32); + int i2 = (class30_sub2_sub4_sub1_sub2_1.x / 32) - (self.x / 32); + int k4 = (class30_sub2_sub4_sub1_sub2_1.z / 32) - (self.z / 32); method81(imageMapmarker1, k4, i2); } } } if (anInt1261 != 0) { - int j2 = ((anInt1261 * 4) + 2) - (aPlayer_1126.x / 32); - int l4 = ((anInt1262 * 4) + 2) - (aPlayer_1126.z / 32); + int j2 = ((anInt1261 * 4) + 2) - (self.x / 32); + int l4 = ((anInt1262 * 4) + 2) - (self.z / 32); method141(imageMapmarker0, j2, l4); } Draw2D.fillRect(97, 78, 3, 3, 0xffffff); @@ -8729,7 +8868,7 @@ public class Game extends GameShell { anInt964 = -1; return; } - int i1 = method42(anInt918, l, i) - j; + int i1 = getHeightmapY(currentPlane, i, l) - j; i -= anInt858; i1 -= anInt859; l -= anInt860; @@ -8876,85 +9015,100 @@ public class Game extends GameShell { return new DataInputStream(inputstream); } - public void method133() { - char c = '\u0100'; - if (anInt1040 > 0) { + public void drawFlames() { + int height = 256; + + if (flameGradientCycle0 > 0) { for (int i = 0; i < 256; i++) { - if (anInt1040 > 768) { - anIntArray850[i] = method83(anIntArray851[i], anIntArray852[i], 1024 - anInt1040); - } else if (anInt1040 > 256) { - anIntArray850[i] = anIntArray852[i]; + if (flameGradientCycle0 > 768) { + flameGradient[i] = mix(flameGradient0[i], flameGradient1[i], 1024 - flameGradientCycle0); + } else if (flameGradientCycle0 > 256) { + flameGradient[i] = flameGradient1[i]; } else { - anIntArray850[i] = method83(anIntArray852[i], anIntArray851[i], 256 - anInt1040); + flameGradient[i] = mix(flameGradient1[i], flameGradient0[i], 256 - flameGradientCycle0); } } - } else if (anInt1041 > 0) { + } else if (flameGradientCycle1 > 0) { for (int j = 0; j < 256; j++) { - if (anInt1041 > 768) { - anIntArray850[j] = method83(anIntArray851[j], anIntArray853[j], 1024 - anInt1041); - } else if (anInt1041 > 256) { - anIntArray850[j] = anIntArray853[j]; + if (flameGradientCycle1 > 768) { + flameGradient[j] = mix(flameGradient0[j], flameGradient2[j], 1024 - flameGradientCycle1); + } else if (flameGradientCycle1 > 256) { + flameGradient[j] = flameGradient2[j]; } else { - anIntArray850[j] = method83(anIntArray853[j], anIntArray851[j], 256 - anInt1041); + flameGradient[j] = mix(flameGradient2[j], flameGradient0[j], 256 - flameGradientCycle1); } } } else { - for (int k = 0; k < 256; k++) { - anIntArray850[k] = anIntArray851[k]; - } + System.arraycopy(flameGradient0, 0, flameGradient, 0, 256); } - for (int l = 0; l < 33920; l++) { - aArea_1110.pixels[l] = aImage_1201.anIntArray1439[l]; - } - int i1 = 0; - int j1 = 1152; - for (int k1 = 1; k1 < (c - 1); k1++) { - int l1 = (anIntArray969[k1] * (c - k1)) / c; - int j2 = 22 + l1; - if (j2 < 0) { - j2 = 0; + + System.arraycopy(imageFlamesLeft.pixels, 0, imageTitle0.pixels, 0, 33920); + + int srcOffset = 0; + int dstOffset = 1152; + + for (int y = 1; y < (height - 1); y++) { + int offset = (flameLineOffset[y] * (height - y)) / height; + int step = 22 + offset; + + if (step < 0) { + step = 0; } - i1 += j2; - for (int l2 = j2; l2 < 128; l2++) { - int j3 = anIntArray828[i1++]; - if (j3 != 0) { - int l3 = j3; - int j4 = 256 - j3; - j3 = anIntArray850[j3]; - int l4 = aArea_1110.pixels[j1]; - aArea_1110.pixels[j1++] = (((((j3 & 0xff00ff) * l3) + ((l4 & 0xff00ff) * j4)) & 0xff00ff00) + ((((j3 & 0xff00) * l3) + ((l4 & 0xff00) * j4)) & 0xff0000)) >> 8; + + srcOffset += step; + + for (int x = step; x < 128; x++) { + int value = flameBuffer3[srcOffset++]; + + if (value != 0) { + int alpha = value; + int invAlpha = 256 - value; + + value = flameGradient[value]; + + int background = imageTitle0.pixels[dstOffset]; + + imageTitle0.pixels[dstOffset++] = (((((value & 0xff00ff) * alpha) + ((background & 0xff00ff) * invAlpha)) & 0xff00ff00) + ((((value & 0xff00) * alpha) + ((background & 0xff00) * invAlpha)) & 0xff0000)) >> 8; } else { - j1++; + dstOffset++; } } - j1 += j2; + + dstOffset += step; } - aArea_1110.draw(super.graphics, 0, 0); - for (int i2 = 0; i2 < 33920; i2++) { - aArea_1111.pixels[i2] = aImage_1202.anIntArray1439[i2]; - } - i1 = 0; - j1 = 1176; - for (int k2 = 1; k2 < (c - 1); k2++) { - int i3 = (anIntArray969[k2] * (c - k2)) / c; - int k3 = 103 - i3; - j1 += i3; - for (int i4 = 0; i4 < k3; i4++) { - int k4 = anIntArray828[i1++]; - if (k4 != 0) { - int i5 = k4; - int j5 = 256 - k4; - k4 = anIntArray850[k4]; - int k5 = aArea_1111.pixels[j1]; - aArea_1111.pixels[j1++] = (((((k4 & 0xff00ff) * i5) + ((k5 & 0xff00ff) * j5)) & 0xff00ff00) + ((((k4 & 0xff00) * i5) + ((k5 & 0xff00) * j5)) & 0xff0000)) >> 8; + + imageTitle0.draw(super.graphics, 0, 0); + System.arraycopy(imageFlamesRight.pixels, 0, imageTitle1.pixels, 0, 33920); + + srcOffset = 0; + dstOffset = 1176; + + for (int y = 1; y < (height - 1); y++) { + int offset = (flameLineOffset[y] * (height - y)) / height; + int step = 103 - offset; + + dstOffset += offset; + + for (int i4 = 0; i4 < step; i4++) { + int value = flameBuffer3[srcOffset++]; + + if (value != 0) { + int alpha = value; + int invAlpha = 256 - value; + value = flameGradient[value]; + + int background = imageTitle1.pixels[dstOffset]; + + imageTitle1.pixels[dstOffset++] = (((((value & 0xff00ff) * alpha) + ((background & 0xff00ff) * invAlpha)) & 0xff00ff00) + ((((value & 0xff00) * alpha) + ((background & 0xff00) * invAlpha)) & 0xff0000)) >> 8; } else { - j1++; + dstOffset++; } } - i1 += 128 - k3; - j1 += 128 - k3 - i3; + srcOffset += 128 - step; + dstOffset += 128 - step - offset; } - aArea_1111.draw(super.graphics, 637, 0); + + imageTitle1.draw(super.graphics, 637, 0); } public void method134(Buffer buffer) { @@ -9011,8 +9165,8 @@ public class Game extends GameShell { public void method135(boolean flag) throws IOException { method64(); - aArea_1109.bind(); - aImage_966.method361(0, 0); + imageTitle4.bind(); + imageTitlebox.blit(0, 0); char c = '\u0168'; char c1 = '\310'; if (anInt833 == 0) { @@ -9022,10 +9176,10 @@ public class Game extends GameShell { fontBold12.drawStringTaggableCenter("Welcome to RuneScape", c / 2, i, 0xffff00, true); int l = (c / 2) - 80; int k1 = (c1 / 2) + 20; - aImage_967.method361(l - 73, k1 - 20); + imageTitlebutton.blit(l - 73, k1 - 20); fontBold12.drawStringTaggableCenter("New User", l, k1 + 5, 0xffffff, true); l = (c / 2) + 80; - aImage_967.method361(l - 73, k1 - 20); + imageTitlebutton.blit(l - 73, k1 - 20); fontBold12.drawStringTaggableCenter("Existing User", l, k1 + 5, 0xffffff, true); } if (anInt833 == 2) { @@ -9043,10 +9197,10 @@ public class Game extends GameShell { if (!flag) { int i1 = (c / 2) - 80; int l1 = (c1 / 2) + 50; - aImage_967.method361(i1 - 73, l1 - 20); + imageTitlebutton.blit(i1 - 73, l1 - 20); fontBold12.drawStringTaggableCenter("Login", i1, l1 + 5, 0xffffff, true); i1 = (c / 2) + 80; - aImage_967.method361(i1 - 73, l1 - 20); + imageTitlebutton.blit(i1 - 73, l1 - 20); fontBold12.drawStringTaggableCenter("Cancel", i1, l1 + 5, 0xffffff, true); } } @@ -9062,50 +9216,40 @@ public class Game extends GameShell { fontBold12.drawStringTaggableCenter("button at the top right of that page.", c / 2, k, 0xffffff, true); int j1 = c / 2; int i2 = (c1 / 2) + 50; - aImage_967.method361(j1 - 73, i2 - 20); + imageTitlebutton.blit(j1 - 73, i2 - 20); fontBold12.drawStringTaggableCenter("Cancel", j1, i2 + 5, 0xffffff, true); } - aArea_1109.draw(super.graphics, 202, 171); + imageTitle4.draw(super.graphics, 202, 171); if (aBoolean1255) { aBoolean1255 = false; - aArea_1107.draw(super.graphics, 128, 0); - aArea_1108.draw(super.graphics, 202, 371); - aArea_1112.draw(super.graphics, 0, 265); - aArea_1113.draw(super.graphics, 562, 265); - aArea_1114.draw(super.graphics, 128, 171); - aArea_1115.draw(super.graphics, 562, 171); + imageTitle2.draw(super.graphics, 128, 0); + imageTitle3.draw(super.graphics, 202, 371); + imageTitle5.draw(super.graphics, 0, 265); + imageTitle6.draw(super.graphics, 562, 265); + imageTitle7.draw(super.graphics, 128, 171); + imageTitle8.draw(super.graphics, 562, 171); } } public void method136() { - aBoolean962 = true; - try { - long l = System.currentTimeMillis(); - int i = 0; - int j = 20; - while (aBoolean831) { + flameThread = true; + + while (flameActive) { flameCycle++; - method58(); - method58(); - method133(); - if (++i > 10) { - long l1 = System.currentTimeMillis(); - int k = ((int) (l1 - l) / 10) - j; - j = 40 - k; - if (j < 5) { - j = 5; - } - i = 0; - l = l1; - } + + updateFlames(); + drawFlames(); + + // the code here originally was some sort of lag detection code. It's not very useful anymore, and + // made the flames look choppier. + try { - Thread.sleep(j); + Thread.sleep(20); // 50fps seems fine } catch (Exception ignored) { } } - } catch (Exception ignored) { - } - aBoolean962 = false; + + flameThread = false; } public void method137(Buffer buffer, int j) { @@ -9117,7 +9261,7 @@ public class Game extends GameShell { int k11 = buffer.get2U(); int l13 = buffer.get2U(); if ((j3 >= 0) && (i6 >= 0) && (j3 < 104) && (i6 < 104)) { - DoublyLinkedList list_1 = aListArrayArrayArray827[anInt918][j3][i6]; + DoublyLinkedList list_1 = aListArrayArrayArray827[currentPlane][j3][i6]; if (list_1 != null) { for (ObjStackEntity objStack_3 = (ObjStackEntity) list_1.peekFront(); objStack_3 != null; objStack_3 = (ObjStackEntity) list_1.prev()) { if ((objStack_3.anInt1558 != (l8 & 0x7fff)) || (objStack_3.anInt1559 != k11)) { @@ -9139,7 +9283,7 @@ public class Game extends GameShell { int l11 = buffer.get1U(); int i14 = (l11 >> 4) & 0xf; int i16 = l11 & 7; - if ((aPlayer_1126.moveQueueTileX[0] >= (k3 - i14)) && (aPlayer_1126.moveQueueTileX[0] <= (k3 + i14)) && (aPlayer_1126.moveQueueTileZ[0] >= (j6 - i14)) && (aPlayer_1126.moveQueueTileZ[0] <= (j6 + i14)) && aBoolean848 && !lowmem && (anInt1062 < 50)) { + if ((self.pathTileX[0] >= (k3 - i14)) && (self.pathTileX[0] <= (k3 + i14)) && (self.pathTileZ[0] >= (j6 - i14)) && (self.pathTileZ[0] <= (j6 + i14)) && aBoolean848 && !lowmem && (anInt1062 < 50)) { anIntArray1207[anInt1062] = i9; anIntArray1241[anInt1062] = i16; anIntArray1250[anInt1062] = SoundTrack.delays[i9]; @@ -9153,14 +9297,14 @@ public class Game extends GameShell { int j9 = anInt1269 + (l3 & 7); int i12 = buffer.get2UA(); int j14 = buffer.get2U(); - if ((k6 >= 0) && (j9 >= 0) && (k6 < 104) && (j9 < 104) && (i12 != anInt884)) { + if ((k6 >= 0) && (j9 >= 0) && (k6 < 104) && (j9 < 104) && (i12 != selfPlayerId)) { ObjStackEntity class30_sub2_sub4_sub2_2 = new ObjStackEntity(); class30_sub2_sub4_sub2_2.anInt1558 = i1; class30_sub2_sub4_sub2_2.anInt1559 = j14; - if (aListArrayArrayArray827[anInt918][k6][j9] == null) { - aListArrayArrayArray827[anInt918][k6][j9] = new DoublyLinkedList(); + if (aListArrayArrayArray827[currentPlane][k6][j9] == null) { + aListArrayArrayArray827[currentPlane][k6][j9] = new DoublyLinkedList(); } - aListArrayArrayArray827[anInt918][k6][j9].pushBack(class30_sub2_sub4_sub2_2); + aListArrayArrayArray827[currentPlane][k6][j9].pushBack(class30_sub2_sub4_sub2_2); method25(k6, j9); } return; @@ -9171,7 +9315,7 @@ public class Game extends GameShell { int l6 = anInt1269 + (j1 & 7); int k9 = buffer.get2U(); if ((i4 >= 0) && (l6 >= 0) && (i4 < 104) && (l6 < 104)) { - DoublyLinkedList list = aListArrayArrayArray827[anInt918][i4][l6]; + DoublyLinkedList list = aListArrayArrayArray827[currentPlane][i4][l6]; if (list != null) { for (ObjStackEntity objStack = (ObjStackEntity) list.peekFront(); objStack != null; objStack = (ObjStackEntity) list.prev()) { if (objStack.anInt1558 != (k9 & 0x7fff)) { @@ -9181,7 +9325,7 @@ public class Game extends GameShell { break; } if (list.peekFront() == null) { - aListArrayArrayArray827[anInt918][i4][l6] = null; + aListArrayArrayArray827[currentPlane][i4][l6] = null; } method25(i4, l6); } @@ -9198,41 +9342,41 @@ public class Game extends GameShell { int j16 = anIntArray1177[j12]; int j17 = buffer.get2UA(); if ((j4 >= 0) && (i7 >= 0) && (j4 < 103) && (i7 < 103)) { - int j18 = anIntArrayArrayArray1214[anInt918][j4][i7]; - int i19 = anIntArrayArrayArray1214[anInt918][j4 + 1][i7]; - int l19 = anIntArrayArrayArray1214[anInt918][j4 + 1][i7 + 1]; - int k20 = anIntArrayArrayArray1214[anInt918][j4][i7 + 1]; + int j18 = anIntArrayArrayArray1214[currentPlane][j4][i7]; + int i19 = anIntArrayArrayArray1214[currentPlane][j4 + 1][i7]; + int l19 = anIntArrayArrayArray1214[currentPlane][j4 + 1][i7 + 1]; + int k20 = anIntArrayArrayArray1214[currentPlane][j4][i7 + 1]; if (j16 == 0) { - SceneWall wall = scene.method296(anInt918, j4, i7); + SceneWall wall = scene.getWall(currentPlane, j4, i7); if (wall != null) { - int k21 = (wall.anInt280 >> 14) & 0x7fff; + int k21 = (wall.bitset >> 14) & 0x7fff; if (j12 == 2) { - wall.aEntity_278 = new LocEntity(k21, 4 + k14, 2, i19, l19, j18, k20, j17, false); - wall.aEntity_279 = new LocEntity(k21, (k14 + 1) & 3, 2, i19, l19, j18, k20, j17, false); + 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.aEntity_278 = new LocEntity(k21, k14, j12, i19, l19, j18, k20, j17, false); + wall.entity0 = new LocEntity(k21, k14, j12, i19, l19, j18, k20, j17, false); } } } if (j16 == 1) { - SceneWallDecoration wallDecoration = scene.method297(j4, i7, anInt918); + SceneWallDecoration wallDecoration = scene.getWallDecoration(currentPlane, j4, i7); if (wallDecoration != null) { - wallDecoration.aEntity_504 = new LocEntity((wallDecoration.anInt505 >> 14) & 0x7fff, 0, 4, i19, l19, j18, k20, j17, false); + wallDecoration.entity = new LocEntity((wallDecoration.bitset >> 14) & 0x7fff, 0, 4, i19, l19, j18, k20, j17, false); } } if (j16 == 2) { - SceneLoc loc = scene.method298(j4, i7, anInt918); + SceneLoc loc = scene.getLoc(currentPlane, j4, i7); if (j12 == 11) { j12 = 10; } if (loc != null) { - loc.aEntity_521 = new LocEntity((loc.anInt529 >> 14) & 0x7fff, k14, j12, i19, l19, j18, k20, j17, false); + loc.entity = new LocEntity((loc.bitset >> 14) & 0x7fff, k14, j12, i19, l19, j18, k20, j17, false); } } if (j16 == 3) { - SceneGroundDecoration groundDecoration = scene.method299(i7, j4, anInt918); + SceneGroundDecoration groundDecoration = scene.getGroundDecoration(i7, j4, currentPlane); if (groundDecoration != null) { - groundDecoration.aEntity_814 = new LocEntity((groundDecoration.anInt815 >> 14) & 0x7fff, k14, 22, i19, l19, j18, k20, j17, false); + groundDecoration.entity = new LocEntity((groundDecoration.bitset >> 14) & 0x7fff, k14, 22, i19, l19, j18, k20, j17, false); } } } @@ -9255,23 +9399,23 @@ public class Game extends GameShell { int l21 = buffer.get2U(); byte byte3 = buffer.get1C(); PlayerEntity player; - if (i10 == anInt884) { - player = aPlayer_1126; + if (i10 == selfPlayerId) { + player = self; } else { player = players[i10]; } if (player != null) { LocType type = LocType.method572(l21); - int i22 = anIntArrayArrayArray1214[anInt918][k4][j7]; - int j22 = anIntArrayArrayArray1214[anInt918][k4 + 1][j7]; - int k22 = anIntArrayArrayArray1214[anInt918][k4 + 1][j7 + 1]; - int l22 = anIntArrayArrayArray1214[anInt918][k4][j7 + 1]; + int i22 = anIntArrayArrayArray1214[currentPlane][k4][j7]; + int j22 = anIntArrayArrayArray1214[currentPlane][k4 + 1][j7]; + int k22 = anIntArrayArrayArray1214[currentPlane][k4 + 1][j7 + 1]; + int l22 = anIntArrayArrayArray1214[currentPlane][k4][j7 + 1]; Model model = type.method578(j19, i20, i22, j22, k22, l22, -1); if (model != null) { - method130(k17 + 1, -1, 0, l20, j7, 0, anInt918, k4, l14 + 1); + method130(k17 + 1, -1, 0, l20, j7, 0, currentPlane, k4, l14 + 1); player.anInt1707 = l14 + loopCycle; player.anInt1708 = k17 + loopCycle; - player.aModel_1714 = model; + player.model = model; int i23 = type.anInt744; int j23 = type.anInt761; if ((i20 == 1) || (i20 == 3)) { @@ -9280,7 +9424,7 @@ public class Game extends GameShell { } player.anInt1711 = (k4 * 128) + (i23 * 64); player.anInt1713 = (j7 * 128) + (j23 * 64); - player.anInt1712 = method42(anInt918, player.anInt1713, player.anInt1711); + player.anInt1712 = getHeightmapY(currentPlane, player.anInt1711, player.anInt1713); if (byte2 > byte0) { byte byte4 = byte2; byte2 = byte0; @@ -9291,10 +9435,10 @@ public class Game extends GameShell { byte3 = byte1; byte1 = byte5; } - player.anInt1719 = k4 + byte2; - player.anInt1721 = k4 + byte0; - player.anInt1720 = j7 + byte3; - player.anInt1722 = j7 + byte1; + player.minSceneTileX = k4 + byte2; + player.maxSceneTileX = k4 + byte0; + player.minSceneTileZ = j7 + byte3; + player.maxSceneTileZ = j7 + byte1; } } } @@ -9308,7 +9452,7 @@ public class Game extends GameShell { int k16 = k12 & 3; int l17 = anIntArray1177[i15]; if ((l4 >= 0) && (k7 >= 0) && (l4 < 104) && (k7 < 104)) { - method130(-1, j10, k16, l17, k7, i15, anInt918, l4, 0); + method130(-1, j10, k16, l17, k7, i15, currentPlane, l4, 0); } return; } @@ -9322,7 +9466,7 @@ public class Game extends GameShell { if ((i5 >= 0) && (l7 >= 0) && (i5 < 104) && (l7 < 104)) { i5 = (i5 * 128) + 64; l7 = (l7 * 128) + 64; - SpotAnimEntity spotAnim = new SpotAnimEntity(anInt918, loopCycle, j15, k10, method42(anInt918, l7, i5) - l12, l7, i5); + SpotAnimEntity spotAnim = new SpotAnimEntity(currentPlane, loopCycle, j15, k10, getHeightmapY(currentPlane, i5, l7) - l12, l7, i5); aList_1056.pushBack(spotAnim); } return; @@ -9337,10 +9481,10 @@ public class Game extends GameShell { ObjStackEntity objStack_1 = new ObjStackEntity(); objStack_1.anInt1558 = k2; objStack_1.anInt1559 = j5; - if (aListArrayArrayArray827[anInt918][l10][i13] == null) { - aListArrayArrayArray827[anInt918][l10][i13] = new DoublyLinkedList(); + if (aListArrayArrayArray827[currentPlane][l10][i13] == null) { + aListArrayArrayArray827[currentPlane][l10][i13] = new DoublyLinkedList(); } - aListArrayArrayArray827[anInt918][l10][i13].pushBack(objStack_1); + aListArrayArrayArray827[currentPlane][l10][i13].pushBack(objStack_1); method25(l10, i13); } return; @@ -9354,7 +9498,7 @@ public class Game extends GameShell { int k15 = anInt1268 + ((j13 >> 4) & 7); int l16 = anInt1269 + (j13 & 7); if ((k15 >= 0) && (l16 >= 0) && (k15 < 104) && (l16 < 104)) { - method130(-1, -1, j8, i11, l16, k5, anInt918, k15, 0); + method130(-1, -1, j8, i11, l16, k5, currentPlane, k15, 0); } return; } @@ -9377,8 +9521,8 @@ public class Game extends GameShell { k8 = (k8 * 128) + 64; j11 = (j11 * 128) + 64; k13 = (k13 * 128) + 64; - ProjectileEntity projectile = new ProjectileEntity(i21, l18, k19 + loopCycle, j20 + loopCycle, j21, anInt918, method42(anInt918, k8, l5) - i18, k8, l5, l15, i17); - projectile.method455(k19 + loopCycle, k13, method42(anInt918, k13, j11) - l18, j11); + ProjectileEntity projectile = new ProjectileEntity(i21, l18, k19 + loopCycle, j20 + loopCycle, j21, currentPlane, getHeightmapY(currentPlane, l5, k8) - i18, k8, l5, l15, i17); + projectile.method455(k19 + loopCycle, k13, getHeightmapY(currentPlane, j11, k13) - l18, j11); aList_1013.pushBack(projectile); } } @@ -9544,14 +9688,14 @@ public class Game extends GameShell { } int i1 = Model.sin[k]; int j1 = Model.cos[k]; - i1 = (i1 * 256) / (anInt1170 + 256); - j1 = (j1 * 256) / (anInt1170 + 256); + i1 = (i1 * 256) / (minimapZoom + 256); + j1 = (j1 * 256) / (minimapZoom + 256); int k1 = ((j * i1) + (i * j1)) >> 16; int l1 = ((j * j1) - (i * i1)) >> 16; if (l > 2500) { - image.method354(imageMapback, 83 - l1 - (image.anInt1445 / 2) - 4, ((94 + k1) - (image.anInt1444 / 2)) + 4); + image.drawMasked(imageMapback, 83 - l1 - (image.cropH / 2) - 4, ((94 + k1) - (image.cropW / 2)) + 4); } else { - image.method348(((94 + k1) - (image.anInt1444 / 2)) + 4, 83 - l1 - (image.anInt1445 / 2) - 4); + image.draw(((94 + k1) - (image.cropW / 2)) + 4, 83 - l1 - (image.cropH / 2) - 4); } } @@ -9559,39 +9703,39 @@ public class Game extends GameShell { if ((i1 < 1) || (i < 1) || (i1 > 102) || (i > 102)) { return; } - if (lowmem && (j != anInt918)) { + if (lowmem && (j != currentPlane)) { return; } int i2 = 0; if (j1 == 0) { - i2 = scene.method300(j, i1, i); + i2 = scene.getWallBitset(j, i1, i); } if (j1 == 1) { - i2 = scene.method301(j, i1, i); + i2 = scene.getWallDecorationBitset(j, i1, i); } if (j1 == 2) { - i2 = scene.method302(j, i1, i); + i2 = scene.getLocBitset(j, i1, i); } if (j1 == 3) { - i2 = scene.method303(j, i1, i); + i2 = scene.getGroundDecorationBitset(j, i1, i); } if (i2 != 0) { - int i3 = scene.method304(j, i1, i, i2); + int i3 = scene.getInfo(j, i1, i, i2); int j2 = (i2 >> 14) & 0x7fff; int k2 = i3 & 0x1f; int l2 = i3 >> 6; if (j1 == 0) { - scene.method291(i1, j, i); + scene.removeWall(i1, j, i); LocType type = LocType.method572(j2); if (type.aBoolean767) { collisions[j].method215(l2, k2, type.aBoolean757, i1, i); } } if (j1 == 1) { - scene.method292(i, j, i1); + scene.removeWallDecoration(j, i1, i); } if (j1 == 2) { - scene.method293(j, i1, i); + scene.removeLoc(j, i1, i); LocType type_1 = LocType.method572(j2); if (((i1 + type_1.anInt744) > 103) || ((i + type_1.anInt744) > 103) || ((i1 + type_1.anInt761) > 103) || ((i + type_1.anInt761) > 103)) { return; @@ -9601,7 +9745,7 @@ public class Game extends GameShell { } } if (j1 == 3) { - scene.method294(j, i, i1); + scene.removeGroundDecoration(j, i1, i); LocType type_2 = LocType.method572(j2); if (type_2.aBoolean767 && type_2.aBoolean778) { collisions[j].method218(i, i1); @@ -9610,7 +9754,7 @@ public class Game extends GameShell { } if (k1 >= 0) { int j3 = j; - if ((j3 < 3) && ((aByteArrayArrayArray1258[1][i1][i] & 2) == 2)) { + if ((j3 < 3) && ((planeTileFlags[1][i1][i] & 2) == 2)) { j3++; } SceneBuilder.method188(scene, k, i, l, j3, collisions[j], anIntArrayArrayArray1214, i1, k1, j); @@ -9759,14 +9903,14 @@ public class Game extends GameShell { anInt1269 = in.get1US(); for (int j = anInt1268; j < (anInt1268 + 8); j++) { for (int l9 = anInt1269; l9 < (anInt1269 + 8); l9++) { - if (aListArrayArrayArray827[anInt918][j][l9] != null) { - aListArrayArrayArray827[anInt918][j][l9] = null; + if (aListArrayArrayArray827[currentPlane][j][l9] != null) { + aListArrayArrayArray827[currentPlane][j][l9] = null; method25(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 == anInt918)) { + if ((loc.sceneTileX >= anInt1268) && (loc.sceneTileX < (anInt1268 + 8)) && (loc.sceneTileZ >= anInt1269) && (loc.sceneTileZ < (anInt1269 + 8)) && (loc.anInt1295 == currentPlane)) { loc.anInt1294 = 0; } } @@ -9776,10 +9920,10 @@ public class Game extends GameShell { if (ptype == 185) { int k = in.get2ULEA(); Component.instances[k].anInt233 = 3; - if (aPlayer_1126.aType_1698 == null) { - Component.instances[k].anInt234 = (aPlayer_1126.anIntArray1700[0] << 25) + (aPlayer_1126.anIntArray1700[4] << 20) + (aPlayer_1126.anIntArray1717[0] << 15) + (aPlayer_1126.anIntArray1717[8] << 10) + (aPlayer_1126.anIntArray1717[11] << 5) + aPlayer_1126.anIntArray1717[1]; + if (self.aType_1698 == null) { + Component.instances[k].anInt234 = (self.anIntArray1700[0] << 25) + (self.anIntArray1700[4] << 20) + (self.anIntArray1717[0] << 15) + (self.anIntArray1717[8] << 10) + (self.anIntArray1717[11] << 5) + self.anIntArray1717[1]; } else { - Component.instances[k].anInt234 = (int) (0x12345678L + aPlayer_1126.aType_1698.aLong78); + Component.instances[k].anInt234 = (int) (0x12345678L + self.aType_1698.uid); } ptype = -1; return true; @@ -9820,7 +9964,7 @@ public class Game extends GameShell { if (anInt1102 >= 100) { anInt858 = (anInt1098 * 128) + 64; anInt860 = (anInt1099 * 128) + 64; - anInt859 = method42(anInt918, anInt860, anInt858) - anInt1100; + anInt859 = getHeightmapY(currentPlane, anInt858, anInt860) - anInt1100; } ptype = -1; return true; @@ -10058,8 +10202,8 @@ public class Game extends GameShell { if (npc != null) { for (int j = 0; j < 10; j++) { - npc.moveQueueTileX[j] -= dtx; - npc.moveQueueTileZ[j] -= dtz; + npc.pathTileX[j] -= dtx; + npc.pathTileZ[j] -= dtz; } npc.x -= dtx * 128; npc.z -= dtz * 128; @@ -10071,8 +10215,8 @@ public class Game extends GameShell { if (player != null) { for (int i31 = 0; i31 < 10; i31++) { - player.moveQueueTileX[i31] -= dtx; - player.moveQueueTileZ[i31] -= dtz; + player.pathTileX[i31] -= dtx; + player.pathTileZ[i31] -= dtz; } player.x -= dtx * 128; player.z -= dtz * 128; @@ -10143,7 +10287,7 @@ public class Game extends GameShell { return true; } if (ptype == 99) { - anInt1021 = in.get1U(); + minimapState = in.get1U(); ptype = -1; return true; } @@ -10626,7 +10770,7 @@ public class Game extends GameShell { if (anInt999 >= 100) { int k7 = (anInt995 * 128) + 64; int k14 = (anInt996 * 128) + 64; - int i20 = method42(anInt918, k14, k7) - anInt997; + int i20 = getHeightmapY(currentPlane, k7, k14) - anInt997; int l22 = k7 - anInt858; int k25 = i20 - anInt859; int j28 = k14 - anInt860; @@ -10645,7 +10789,7 @@ public class Game extends GameShell { } if (ptype == 249) { anInt1046 = in.get1UA(); - anInt884 = in.get2ULEA(); + selfPlayerId = in.get2ULEA(); ptype = -1; return true; } @@ -10814,7 +10958,7 @@ public class Game extends GameShell { } catch (IOException _ex) { method68(); } catch (Exception exception) { - StringBuilder s2 = new StringBuilder("T2 - " + ptype + "," + anInt842 + "," + anInt843 + " - " + psize + "," + (sceneBaseTileX + aPlayer_1126.moveQueueTileX[0]) + "," + (sceneBaseTileZ + aPlayer_1126.moveQueueTileZ[0]) + " - "); + StringBuilder s2 = new StringBuilder("T2 - " + ptype + "," + anInt842 + "," + anInt843 + " - " + psize + "," + (sceneBaseTileX + self.pathTileX[0]) + "," + (sceneBaseTileZ + self.pathTileZ[0]) + " - "); for (int j15 = 0; (j15 < psize) && (j15 < 50); j15++) { s2.append(in.data[j15]).append(","); } @@ -10842,7 +10986,7 @@ public class Game extends GameShell { i = anIntArray1203[4] + 128; } int k = (anInt1185 + anInt896) & 0x7ff; - method144(600 + (i * 3), i, anInt1014, method42(anInt918, aPlayer_1126.z, aPlayer_1126.x) - 50, k, anInt1015); + method144(600 + (i * 3), i, anInt1014, getHeightmapY(currentPlane, self.x, self.z) - 50, k, anInt1015); } int j; if (!aBoolean1160) { @@ -10888,7 +11032,7 @@ public class Game extends GameShell { Model.mouseY = super.anInt21 - 4; Draw2D.clear(); scene.method313(anInt858, anInt860, anInt862, anInt859, j, anInt861); - scene.method288(); + scene.clearTemporaryLocs(); method34(); method61(); method37(k2); diff --git a/src/main/java/Image24.java b/src/main/java/Image24.java index 8de36e3..268eeee 100644 --- a/src/main/java/Image24.java +++ b/src/main/java/Image24.java @@ -4,19 +4,19 @@ import java.io.IOException; public class Image24 extends DoublyLinkedList.Node { - public int[] anIntArray1439; - public int anInt1440; - public int anInt1441; - public int anInt1442; - public int anInt1443; - public int anInt1444; - public int anInt1445; + public int[] pixels; + public int width; + public int height; + public int cropX; + public int cropY; + public int cropW; + public int cropH; public Image24(int i, int j) { - anIntArray1439 = new int[i * j]; - anInt1440 = anInt1444 = i; - anInt1441 = anInt1445 = j; - anInt1442 = anInt1443 = 0; + pixels = new int[i * j]; + width = cropW = i; + height = cropH = j; + cropX = cropY = 0; } public Image24(byte[] abyte0, java.awt.Component component) { @@ -25,14 +25,14 @@ public class Image24 extends DoublyLinkedList.Node { MediaTracker mediatracker = new MediaTracker(component); mediatracker.addImage(image, 0); mediatracker.waitForAll(); - anInt1440 = image.getWidth(component); - anInt1441 = image.getHeight(component); - anInt1444 = anInt1440; - anInt1445 = anInt1441; - anInt1442 = 0; - anInt1443 = 0; - anIntArray1439 = new int[anInt1440 * anInt1441]; - PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, anInt1440, anInt1441, anIntArray1439, 0, anInt1440); + width = image.getWidth(component); + height = image.getHeight(component); + cropW = width; + cropH = height; + cropX = 0; + cropY = 0; + pixels = new int[width * height]; + PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, width, height, pixels, 0, width); pixelgrabber.grabPixels(); } catch (Exception _ex) { System.out.println("Error converting jpg"); @@ -43,8 +43,8 @@ public class Image24 extends DoublyLinkedList.Node { Buffer buffer = new Buffer(archive.read(s + ".dat")); Buffer buffer_1 = new Buffer(archive.read("index.dat")); buffer_1.position = buffer.get2U(); - anInt1444 = buffer_1.get2U(); - anInt1445 = buffer_1.get2U(); + cropW = buffer_1.get2U(); + cropH = buffer_1.get2U(); int j = buffer_1.get1U(); int[] ai = new int[j]; for (int k = 0; k < (j - 1); k++) { @@ -58,35 +58,35 @@ public class Image24 extends DoublyLinkedList.Node { buffer.position += buffer_1.get2U() * buffer_1.get2U(); buffer_1.position++; } - anInt1442 = buffer_1.get1U(); - anInt1443 = buffer_1.get1U(); - anInt1440 = buffer_1.get2U(); - anInt1441 = buffer_1.get2U(); - int i1 = buffer_1.get1U(); - int j1 = anInt1440 * anInt1441; - anIntArray1439 = new int[j1]; - if (i1 == 0) { - for (int k1 = 0; k1 < j1; k1++) { - anIntArray1439[k1] = ai[buffer.get1U()]; + cropX = buffer_1.get1U(); + cropY = buffer_1.get1U(); + width = buffer_1.get2U(); + height = buffer_1.get2U(); + int layout = buffer_1.get1U(); + int pixelLen = width * height; + pixels = new int[pixelLen]; + if (layout == 0) { + for (int k1 = 0; k1 < pixelLen; k1++) { + pixels[k1] = ai[buffer.get1U()]; } return; } - if (i1 == 1) { - for (int l1 = 0; l1 < anInt1440; l1++) { - for (int i2 = 0; i2 < anInt1441; i2++) { - anIntArray1439[l1 + (i2 * anInt1440)] = ai[buffer.get1U()]; + if (layout == 1) { + for (int l1 = 0; l1 < width; l1++) { + for (int i2 = 0; i2 < height; i2++) { + pixels[l1 + (i2 * width)] = ai[buffer.get1U()]; } } } } - public void method343() { - Draw2D.bind(anIntArray1439, anInt1440, anInt1441); + public void bind() { + Draw2D.bind(pixels, width, height); } public void method344(int i, int j, int k) { - for (int i1 = 0; i1 < anIntArray1439.length; i1++) { - int j1 = anIntArray1439[i1]; + for (int i1 = 0; i1 < pixels.length; i1++) { + int j1 = pixels[i1]; if (j1 != 0) { int k1 = (j1 >> 16) & 0xff; k1 += i; @@ -109,367 +109,364 @@ public class Image24 extends DoublyLinkedList.Node { } else if (i2 > 255) { i2 = 255; } - anIntArray1439[i1] = (k1 << 16) + (l1 << 8) + i2; + pixels[i1] = (k1 << 16) + (l1 << 8) + i2; } } } public void method345() { - int[] ai = new int[anInt1444 * anInt1445]; - for (int j = 0; j < anInt1441; j++) { - for (int k = 0; k < anInt1440; k++) { - ai[((j + anInt1443) * anInt1444) + (k + anInt1442)] = anIntArray1439[(j * anInt1440) + k]; + int[] pixels = new int[cropW * cropH]; + for (int j = 0; j < height; j++) { + for (int k = 0; k < width; k++) { + pixels[((j + cropY) * cropW) + (k + cropX)] = this.pixels[(j * width) + k]; } } - anIntArray1439 = ai; - anInt1440 = anInt1444; - anInt1441 = anInt1445; - anInt1442 = 0; - anInt1443 = 0; + this.pixels = pixels; + width = cropW; + height = cropH; + cropX = 0; + cropY = 0; } - public void method346(int i, int j) { - i += anInt1442; - j += anInt1443; - int l = i + (j * Draw2D.width); - int i1 = 0; - int j1 = anInt1441; - int k1 = anInt1440; - int l1 = Draw2D.width - k1; - int i2 = 0; - if (j < Draw2D.top) { - int j2 = Draw2D.top - j; - j1 -= j2; - j = Draw2D.top; - i1 += j2 * k1; - l += j2 * Draw2D.width; + public void blitOpaque(int x, int y) { + x += cropX; + y += cropY; + int dstOff = x + (y * Draw2D.width); + int srcOff = 0; + int h = height; + int w = width; + int dstStep = Draw2D.width - w; + int srcStep = 0; + if (y < Draw2D.top) { + int trim = Draw2D.top - y; + h -= trim; + y = Draw2D.top; + srcOff += trim * w; + dstOff += trim * Draw2D.width; } - if ((j + j1) > Draw2D.bottom) { - j1 -= (j + j1) - Draw2D.bottom; + if ((y + h) > Draw2D.bottom) { + h -= (y + h) - Draw2D.bottom; } - if (i < Draw2D.left) { - int k2 = Draw2D.left - i; - k1 -= k2; - i = Draw2D.left; - i1 += k2; - l += k2; - i2 += k2; - l1 += k2; + if (x < Draw2D.left) { + int trim = Draw2D.left - x; + w -= trim; + x = Draw2D.left; + srcOff += trim; + dstOff += trim; + srcStep += trim; + dstStep += trim; } - if ((i + k1) > Draw2D.right) { - int l2 = (i + k1) - Draw2D.right; - k1 -= l2; - i2 += l2; - l1 += l2; + if ((x + w) > Draw2D.right) { + int trim = (x + w) - Draw2D.right; + w -= trim; + srcStep += trim; + dstStep += trim; } - if ((k1 <= 0) || (j1 <= 0)) { - } else { - method347(l, k1, j1, i2, i1, l1, anIntArray1439, Draw2D.pixels); + if ((w > 0) && (h > 0)) { + copyPixels(dstOff, w, h, srcStep, srcOff, dstStep, pixels, Draw2D.pixels); } } - public void method347(int i, int j, int k, int l, int i1, int k1, int[] ai, int[] ai1) { - int l1 = -(j >> 2); - j = -(j & 3); - for (int i2 = -k; i2 < 0; i2++) { - for (int j2 = l1; j2 < 0; j2++) { - ai1[i++] = ai[i1++]; - ai1[i++] = ai[i1++]; - ai1[i++] = ai[i1++]; - ai1[i++] = ai[i1++]; + public void copyPixels(int dstOff, int w, int h, int srcStep, int srcOff, int dstStep, int[] src, int[] dst) { + int quarterWidth = -(w >> 2); + w = -(w & 3); + for (int i2 = -h; i2 < 0; i2++) { + for (int j2 = quarterWidth; j2 < 0; j2++) { + dst[dstOff++] = src[srcOff++]; + dst[dstOff++] = src[srcOff++]; + dst[dstOff++] = src[srcOff++]; + dst[dstOff++] = src[srcOff++]; } - for (int k2 = j; k2 < 0; k2++) { - ai1[i++] = ai[i1++]; + for (int k2 = w; k2 < 0; k2++) { + dst[dstOff++] = src[srcOff++]; } - i += k1; - i1 += l; + dstOff += dstStep; + srcOff += srcStep; } } - public void method348(int i, int k) { - i += anInt1442; - k += anInt1443; - int l = i + (k * Draw2D.width); - int i1 = 0; - int j1 = anInt1441; - int k1 = anInt1440; - int l1 = Draw2D.width - k1; - int i2 = 0; - if (k < Draw2D.top) { - int j2 = Draw2D.top - k; - j1 -= j2; - k = Draw2D.top; - i1 += j2 * k1; - l += j2 * Draw2D.width; + public void draw(int x, int y) { + x += cropX; + y += cropY; + int dstOff = x + (y * Draw2D.width); + int srcOff = 0; + int h = height; + int w = width; + int dstStep = Draw2D.width - w; + int srcStep = 0; + if (y < Draw2D.top) { + int j2 = Draw2D.top - y; + h -= j2; + y = Draw2D.top; + srcOff += j2 * w; + dstOff += j2 * Draw2D.width; } - if ((k + j1) > Draw2D.bottom) { - j1 -= (k + j1) - Draw2D.bottom; + if ((y + h) > Draw2D.bottom) { + h -= (y + h) - Draw2D.bottom; } - if (i < Draw2D.left) { - int k2 = Draw2D.left - i; - k1 -= k2; - i = Draw2D.left; - i1 += k2; - l += k2; - i2 += k2; - l1 += k2; + if (x < Draw2D.left) { + int k2 = Draw2D.left - x; + w -= k2; + x = Draw2D.left; + srcOff += k2; + dstOff += k2; + srcStep += k2; + dstStep += k2; } - if ((i + k1) > Draw2D.right) { - int l2 = (i + k1) - Draw2D.right; - k1 -= l2; - i2 += l2; - l1 += l2; + if ((x + w) > Draw2D.right) { + int trim = (x + w) - Draw2D.right; + w -= trim; + srcStep += trim; + dstStep += trim; } - if ((k1 <= 0) || (j1 <= 0)) { - } else { - method349(Draw2D.pixels, anIntArray1439, i1, l, k1, j1, l1, i2); + if ((w > 0) && (h > 0)) { + copyPixels(Draw2D.pixels, pixels, srcOff, dstOff, w, h, dstStep, srcStep); } } - public void method349(int[] ai, int[] ai1, int j, int k, int l, int i1, int j1, int k1) { - int l1 = -(l >> 2); - l = -(l & 3); - for (int i2 = -i1; i2 < 0; i2++) { - int i; - for (int j2 = l1; j2 < 0; j2++) { - i = ai1[j++]; - if (i != 0) { - ai[k++] = i; + public void copyPixels(int[] dst, int[] src, int srcOff, int dstOff, int w, int h, int dstStep, int srcstep) { + int quarterW = -(w >> 2); + w = -(w & 3); + for (int y = -h; y < 0; y++) { + int rgb; + for (int x = quarterW; x < 0; x++) { + rgb = src[srcOff++]; + if (rgb != 0) { + dst[dstOff++] = rgb; } else { - k++; + dstOff++; } - i = ai1[j++]; - if (i != 0) { - ai[k++] = i; + rgb = src[srcOff++]; + if (rgb != 0) { + dst[dstOff++] = rgb; } else { - k++; + dstOff++; } - i = ai1[j++]; - if (i != 0) { - ai[k++] = i; + rgb = src[srcOff++]; + if (rgb != 0) { + dst[dstOff++] = rgb; } else { - k++; + dstOff++; } - i = ai1[j++]; - if (i != 0) { - ai[k++] = i; + rgb = src[srcOff++]; + if (rgb != 0) { + dst[dstOff++] = rgb; } else { - k++; + dstOff++; } } - for (int k2 = l; k2 < 0; k2++) { - i = ai1[j++]; - if (i != 0) { - ai[k++] = i; + for (int k2 = w; k2 < 0; k2++) { + rgb = src[srcOff++]; + if (rgb != 0) { + dst[dstOff++] = rgb; } else { - k++; + dstOff++; } } - k += j1; - j += k1; + dstOff += dstStep; + srcOff += srcstep; } } - public void method350(int i, int j, int k) { - i += anInt1442; - j += anInt1443; - int i1 = i + (j * Draw2D.width); + public void draw(int x, int y, int alpha) { + x += cropX; + y += cropY; + int i1 = x + (y * Draw2D.width); int j1 = 0; - int k1 = anInt1441; - int l1 = anInt1440; - int i2 = Draw2D.width - l1; + int k1 = height; + int w = width; + int i2 = Draw2D.width - w; int j2 = 0; - if (j < Draw2D.top) { - int k2 = Draw2D.top - j; + if (y < Draw2D.top) { + int k2 = Draw2D.top - y; k1 -= k2; - j = Draw2D.top; - j1 += k2 * l1; + y = Draw2D.top; + j1 += k2 * w; i1 += k2 * Draw2D.width; } - if ((j + k1) > Draw2D.bottom) { - k1 -= (j + k1) - Draw2D.bottom; + if ((y + k1) > Draw2D.bottom) { + k1 -= (y + k1) - Draw2D.bottom; } - if (i < Draw2D.left) { - int l2 = Draw2D.left - i; - l1 -= l2; - i = Draw2D.left; + if (x < Draw2D.left) { + int l2 = Draw2D.left - x; + w -= l2; + x = Draw2D.left; j1 += l2; i1 += l2; j2 += l2; i2 += l2; } - if ((i + l1) > Draw2D.right) { - int i3 = (i + l1) - Draw2D.right; - l1 -= i3; + if ((x + w) > Draw2D.right) { + int i3 = (x + w) - Draw2D.right; + w -= i3; j2 += i3; i2 += i3; } - if ((l1 <= 0) || (k1 <= 0)) { - } else { - method351(j1, l1, Draw2D.pixels, anIntArray1439, j2, k1, i2, k, i1); + if ((w > 0) && (k1 > 0)) { + copyPixelsAlpha(j1, w, Draw2D.pixels, pixels, j2, k1, i2, alpha, i1); } } - public void method351(int i, int j, int[] ai, int[] ai1, int l, int i1, int j1, int k1, int l1) { - int j2 = 256 - k1; - for (int k2 = -i1; k2 < 0; k2++) { - for (int l2 = -j; l2 < 0; l2++) { - int k = ai1[i++]; - if (k != 0) { - int i3 = ai[l1]; - ai[l1++] = (((((k & 0xff00ff) * k1) + ((i3 & 0xff00ff) * j2)) & 0xff00ff00) + ((((k & 0xff00) * k1) + ((i3 & 0xff00) * j2)) & 0xff0000)) >> 8; + public void copyPixelsAlpha(int srcOff, int w, int[] dst, int[] src, int srcstep, int h, int dstStep, int alpha, int dstOff) { + int invAlpha = 256 - alpha; + for (int k2 = -h; k2 < 0; k2++) { + for (int l2 = -w; l2 < 0; l2++) { + int srcRGB = src[srcOff++]; + if (srcRGB != 0) { + int dstRGB = dst[dstOff]; + dst[dstOff++] = (((((srcRGB & 0xff00ff) * alpha) + ((dstRGB & 0xff00ff) * invAlpha)) & 0xff00ff00) + ((((srcRGB & 0xff00) * alpha) + ((dstRGB & 0xff00) * invAlpha)) & 0xff0000)) >> 8; } else { - l1++; + dstOff++; } } - l1 += j1; - i += l; + dstOff += dstStep; + srcOff += srcstep; } } - public void method352(int i, int j, int[] ai, int k, int[] ai1, int i1, int j1, int k1, int l1, int i2) { + public void drawRotatedMasked(int x, int y, int width, int height, int anchorX, int anchorY, int zoom, int angle, int[] lineLengths, int[] lineOffsets) { try { - int j2 = -l1 / 2; - int k2 = -i / 2; - int l2 = (int) (Math.sin((double) j / 326.11000000000001D) * 65536D); - int i3 = (int) (Math.cos((double) j / 326.11000000000001D) * 65536D); - l2 = (l2 * k) >> 8; - i3 = (i3 * k) >> 8; - int j3 = (i2 << 16) + ((k2 * l2) + (j2 * i3)); - int k3 = (i1 << 16) + ((k2 * i3) - (j2 * l2)); - int l3 = k1 + (j1 * Draw2D.width); - for (j1 = 0; j1 < i; j1++) { - int i4 = ai1[j1]; - int j4 = l3 + i4; - int k4 = j3 + (i3 * i4); - int l4 = k3 - (l2 * i4); - for (k1 = -ai[j1]; k1 < 0; k1++) { - Draw2D.pixels[j4++] = anIntArray1439[(k4 >> 16) + ((l4 >> 16) * anInt1440)]; - k4 += i3; - l4 -= l2; + int midX = -width / 2; + int midY = -height / 2; + int sin = (int) (Math.sin((double) angle / 326.11000000000001D) * 65536D); + int cos = (int) (Math.cos((double) angle / 326.11000000000001D) * 65536D); + sin = (sin * zoom) >> 8; + cos = (cos * zoom) >> 8; + int leftX = (anchorX << 16) + ((midY * sin) + (midX * cos)); + int lefty = (anchorY << 16) + ((midY * cos) - (midX * sin)); + int leftOff = x + (y * Draw2D.width); + for (y = 0; y < height; y++) { + int lineOffset = lineOffsets[y]; + int dstOff = leftOff + lineOffset; + int srcX = leftX + (cos * lineOffset); + int srcY = lefty - (sin * lineOffset); + for (x = -lineLengths[y]; x < 0; x++) { + Draw2D.pixels[dstOff++] = pixels[(srcX >> 16) + ((srcY >> 16) * this.width)]; + srcX += cos; + srcY -= sin; } - j3 += l2; - k3 += i3; - l3 += Draw2D.width; + leftX += sin; + lefty += cos; + leftOff += Draw2D.width; } } catch (Exception ignored) { } } - public void method353(int i, int j, int k, int l, int j1, int k1, double d, int l1) { + public void drawRotated(int x, int y, int width, int height, int anchorX, int anchorY, double radians, int zoom) { try { - int i2 = -k / 2; - int j2 = -k1 / 2; - int k2 = (int) (Math.sin(d) * 65536D); - int l2 = (int) (Math.cos(d) * 65536D); - k2 = (k2 * j1) >> 8; - l2 = (l2 * j1) >> 8; - int i3 = (l << 16) + ((j2 * k2) + (i2 * l2)); - int j3 = (j << 16) + ((j2 * l2) - (i2 * k2)); - int k3 = l1 + (i * Draw2D.width); - for (i = 0; i < k1; i++) { - int l3 = k3; - int i4 = i3; - int j4 = j3; - for (l1 = -k; l1 < 0; l1++) { - int k4 = anIntArray1439[(i4 >> 16) + ((j4 >> 16) * anInt1440)]; - if (k4 != 0) { - Draw2D.pixels[l3++] = k4; + int centerX = -width / 2; + int centerY = -height / 2; + int sin = (int) (Math.sin(radians) * 65536D); + int cos = (int) (Math.cos(radians) * 65536D); + sin = (sin * zoom) >> 8; + cos = (cos * zoom) >> 8; + int leftX = (anchorX << 16) + ((centerY * sin) + (centerX * cos)); + int leftY = (anchorY << 16) + ((centerY * cos) - (centerX * sin)); + int leftOff = x + (y * Draw2D.width); + + for (y = 0; y < height; y++) { + int dstOff = leftOff; + int dstX = leftX; + int dstY = leftY; + for (x = -width; x < 0; x++) { + int rgb = pixels[(dstX >> 16) + ((dstY >> 16) * this.width)]; + if (rgb != 0) { + Draw2D.pixels[dstOff++] = rgb; } else { - l3++; + dstOff++; } - i4 += l2; - j4 -= k2; + dstX += cos; + dstY -= sin; } - i3 += k2; - j3 += l2; - k3 += Draw2D.width; + leftX += sin; + leftY += cos; + leftOff += Draw2D.width; } } catch (Exception ignored) { } } - public void method354(Image8 image, int i, int j) { - j += anInt1442; - i += anInt1443; - int k = j + (i * Draw2D.width); - int l = 0; - int i1 = anInt1441; - int j1 = anInt1440; - int k1 = Draw2D.width - j1; - int l1 = 0; - if (i < Draw2D.top) { - int i2 = Draw2D.top - i; - i1 -= i2; - i = Draw2D.top; - l += i2 * j1; - k += i2 * Draw2D.width; + public void drawMasked(Image8 mask, int y, int x) { + x += cropX; + y += cropY; + int dstOff = x + (y * Draw2D.width); + int srcOff = 0; + int h = height; + int w = width; + int dstStep = Draw2D.width - w; + int srcStep = 0; + if (y < Draw2D.top) { + int trim = Draw2D.top - y; + h -= trim; + y = Draw2D.top; + srcOff += trim * w; + dstOff += trim * Draw2D.width; } - if ((i + i1) > Draw2D.bottom) { - i1 -= (i + i1) - Draw2D.bottom; + if ((y + h) > Draw2D.bottom) { + h -= (y + h) - Draw2D.bottom; } - if (j < Draw2D.left) { - int j2 = Draw2D.left - j; - j1 -= j2; - j = Draw2D.left; - l += j2; - k += j2; - l1 += j2; - k1 += j2; + if (x < Draw2D.left) { + int trim = Draw2D.left - x; + w -= trim; + x = Draw2D.left; + srcOff += trim; + dstOff += trim; + srcStep += trim; + dstStep += trim; } - if ((j + j1) > Draw2D.right) { - int k2 = (j + j1) - Draw2D.right; - j1 -= k2; - l1 += k2; - k1 += k2; + if ((x + w) > Draw2D.right) { + int trim = (x + w) - Draw2D.right; + w -= trim; + srcStep += trim; + dstStep += trim; } - if ((j1 <= 0) || (i1 <= 0)) { - } else { - method355(anIntArray1439, j1, image.pixels, i1, Draw2D.pixels, k1, k, l1, l); + if ((w > 0) && (h > 0)) { + copyPixelsMasked(pixels, srcOff, srcStep, mask.pixels, w, h, Draw2D.pixels, dstOff, dstStep); } } - public void method355(int[] ai, int i, byte[] abyte0, int j, int[] ai1, int l, int i1, int j1, int k1) { - int l1 = -(i >> 2); - i = -(i & 3); - for (int j2 = -j; j2 < 0; j2++) { - int k; - for (int k2 = l1; k2 < 0; k2++) { - k = ai[k1++]; - if ((k != 0) && (abyte0[i1] == 0)) { - ai1[i1++] = k; + public void copyPixelsMasked(int[] src, int srcOff, int srcStep, byte[] mask, int w, int h, int[] dst, int dstOff, int dstStep) { + int quarterW = -(w >> 2); + w = -(w & 3); + for (int y = -h; y < 0; y++) { + int rgb; + for (int k2 = quarterW; k2 < 0; k2++) { + rgb = src[srcOff++]; + if ((rgb != 0) && (mask[dstOff] == 0)) { + dst[dstOff++] = rgb; } else { - i1++; + dstOff++; } - k = ai[k1++]; - if ((k != 0) && (abyte0[i1] == 0)) { - ai1[i1++] = k; + rgb = src[srcOff++]; + if ((rgb != 0) && (mask[dstOff] == 0)) { + dst[dstOff++] = rgb; } else { - i1++; + dstOff++; } - k = ai[k1++]; - if ((k != 0) && (abyte0[i1] == 0)) { - ai1[i1++] = k; + rgb = src[srcOff++]; + if ((rgb != 0) && (mask[dstOff] == 0)) { + dst[dstOff++] = rgb; } else { - i1++; + dstOff++; } - k = ai[k1++]; - if ((k != 0) && (abyte0[i1] == 0)) { - ai1[i1++] = k; + rgb = src[srcOff++]; + if ((rgb != 0) && (mask[dstOff] == 0)) { + dst[dstOff++] = rgb; } else { - i1++; + dstOff++; } } - for (int l2 = i; l2 < 0; l2++) { - k = ai[k1++]; - if ((k != 0) && (abyte0[i1] == 0)) { - ai1[i1++] = k; + for (int l2 = w; l2 < 0; l2++) { + rgb = src[srcOff++]; + if ((rgb != 0) && (mask[dstOff] == 0)) { + dst[dstOff++] = rgb; } else { - i1++; + dstOff++; } } - i1 += l; - k1 += j1; + dstOff += dstStep; + srcOff += srcStep; } } diff --git a/src/main/java/Image8.java b/src/main/java/Image8.java index cb46508..a0e4a29 100644 --- a/src/main/java/Image8.java +++ b/src/main/java/Image8.java @@ -4,8 +4,8 @@ public class Image8 { public final int[] palette; public byte[] pixels; - public int anInt1452; - public int anInt1453; + public int width; + public int height; public int anInt1454; public int anInt1455; public int anInt1456; @@ -29,10 +29,10 @@ public class Image8 { } anInt1454 = buffer_1.get1U(); anInt1455 = buffer_1.get1U(); - anInt1452 = buffer_1.get2U(); - anInt1453 = buffer_1.get2U(); + width = buffer_1.get2U(); + height = buffer_1.get2U(); int i1 = buffer_1.get1U(); - int j1 = anInt1452 * anInt1453; + int j1 = width * height; pixels = new byte[j1]; if (i1 == 0) { for (int k1 = 0; k1 < j1; k1++) { @@ -41,9 +41,9 @@ public class Image8 { return; } if (i1 == 1) { - for (int l1 = 0; l1 < anInt1452; l1++) { - for (int i2 = 0; i2 < anInt1453; i2++) { - pixels[l1 + (i2 * anInt1452)] = buffer.get1(); + for (int l1 = 0; l1 < width; l1++) { + for (int i2 = 0; i2 < height; i2++) { + pixels[l1 + (i2 * width)] = buffer.get1(); } } } @@ -54,58 +54,58 @@ public class Image8 { anInt1457 /= 2; byte[] abyte0 = new byte[anInt1456 * anInt1457]; int i = 0; - for (int j = 0; j < anInt1453; j++) { - for (int k = 0; k < anInt1452; k++) { + for (int j = 0; j < height; j++) { + for (int k = 0; k < width; k++) { abyte0[((k + anInt1454) >> 1) + (((j + anInt1455) >> 1) * anInt1456)] = pixels[i++]; } } pixels = abyte0; - anInt1452 = anInt1456; - anInt1453 = anInt1457; + width = anInt1456; + height = anInt1457; anInt1454 = 0; anInt1455 = 0; } public void method357() { - if ((anInt1452 == anInt1456) && (anInt1453 == anInt1457)) { + if ((width == anInt1456) && (height == anInt1457)) { return; } byte[] abyte0 = new byte[anInt1456 * anInt1457]; int i = 0; - for (int j = 0; j < anInt1453; j++) { - for (int k = 0; k < anInt1452; k++) { + for (int j = 0; j < height; j++) { + for (int k = 0; k < width; k++) { abyte0[k + anInt1454 + ((j + anInt1455) * anInt1456)] = pixels[i++]; } } pixels = abyte0; - anInt1452 = anInt1456; - anInt1453 = anInt1457; + width = anInt1456; + height = anInt1457; anInt1454 = 0; anInt1455 = 0; } public void method358() { - byte[] abyte0 = new byte[anInt1452 * anInt1453]; + byte[] abyte0 = new byte[width * height]; int j = 0; - for (int k = 0; k < anInt1453; k++) { - for (int l = anInt1452 - 1; l >= 0; l--) { - abyte0[j++] = pixels[l + (k * anInt1452)]; + for (int k = 0; k < height; k++) { + for (int l = width - 1; l >= 0; l--) { + abyte0[j++] = pixels[l + (k * width)]; } } pixels = abyte0; - anInt1454 = anInt1456 - anInt1452 - anInt1454; + anInt1454 = anInt1456 - width - anInt1454; } public void method359() { - byte[] abyte0 = new byte[anInt1452 * anInt1453]; + byte[] abyte0 = new byte[width * height]; int i = 0; - for (int j = anInt1453 - 1; j >= 0; j--) { - for (int k = 0; k < anInt1452; k++) { - abyte0[i++] = pixels[k + (j * anInt1452)]; + for (int j = height - 1; j >= 0; j--) { + for (int k = 0; k < width; k++) { + abyte0[i++] = pixels[k + (j * width)]; } } pixels = abyte0; - anInt1455 = anInt1457 - anInt1453 - anInt1455; + anInt1455 = anInt1457 - height - anInt1455; } public void method360(int i, int j, int k) { @@ -135,46 +135,46 @@ public class Image8 { } } - public void method361(int i, int k) { - i += anInt1454; - k += anInt1455; - int l = i + (k * Draw2D.width); + public void blit(int x, int y) { + x += anInt1454; + y += anInt1455; + int l = x + (y * Draw2D.width); int i1 = 0; - int j1 = anInt1453; - int k1 = anInt1452; + int j1 = height; + int k1 = width; int l1 = Draw2D.width - k1; int i2 = 0; - if (k < Draw2D.top) { - int j2 = Draw2D.top - k; + if (y < Draw2D.top) { + int j2 = Draw2D.top - y; j1 -= j2; - k = Draw2D.top; + y = Draw2D.top; i1 += j2 * k1; l += j2 * Draw2D.width; } - if ((k + j1) > Draw2D.bottom) { - j1 -= (k + j1) - Draw2D.bottom; + if ((y + j1) > Draw2D.bottom) { + j1 -= (y + j1) - Draw2D.bottom; } - if (i < Draw2D.left) { - int k2 = Draw2D.left - i; + if (x < Draw2D.left) { + int k2 = Draw2D.left - x; k1 -= k2; - i = Draw2D.left; + x = Draw2D.left; i1 += k2; l += k2; i2 += k2; l1 += k2; } - if ((i + k1) > Draw2D.right) { - int l2 = (i + k1) - Draw2D.right; + if ((x + k1) > Draw2D.right) { + int l2 = (x + k1) - Draw2D.right; k1 -= l2; i2 += l2; l1 += l2; } if ((k1 > 0) && (j1 > 0)) { - method362(j1, Draw2D.pixels, pixels, l1, l, k1, i1, palette, i2); + blit(j1, Draw2D.pixels, pixels, l1, l, k1, i1, palette, i2); } } - public void method362(int i, int[] ai, byte[] abyte0, int j, int k, int l, int i1, int[] ai1, int j1) { + public void blit(int i, int[] ai, byte[] abyte0, int j, int k, int l, int i1, int[] ai1, int j1) { int k1 = -(l >> 2); l = -(l & 3); for (int l1 = -i; l1 < 0; l1++) { diff --git a/src/main/java/LocEntity.java b/src/main/java/LocEntity.java index e53805c..4ccb707 100644 --- a/src/main/java/LocEntity.java +++ b/src/main/java/LocEntity.java @@ -4,7 +4,7 @@ public class LocEntity extends Entity { - public static Game aGame1609; + public static Game game; public final int[] anIntArray1600; public final int anInt1601; public final int anInt1602; @@ -32,8 +32,8 @@ public class LocEntity extends Entity { anInt1599 = 0; anInt1608 = Game.loopCycle; if (flag && (aType_1607.anInt356 != -1)) { - anInt1599 = (int) (Math.random() * (double) aType_1607.anInt352); - anInt1608 -= (int) (Math.random() * (double) aType_1607.method258(anInt1599)); + anInt1599 = (int) (Math.random() * (double) aType_1607.frameCount); + anInt1608 -= (int) (Math.random() * (double) aType_1607.getFrameDelay(anInt1599)); } } LocType type = LocType.method572(anInt1610); @@ -50,14 +50,14 @@ public class LocEntity extends Entity { if ((k > 100) && (aType_1607.anInt356 > 0)) { k = 100; } - while (k > aType_1607.method258(anInt1599)) { - k -= aType_1607.method258(anInt1599); + while (k > aType_1607.getFrameDelay(anInt1599)) { + k -= aType_1607.getFrameDelay(anInt1599); anInt1599++; - if (anInt1599 < aType_1607.anInt352) { + if (anInt1599 < aType_1607.frameCount) { continue; } anInt1599 -= aType_1607.anInt356; - if ((anInt1599 >= 0) && (anInt1599 < aType_1607.anInt352)) { + if ((anInt1599 >= 0) && (anInt1599 < aType_1607.frameCount)) { continue; } aType_1607 = null; @@ -65,7 +65,7 @@ public class LocEntity extends Entity { } anInt1608 = Game.loopCycle - k; if (aType_1607 != null) { - j = aType_1607.anIntArray353[anInt1599]; + j = aType_1607.primaryFrames[anInt1599]; } } LocType type; @@ -84,14 +84,14 @@ public class LocEntity extends Entity { public LocType method457() { int i = -1; if (anInt1601 != -1) { - VarbitType varbit = VarbitType.aVarbitArray646[anInt1601]; - int k = varbit.anInt648; - int l = varbit.anInt649; - int i1 = varbit.anInt650; - int j1 = Game.anIntArray1232[i1 - l]; - i = (aGame1609.anIntArray971[k] >> l) & j1; + 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.anIntArray971[k] >> l) & j1; } else if (anInt1602 != -1) { - i = aGame1609.anIntArray971[anInt1602]; + i = game.anIntArray971[anInt1602]; } if ((i < 0) || (i >= anIntArray1600.length) || (anIntArray1600[i] == -1)) { return null; diff --git a/src/main/java/LocType.java b/src/main/java/LocType.java index 39178bb..74e06b3 100644 --- a/src/main/java/LocType.java +++ b/src/main/java/LocType.java @@ -13,7 +13,7 @@ public class LocType { public static Buffer aBuffer_753; public static int[] anIntArray755; public static int anInt756; - public static Game aGame765; + public static Game game; public static int anInt771; public static LRUMap aCache_780 = new LRUMap(30); public static LocType[] aTypeArray782; @@ -205,14 +205,14 @@ public class LocType { public LocType method580() { int i = -1; if (anInt774 != -1) { - VarbitType varbit = VarbitType.aVarbitArray646[anInt774]; - int j = varbit.anInt648; - int k = varbit.anInt649; - int l = varbit.anInt650; - int i1 = Game.anIntArray1232[l - k]; - i = (aGame765.anIntArray971[j] >> k) & i1; + VarbitType varbit = VarbitType.instances[anInt774]; + int j = varbit.varp; + int k = varbit.lsb; + int l = varbit.msb; + int i1 = Game.BITMASK[l - k]; + i = (game.anIntArray971[j] >> k) & i1; } else if (anInt749 != -1) { - i = aGame765.anIntArray971[anInt749]; + i = game.anIntArray971[anInt749]; } if ((i < 0) || (i >= anIntArray759.length) || (anIntArray759[i] == -1)) { return null; diff --git a/src/main/java/NPCEntity.java b/src/main/java/NPCEntity.java index 0376a94..66014a5 100644 --- a/src/main/java/NPCEntity.java +++ b/src/main/java/NPCEntity.java @@ -4,30 +4,30 @@ public class NPCEntity extends PathingEntity { - public NPCType aType_1696; + public NPCType type; public NPCEntity() { } public Model method450() { if ((super.anInt1526 >= 0) && (super.anInt1529 == 0)) { - int k = SeqType.instances[super.anInt1526].anIntArray353[super.anInt1527]; + int k = SeqType.instances[super.anInt1526].primaryFrames[super.anInt1527]; int i1 = -1; - if ((super.anInt1517 >= 0) && (super.anInt1517 != super.anInt1511)) { - i1 = SeqType.instances[super.anInt1517].anIntArray353[super.anInt1518]; + if ((super.seqCurrent >= 0) && (super.seqCurrent != super.seqStand)) { + i1 = SeqType.instances[super.seqCurrent].primaryFrames[super.seqFrame]; } - return aType_1696.method164(i1, k, SeqType.instances[super.anInt1526].anIntArray357); + return type.method164(i1, k, SeqType.instances[super.anInt1526].anIntArray357); } int l = -1; - if (super.anInt1517 >= 0) { - l = SeqType.instances[super.anInt1517].anIntArray353[super.anInt1518]; + if (super.seqCurrent >= 0) { + l = SeqType.instances[super.seqCurrent].primaryFrames[super.seqFrame]; } - return aType_1696.method164(-1, l, null); + return type.method164(-1, l, null); } @Override public Model getModel() { - if (aType_1696 == null) { + if (type == null) { return null; } Model model = method450(); @@ -35,11 +35,11 @@ public class NPCEntity extends PathingEntity { return null; } super.anInt1507 = model.minY; - if ((super.anInt1520 != -1) && (super.anInt1521 != -1)) { - SpotAnimType type = SpotAnimType.instances[super.anInt1520]; + if ((super.spotanim != -1) && (super.spotanimFrame != -1)) { + SpotAnimType type = SpotAnimType.instances[super.spotanim]; Model model_1 = type.method266(); if (model_1 != null) { - int j = type.aType_407.anIntArray353[super.anInt1521]; + int j = type.seq.primaryFrames[super.spotanimFrame]; Model class30_sub2_sub4_sub6_2 = new Model(true, SeqFrame.isNull(j), false, model_1); class30_sub2_sub4_sub6_2.translate(0, -super.anInt1524, 0); class30_sub2_sub4_sub6_2.createLabelReferences(); @@ -54,7 +54,7 @@ public class NPCEntity extends PathingEntity { model = new Model(2, -819, aclass30_sub2_sub4_sub6); } } - if (aType_1696.aByte68 == 1) { + if (type.size == 1) { model.pickBounds = true; } return model; @@ -62,7 +62,7 @@ public class NPCEntity extends PathingEntity { @Override public boolean method449() { - return aType_1696 != null; + return type != null; } } diff --git a/src/main/java/NPCType.java b/src/main/java/NPCType.java index 95b96b2..cd49a5f 100644 --- a/src/main/java/NPCType.java +++ b/src/main/java/NPCType.java @@ -8,78 +8,79 @@ import java.io.IOException; public class NPCType { - public static int anInt56; - public static Buffer aBuffer_60; - public static int anInt62; - public static int[] anIntArray72; - public static NPCType[] aTypeArray80; - public static Game aGame82; + private static int cachePosition; + private static Buffer dat; + public static int[] offsets; + private static NPCType[] cache; + public static Game game; public static LRUMap modelCache = new LRUMap<>(30); - public static NPCType method159(int i) { - if (i > aTypeArray80.length) { - i = 0; + public static NPCType get(int id) { + if (id > cache.length) { + id = 0; } - for (int j = 0; j < 20; j++) { - if (aTypeArray80[j].aLong78 == (long) i) { - return aTypeArray80[j]; + if (cache[j].uid == (long) id) { + return cache[j]; } } - anInt56 = (anInt56 + 1) % 20; - NPCType type = aTypeArray80[anInt56] = new NPCType(); - aBuffer_60.position = anIntArray72[i]; - type.aLong78 = i; - type.method165(aBuffer_60); + cachePosition = (cachePosition + 1) % 20; + NPCType type = cache[cachePosition] = new NPCType(); + dat.position = offsets[id]; + type.uid = id; + type.read(dat); return type; } public static void unpack(FileArchive archive) throws IOException { - aBuffer_60 = new Buffer(archive.read("npc.dat")); + dat = new Buffer(archive.read("npc.dat")); Buffer buffer = new Buffer(archive.read("npc.idx")); - anInt62 = buffer.get2U(); - anIntArray72 = new int[anInt62]; - int i = 2; - for (int j = 0; j < anInt62; j++) { - anIntArray72[j] = i; - i += buffer.get2U(); + int count = buffer.get2U(); + offsets = new int[count]; + + int offset = 2; + for (int i = 0; i < count; i++) { + offsets[i] = offset; + offset += buffer.get2U(); } - aTypeArray80 = new NPCType[20]; + + cache = new NPCType[20]; + for (int k = 0; k < 20; k++) { - aTypeArray80[k] = new NPCType(); + cache[k] = new NPCType(); } } public static void unload() { modelCache = null; - anIntArray72 = null; - aTypeArray80 = null; - aBuffer_60 = null; + offsets = null; + cache = null; + dat = null; } - public int anInt55 = -1; - public int anInt57 = -1; - public int anInt58 = -1; - public int anInt59 = -1; + public int seqTurnRight = -1; + public int varbit = -1; + public int seqTurnAround = -1; + public int varp = -1; public int anInt61 = -1; public String aString65; public String[] aStringArray66; - public int anInt67 = -1; - public byte aByte68 = 1; + public int seqWalk = -1; + public byte size = 1; public int[] anIntArray70; public int unusedInt0 = -1; public int[] anIntArray73; public int anInt75 = -1; public int[] anIntArray76; - public int anInt77 = -1; - public long aLong78 = -1L; - public int anInt79 = 32; - public int anInt83 = -1; + public int seqStand = -1; + public long uid = -1L; + public int turnSpeed = 32; + public int seqTurnLeft = -1; public boolean aBoolean84 = true; public int anInt85; public int anInt86 = 128; public boolean aBoolean87 = true; - public int[] anIntArray88; + public int[] overrides; public byte[] aByteArray89; public int unusedInt1 = -1; public int anInt91 = 128; @@ -92,8 +93,8 @@ public class NPCType { } public Model method160() { - if (anIntArray88 != null) { - NPCType type = method161(); + if (overrides != null) { + NPCType type = getOverrideType(); if (type == null) { return null; } else { @@ -130,35 +131,39 @@ public class NPCType { return model; } - public NPCType method161() { - int j = -1; - if (anInt57 != -1) { - VarbitType varbit = VarbitType.aVarbitArray646[anInt57]; - int k = varbit.anInt648; - int l = varbit.anInt649; - int i1 = varbit.anInt650; - int j1 = Game.anIntArray1232[i1 - l]; - j = (aGame82.anIntArray971[k] >> l) & j1; - } else if (anInt59 != -1) { - j = aGame82.anIntArray971[anInt59]; + public NPCType getOverrideType() { + int value = -1; + + if (varbit != -1) { + VarbitType vb = VarbitType.instances[this.varbit]; + int varp = vb.varp; + int lsb = vb.lsb; + int msb = vb.msb; + int mask = Game.BITMASK[msb - lsb]; + value = (game.anIntArray971[varp] >> lsb) & mask; + } else if (varp != -1) { + value = game.anIntArray971[varp]; } - if ((j < 0) || (j >= anIntArray88.length) || (anIntArray88[j] == -1)) { + + if ((value < 0) || (value >= overrides.length) || (overrides[value] == -1)) { return null; } else { - return method159(anIntArray88[j]); + return get(overrides[value]); } } public Model method164(int j, int k, int[] ai) { - if (anIntArray88 != null) { - NPCType type = method161(); + if (overrides != null) { + NPCType type = getOverrideType(); if (type == null) { return null; } else { return type.method164(j, k, ai); } } - Model model = modelCache.get(aLong78); + + Model model = modelCache.get(uid); + if (model == null) { boolean flag = false; for (int value : anIntArray94) { @@ -185,7 +190,7 @@ public class NPCType { } model.createLabelReferences(); model.calculateNormals(64 + anInt85, 850 + anInt92, -30, -50, -30, true); - modelCache.put(aLong78, model); + modelCache.put(uid, model); } Model model_1 = Model.EMPTY; model_1.set(model, SeqFrame.isNull(k) & SeqFrame.isNull(j)); @@ -200,13 +205,13 @@ public class NPCType { model_1.calculateBoundsCylinder(); model_1.labelFaces = null; model_1.labelVertices = null; - if (aByte68 == 1) { + if (size == 1) { model_1.pickBounds = true; } return model_1; } - public void method165(Buffer buffer) { + public void read(Buffer buffer) { do { int i = buffer.get1U(); if (i == 0) { @@ -223,16 +228,16 @@ public class NPCType { } else if (i == 3) { aByteArray89 = buffer.getStringRaw(); } else if (i == 12) { - aByte68 = buffer.get1(); + size = buffer.get1(); } else if (i == 13) { - anInt77 = buffer.get2U(); + seqStand = buffer.get2U(); } else if (i == 14) { - anInt67 = buffer.get2U(); + seqWalk = buffer.get2U(); } else if (i == 17) { - anInt67 = buffer.get2U(); - anInt58 = buffer.get2U(); - anInt83 = buffer.get2U(); - anInt55 = buffer.get2U(); + seqWalk = buffer.get2U(); + seqTurnAround = buffer.get2U(); + seqTurnLeft = buffer.get2U(); + seqTurnRight = buffer.get2U(); } else if ((i >= 30) && (i < 40)) { if (aStringArray66 == null) { aStringArray66 = new String[5]; @@ -278,22 +283,22 @@ public class NPCType { } else if (i == 102) { anInt75 = buffer.get2U(); } else if (i == 103) { - anInt79 = buffer.get2U(); + turnSpeed = buffer.get2U(); } else if (i == 106) { - anInt57 = buffer.get2U(); - if (anInt57 == 65535) { - anInt57 = -1; + varbit = buffer.get2U(); + if (varbit == 65535) { + varbit = -1; } - anInt59 = buffer.get2U(); - if (anInt59 == 65535) { - anInt59 = -1; + varp = buffer.get2U(); + if (varp == 65535) { + varp = -1; } int i1 = buffer.get1U(); - anIntArray88 = new int[i1 + 1]; + overrides = new int[i1 + 1]; for (int i2 = 0; i2 <= i1; i2++) { - anIntArray88[i2] = buffer.get2U(); - if (anIntArray88[i2] == 65535) { - anIntArray88[i2] = -1; + overrides[i2] = buffer.get2U(); + if (overrides[i2] == 65535) { + overrides[i2] = -1; } } } else if (i == 107) { diff --git a/src/main/java/ObjType.java b/src/main/java/ObjType.java index 11765ee..933f7e2 100644 --- a/src/main/java/ObjType.java +++ b/src/main/java/ObjType.java @@ -69,7 +69,7 @@ public class ObjType { public static Image24 method200(int i, int j, int k) { if (k == 0) { Image24 image = iconCache.get(i); - if ((image != null) && (image.anInt1445 != j) && (image.anInt1445 != -1)) { + if ((image != null) && (image.cropH != j) && (image.cropH != -1)) { image.unlink(); image = null; } @@ -115,7 +115,7 @@ public class ObjType { int i3 = Draw2D.top; int j3 = Draw2D.bottom; Draw3D.jagged = false; - Draw2D.bind(class30_sub2_sub1_sub1_1.anIntArray1439, 32, 32); + Draw2D.bind(class30_sub2_sub1_sub1_1.pixels, 32, 32); Draw2D.fillRect(0, 0, 32, 32, 0); Draw3D.init2D(); int k3 = type.anInt181; @@ -130,15 +130,15 @@ public class ObjType { model.drawSimple(0, type.anInt198, type.anInt204, type.anInt190, type.anInt169, l3 + (model.minY / 2) + type.anInt194, i4 + type.anInt194); for (int i5 = 31; i5 >= 0; i5--) { for (int j4 = 31; j4 >= 0; j4--) { - if (class30_sub2_sub1_sub1_1.anIntArray1439[i5 + (j4 * 32)] == 0) { - if ((i5 > 0) && (class30_sub2_sub1_sub1_1.anIntArray1439[(i5 - 1) + (j4 * 32)] > 1)) { - class30_sub2_sub1_sub1_1.anIntArray1439[i5 + (j4 * 32)] = 1; - } else if ((j4 > 0) && (class30_sub2_sub1_sub1_1.anIntArray1439[i5 + ((j4 - 1) * 32)] > 1)) { - class30_sub2_sub1_sub1_1.anIntArray1439[i5 + (j4 * 32)] = 1; - } else if ((i5 < 31) && (class30_sub2_sub1_sub1_1.anIntArray1439[i5 + 1 + (j4 * 32)] > 1)) { - class30_sub2_sub1_sub1_1.anIntArray1439[i5 + (j4 * 32)] = 1; - } else if ((j4 < 31) && (class30_sub2_sub1_sub1_1.anIntArray1439[i5 + ((j4 + 1) * 32)] > 1)) { - class30_sub2_sub1_sub1_1.anIntArray1439[i5 + (j4 * 32)] = 1; + if (class30_sub2_sub1_sub1_1.pixels[i5 + (j4 * 32)] == 0) { + if ((i5 > 0) && (class30_sub2_sub1_sub1_1.pixels[(i5 - 1) + (j4 * 32)] > 1)) { + class30_sub2_sub1_sub1_1.pixels[i5 + (j4 * 32)] = 1; + } else if ((j4 > 0) && (class30_sub2_sub1_sub1_1.pixels[i5 + ((j4 - 1) * 32)] > 1)) { + class30_sub2_sub1_sub1_1.pixels[i5 + (j4 * 32)] = 1; + } else if ((i5 < 31) && (class30_sub2_sub1_sub1_1.pixels[i5 + 1 + (j4 * 32)] > 1)) { + class30_sub2_sub1_sub1_1.pixels[i5 + (j4 * 32)] = 1; + } else if ((j4 < 31) && (class30_sub2_sub1_sub1_1.pixels[i5 + ((j4 + 1) * 32)] > 1)) { + class30_sub2_sub1_sub1_1.pixels[i5 + (j4 * 32)] = 1; } } } @@ -146,15 +146,15 @@ public class ObjType { if (k > 0) { for (int j5 = 31; j5 >= 0; j5--) { for (int k4 = 31; k4 >= 0; k4--) { - if (class30_sub2_sub1_sub1_1.anIntArray1439[j5 + (k4 * 32)] == 0) { - if ((j5 > 0) && (class30_sub2_sub1_sub1_1.anIntArray1439[(j5 - 1) + (k4 * 32)] == 1)) { - class30_sub2_sub1_sub1_1.anIntArray1439[j5 + (k4 * 32)] = k; - } else if ((k4 > 0) && (class30_sub2_sub1_sub1_1.anIntArray1439[j5 + ((k4 - 1) * 32)] == 1)) { - class30_sub2_sub1_sub1_1.anIntArray1439[j5 + (k4 * 32)] = k; - } else if ((j5 < 31) && (class30_sub2_sub1_sub1_1.anIntArray1439[j5 + 1 + (k4 * 32)] == 1)) { - class30_sub2_sub1_sub1_1.anIntArray1439[j5 + (k4 * 32)] = k; - } else if ((k4 < 31) && (class30_sub2_sub1_sub1_1.anIntArray1439[j5 + ((k4 + 1) * 32)] == 1)) { - class30_sub2_sub1_sub1_1.anIntArray1439[j5 + (k4 * 32)] = k; + if (class30_sub2_sub1_sub1_1.pixels[j5 + (k4 * 32)] == 0) { + if ((j5 > 0) && (class30_sub2_sub1_sub1_1.pixels[(j5 - 1) + (k4 * 32)] == 1)) { + class30_sub2_sub1_sub1_1.pixels[j5 + (k4 * 32)] = k; + } else if ((k4 > 0) && (class30_sub2_sub1_sub1_1.pixels[j5 + ((k4 - 1) * 32)] == 1)) { + class30_sub2_sub1_sub1_1.pixels[j5 + (k4 * 32)] = k; + } else if ((j5 < 31) && (class30_sub2_sub1_sub1_1.pixels[j5 + 1 + (k4 * 32)] == 1)) { + class30_sub2_sub1_sub1_1.pixels[j5 + (k4 * 32)] = k; + } else if ((k4 < 31) && (class30_sub2_sub1_sub1_1.pixels[j5 + ((k4 + 1) * 32)] == 1)) { + class30_sub2_sub1_sub1_1.pixels[j5 + (k4 * 32)] = k; } } } @@ -162,20 +162,20 @@ public class ObjType { } else if (k == 0) { for (int k5 = 31; k5 >= 0; k5--) { for (int l4 = 31; l4 >= 0; l4--) { - if ((class30_sub2_sub1_sub1_1.anIntArray1439[k5 + (l4 * 32)] == 0) && (k5 > 0) && (l4 > 0) && (class30_sub2_sub1_sub1_1.anIntArray1439[(k5 - 1) + ((l4 - 1) * 32)] > 0)) { - class30_sub2_sub1_sub1_1.anIntArray1439[k5 + (l4 * 32)] = 0x302020; + if ((class30_sub2_sub1_sub1_1.pixels[k5 + (l4 * 32)] == 0) && (k5 > 0) && (l4 > 0) && (class30_sub2_sub1_sub1_1.pixels[(k5 - 1) + ((l4 - 1) * 32)] > 0)) { + class30_sub2_sub1_sub1_1.pixels[k5 + (l4 * 32)] = 0x302020; } } } } if (type.anInt163 != -1) { - int l5 = class30_sub2_sub1_sub1_2.anInt1444; - int j6 = class30_sub2_sub1_sub1_2.anInt1445; - class30_sub2_sub1_sub1_2.anInt1444 = 32; - class30_sub2_sub1_sub1_2.anInt1445 = 32; - class30_sub2_sub1_sub1_2.method348(0, 0); - class30_sub2_sub1_sub1_2.anInt1444 = l5; - class30_sub2_sub1_sub1_2.anInt1445 = j6; + int l5 = class30_sub2_sub1_sub1_2.cropW; + int j6 = class30_sub2_sub1_sub1_2.cropH; + class30_sub2_sub1_sub1_2.cropW = 32; + class30_sub2_sub1_sub1_2.cropH = 32; + class30_sub2_sub1_sub1_2.draw(0, 0); + class30_sub2_sub1_sub1_2.cropW = l5; + class30_sub2_sub1_sub1_2.cropH = j6; } if (k == 0) { iconCache.put(i, class30_sub2_sub1_sub1_1); @@ -187,11 +187,11 @@ public class ObjType { Draw3D.lineOffset = ai; Draw3D.jagged = true; if (type.aBoolean176) { - class30_sub2_sub1_sub1_1.anInt1444 = 33; + class30_sub2_sub1_sub1_1.cropW = 33; } else { - class30_sub2_sub1_sub1_1.anInt1444 = 32; + class30_sub2_sub1_sub1_1.cropW = 32; } - class30_sub2_sub1_sub1_1.anInt1445 = j; + class30_sub2_sub1_sub1_1.cropH = j; return class30_sub2_sub1_sub1_1; } public byte aByte154; diff --git a/src/main/java/PathingEntity.java b/src/main/java/PathingEntity.java index 64934be..2143e33 100644 --- a/src/main/java/PathingEntity.java +++ b/src/main/java/PathingEntity.java @@ -4,31 +4,31 @@ public class PathingEntity extends Entity { - public final int[] moveQueueTileX = new int[10]; - public final int[] moveQueueTileZ = new int[10]; + public final int[] pathTileX = new int[10]; + public final int[] pathTileZ = new int[10]; public final int[] anIntArray1514 = new int[4]; public final int[] anIntArray1515 = new int[4]; public final int[] anIntArray1516 = new int[4]; - public final boolean[] aBooleanArray1553 = new boolean[10]; - public int anInt1502 = -1; + public final boolean[] pathRunning = new boolean[10]; + public int index = -1; public int anInt1503; - public int anInt1504 = 32; - public int anInt1505 = -1; + public int turnSpeed = 32; + public int seqRun = -1; public String aString1506; public int anInt1507 = 200; - public int anInt1510; - public int anInt1511 = -1; - public int anInt1512 = -1; + public int dstYaw; + public int seqStand = -1; + public int seqTurn = -1; public int anInt1513; - public int anInt1517 = -1; - public int anInt1518; - public int anInt1519; - public int anInt1520 = -1; - public int anInt1521; - public int anInt1522; + public int seqCurrent = -1; + public int seqFrame; + public int seqCycle; + public int spotanim = -1; + public int spotanimFrame; + public int spotanimCycle; public int anInt1523; public int anInt1524; - public int anInt1525; + public int pathRemaining; public int anInt1526 = -1; public int anInt1527; public int anInt1528; @@ -40,62 +40,65 @@ public class PathingEntity extends Entity { public int anInt1534; public int anInt1535 = 100; public int anInt1537; - public int anInt1538; - public int anInt1539; - public int anInt1540 = 1; + public int faceTileX; + public int faceTileZ; + public int size = 1; public boolean aBoolean1541 = false; public int anInt1542; - public int anInt1543; - public int anInt1544; - public int anInt1545; - public int anInt1546; - public int anInt1547; - public int anInt1548; - public int anInt1549; + public int forceMoveStartSceneTileX; + public int forceMoveEndSceneTileX; + public int forceMoveStartSceneTileZ; + public int forceMoveEndSceneTileZ; + public int forceMoveEndCycle; + public int forceMoveStartCycle; + public int forceMoveFaceDirection; public int x; public int z; - public int anInt1552; - public int anInt1554 = -1; - public int anInt1555 = -1; - public int anInt1556 = -1; - public int anInt1557 = -1; + public int yaw; + public int seqWalk = -1; + public int seqTurnAround = -1; + public int seqTurnLeft = -1; + public int seqTurnRight = -1; public PathingEntity() { } - public void method445(int i, int j, boolean flag) { + public void move(int x, int z, boolean teleport) { if ((anInt1526 != -1) && (SeqType.instances[anInt1526].anInt364 == 1)) { anInt1526 = -1; } - if (!flag) { - int k = i - moveQueueTileX[0]; - int l = j - moveQueueTileZ[0]; - if ((k >= -8) && (k <= 8) && (l >= -8) && (l <= 8)) { - if (anInt1525 < 9) { - anInt1525++; + if (!teleport) { + int dx = x - pathTileX[0]; + int dz = z - pathTileZ[0]; + + if ((dx >= -8) && (dx <= 8) && (dz >= -8) && (dz <= 8)) { + if (pathRemaining < 9) { + pathRemaining++; } - for (int i1 = anInt1525; i1 > 0; i1--) { - moveQueueTileX[i1] = moveQueueTileX[i1 - 1]; - moveQueueTileZ[i1] = moveQueueTileZ[i1 - 1]; - aBooleanArray1553[i1] = aBooleanArray1553[i1 - 1]; + + for (int i = pathRemaining; i > 0; i--) { + pathTileX[i] = pathTileX[i - 1]; + pathTileZ[i] = pathTileZ[i - 1]; + pathRunning[i] = pathRunning[i - 1]; } - moveQueueTileX[0] = i; - moveQueueTileZ[0] = j; - aBooleanArray1553[0] = false; + + pathTileX[0] = x; + pathTileZ[0] = z; + pathRunning[0] = false; return; } } - anInt1525 = 0; + pathRemaining = 0; anInt1542 = 0; anInt1503 = 0; - moveQueueTileX[0] = i; - moveQueueTileZ[0] = j; - x = (moveQueueTileX[0] * 128) + (anInt1540 * 64); - z = (moveQueueTileZ[0] * 128) + (anInt1540 * 64); + pathTileX[0] = x; + pathTileZ[0] = z; + this.x = (pathTileX[0] * 128) + (size * 64); + this.z = (pathTileZ[0] * 128) + (size * 64); } public void method446() { - anInt1525 = 0; + pathRemaining = 0; anInt1542 = 0; } @@ -111,8 +114,8 @@ public class PathingEntity extends Entity { } public void method448(boolean flag, int i) { - int j = moveQueueTileX[0]; - int k = moveQueueTileZ[0]; + int j = pathTileX[0]; + int k = pathTileZ[0]; if (i == 0) { j--; k++; @@ -144,17 +147,17 @@ public class PathingEntity extends Entity { if ((anInt1526 != -1) && (SeqType.instances[anInt1526].anInt364 == 1)) { anInt1526 = -1; } - if (anInt1525 < 9) { - anInt1525++; + if (pathRemaining < 9) { + pathRemaining++; } - for (int l = anInt1525; l > 0; l--) { - moveQueueTileX[l] = moveQueueTileX[l - 1]; - moveQueueTileZ[l] = moveQueueTileZ[l - 1]; - aBooleanArray1553[l] = aBooleanArray1553[l - 1]; + for (int l = pathRemaining; l > 0; l--) { + pathTileX[l] = pathTileX[l - 1]; + pathTileZ[l] = pathTileZ[l - 1]; + pathRunning[l] = pathRunning[l - 1]; } - moveQueueTileX[0] = j; - moveQueueTileZ[0] = k; - aBooleanArray1553[0] = flag; + pathTileX[0] = j; + pathTileZ[0] = k; + pathRunning[0] = flag; } public boolean method449() { diff --git a/src/main/java/PlayerEntity.java b/src/main/java/PlayerEntity.java index ced6ed7..47f8372 100644 --- a/src/main/java/PlayerEntity.java +++ b/src/main/java/PlayerEntity.java @@ -19,17 +19,17 @@ public class PlayerEntity extends PathingEntity { public int anInt1706; public int anInt1707; public int anInt1708; - public int anInt1709; + public int y; public boolean aBoolean1710 = false; public int anInt1711; public int anInt1712; public int anInt1713; - public Model aModel_1714; + public Model model; public long aLong1718; - public int anInt1719; - public int anInt1720; - public int anInt1721; - public int anInt1722; + public int minSceneTileX; + public int minSceneTileZ; + public int maxSceneTileX; + public int maxSceneTileZ; public int anInt1723; public PlayerEntity() { @@ -49,14 +49,14 @@ public class PlayerEntity extends PathingEntity { if (aBoolean1699) { return model; } - if ((super.anInt1520 != -1) && (super.anInt1521 != -1)) { - SpotAnimType type = SpotAnimType.instances[super.anInt1520]; + if ((super.spotanim != -1) && (super.spotanimFrame != -1)) { + SpotAnimType type = SpotAnimType.instances[super.spotanim]; Model class30_sub2_sub4_sub6_2 = type.method266(); if (class30_sub2_sub4_sub6_2 != null) { - Model model_3 = new Model(true, SeqFrame.isNull(super.anInt1521), false, class30_sub2_sub4_sub6_2); + Model model_3 = new Model(true, SeqFrame.isNull(super.spotanimFrame), false, class30_sub2_sub4_sub6_2); model_3.translate(0, -super.anInt1524, 0); model_3.createLabelReferences(); - model_3.applySequenceFrame(type.aType_407.anIntArray353[super.anInt1521]); + model_3.applySequenceFrame(type.seq.primaryFrames[super.spotanimFrame]); model_3.labelFaces = null; model_3.labelVertices = null; if ((type.anInt410 != 128) || (type.anInt411 != 128)) { @@ -67,36 +67,36 @@ public class PlayerEntity extends PathingEntity { model = new Model(2, -819, aclass30_sub2_sub4_sub6_1); } } - if (aModel_1714 != null) { + if (this.model != null) { if (Game.loopCycle >= anInt1708) { - aModel_1714 = null; + this.model = null; } if ((Game.loopCycle >= anInt1707) && (Game.loopCycle < anInt1708)) { - Model model_1 = aModel_1714; - model_1.translate(anInt1711 - super.x, anInt1712 - anInt1709, anInt1713 - super.z); - if (super.anInt1510 == 512) { + Model model_1 = this.model; + model_1.translate(anInt1711 - super.x, anInt1712 - y, anInt1713 - super.z); + if (super.dstYaw == 512) { model_1.rotateY90(); model_1.rotateY90(); model_1.rotateY90(); - } else if (super.anInt1510 == 1024) { + } else if (super.dstYaw == 1024) { model_1.rotateY90(); model_1.rotateY90(); - } else if (super.anInt1510 == 1536) { + } else if (super.dstYaw == 1536) { model_1.rotateY90(); } Model[] aclass30_sub2_sub4_sub6 = {model, model_1}; model = new Model(2, -819, aclass30_sub2_sub4_sub6); - if (super.anInt1510 == 512) { + if (super.dstYaw == 512) { model_1.rotateY90(); - } else if (super.anInt1510 == 1024) { + } else if (super.dstYaw == 1024) { model_1.rotateY90(); model_1.rotateY90(); - } else if (super.anInt1510 == 1536) { + } else if (super.dstYaw == 1536) { model_1.rotateY90(); model_1.rotateY90(); model_1.rotateY90(); } - model_1.translate(super.x - anInt1711, anInt1709 - anInt1712, super.z - anInt1713); + model_1.translate(super.x - anInt1711, y - anInt1712, super.z - anInt1713); } } model.pickBounds = true; @@ -118,7 +118,7 @@ public class PlayerEntity extends PathingEntity { int i1 = buffer.get1U(); anIntArray1717[j] = (k << 8) + i1; if ((j == 0) && (anIntArray1717[0] == 65535)) { - aType_1698 = NPCType.method159(buffer.get2U()); + aType_1698 = NPCType.get(buffer.get2U()); break; } if ((anIntArray1717[j] >= 512) && ((anIntArray1717[j] - 512) < ObjType.anInt203)) { @@ -135,33 +135,33 @@ public class PlayerEntity extends PathingEntity { } anIntArray1700[l] = j1; } - super.anInt1511 = buffer.get2U(); - if (super.anInt1511 == 65535) { - super.anInt1511 = -1; + super.seqStand = buffer.get2U(); + if (super.seqStand == 65535) { + super.seqStand = -1; } - super.anInt1512 = buffer.get2U(); - if (super.anInt1512 == 65535) { - super.anInt1512 = -1; + super.seqTurn = buffer.get2U(); + if (super.seqTurn == 65535) { + super.seqTurn = -1; } - super.anInt1554 = buffer.get2U(); - if (super.anInt1554 == 65535) { - super.anInt1554 = -1; + super.seqWalk = buffer.get2U(); + if (super.seqWalk == 65535) { + super.seqWalk = -1; } - super.anInt1555 = buffer.get2U(); - if (super.anInt1555 == 65535) { - super.anInt1555 = -1; + super.seqTurnAround = buffer.get2U(); + if (super.seqTurnAround == 65535) { + super.seqTurnAround = -1; } - super.anInt1556 = buffer.get2U(); - if (super.anInt1556 == 65535) { - super.anInt1556 = -1; + super.seqTurnLeft = buffer.get2U(); + if (super.seqTurnLeft == 65535) { + super.seqTurnLeft = -1; } - super.anInt1557 = buffer.get2U(); - if (super.anInt1557 == 65535) { - super.anInt1557 = -1; + super.seqTurnRight = buffer.get2U(); + if (super.seqTurnRight == 65535) { + super.seqTurnRight = -1; } - super.anInt1505 = buffer.get2U(); - if (super.anInt1505 == 65535) { - super.anInt1505 = -1; + super.seqRun = buffer.get2U(); + if (super.seqRun == 65535) { + super.seqRun = -1; } aString1703 = StringUtil.formatName(StringUtil.fromBase37(buffer.get8())); anInt1705 = buffer.get1U(); @@ -192,9 +192,9 @@ public class PlayerEntity extends PathingEntity { if (aType_1698 != null) { int j = -1; if ((super.anInt1526 >= 0) && (super.anInt1529 == 0)) { - j = SeqType.instances[super.anInt1526].anIntArray353[super.anInt1527]; - } else if (super.anInt1517 >= 0) { - j = SeqType.instances[super.anInt1517].anIntArray353[super.anInt1518]; + j = SeqType.instances[super.anInt1526].primaryFrames[super.anInt1527]; + } else if (super.seqCurrent >= 0) { + j = SeqType.instances[super.seqCurrent].primaryFrames[super.seqFrame]; } return aType_1698.method164(-1, j, null); } @@ -205,9 +205,9 @@ public class PlayerEntity extends PathingEntity { int k1 = -1; if ((super.anInt1526 >= 0) && (super.anInt1529 == 0)) { SeqType type = SeqType.instances[super.anInt1526]; - k = type.anIntArray353[super.anInt1527]; - if ((super.anInt1517 >= 0) && (super.anInt1517 != super.anInt1511)) { - i1 = SeqType.instances[super.anInt1517].anIntArray353[super.anInt1518]; + k = type.primaryFrames[super.anInt1527]; + if ((super.seqCurrent >= 0) && (super.seqCurrent != super.seqStand)) { + i1 = SeqType.instances[super.seqCurrent].primaryFrames[super.seqFrame]; } if (type.anInt360 >= 0) { j1 = type.anInt360; @@ -217,8 +217,8 @@ public class PlayerEntity extends PathingEntity { k1 = type.anInt361; l += ((long) k1 - anIntArray1717[3]) << 16; } - } else if (super.anInt1517 >= 0) { - k = SeqType.instances[super.anInt1517].anIntArray353[super.anInt1518]; + } else if (super.seqCurrent >= 0) { + k = SeqType.instances[super.seqCurrent].primaryFrames[super.seqFrame]; } Model model_1 = modelCache.get(l); if (model_1 == null) { diff --git a/src/main/java/ProjectileEntity.java b/src/main/java/ProjectileEntity.java index 7c0e3c7..8963d08 100644 --- a/src/main/java/ProjectileEntity.java +++ b/src/main/java/ProjectileEntity.java @@ -69,8 +69,8 @@ public class ProjectileEntity extends Entity { return null; } int j = -1; - if (aType_1592.aType_407 != null) { - j = aType_1592.aType_407.anIntArray353[anInt1593]; + if (aType_1592.seq != null) { + j = aType_1592.seq.primaryFrames[anInt1593]; } Model model_1 = new Model(true, SeqFrame.isNull(j), false, model); if (j != -1) { @@ -95,11 +95,11 @@ public class ProjectileEntity extends Entity { aDouble1577 += aDouble1578 * (double) i; anInt1595 = ((int) (Math.atan2(aDouble1574, aDouble1575) * 325.94900000000001D) + 1024) & 0x7ff; anInt1596 = (int) (Math.atan2(aDouble1577, aDouble1576) * 325.94900000000001D) & 0x7ff; - if (aType_1592.aType_407 != null) { - for (anInt1594 += i; anInt1594 > aType_1592.aType_407.method258(anInt1593); ) { - anInt1594 -= aType_1592.aType_407.method258(anInt1593) + 1; + if (aType_1592.seq != null) { + for (anInt1594 += i; anInt1594 > aType_1592.seq.getFrameDelay(anInt1593); ) { + anInt1594 -= aType_1592.seq.getFrameDelay(anInt1593) + 1; anInt1593++; - if (anInt1593 >= aType_1592.aType_407.anInt352) { + if (anInt1593 >= aType_1592.seq.frameCount) { anInt1593 = 0; } } diff --git a/src/main/java/Scene.java b/src/main/java/Scene.java index 077f6cd..e4dc912 100644 --- a/src/main/java/Scene.java +++ b/src/main/java/Scene.java @@ -19,11 +19,11 @@ public class Scene { public static final int[] anIntArray484 = {1, 1, 0, 0, 0, 8, 0, 0, 8}; public static final int[] anIntArray485 = {41, 39248, 41, 4643, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 43086, 41, 41, 41, 41, 41, 41, 41, 8602, 41, 28992, 41, 41, 41, 41, 41, 5056, 41, 41, 41, 7079, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 3131, 41, 41, 41}; public static final int anInt472 = 4; - public static final SceneOccluder[] A_OCCLUDER_ARRAY_476 = new SceneOccluder[500]; + public static final SceneOccluder[] activeOccluders = new SceneOccluder[500]; public static boolean lowmem = true; public static int anInt446; public static int anInt447; - public static int anInt448; + public static int cycle; public static int anInt449; public static int anInt450; public static int anInt451; @@ -37,7 +37,7 @@ public class Scene { public static int cosEyePitch; public static int sinEyeYaw; public static int cosEyeYaw; - public static SceneLoc[] aLocArray462 = new SceneLoc[100]; + public static SceneLoc[] tmp = new SceneLoc[100]; public static boolean aBoolean467; public static int anInt468; public static int anInt469; @@ -45,7 +45,7 @@ public class Scene { public static int anInt471 = -1; public static int[] anIntArray473 = new int[anInt472]; public static SceneOccluder[][] aOccluderArrayArray474 = new SceneOccluder[anInt472][500]; - public static int anInt475; + public static int activeOccluderCount; public static DoublyLinkedList aList_477 = new DoublyLinkedList(); public static boolean[][][][] aBooleanArrayArrayArrayArray491 = new boolean[8][32][51][51]; public static boolean[][] aBooleanArrayArray492; @@ -57,7 +57,7 @@ public class Scene { public static int anInt498; public static void unload() { - aLocArray462 = null; + tmp = null; anIntArray473 = null; aOccluderArrayArray474 = null; aList_477 = null; @@ -156,36 +156,37 @@ public class Scene { int i2 = anInt494 + ((k1 << 9) / j1); return (l1 >= anInt495) && (l1 <= anInt497) && (i2 >= anInt496) && (i2 <= anInt498); } - public final int anInt437; - public final int anInt438; - public final int anInt439; - public final int[][][] anIntArrayArrayArray440; - public final SceneTile[][][] aTileArrayArrayArray441; - public final SceneLoc[] aLocArray444 = new SceneLoc[5000]; - public final int[][][] anIntArrayArrayArray445; + + public final int maxPlane; + public final int maxTileX; + public final int maxTileZ; + public final int[][][] planeHeightmaps; + public final SceneTile[][][] planeTiles; + public final SceneLoc[] temporaryLocs = new SceneLoc[5000]; + public final int[][][] planeTileOcclusionCycles; public final int[] anIntArray486 = new int[10000]; public final int[] anIntArray487 = new int[10000]; public final int[][] anIntArrayArray489 = {new int[16], {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1}, {0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1}, {1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1}}; public final int[][] anIntArrayArray490 = {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, {12, 8, 4, 0, 13, 9, 5, 1, 14, 10, 6, 2, 15, 11, 7, 3}, {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, {3, 7, 11, 15, 2, 6, 10, 14, 1, 5, 9, 13, 0, 4, 8, 12}}; - public int anInt442; - public int anInt443; + public int minPlane; + public int temporaryLocCount; public int anInt488; - public Scene(int i, int j, int[][][] ai, int k) { - anInt437 = k; - anInt438 = j; - anInt439 = i; - aTileArrayArrayArray441 = new SceneTile[k][j][i]; - anIntArrayArrayArray445 = new int[k][j + 1][i + 1]; - anIntArrayArrayArray440 = ai; - method274(); + public Scene(int maxTileZ, int maxTileX, int[][][] planeHeightmaps, int maxPlane) { + this.maxPlane = maxPlane; + this.maxTileX = maxTileX; + this.maxTileZ = maxTileZ; + planeTiles = new SceneTile[maxPlane][maxTileX][maxTileZ]; + planeTileOcclusionCycles = new int[maxPlane][maxTileX + 1][maxTileZ + 1]; + this.planeHeightmaps = planeHeightmaps; + clear(); } - public void method274() { - for (int j = 0; j < anInt437; j++) { - for (int k = 0; k < anInt438; k++) { - for (int i1 = 0; i1 < anInt439; i1++) { - aTileArrayArrayArray441[j][k][i1] = null; + public void clear() { + for (int plane = 0; plane < maxPlane; plane++) { + for (int stx = 0; stx < maxTileX; stx++) { + for (int stz = 0; stz < maxTileZ; stz++) { + planeTiles[plane][stx][stz] = null; } } } @@ -195,466 +196,496 @@ public class Scene { } anIntArray473[l] = 0; } - for (int k1 = 0; k1 < anInt443; k1++) { - aLocArray444[k1] = null; + for (int k1 = 0; k1 < temporaryLocCount; k1++) { + temporaryLocs[k1] = null; } - anInt443 = 0; - Arrays.fill(aLocArray462, null); + temporaryLocCount = 0; + Arrays.fill(tmp, null); } - public void method275(int i) { - anInt442 = i; - for (int k = 0; k < anInt438; k++) { - for (int l = 0; l < anInt439; l++) { - if (aTileArrayArrayArray441[i][k][l] == null) { - aTileArrayArrayArray441[i][k][l] = new SceneTile(i, k, l); + public void setMinPlane(int plane) { + minPlane = plane; + for (int stx = 0; stx < maxTileX; stx++) { + for (int stz = 0; stz < maxTileZ; stz++) { + if (planeTiles[plane][stx][stz] == null) { + planeTiles[plane][stx][stz] = new SceneTile(plane, stx, stz); } } } } - public void method276(int i, int j) { - SceneTile tile = aTileArrayArrayArray441[0][j][i]; - for (int l = 0; l < 3; l++) { - SceneTile tile_1 = aTileArrayArrayArray441[l][j][i] = aTileArrayArrayArray441[l + 1][j][i]; - if (tile_1 != null) { - tile_1.anInt1307--; - for (int j1 = 0; j1 < tile_1.anInt1317; j1++) { - SceneLoc loc = tile_1.aLocArray1318[j1]; - if ((((loc.anInt529 >> 29) & 3) == 2) && (loc.anInt523 == j) && (loc.anInt525 == i)) { - loc.anInt517--; - } + public void setBridge(int stx, int stz) { + SceneTile ground = planeTiles[0][stx][stz]; + + for (int plane = 0; plane < 3; plane++) { + SceneTile above = planeTiles[plane][stx][stz] = planeTiles[plane + 1][stx][stz]; + + if (above == null) { + continue; + } + + above.anInt1307--; + + for (int i = 0; i < above.locCount; i++) { + SceneLoc loc = above.locs[i]; + + if ((((loc.bitset >> 29) & 3) == 2) && (loc.minSceneTileX == stx) && (loc.minSceneTileZ == stz)) { + loc.plane--; } } } - if (aTileArrayArrayArray441[0][j][i] == null) { - aTileArrayArrayArray441[0][j][i] = new SceneTile(0, j, i); + + if (planeTiles[0][stx][stz] == null) { + planeTiles[0][stx][stz] = new SceneTile(0, stx, stz); } - aTileArrayArrayArray441[0][j][i].aTile_1329 = tile; - aTileArrayArrayArray441[3][j][i] = null; + + planeTiles[0][stx][stz].bridge = ground; + planeTiles[3][stx][stz] = null; } - public void method278(int i, int j, int k, int l) { - SceneTile tile = aTileArrayArrayArray441[i][j][k]; - if (tile == null) { - } else { - aTileArrayArrayArray441[i][j][k].anInt1321 = l; + public void setDrawPlane(int plane, int stx, int stz, int drawPlane) { + SceneTile tile = planeTiles[plane][stx][stz]; + if (tile != null) { + planeTiles[plane][stx][stz].drawPlane = drawPlane; } } - public void method279(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2, int j2, int k2, int l2, int i3, int j3, int k3, int l3, int i4, int j4, int k4, int l4) { - if (l == 0) { + public void method279(int plane, int stx, int stz, int type, int i1, int j1, int k1, int l1, int i2, int j2, int k2, int l2, int i3, int j3, int k3, int l3, int i4, int j4, int k4, int l4) { + if (type == 0) { SceneTileUnderlay underlay = new SceneTileUnderlay(k2, l2, i3, j3, -1, k4, false); - for (int i5 = i; i5 >= 0; i5--) { - if (aTileArrayArrayArray441[i5][j][k] == null) { - aTileArrayArrayArray441[i5][j][k] = new SceneTile(i5, j, k); + for (int p = plane; p >= 0; p--) { + if (planeTiles[p][stx][stz] == null) { + planeTiles[p][stx][stz] = new SceneTile(p, stx, stz); } } - aTileArrayArrayArray441[i][j][k].aUnderlay_1311 = underlay; - return; - } - if (l == 1) { - SceneTileUnderlay underlay_1 = new SceneTileUnderlay(k3, l3, i4, j4, j1, l4, (k1 == l1) && (k1 == i2) && (k1 == j2)); - for (int j5 = i; j5 >= 0; j5--) { - if (aTileArrayArrayArray441[j5][j][k] == null) { - aTileArrayArrayArray441[j5][j][k] = new SceneTile(j5, j, k); + planeTiles[plane][stx][stz].underlay = underlay; + } else if (type == 1) { + SceneTileUnderlay underlay = new SceneTileUnderlay(k3, l3, i4, j4, j1, l4, (k1 == l1) && (k1 == i2) && (k1 == j2)); + for (int p = plane; p >= 0; p--) { + if (planeTiles[p][stx][stz] == null) { + planeTiles[p][stx][stz] = new SceneTile(p, stx, stz); } } - aTileArrayArrayArray441[i][j][k].aUnderlay_1311 = underlay_1; - return; - } - SceneTileOverlay overlay = new SceneTileOverlay(k, k3, j3, i2, j1, i4, i1, k2, k4, i3, j2, l1, k1, l, j4, l3, l2, j, l4); - for (int k5 = i; k5 >= 0; k5--) { - if (aTileArrayArrayArray441[k5][j][k] == null) { - aTileArrayArrayArray441[k5][j][k] = new SceneTile(k5, j, k); + planeTiles[plane][stx][stz].underlay = underlay; + } else { + SceneTileOverlay overlay = new SceneTileOverlay(stz, k3, j3, i2, j1, i4, i1, k2, k4, i3, j2, l1, k1, type, j4, l3, l2, stx, l4); + for (int k5 = plane; k5 >= 0; k5--) { + if (planeTiles[k5][stx][stz] == null) { + planeTiles[k5][stx][stz] = new SceneTile(k5, stx, stz); + } } + planeTiles[plane][stx][stz].overlay = overlay; } - aTileArrayArrayArray441[i][j][k].aOverlay_1312 = overlay; } - public void method280(int i, int j, int k, Entity entity, byte byte0, int i1, int j1) { + public void addGroundDecoration(Entity entity, int plane, int stx, int stz, int y, int bitset, byte info) { if (entity == null) { return; } - SceneGroundDecoration groundDecoration = new SceneGroundDecoration(); - groundDecoration.aEntity_814 = entity; - groundDecoration.anInt812 = (j1 * 128) + 64; - groundDecoration.anInt813 = (k * 128) + 64; - groundDecoration.anInt811 = j; - groundDecoration.anInt815 = i1; - groundDecoration.aByte816 = byte0; - if (aTileArrayArrayArray441[i][j1][k] == null) { - aTileArrayArrayArray441[i][j1][k] = new SceneTile(i, j1, k); + SceneGroundDecoration decor = new SceneGroundDecoration(); + decor.entity = entity; + decor.x = (stx * 128) + 64; + decor.z = (stz * 128) + 64; + decor.y = y; + decor.bitset = bitset; + decor.info = info; + if (planeTiles[plane][stx][stz] == null) { + planeTiles[plane][stx][stz] = new SceneTile(plane, stx, stz); } - aTileArrayArrayArray441[i][j1][k].aGroundDecoration_1315 = groundDecoration; + planeTiles[plane][stx][stz].groundDecoration = decor; } - public void method281(int i, int j, Entity entity, int k, Entity entity_1, Entity class30_sub2_sub4_2, int l, int i1) { + public void addObjStack(Entity entity0, Entity entity1, Entity entity2, int plane, int stx, int stz, int y, int bitset) { SceneObjStack objStack = new SceneObjStack(); - objStack.aEntity_48 = class30_sub2_sub4_2; - objStack.anInt46 = (i * 128) + 64; - objStack.anInt47 = (i1 * 128) + 64; - objStack.anInt45 = k; - objStack.anInt51 = j; - objStack.aEntity_49 = entity; - objStack.aEntity_50 = entity_1; - int j1 = 0; - SceneTile tile = aTileArrayArrayArray441[l][i][i1]; + objStack.x = (stx * 128) + 64; + objStack.z = (stz * 128) + 64; + objStack.y = y; + objStack.bitset = bitset; + objStack.entity0 = entity0; + objStack.entity1 = entity1; + objStack.entity2 = entity2; + + int stackOffset = 0; + + SceneTile tile = planeTiles[plane][stx][stz]; + if (tile != null) { - for (int k1 = 0; k1 < tile.anInt1317; k1++) { - if (tile.aLocArray1318[k1].aEntity_521 instanceof Model) { - int l1 = ((Model) tile.aLocArray1318[k1].aEntity_521).anInt1654; - if (l1 > j1) { - j1 = l1; - } + for (int l = 0; l < tile.locCount; l++) { + if (!(tile.locs[l].entity instanceof Model)) { + continue; + } + int height = ((Model) tile.locs[l].entity).anInt1654; + if (height > stackOffset) { + stackOffset = height; } } } - objStack.anInt52 = j1; - if (aTileArrayArrayArray441[l][i][i1] == null) { - aTileArrayArrayArray441[l][i][i1] = new SceneTile(l, i, i1); + + objStack.offset = stackOffset; + + if (planeTiles[plane][stx][stz] == null) { + planeTiles[plane][stx][stz] = new SceneTile(plane, stx, stz); } - aTileArrayArrayArray441[l][i][i1].aObjStack_1316 = objStack; + planeTiles[plane][stx][stz].objStack = objStack; } - public void method282(int i, Entity entity, int j, int k, byte byte0, int l, Entity entity_1, int i1, int j1, int k1) { - if ((entity == null) && (entity_1 == null)) { + 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)) { return; } SceneWall wall = new SceneWall(); - wall.anInt280 = j; - wall.aByte281 = byte0; - wall.anInt274 = (l * 128) + 64; - wall.anInt275 = (k * 128) + 64; - wall.anInt273 = i1; - wall.aEntity_278 = entity; - wall.aEntity_279 = entity_1; - wall.anInt276 = i; - wall.anInt277 = j1; - for (int l1 = k1; l1 >= 0; l1--) { - if (aTileArrayArrayArray441[l1][l][k] == null) { - aTileArrayArrayArray441[l1][l][k] = new SceneTile(l1, l, k); + wall.bitset = bitset; + wall.info = info; + wall.x = (stx * 128) + 64; + wall.z = (stz * 128) + 64; + wall.y = y; + wall.entity0 = wall0; + wall.entity1 = wall1; + wall.type0 = type0; + wall.type1 = type1; + for (int p = plane; p >= 0; p--) { + if (planeTiles[p][stx][stz] == null) { + planeTiles[p][stx][stz] = new SceneTile(p, stx, stz); } } - aTileArrayArrayArray441[k1][l][k].aWall_1313 = wall; + planeTiles[plane][stx][stz].wall = wall; } - public void method283(int i, int j, int k, int i1, int j1, int k1, Entity entity, int l1, byte byte0, int i2, int j2) { + 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) { if (entity == null) { return; } - SceneWallDecoration wallDecoration = new SceneWallDecoration(); - wallDecoration.anInt505 = i; - wallDecoration.aByte506 = byte0; - wallDecoration.anInt500 = (l1 * 128) + 64 + j1; - wallDecoration.anInt501 = (j * 128) + 64 + i2; - wallDecoration.anInt499 = k1; - wallDecoration.aEntity_504 = entity; - wallDecoration.anInt502 = j2; - wallDecoration.anInt503 = k; - for (int k2 = i1; k2 >= 0; k2--) { - if (aTileArrayArrayArray441[k2][l1][j] == null) { - aTileArrayArrayArray441[k2][l1][j] = new SceneTile(k2, l1, j); + 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; + for (int p = plane; p >= 0; p--) { + if (planeTiles[p][stx][stz] == null) { + planeTiles[p][stx][stz] = new SceneTile(p, stx, stz); } } - aTileArrayArrayArray441[i1][l1][j].aWallDecoration_1314 = wallDecoration; + planeTiles[plane][stx][stz].wallDecoration = decor; } - public boolean method284(int i, byte byte0, int j, int k, Entity entity, int l, int i1, int j1, int k1, int l1) { + public boolean add(Entity entity, int plane, int stx, int stz, int y, int sizeX, int sizeZ, int yaw, int bitset, byte info) { if (entity == null) { return true; } else { - int i2 = (l1 * 128) + (64 * l); - int j2 = (k1 * 128) + (64 * k); - return method287(i1, l1, k1, l, k, i2, j2, j, entity, j1, false, i, byte0); + int x = (stx * 128) + (64 * sizeX); + int z = (stz * 128) + (64 * sizeZ); + return add(entity, plane, stx, stz, sizeX, sizeZ, x, z, y, yaw, bitset, info, false); } } - public boolean method285(int i, int j, int k, int l, int i1, int j1, int k1, Entity entity, boolean flag) { + public boolean addTemporary(Entity entity, int plane, int x, int z, int y, int yaw, int bitset, boolean forwardPadding, int padding) { if (entity == null) { return true; } - int l1 = k1 - j1; - int i2 = i1 - j1; - int j2 = k1 + j1; - int k2 = i1 + j1; - if (flag) { - if ((j > 640) && (j < 1408)) { - k2 += 128; + + int x0 = x - padding; + int z0 = z - padding; + int x1 = x + padding; + int z1 = z + padding; + + if (forwardPadding) { + if ((yaw > 640) && (yaw < 1408)) { + z1 += 128; } - if ((j > 1152) && (j < 1920)) { - j2 += 128; + if ((yaw > 1152) && (yaw < 1920)) { + x1 += 128; } - if ((j > 1664) || (j < 384)) { - i2 -= 128; + if ((yaw > 1664) || (yaw < 384)) { + z0 -= 128; } - if ((j > 128) && (j < 896)) { - l1 -= 128; + if ((yaw > 128) && (yaw < 896)) { + x0 -= 128; } } - l1 /= 128; - i2 /= 128; - j2 /= 128; - k2 /= 128; - return method287(i, l1, i2, (j2 - l1) + 1, (k2 - i2) + 1, k1, i1, k, entity, j, true, l, (byte) 0); + + x0 /= 128; + z0 /= 128; + x1 /= 128; + z1 /= 128; + return add(entity, plane, x0, z0, (x1 - x0) + 1, (z1 - z0) + 1, x, z, y, yaw, bitset, (byte) 0, true); } - public boolean method286(int j, int k, Entity entity, int l, int i1, int j1, int k1, int l1, int i2, int j2, int k2) { + public boolean addTemporary(Entity entity, int plane, int stx0, int stz0, int stx1, int stz1, int x, int z, int y, int yaw, int bitset) { if (entity == null) { return true; } else { - return method287(j, l1, k2, (i2 - l1) + 1, (i1 - k2) + 1, j1, k, k1, entity, l, true, j2, (byte) 0); + return add(entity, plane, stx0, stz0, (stx1 - stx0) + 1, (stz1 - stz0) + 1, x, z, y, yaw, bitset, (byte) 0, true); } } - public boolean method287(int i, int j, int k, int l, int i1, int j1, int k1, int l1, Entity entity, int i2, boolean flag, int j2, byte byte0) { - for (int k2 = j; k2 < (j + l); k2++) { - for (int l2 = k; l2 < (k + i1); l2++) { - if ((k2 < 0) || (l2 < 0) || (k2 >= anInt438) || (l2 >= anInt439)) { + public boolean add(Entity entity, int plane, int stx, int stz, int sizeX, int sizeZ, int x, int z, int y, int yaw, int bitset, byte info, boolean temporary) { + for (int tx = stx; tx < (stx + sizeX); tx++) { + for (int tz = stz; tz < (stz + sizeZ); tz++) { + if ((tx < 0) || (tz < 0) || (tx >= maxTileX) || (tz >= maxTileZ)) { return false; } - SceneTile tile = aTileArrayArrayArray441[i][k2][l2]; - if ((tile != null) && (tile.anInt1317 >= 5)) { + SceneTile tile = planeTiles[plane][tx][tz]; + if ((tile != null) && (tile.locCount >= 5)) { return false; } } } SceneLoc loc = new SceneLoc(); - loc.anInt529 = j2; - loc.aByte530 = byte0; - loc.anInt517 = i; - loc.anInt519 = j1; - loc.anInt520 = k1; - loc.anInt518 = l1; - loc.aEntity_521 = entity; - loc.anInt522 = i2; - loc.anInt523 = j; - loc.anInt525 = k; - loc.anInt524 = (j + l) - 1; - loc.anInt526 = (k + i1) - 1; - for (int i3 = j; i3 < (j + l); i3++) { - for (int j3 = k; j3 < (k + i1); j3++) { - int k3 = 0; - if (i3 > j) { - k3++; + loc.bitset = bitset; + loc.info = info; + loc.plane = plane; + loc.x = x; + loc.z = z; + loc.y = y; + loc.entity = entity; + loc.yaw = yaw; + loc.minSceneTileX = stx; + loc.minSceneTileZ = stz; + loc.maxSceneTileX = (stx + sizeX) - 1; + loc.maxSceneTileZ = (stz + sizeZ) - 1; + + for (int tx = stx; tx < (stx + sizeX); tx++) { + for (int tz = stz; tz < (stz + sizeZ); tz++) { + int flags = 0; + + if (tx > stx) { + flags++; } - if (i3 < ((j + l) - 1)) { - k3 += 4; + + if (tx < ((stx + sizeX) - 1)) { + flags += 4; } - if (j3 > k) { - k3 += 8; + + if (tz > stz) { + flags += 8; } - if (j3 < ((k + i1) - 1)) { - k3 += 2; + + if (tz < ((stz + sizeZ) - 1)) { + flags += 2; } - for (int l3 = i; l3 >= 0; l3--) { - if (aTileArrayArrayArray441[l3][i3][j3] == null) { - aTileArrayArrayArray441[l3][i3][j3] = new SceneTile(l3, i3, j3); + + for (int p = plane; p >= 0; p--) { + if (planeTiles[p][tx][tz] == null) { + planeTiles[p][tx][tz] = new SceneTile(p, tx, tz); } } - SceneTile tile_1 = aTileArrayArrayArray441[i][i3][j3]; - tile_1.aLocArray1318[tile_1.anInt1317] = loc; - tile_1.anIntArray1319[tile_1.anInt1317] = k3; - tile_1.anInt1320 |= k3; - tile_1.anInt1317++; + + SceneTile tile = planeTiles[plane][tx][tz]; + tile.locs[tile.locCount] = loc; + tile.locFlags[tile.locCount] = flags; + tile.flags |= flags; + tile.locCount++; } } - if (flag) { - aLocArray444[anInt443++] = loc; + + if (temporary) { + temporaryLocs[temporaryLocCount++] = loc; } + return true; } - public void method288() { - for (int i = 0; i < anInt443; i++) { - SceneLoc loc = aLocArray444[i]; - method289(loc); - aLocArray444[i] = null; + public void clearTemporaryLocs() { + for (int i = 0; i < temporaryLocCount; i++) { + SceneLoc loc = temporaryLocs[i]; + remove(loc); + temporaryLocs[i] = null; } - anInt443 = 0; + temporaryLocCount = 0; } - public void method289(SceneLoc loc) { - for (int j = loc.anInt523; j <= loc.anInt524; j++) { - for (int k = loc.anInt525; k <= loc.anInt526; k++) { - SceneTile tile = aTileArrayArrayArray441[loc.anInt517][j][k]; - if (tile != null) { - for (int l = 0; l < tile.anInt1317; l++) { - if (tile.aLocArray1318[l] != loc) { - continue; - } - tile.anInt1317--; - for (int i1 = l; i1 < tile.anInt1317; i1++) { - tile.aLocArray1318[i1] = tile.aLocArray1318[i1 + 1]; - tile.anIntArray1319[i1] = tile.anIntArray1319[i1 + 1]; - } - tile.aLocArray1318[tile.anInt1317] = null; - break; + public void remove(SceneLoc loc) { + for (int tx = loc.minSceneTileX; tx <= loc.maxSceneTileX; tx++) { + for (int tz = loc.minSceneTileZ; tz <= loc.maxSceneTileZ; tz++) { + SceneTile tile = planeTiles[loc.plane][tx][tz]; + + if (tile == null) { + continue; + } + + for (int i = 0; i < tile.locCount; i++) { + if (tile.locs[i] != loc) { + continue; } - tile.anInt1320 = 0; - for (int j1 = 0; j1 < tile.anInt1317; j1++) { - tile.anInt1320 |= tile.anIntArray1319[j1]; + + tile.locCount--; + + for (int j = i; j < tile.locCount; j++) { + tile.locs[j] = tile.locs[j + 1]; + tile.locFlags[j] = tile.locFlags[j + 1]; } + tile.locs[tile.locCount] = null; + break; + } + + tile.flags = 0; + + for (int j1 = 0; j1 < tile.locCount; j1++) { + tile.flags |= tile.locFlags[j1]; } } } } - public void method290(int i, int k, int l, int i1) { - SceneTile tile = aTileArrayArrayArray441[i1][l][i]; + public void setWallDecorationOffset(int plane, int stx, int stz, int offset) { + SceneTile tile = planeTiles[plane][stx][stz]; if (tile == null) { return; } - SceneWallDecoration wallDecoration = tile.aWallDecoration_1314; - if (wallDecoration != null) { - int j1 = (l * 128) + 64; - int k1 = (i * 128) + 64; - wallDecoration.anInt500 = j1 + (((wallDecoration.anInt500 - j1) * k) / 16); - wallDecoration.anInt501 = k1 + (((wallDecoration.anInt501 - k1) * k) / 16); + SceneWallDecoration decoration = tile.wallDecoration; + if (decoration != null) { + int sx = (stx * 128) + 64; + int sz = (stz * 128) + 64; + decoration.x = sx + (((decoration.x - sx) * offset) / 16); + decoration.z = sz + (((decoration.z - sz) * offset) / 16); } } - public void method291(int i, int j, int k) { - SceneTile tile = aTileArrayArrayArray441[j][i][k]; + public void removeWall(int x, int plane, int z) { + SceneTile tile = planeTiles[plane][x][z]; if (tile != null) { - tile.aWall_1313 = null; + tile.wall = null; } } - public void method292(int j, int k, int l) { - SceneTile tile = aTileArrayArrayArray441[k][l][j]; + public void removeWallDecoration(int plane, int x, int z) { + SceneTile tile = planeTiles[plane][x][z]; if (tile != null) { - tile.aWallDecoration_1314 = null; + tile.wallDecoration = null; } } - public void method293(int i, int k, int l) { - SceneTile tile = aTileArrayArrayArray441[i][k][l]; + public void removeLoc(int plane, int x, int z) { + SceneTile tile = planeTiles[plane][x][z]; if (tile == null) { return; } - for (int j1 = 0; j1 < tile.anInt1317; j1++) { - SceneLoc loc = tile.aLocArray1318[j1]; - if ((((loc.anInt529 >> 29) & 3) == 2) && (loc.anInt523 == k) && (loc.anInt525 == l)) { - method289(loc); + for (int j1 = 0; j1 < tile.locCount; j1++) { + SceneLoc loc = tile.locs[j1]; + if ((((loc.bitset >> 29) & 3) == 2) && (loc.minSceneTileX == x) && (loc.minSceneTileZ == z)) { + remove(loc); return; } } } - public void method294(int i, int j, int k) { - SceneTile tile = aTileArrayArrayArray441[i][k][j]; + public void removeGroundDecoration(int plane, int x, int z) { + SceneTile tile = planeTiles[plane][x][z]; if (tile != null) { - tile.aGroundDecoration_1315 = null; + tile.groundDecoration = null; } } - public void method295(int i, int j, int k) { - SceneTile tile = aTileArrayArrayArray441[i][j][k]; + public void removeObjStack(int plane, int x, int z) { + SceneTile tile = planeTiles[plane][x][z]; if (tile != null) { - tile.aObjStack_1316 = null; + tile.objStack = null; } } - public SceneWall method296(int i, int j, int k) { - SceneTile tile = aTileArrayArrayArray441[i][j][k]; + public SceneWall getWall(int plane, int x, int z) { + SceneTile tile = planeTiles[plane][x][z]; if (tile != null) { - return tile.aWall_1313; + return tile.wall; } else { return null; } } - public SceneWallDecoration method297(int i, int k, int l) { - SceneTile tile = aTileArrayArrayArray441[l][i][k]; + public SceneWallDecoration getWallDecoration(int plane, int x, int z) { + SceneTile tile = planeTiles[plane][x][z]; if (tile != null) { - return tile.aWallDecoration_1314; + return tile.wallDecoration; } else { return null; } } - public SceneLoc method298(int i, int j, int k) { - SceneTile tile = aTileArrayArrayArray441[k][i][j]; + public SceneLoc getLoc(int plane, int x, int z) { + SceneTile tile = planeTiles[plane][x][z]; if (tile == null) { return null; } - for (int l = 0; l < tile.anInt1317; l++) { - SceneLoc loc = tile.aLocArray1318[l]; - if ((((loc.anInt529 >> 29) & 3) == 2) && (loc.anInt523 == i) && (loc.anInt525 == j)) { + for (int l = 0; l < tile.locCount; l++) { + SceneLoc loc = tile.locs[l]; + if ((((loc.bitset >> 29) & 3) == 2) && (loc.minSceneTileX == x) && (loc.minSceneTileZ == z)) { return loc; } } return null; } - public SceneGroundDecoration method299(int i, int j, int k) { - SceneTile tile = aTileArrayArrayArray441[k][j][i]; - if ((tile != null) && (tile.aGroundDecoration_1315 != null)) { - return tile.aGroundDecoration_1315; + public SceneGroundDecoration getGroundDecoration(int z, int x, int plane) { + SceneTile tile = planeTiles[plane][x][z]; + if ((tile != null) && (tile.groundDecoration != null)) { + return tile.groundDecoration; } else { return null; } } - public int method300(int i, int j, int k) { - SceneTile tile = aTileArrayArrayArray441[i][j][k]; - if ((tile != null) && (tile.aWall_1313 != null)) { - return tile.aWall_1313.anInt280; + public int getWallBitset(int i, int j, int k) { + SceneTile tile = planeTiles[i][j][k]; + if ((tile != null) && (tile.wall != null)) { + return tile.wall.bitset; } else { return 0; } } - public int method301(int i, int j, int l) { - SceneTile tile = aTileArrayArrayArray441[i][j][l]; - if ((tile == null) || (tile.aWallDecoration_1314 == null)) { + public int getWallDecorationBitset(int plane, int x, int z) { + SceneTile tile = planeTiles[plane][x][z]; + if ((tile == null) || (tile.wallDecoration == null)) { return 0; } else { - return tile.aWallDecoration_1314.anInt505; + return tile.wallDecoration.bitset; } } - public int method302(int i, int j, int k) { - SceneTile tile = aTileArrayArrayArray441[i][j][k]; + public int getLocBitset(int plane, int x, int z) { + SceneTile tile = planeTiles[plane][x][z]; if (tile == null) { return 0; } - for (int l = 0; l < tile.anInt1317; l++) { - SceneLoc loc = tile.aLocArray1318[l]; - if ((((loc.anInt529 >> 29) & 3) == 2) && (loc.anInt523 == j) && (loc.anInt525 == k)) { - return loc.anInt529; + for (int l = 0; l < tile.locCount; l++) { + SceneLoc loc = tile.locs[l]; + if ((((loc.bitset >> 29) & 3) == 2) && (loc.minSceneTileX == x) && (loc.minSceneTileZ == z)) { + return loc.bitset; } } return 0; } - public int method303(int i, int j, int k) { - SceneTile tile = aTileArrayArrayArray441[i][j][k]; - if ((tile == null) || (tile.aGroundDecoration_1315 == null)) { + public int getGroundDecorationBitset(int plane, int x, int z) { + SceneTile tile = planeTiles[plane][x][z]; + if ((tile == null) || (tile.groundDecoration == null)) { return 0; } else { - return tile.aGroundDecoration_1315.anInt815; + return tile.groundDecoration.bitset; } } - public int method304(int i, int j, int k, int l) { - SceneTile tile = aTileArrayArrayArray441[i][j][k]; + public int getInfo(int plane, int x, int z, int bitset) { + SceneTile tile = planeTiles[plane][x][z]; if (tile == null) { return -1; } - if ((tile.aWall_1313 != null) && (tile.aWall_1313.anInt280 == l)) { - return tile.aWall_1313.aByte281 & 0xff; + if ((tile.wall != null) && (tile.wall.bitset == bitset)) { + return tile.wall.info & 0xff; } - if ((tile.aWallDecoration_1314 != null) && (tile.aWallDecoration_1314.anInt505 == l)) { - return tile.aWallDecoration_1314.aByte506 & 0xff; + if ((tile.wallDecoration != null) && (tile.wallDecoration.bitset == bitset)) { + return tile.wallDecoration.info & 0xff; } - if ((tile.aGroundDecoration_1315 != null) && (tile.aGroundDecoration_1315.anInt815 == l)) { - return tile.aGroundDecoration_1315.aByte816 & 0xff; + if ((tile.groundDecoration != null) && (tile.groundDecoration.bitset == bitset)) { + return tile.groundDecoration.info & 0xff; } - for (int i1 = 0; i1 < tile.anInt1317; i1++) { - if (tile.aLocArray1318[i1].anInt529 == l) { - return tile.aLocArray1318[i1].aByte530 & 0xff; + for (int i1 = 0; i1 < tile.locCount; i1++) { + if (tile.locs[i1].bitset == bitset) { + return tile.locs[i1].info & 0xff; } } return -1; @@ -663,32 +694,32 @@ public class Scene { public void method305(int i, int j, int k, int l, int i1) { int j1 = (int) Math.sqrt((k * k) + (i * i) + (i1 * i1)); int k1 = (l * j1) >> 8; - for (int l1 = 0; l1 < anInt437; l1++) { - for (int i2 = 0; i2 < anInt438; i2++) { - for (int j2 = 0; j2 < anInt439; j2++) { - SceneTile tile = aTileArrayArrayArray441[l1][i2][j2]; + for (int l1 = 0; l1 < maxPlane; l1++) { + for (int i2 = 0; i2 < maxTileX; i2++) { + for (int j2 = 0; j2 < maxTileZ; j2++) { + SceneTile tile = planeTiles[l1][i2][j2]; if (tile != null) { - SceneWall wall = tile.aWall_1313; - if ((wall != null) && (wall.aEntity_278 != null) && (wall.aEntity_278.vertexNormal != null)) { - method307(l1, 1, 1, i2, j2, (Model) wall.aEntity_278); - if ((wall.aEntity_279 != null) && (wall.aEntity_279.vertexNormal != null)) { - method307(l1, 1, 1, i2, j2, (Model) wall.aEntity_279); - method308((Model) wall.aEntity_278, (Model) wall.aEntity_279, 0, 0, 0, false); - ((Model) wall.aEntity_279).applyLighting(j, k1, k, i, i1); + 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); } - ((Model) wall.aEntity_278).applyLighting(j, k1, k, i, i1); + ((Model) wall.entity0).applyLighting(j, k1, k, i, i1); } - for (int k2 = 0; k2 < tile.anInt1317; k2++) { - SceneLoc loc = tile.aLocArray1318[k2]; - if ((loc != null) && (loc.aEntity_521 != null) && (loc.aEntity_521.vertexNormal != null)) { - method307(l1, (loc.anInt524 - loc.anInt523) + 1, (loc.anInt526 - loc.anInt525) + 1, i2, j2, (Model) loc.aEntity_521); - ((Model) loc.aEntity_521).applyLighting(j, k1, k, i, i1); + for (int k2 = 0; k2 < tile.locCount; k2++) { + SceneLoc loc = tile.locs[k2]; + if ((loc != null) && (loc.entity != null) && (loc.entity.vertexNormal != null)) { + method307(l1, (loc.maxSceneTileX - loc.minSceneTileX) + 1, (loc.maxSceneTileZ - loc.minSceneTileZ) + 1, i2, j2, (Model) loc.entity); + ((Model) loc.entity).applyLighting(j, k1, k, i, i1); } } - SceneGroundDecoration groundDecoration = tile.aGroundDecoration_1315; - if ((groundDecoration != null) && (groundDecoration.aEntity_814.vertexNormal != null)) { - method306(i2, l1, (Model) groundDecoration.aEntity_814, j2); - ((Model) groundDecoration.aEntity_814).applyLighting(j, k1, k, i, i1); + SceneGroundDecoration groundDecoration = tile.groundDecoration; + if ((groundDecoration != null) && (groundDecoration.entity.vertexNormal != null)) { + method306(i2, l1, (Model) groundDecoration.entity, j2); + ((Model) groundDecoration.entity).applyLighting(j, k1, k, i, i1); } } } @@ -697,28 +728,28 @@ public class Scene { } public void method306(int i, int j, Model model, int k) { - if (i < anInt438) { - SceneTile tile = aTileArrayArrayArray441[j][i + 1][k]; - if ((tile != null) && (tile.aGroundDecoration_1315 != null) && (tile.aGroundDecoration_1315.aEntity_814.vertexNormal != null)) { - method308(model, (Model) tile.aGroundDecoration_1315.aEntity_814, 128, 0, 0, true); + if (i < maxTileX) { + SceneTile tile = planeTiles[j][i + 1][k]; + if ((tile != null) && (tile.groundDecoration != null) && (tile.groundDecoration.entity.vertexNormal != null)) { + method308(model, (Model) tile.groundDecoration.entity, 128, 0, 0, true); } } - if (k < anInt438) { - SceneTile tile_1 = aTileArrayArrayArray441[j][i][k + 1]; - if ((tile_1 != null) && (tile_1.aGroundDecoration_1315 != null) && (tile_1.aGroundDecoration_1315.aEntity_814.vertexNormal != null)) { - method308(model, (Model) tile_1.aGroundDecoration_1315.aEntity_814, 0, 0, 128, true); + if (k < maxTileX) { + SceneTile tile_1 = planeTiles[j][i][k + 1]; + if ((tile_1 != null) && (tile_1.groundDecoration != null) && (tile_1.groundDecoration.entity.vertexNormal != null)) { + method308(model, (Model) tile_1.groundDecoration.entity, 0, 0, 128, true); } } - if ((i < anInt438) && (k < anInt439)) { - SceneTile tile_2 = aTileArrayArrayArray441[j][i + 1][k + 1]; - if ((tile_2 != null) && (tile_2.aGroundDecoration_1315 != null) && (tile_2.aGroundDecoration_1315.aEntity_814.vertexNormal != null)) { - method308(model, (Model) tile_2.aGroundDecoration_1315.aEntity_814, 128, 0, 128, true); + if ((i < maxTileX) && (k < maxTileZ)) { + SceneTile tile_2 = planeTiles[j][i + 1][k + 1]; + if ((tile_2 != null) && (tile_2.groundDecoration != null) && (tile_2.groundDecoration.entity.vertexNormal != null)) { + method308(model, (Model) tile_2.groundDecoration.entity, 128, 0, 128, true); } } - if ((i < anInt438) && (k > 0)) { - SceneTile tile_3 = aTileArrayArrayArray441[j][i + 1][k - 1]; - if ((tile_3 != null) && (tile_3.aGroundDecoration_1315 != null) && (tile_3.aGroundDecoration_1315.aEntity_814.vertexNormal != null)) { - method308(model, (Model) tile_3.aGroundDecoration_1315.aEntity_814, 128, 0, -128, true); + if ((i < maxTileX) && (k > 0)) { + SceneTile tile_3 = planeTiles[j][i + 1][k - 1]; + if ((tile_3 != null) && (tile_3.groundDecoration != null) && (tile_3.groundDecoration.entity.vertexNormal != null)) { + method308(model, (Model) tile_3.groundDecoration.entity, 128, 0, -128, true); } } } @@ -730,27 +761,27 @@ public class Scene { int l1 = i1 - 1; int i2 = i1 + k; for (int j2 = i; j2 <= (i + 1); j2++) { - if (j2 != anInt437) { + if (j2 != maxPlane) { for (int k2 = j1; k2 <= k1; k2++) { - if ((k2 >= 0) && (k2 < anInt438)) { + if ((k2 >= 0) && (k2 < maxTileX)) { for (int l2 = l1; l2 <= i2; l2++) { - if ((l2 >= 0) && (l2 < anInt439) && (!flag || (k2 >= k1) || (l2 >= i2) || ((l2 < i1) && (k2 != l)))) { - SceneTile tile = aTileArrayArrayArray441[j2][k2][l2]; + if ((l2 >= 0) && (l2 < maxTileZ) && (!flag || (k2 >= k1) || (l2 >= i2) || ((l2 < i1) && (k2 != l)))) { + SceneTile tile = planeTiles[j2][k2][l2]; if (tile != null) { - int i3 = ((anIntArrayArrayArray440[j2][k2][l2] + anIntArrayArrayArray440[j2][k2 + 1][l2] + anIntArrayArrayArray440[j2][k2][l2 + 1] + anIntArrayArrayArray440[j2][k2 + 1][l2 + 1]) / 4) - ((anIntArrayArrayArray440[i][l][i1] + anIntArrayArrayArray440[i][l + 1][i1] + anIntArrayArrayArray440[i][l][i1 + 1] + anIntArrayArrayArray440[i][l + 1][i1 + 1]) / 4); - SceneWall wall = tile.aWall_1313; - if ((wall != null) && (wall.aEntity_278 != null) && (wall.aEntity_278.vertexNormal != null)) { - method308(model, (Model) wall.aEntity_278, ((k2 - l) * 128) + ((1 - j) * 64), i3, ((l2 - i1) * 128) + ((1 - k) * 64), flag); + 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.aEntity_279 != null) && (wall.aEntity_279.vertexNormal != null)) { - method308(model, (Model) wall.aEntity_279, ((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); } - for (int j3 = 0; j3 < tile.anInt1317; j3++) { - SceneLoc loc = tile.aLocArray1318[j3]; - if ((loc != null) && (loc.aEntity_521 != null) && (loc.aEntity_521.vertexNormal != null)) { - int k3 = (loc.anInt524 - loc.anInt523) + 1; - int l3 = (loc.anInt526 - loc.anInt525) + 1; - method308(model, (Model) loc.aEntity_521, ((loc.anInt523 - l) * 128) + ((k3 - j) * 64), i3, ((loc.anInt525 - i1) * 128) + ((l3 - k) * 64), flag); + for (int j3 = 0; j3 < tile.locCount; j3++) { + SceneLoc loc = tile.locs[j3]; + if ((loc != null) && (loc.entity != null) && (loc.entity.vertexNormal != null)) { + int k3 = (loc.maxSceneTileX - loc.minSceneTileX) + 1; + int l3 = (loc.maxSceneTileZ - loc.minSceneTileZ) + 1; + method308(model, (Model) loc.entity, ((loc.minSceneTileX - l) * 128) + ((k3 - j) * 64), i3, ((loc.minSceneTileZ - i1) * 128) + ((l3 - k) * 64), flag); } } } @@ -816,12 +847,12 @@ public class Scene { } } - public void method309(int[] ai, int i, int j, int k, int l, int i1) { - SceneTile tile = aTileArrayArrayArray441[k][l][i1]; + public void drawMinimapTile(int[] ai, int i, int j, int k, int l, int i1) { + SceneTile tile = planeTiles[k][l][i1]; if (tile == null) { return; } - SceneTileUnderlay underlay = tile.aUnderlay_1311; + SceneTileUnderlay underlay = tile.underlay; if (underlay != null) { int j1 = underlay.anInt722; if (j1 == 0) { @@ -836,7 +867,7 @@ public class Scene { } return; } - SceneTileOverlay overlay = tile.aOverlay_1312; + SceneTileOverlay overlay = tile.overlay; if (overlay == null) { return; } @@ -885,15 +916,15 @@ public class Scene { public void method313(int eyeX, int eyeZ, int eyeYaw, int eyeY, int i1, int eyePitch) { if (eyeX < 0) { eyeX = 0; - } else if (eyeX >= (anInt438 * 128)) { - eyeX = (anInt438 * 128) - 1; + } else if (eyeX >= (maxTileX * 128)) { + eyeX = (maxTileX * 128) - 1; } if (eyeZ < 0) { eyeZ = 0; - } else if (eyeZ >= (anInt439 * 128)) { - eyeZ = (anInt439 * 128) - 1; + } else if (eyeZ >= (maxTileZ * 128)) { + eyeZ = (maxTileZ * 128) - 1; } - anInt448++; + cycle++; sinEyePitch = Model.sin[eyePitch]; cosEyePitch = Model.cos[eyePitch]; sinEyeYaw = Model.sin[eyeYaw]; @@ -914,37 +945,37 @@ public class Scene { anInt451 = 0; } anInt450 = eyeTileX + 25; - if (anInt450 > anInt438) { - anInt450 = anInt438; + if (anInt450 > maxTileX) { + anInt450 = maxTileX; } anInt452 = eyeTileZ + 25; - if (anInt452 > anInt439) { - anInt452 = anInt439; + if (anInt452 > maxTileZ) { + anInt452 = maxTileZ; } method319(); anInt446 = 0; - for (int k1 = anInt442; k1 < anInt437; k1++) { - SceneTile[][] aclass30_sub3 = aTileArrayArrayArray441[k1]; + for (int k1 = minPlane; k1 < maxPlane; k1++) { + SceneTile[][] aclass30_sub3 = planeTiles[k1]; for (int i2 = anInt449; i2 < anInt450; i2++) { for (int k2 = anInt451; k2 < anInt452; k2++) { SceneTile tile = aclass30_sub3[i2][k2]; if (tile != null) { - if ((tile.anInt1321 > i1) || (!aBooleanArrayArray492[(i2 - eyeTileX) + 25][(k2 - eyeTileZ) + 25] && ((anIntArrayArrayArray440[k1][i2][k2] - eyeY) < 2000))) { + if ((tile.drawPlane > i1) || (!aBooleanArrayArray492[(i2 - eyeTileX) + 25][(k2 - eyeTileZ) + 25] && ((planeHeightmaps[k1][i2][k2] - eyeY) < 2000))) { tile.aBoolean1322 = false; tile.aBoolean1323 = false; tile.anInt1325 = 0; } else { tile.aBoolean1322 = true; tile.aBoolean1323 = true; - tile.aBoolean1324 = tile.anInt1317 > 0; + tile.aBoolean1324 = tile.locCount > 0; anInt446++; } } } } } - for (int l1 = anInt442; l1 < anInt437; l1++) { - SceneTile[][] aclass30_sub3_1 = aTileArrayArrayArray441[l1]; + for (int l1 = minPlane; l1 < maxPlane; l1++) { + SceneTile[][] aclass30_sub3_1 = planeTiles[l1]; for (int l2 = -25; l2 <= 0; l2++) { int i3 = eyeTileX + l2; int k3 = eyeTileX - l2; @@ -988,8 +1019,8 @@ public class Scene { } } } - for (int j2 = anInt442; j2 < anInt437; j2++) { - SceneTile[][] aclass30_sub3_2 = aTileArrayArrayArray441[j2]; + for (int j2 = minPlane; j2 < maxPlane; j2++) { + SceneTile[][] aclass30_sub3_2 = planeTiles[j2]; for (int j3 = -25; j3 <= 0; j3++) { int l3 = eyeTileX + j3; int j4 = eyeTileX - j3; @@ -1050,36 +1081,36 @@ public class Scene { int j = tile_1.anInt1309; int k = tile_1.anInt1307; int l = tile_1.anInt1310; - SceneTile[][] aclass30_sub3 = aTileArrayArrayArray441[k]; + SceneTile[][] tiles = planeTiles[k]; if (tile_1.aBoolean1322) { if (flag) { if (k > 0) { - SceneTile tile_2 = aTileArrayArrayArray441[k - 1][i][j]; + SceneTile tile_2 = planeTiles[k - 1][i][j]; if ((tile_2 != null) && tile_2.aBoolean1323) { continue; } } if ((i <= eyeTileX) && (i > anInt449)) { - SceneTile tile_3 = aclass30_sub3[i - 1][j]; - if ((tile_3 != null) && tile_3.aBoolean1323 && (tile_3.aBoolean1322 || ((tile_1.anInt1320 & 1) == 0))) { + SceneTile tile_3 = tiles[i - 1][j]; + if ((tile_3 != null) && tile_3.aBoolean1323 && (tile_3.aBoolean1322 || ((tile_1.flags & 1) == 0))) { continue; } } if ((i >= eyeTileX) && (i < (anInt450 - 1))) { - SceneTile tile_4 = aclass30_sub3[i + 1][j]; - if ((tile_4 != null) && tile_4.aBoolean1323 && (tile_4.aBoolean1322 || ((tile_1.anInt1320 & 4) == 0))) { + SceneTile tile_4 = tiles[i + 1][j]; + if ((tile_4 != null) && tile_4.aBoolean1323 && (tile_4.aBoolean1322 || ((tile_1.flags & 4) == 0))) { continue; } } if ((j <= eyeTileZ) && (j > anInt451)) { - SceneTile tile_5 = aclass30_sub3[i][j - 1]; - if ((tile_5 != null) && tile_5.aBoolean1323 && (tile_5.aBoolean1322 || ((tile_1.anInt1320 & 8) == 0))) { + SceneTile tile_5 = tiles[i][j - 1]; + if ((tile_5 != null) && tile_5.aBoolean1323 && (tile_5.aBoolean1322 || ((tile_1.flags & 8) == 0))) { continue; } } if ((j >= eyeTileZ) && (j < (anInt452 - 1))) { - SceneTile tile_6 = aclass30_sub3[i][j + 1]; - if ((tile_6 != null) && tile_6.aBoolean1323 && (tile_6.aBoolean1322 || ((tile_1.anInt1320 & 2) == 0))) { + SceneTile tile_6 = tiles[i][j + 1]; + if ((tile_6 != null) && tile_6.aBoolean1323 && (tile_6.aBoolean1322 || ((tile_1.flags & 2) == 0))) { continue; } } @@ -1087,41 +1118,41 @@ public class Scene { flag = true; } tile_1.aBoolean1322 = false; - if (tile_1.aTile_1329 != null) { - SceneTile tile_7 = tile_1.aTile_1329; - if (tile_7.aUnderlay_1311 != null) { - if (!method320(0, i, j)) { - method315(tile_7.aUnderlay_1311, 0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, i, j); + if (tile_1.bridge != null) { + SceneTile tile_7 = tile_1.bridge; + if (tile_7.underlay != null) { + if (!tileOccluded(0, i, j)) { + method315(tile_7.underlay, 0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, i, j); } - } else if ((tile_7.aOverlay_1312 != null) && !method320(0, i, j)) { - method316(i, sinEyePitch, sinEyeYaw, tile_7.aOverlay_1312, cosEyePitch, j, cosEyeYaw); + } else if ((tile_7.overlay != null) && !tileOccluded(0, i, j)) { + method316(i, sinEyePitch, sinEyeYaw, tile_7.overlay, cosEyePitch, j, cosEyeYaw); } - SceneWall wall = tile_7.aWall_1313; + SceneWall wall = tile_7.wall; if (wall != null) { - wall.aEntity_278.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall.anInt274 - eyeX, wall.anInt273 - eyeY, wall.anInt275 - eyeZ, wall.anInt280); + wall.entity0.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall.x - eyeX, wall.y - eyeY, wall.z - eyeZ, wall.bitset); } - for (int i2 = 0; i2 < tile_7.anInt1317; i2++) { - SceneLoc loc = tile_7.aLocArray1318[i2]; + for (int i2 = 0; i2 < tile_7.locCount; i2++) { + SceneLoc loc = tile_7.locs[i2]; if (loc != null) { - loc.aEntity_521.draw(loc.anInt522, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, loc.anInt519 - eyeX, loc.anInt518 - eyeY, loc.anInt520 - eyeZ, loc.anInt529); + loc.entity.draw(loc.yaw, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, loc.x - eyeX, loc.y - eyeY, loc.z - eyeZ, loc.bitset); } } } boolean flag1 = false; - if (tile_1.aUnderlay_1311 != null) { - if (!method320(l, i, j)) { + if (tile_1.underlay != null) { + if (!tileOccluded(l, i, j)) { flag1 = true; - method315(tile_1.aUnderlay_1311, l, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, i, j); + method315(tile_1.underlay, l, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, i, j); } - } else if ((tile_1.aOverlay_1312 != null) && !method320(l, i, j)) { + } else if ((tile_1.overlay != null) && !tileOccluded(l, i, j)) { flag1 = true; - method316(i, sinEyePitch, sinEyeYaw, tile_1.aOverlay_1312, cosEyePitch, j, cosEyeYaw); + method316(i, sinEyePitch, sinEyeYaw, tile_1.overlay, cosEyePitch, j, cosEyeYaw); } int j1 = 0; int j2 = 0; - SceneWall wall_3 = tile_1.aWall_1313; - SceneWallDecoration wallDecoration_1 = tile_1.aWallDecoration_1314; - if ((wall_3 != null) || (wallDecoration_1 != null)) { + SceneWall wall = tile_1.wall; + SceneWallDecoration decor = tile_1.wallDecoration; + if ((wall != null) || (decor != null)) { if (eyeTileX == i) { j1++; } else if (eyeTileX < i) { @@ -1135,17 +1166,17 @@ public class Scene { j2 = anIntArray478[j1]; tile_1.anInt1328 = anIntArray480[j1]; } - if (wall_3 != null) { - if ((wall_3.anInt276 & anIntArray479[j1]) != 0) { - if (wall_3.anInt276 == 16) { + if (wall != null) { + if ((wall.type0 & anIntArray479[j1]) != 0) { + if (wall.type0 == 16) { tile_1.anInt1325 = 3; tile_1.anInt1326 = anIntArray481[j1]; tile_1.anInt1327 = 3 - tile_1.anInt1326; - } else if (wall_3.anInt276 == 32) { + } else if (wall.type0 == 32) { tile_1.anInt1325 = 6; tile_1.anInt1326 = anIntArray482[j1]; tile_1.anInt1327 = 6 - tile_1.anInt1326; - } else if (wall_3.anInt276 == 64) { + } else if (wall.type0 == 64) { tile_1.anInt1325 = 12; tile_1.anInt1326 = anIntArray483[j1]; tile_1.anInt1327 = 12 - tile_1.anInt1326; @@ -1157,21 +1188,21 @@ public class Scene { } else { tile_1.anInt1325 = 0; } - if (((wall_3.anInt276 & j2) != 0) && !method321(l, i, j, wall_3.anInt276)) { - wall_3.aEntity_278.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall_3.anInt274 - eyeX, wall_3.anInt273 - eyeY, wall_3.anInt275 - eyeZ, wall_3.anInt280); + 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_3.anInt277 & j2) != 0) && !method321(l, i, j, wall_3.anInt277)) { - wall_3.aEntity_279.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall_3.anInt274 - eyeX, wall_3.anInt273 - eyeY, wall_3.anInt275 - eyeZ, wall_3.anInt280); + 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 ((wallDecoration_1 != null) && !method322(l, i, j, wallDecoration_1.aEntity_504.minY)) { - if ((wallDecoration_1.anInt502 & j2) != 0) { - wallDecoration_1.aEntity_504.draw(wallDecoration_1.anInt503, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wallDecoration_1.anInt500 - eyeX, wallDecoration_1.anInt499 - eyeY, wallDecoration_1.anInt501 - eyeZ, wallDecoration_1.anInt505); - } else if ((wallDecoration_1.anInt502 & 0x300) != 0) { - int j4 = wallDecoration_1.anInt500 - eyeX; - int l5 = wallDecoration_1.anInt499 - eyeY; - int k6 = wallDecoration_1.anInt501 - eyeZ; - int i8 = wallDecoration_1.anInt503; + if ((decor != null) && !occluded(l, i, j, decor.entity.minY)) { + if ((decor.type & 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) { + int j4 = decor.x - eyeX; + int l5 = decor.y - eyeY; + int k6 = decor.z - eyeZ; + int i8 = decor.yaw; int k9; if ((i8 == 1) || (i8 == 2)) { k9 = -j4; @@ -1184,58 +1215,58 @@ public class Scene { } else { k10 = k6; } - if (((wallDecoration_1.anInt502 & 0x100) != 0) && (k10 < k9)) { + if (((decor.type & 0x100) != 0) && (k10 < k9)) { int i11 = j4 + anIntArray463[i8]; int k11 = k6 + anIntArray464[i8]; - wallDecoration_1.aEntity_504.draw((i8 * 512) + 256, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, i11, l5, k11, wallDecoration_1.anInt505); + decor.entity.draw((i8 * 512) + 256, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, i11, l5, k11, decor.bitset); } - if (((wallDecoration_1.anInt502 & 0x200) != 0) && (k10 > k9)) { + if (((decor.type & 0x200) != 0) && (k10 > k9)) { int j11 = j4 + anIntArray465[i8]; int l11 = k6 + anIntArray466[i8]; - wallDecoration_1.aEntity_504.draw(((i8 * 512) + 1280) & 0x7ff, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, j11, l5, l11, wallDecoration_1.anInt505); + decor.entity.draw(((i8 * 512) + 1280) & 0x7ff, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, j11, l5, l11, decor.bitset); } } } if (flag1) { - SceneGroundDecoration groundDecoration = tile_1.aGroundDecoration_1315; + SceneGroundDecoration groundDecoration = tile_1.groundDecoration; if (groundDecoration != null) { - groundDecoration.aEntity_814.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, groundDecoration.anInt812 - eyeX, groundDecoration.anInt811 - eyeY, groundDecoration.anInt813 - eyeZ, groundDecoration.anInt815); + groundDecoration.entity.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, groundDecoration.x - eyeX, groundDecoration.y - eyeY, groundDecoration.z - eyeZ, groundDecoration.bitset); } - SceneObjStack objStack_1 = tile_1.aObjStack_1316; - if ((objStack_1 != null) && (objStack_1.anInt52 == 0)) { - if (objStack_1.aEntity_49 != null) { - objStack_1.aEntity_49.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack_1.anInt46 - eyeX, objStack_1.anInt45 - eyeY, objStack_1.anInt47 - eyeZ, objStack_1.anInt51); + SceneObjStack objStack_1 = tile_1.objStack; + if ((objStack_1 != null) && (objStack_1.offset == 0)) { + if (objStack_1.entity1 != null) { + objStack_1.entity1.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack_1.x - eyeX, objStack_1.y - eyeY, objStack_1.z - eyeZ, objStack_1.bitset); } - if (objStack_1.aEntity_50 != null) { - objStack_1.aEntity_50.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack_1.anInt46 - eyeX, objStack_1.anInt45 - eyeY, objStack_1.anInt47 - eyeZ, objStack_1.anInt51); + if (objStack_1.entity2 != null) { + objStack_1.entity2.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack_1.x - eyeX, objStack_1.y - eyeY, objStack_1.z - eyeZ, objStack_1.bitset); } - if (objStack_1.aEntity_48 != null) { - objStack_1.aEntity_48.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack_1.anInt46 - eyeX, objStack_1.anInt45 - eyeY, objStack_1.anInt47 - eyeZ, objStack_1.anInt51); + if (objStack_1.entity0 != null) { + objStack_1.entity0.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack_1.x - eyeX, objStack_1.y - eyeY, objStack_1.z - eyeZ, objStack_1.bitset); } } } - int k4 = tile_1.anInt1320; + int k4 = tile_1.flags; if (k4 != 0) { if ((i < eyeTileX) && ((k4 & 4) != 0)) { - SceneTile tile_17 = aclass30_sub3[i + 1][j]; + SceneTile tile_17 = tiles[i + 1][j]; if ((tile_17 != null) && tile_17.aBoolean1323) { aList_477.pushBack(tile_17); } } if ((j < eyeTileZ) && ((k4 & 2) != 0)) { - SceneTile tile_18 = aclass30_sub3[i][j + 1]; + SceneTile tile_18 = tiles[i][j + 1]; if ((tile_18 != null) && tile_18.aBoolean1323) { aList_477.pushBack(tile_18); } } if ((i > eyeTileX) && ((k4 & 1) != 0)) { - SceneTile tile_19 = aclass30_sub3[i - 1][j]; + SceneTile tile_19 = tiles[i - 1][j]; if ((tile_19 != null) && tile_19.aBoolean1323) { aList_477.pushBack(tile_19); } } if ((j > eyeTileZ) && ((k4 & 8) != 0)) { - SceneTile tile_20 = aclass30_sub3[i][j - 1]; + SceneTile tile_20 = tiles[i][j - 1]; if ((tile_20 != null) && tile_20.aBoolean1323) { aList_477.pushBack(tile_20); } @@ -1244,53 +1275,57 @@ public class Scene { } if (tile_1.anInt1325 != 0) { boolean flag2 = true; - for (int k1 = 0; k1 < tile_1.anInt1317; k1++) { - if ((tile_1.aLocArray1318[k1].anInt528 == anInt448) || ((tile_1.anIntArray1319[k1] & tile_1.anInt1325) != tile_1.anInt1326)) { + for (int k1 = 0; k1 < tile_1.locCount; k1++) { + if ((tile_1.locs[k1].cycle == cycle) || ((tile_1.locFlags[k1] & tile_1.anInt1325) != tile_1.anInt1326)) { continue; } flag2 = false; break; } if (flag2) { - SceneWall wall_1 = tile_1.aWall_1313; - if (!method321(l, i, j, wall_1.anInt276)) { - wall_1.aEntity_278.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall_1.anInt274 - eyeX, wall_1.anInt273 - eyeY, wall_1.anInt275 - eyeZ, wall_1.anInt280); + 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); } tile_1.anInt1325 = 0; } } if (tile_1.aBoolean1324) { try { - int i1 = tile_1.anInt1317; + int locCount = tile_1.locCount; tile_1.aBoolean1324 = false; - int l1 = 0; + int tmpCount = 0; + label0: - for (int k2 = 0; k2 < i1; k2++) { - SceneLoc loc_1 = tile_1.aLocArray1318[k2]; - if (loc_1.anInt528 == anInt448) { + for (int k2 = 0; k2 < locCount; k2++) { + SceneLoc loc = tile_1.locs[k2]; + + if (loc.cycle == cycle) { continue; } - for (int k3 = loc_1.anInt523; k3 <= loc_1.anInt524; k3++) { - for (int l4 = loc_1.anInt525; l4 <= loc_1.anInt526; l4++) { - SceneTile tile_21 = aclass30_sub3[k3][l4]; - if (!tile_21.aBoolean1322) { - if (tile_21.anInt1325 == 0) { + + for (int stx = loc.minSceneTileX; stx <= loc.maxSceneTileX; stx++) { + for (int stz = loc.minSceneTileZ; stz <= loc.maxSceneTileZ; stz++) { + SceneTile ground = tiles[stx][stz]; + + if (!ground.aBoolean1322) { + if (ground.anInt1325 == 0) { continue; } int l6 = 0; - if (k3 > loc_1.anInt523) { + if (stx > loc.minSceneTileX) { l6++; } - if (k3 < loc_1.anInt524) { + if (stx < loc.maxSceneTileX) { l6 += 4; } - if (l4 > loc_1.anInt525) { + if (stz > loc.minSceneTileZ) { l6 += 8; } - if (l4 < loc_1.anInt526) { + if (stz < loc.maxSceneTileZ) { l6 += 2; } - if ((l6 & tile_21.anInt1325) != tile_1.anInt1327) { + if ((l6 & ground.anInt1325) != tile_1.anInt1327) { continue; } } @@ -1298,51 +1333,65 @@ public class Scene { continue label0; } } - aLocArray462[l1++] = loc_1; - int i5 = eyeTileX - loc_1.anInt523; - int i6 = loc_1.anInt524 - eyeTileX; - if (i6 > i5) { - i5 = i6; + + tmp[tmpCount++] = loc; + + int dtx0 = eyeTileX - loc.minSceneTileX; + int dtx1 = loc.maxSceneTileX - eyeTileX; + + if (dtx1 > dtx0) { + dtx0 = dtx1; } - int i7 = eyeTileZ - loc_1.anInt525; - int j8 = loc_1.anInt526 - eyeTileZ; - if (j8 > i7) { - loc_1.anInt527 = i5 + j8; + + int dtz0 = eyeTileZ - loc.minSceneTileZ; + int dtz1 = loc.maxSceneTileZ - eyeTileZ; + + if (dtz1 > dtz0) { + loc.distance = dtx0 + dtz1; } else { - loc_1.anInt527 = i5 + i7; + loc.distance = dtx0 + dtz0; } } + while (true) { - int i3 = -50; - int l3 = -1; - for (int j5 = 0; j5 < l1; j5++) { - SceneLoc loc_2 = aLocArray462[j5]; - if (loc_2.anInt528 != anInt448) { - if (loc_2.anInt527 > i3) { - i3 = loc_2.anInt527; - l3 = j5; - } else if (loc_2.anInt527 == i3) { - int j7 = loc_2.anInt519 - eyeX; - int k8 = loc_2.anInt520 - eyeZ; - int l9 = aLocArray462[l3].anInt519 - eyeX; - int l10 = aLocArray462[l3].anInt520 - eyeZ; - if (((j7 * j7) + (k8 * k8)) > ((l9 * l9) + (l10 * l10))) { - l3 = j5; + int farthestDistance = -50; + int farthestIndex = -1; + + for (int i0 = 0; i0 < tmpCount; i0++) { + SceneLoc loc = tmp[i0]; + + if (loc.cycle != cycle) { + if (loc.distance > farthestDistance) { + farthestDistance = loc.distance; + farthestIndex = i0; + } else if (loc.distance == farthestDistance) { + int dx0 = loc.x - eyeX; + int dz0 = loc.z - eyeZ; + int dx1 = tmp[farthestIndex].x - eyeX; + int dz1 = tmp[farthestIndex].z - eyeZ; + + // dot + if (((dx0 * dx0) + (dz0 * dz0)) > ((dx1 * dx1) + (dz1 * dz1))) { + farthestIndex = i0; } } } } - if (l3 == -1) { + + if (farthestIndex == -1) { break; } - SceneLoc loc_3 = aLocArray462[l3]; - loc_3.anInt528 = anInt448; - if (!method323(l, loc_3.anInt523, loc_3.anInt524, loc_3.anInt525, loc_3.anInt526, loc_3.aEntity_521.minY)) { - loc_3.aEntity_521.draw(loc_3.anInt522, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, loc_3.anInt519 - eyeX, loc_3.anInt518 - eyeY, loc_3.anInt520 - eyeZ, loc_3.anInt529); + + SceneLoc farthest = tmp[farthestIndex]; + farthest.cycle = cycle; + + if (!occluded(l, farthest.minSceneTileX, farthest.maxSceneTileX, farthest.minSceneTileZ, farthest.maxSceneTileZ, farthest.entity.minY)) { + farthest.entity.draw(farthest.yaw, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, farthest.x - eyeX, farthest.y - eyeY, farthest.z - eyeZ, farthest.bitset); } - for (int k7 = loc_3.anInt523; k7 <= loc_3.anInt524; k7++) { - for (int l8 = loc_3.anInt525; l8 <= loc_3.anInt526; l8++) { - SceneTile tile_22 = aclass30_sub3[k7][l8]; + + for (int k7 = farthest.minSceneTileX; k7 <= farthest.maxSceneTileX; k7++) { + for (int l8 = farthest.minSceneTileZ; l8 <= farthest.maxSceneTileZ; l8++) { + SceneTile tile_22 = tiles[k7][l8]; if (tile_22.anInt1325 != 0) { aList_477.pushBack(tile_22); } else if (((k7 != i) || (l8 != j)) && tile_22.aBoolean1323) { @@ -1362,53 +1411,53 @@ public class Scene { continue; } if ((i <= eyeTileX) && (i > anInt449)) { - SceneTile tile_8 = aclass30_sub3[i - 1][j]; + SceneTile tile_8 = tiles[i - 1][j]; if ((tile_8 != null) && tile_8.aBoolean1323) { continue; } } if ((i >= eyeTileX) && (i < (anInt450 - 1))) { - SceneTile tile_9 = aclass30_sub3[i + 1][j]; + SceneTile tile_9 = tiles[i + 1][j]; if ((tile_9 != null) && tile_9.aBoolean1323) { continue; } } if ((j <= eyeTileZ) && (j > anInt451)) { - SceneTile tile_10 = aclass30_sub3[i][j - 1]; + SceneTile tile_10 = tiles[i][j - 1]; if ((tile_10 != null) && tile_10.aBoolean1323) { continue; } } if ((j >= eyeTileZ) && (j < (anInt452 - 1))) { - SceneTile tile_11 = aclass30_sub3[i][j + 1]; + SceneTile tile_11 = tiles[i][j + 1]; if ((tile_11 != null) && tile_11.aBoolean1323) { continue; } } tile_1.aBoolean1323 = false; anInt446--; - SceneObjStack objStack = tile_1.aObjStack_1316; - if ((objStack != null) && (objStack.anInt52 != 0)) { - if (objStack.aEntity_49 != null) { - objStack.aEntity_49.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack.anInt46 - eyeX, objStack.anInt45 - eyeY - objStack.anInt52, objStack.anInt47 - eyeZ, objStack.anInt51); + SceneObjStack objStack = tile_1.objStack; + if ((objStack != null) && (objStack.offset != 0)) { + if (objStack.entity1 != null) { + objStack.entity1.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack.x - eyeX, objStack.y - eyeY - objStack.offset, objStack.z - eyeZ, objStack.bitset); } - if (objStack.aEntity_50 != null) { - objStack.aEntity_50.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack.anInt46 - eyeX, objStack.anInt45 - eyeY - objStack.anInt52, objStack.anInt47 - eyeZ, objStack.anInt51); + if (objStack.entity2 != null) { + objStack.entity2.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack.x - eyeX, objStack.y - eyeY - objStack.offset, objStack.z - eyeZ, objStack.bitset); } - if (objStack.aEntity_48 != null) { - objStack.aEntity_48.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack.anInt46 - eyeX, objStack.anInt45 - eyeY - objStack.anInt52, objStack.anInt47 - eyeZ, objStack.anInt51); + if (objStack.entity0 != null) { + objStack.entity0.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, objStack.x - eyeX, objStack.y - eyeY - objStack.offset, objStack.z - eyeZ, objStack.bitset); } } if (tile_1.anInt1328 != 0) { - SceneWallDecoration wallDecoration = tile_1.aWallDecoration_1314; - if ((wallDecoration != null) && !method322(l, i, j, wallDecoration.aEntity_504.minY)) { - if ((wallDecoration.anInt502 & tile_1.anInt1328) != 0) { - wallDecoration.aEntity_504.draw(wallDecoration.anInt503, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wallDecoration.anInt500 - eyeX, wallDecoration.anInt499 - eyeY, wallDecoration.anInt501 - eyeZ, wallDecoration.anInt505); - } else if ((wallDecoration.anInt502 & 0x300) != 0) { - int l2 = wallDecoration.anInt500 - eyeX; - int j3 = wallDecoration.anInt499 - eyeY; - int i4 = wallDecoration.anInt501 - eyeZ; - int k5 = wallDecoration.anInt503; + 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; int j6; if ((k5 == 1) || (k5 == 2)) { j6 = -l2; @@ -1421,54 +1470,54 @@ public class Scene { } else { l7 = i4; } - if (((wallDecoration.anInt502 & 0x100) != 0) && (l7 >= j6)) { + if (((wallDecoration.type & 0x100) != 0) && (l7 >= j6)) { int i9 = l2 + anIntArray463[k5]; int i10 = i4 + anIntArray464[k5]; - wallDecoration.aEntity_504.draw((k5 * 512) + 256, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, i9, j3, i10, wallDecoration.anInt505); + wallDecoration.entity.draw((k5 * 512) + 256, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, i9, j3, i10, wallDecoration.bitset); } - if (((wallDecoration.anInt502 & 0x200) != 0) && (l7 <= j6)) { + if (((wallDecoration.type & 0x200) != 0) && (l7 <= j6)) { int j9 = l2 + anIntArray465[k5]; int j10 = i4 + anIntArray466[k5]; - wallDecoration.aEntity_504.draw(((k5 * 512) + 1280) & 0x7ff, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, j9, j3, j10, wallDecoration.anInt505); + wallDecoration.entity.draw(((k5 * 512) + 1280) & 0x7ff, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, j9, j3, j10, wallDecoration.bitset); } } } - SceneWall wall_2 = tile_1.aWall_1313; + SceneWall wall_2 = tile_1.wall; if (wall_2 != null) { - if (((wall_2.anInt277 & tile_1.anInt1328) != 0) && !method321(l, i, j, wall_2.anInt277)) { - wall_2.aEntity_279.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall_2.anInt274 - eyeX, wall_2.anInt273 - eyeY, wall_2.anInt275 - eyeZ, wall_2.anInt280); + 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.anInt276 & tile_1.anInt1328) != 0) && !method321(l, i, j, wall_2.anInt276)) { - wall_2.aEntity_278.draw(0, sinEyePitch, cosEyePitch, sinEyeYaw, cosEyeYaw, wall_2.anInt274 - eyeX, wall_2.anInt273 - eyeY, wall_2.anInt275 - eyeZ, wall_2.anInt280); + 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 (k < (anInt437 - 1)) { - SceneTile tile_12 = aTileArrayArrayArray441[k + 1][i][j]; + if (k < (maxPlane - 1)) { + SceneTile tile_12 = planeTiles[k + 1][i][j]; if ((tile_12 != null) && tile_12.aBoolean1323) { aList_477.pushBack(tile_12); } } if (i < eyeTileX) { - SceneTile tile_13 = aclass30_sub3[i + 1][j]; + SceneTile tile_13 = tiles[i + 1][j]; if ((tile_13 != null) && tile_13.aBoolean1323) { aList_477.pushBack(tile_13); } } if (j < eyeTileZ) { - SceneTile tile_14 = aclass30_sub3[i][j + 1]; + SceneTile tile_14 = tiles[i][j + 1]; if ((tile_14 != null) && tile_14.aBoolean1323) { aList_477.pushBack(tile_14); } } if (i > eyeTileX) { - SceneTile tile_15 = aclass30_sub3[i - 1][j]; + SceneTile tile_15 = tiles[i - 1][j]; if ((tile_15 != null) && tile_15.aBoolean1323) { aList_477.pushBack(tile_15); } } if (j > eyeTileZ) { - SceneTile tile_16 = aclass30_sub3[i][j - 1]; + SceneTile tile_16 = tiles[i][j - 1]; if ((tile_16 != null) && tile_16.aBoolean1323) { aList_477.pushBack(tile_16); } @@ -1485,10 +1534,10 @@ public class Scene { int i3 = l2 = i2 + 128; int j3; int k3 = j3 = k2 + 128; - int l3 = anIntArrayArrayArray440[i][j1][k1] - eyeY; - int i4 = anIntArrayArrayArray440[i][j1 + 1][k1] - eyeY; - int j4 = anIntArrayArrayArray440[i][j1 + 1][k1 + 1] - eyeY; - int k4 = anIntArrayArrayArray440[i][j1][k1 + 1] - eyeY; + int l3 = planeHeightmaps[i][j1][k1] - eyeY; + int i4 = planeHeightmaps[i][j1 + 1][k1] - eyeY; + int j4 = planeHeightmaps[i][j1 + 1][k1 + 1] - eyeY; + int k4 = planeHeightmaps[i][j1][k1 + 1] - eyeY; int l4 = ((k2 * l) + (i2 * i1)) >> 16; k2 = ((k2 * i1) - (i2 * l)) >> 16; i2 = l4; @@ -1668,7 +1717,7 @@ public class Scene { public void method319() { int j = anIntArray473[anInt447]; SceneOccluder[] aclass47 = aOccluderArrayArray474[anInt447]; - anInt475 = 0; + activeOccluderCount = 0; for (int k = 0; k < j; k++) { SceneOccluder occluder = aclass47[k]; if (occluder.anInt791 == 1) { @@ -1696,19 +1745,19 @@ public class Scene { } int j3 = eyeX - occluder.anInt792; if (j3 > 32) { - occluder.anInt798 = 1; + occluder.mode = 1; } else { if (j3 >= -32) { continue; } - occluder.anInt798 = 2; + occluder.mode = 2; j3 = -j3; } occluder.anInt801 = ((occluder.anInt794 - eyeZ) << 8) / j3; occluder.anInt802 = ((occluder.anInt795 - eyeZ) << 8) / j3; occluder.anInt803 = ((occluder.anInt796 - eyeY) << 8) / j3; occluder.anInt804 = ((occluder.anInt797 - eyeY) << 8) / j3; - A_OCCLUDER_ARRAY_476[anInt475++] = occluder; + activeOccluders[activeOccluderCount++] = occluder; continue; } if (occluder.anInt791 == 2) { @@ -1736,19 +1785,19 @@ public class Scene { } int k3 = eyeZ - occluder.anInt794; if (k3 > 32) { - occluder.anInt798 = 3; + occluder.mode = 3; } else { if (k3 >= -32) { continue; } - occluder.anInt798 = 4; + occluder.mode = 4; k3 = -k3; } occluder.anInt799 = ((occluder.anInt792 - eyeX) << 8) / k3; occluder.anInt800 = ((occluder.anInt793 - eyeX) << 8) / k3; occluder.anInt803 = ((occluder.anInt796 - eyeY) << 8) / k3; occluder.anInt804 = ((occluder.anInt797 - eyeY) << 8) / k3; - A_OCCLUDER_ARRAY_476[anInt475++] = occluder; + activeOccluders[activeOccluderCount++] = occluder; } else if (occluder.anInt791 == 4) { int j1 = occluder.anInt796 - eyeY; if (j1 > 128) { @@ -1781,12 +1830,12 @@ public class Scene { } } if (flag2) { - occluder.anInt798 = 5; + occluder.mode = 5; occluder.anInt799 = ((occluder.anInt792 - eyeX) << 8) / j1; occluder.anInt800 = ((occluder.anInt793 - eyeX) << 8) / j1; occluder.anInt801 = ((occluder.anInt794 - eyeZ) << 8) / j1; occluder.anInt802 = ((occluder.anInt795 - eyeZ) << 8) / j1; - A_OCCLUDER_ARRAY_476[anInt475++] = occluder; + activeOccluders[activeOccluderCount++] = occluder; } } } @@ -1794,244 +1843,268 @@ public class Scene { } } - public boolean method320(int i, int j, int k) { - int l = anIntArrayArrayArray445[i][j][k]; - if (l == -anInt448) { + public boolean tileOccluded(int plane, int x, int z) { + int cycle = planeTileOcclusionCycles[plane][x][z]; + + if (cycle == -Scene.cycle) { return false; } - if (l == anInt448) { + + if (cycle == Scene.cycle) { return true; } - int i1 = j << 7; - int j1 = k << 7; - if (method324(i1 + 1, anIntArrayArrayArray440[i][j][k], j1 + 1) && method324((i1 + 128) - 1, anIntArrayArrayArray440[i][j + 1][k], j1 + 1) && method324((i1 + 128) - 1, anIntArrayArrayArray440[i][j + 1][k + 1], (j1 + 128) - 1) && method324(i1 + 1, anIntArrayArrayArray440[i][j][k + 1], (j1 + 128) - 1)) { - anIntArrayArrayArray445[i][j][k] = anInt448; + + int sx = x << 7; + int sz = z << 7; + + if (occluded(sx + 1, planeHeightmaps[plane][x][z], sz + 1) && occluded((sx + 128) - 1, planeHeightmaps[plane][x + 1][z], sz + 1) && occluded((sx + 128) - 1, planeHeightmaps[plane][x + 1][z + 1], (sz + 128) - 1) && occluded(sx + 1, planeHeightmaps[plane][x][z + 1], (sz + 128) - 1)) { + planeTileOcclusionCycles[plane][x][z] = Scene.cycle; return true; } else { - anIntArrayArrayArray445[i][j][k] = -anInt448; + planeTileOcclusionCycles[plane][x][z] = -Scene.cycle; return false; } } - public boolean method321(int i, int j, int k, int l) { - if (!method320(i, j, k)) { + public boolean wallOccluded(int plane, int stx, int stz, int type) { + if (!tileOccluded(plane, stx, stz)) { return false; } - int i1 = j << 7; - int j1 = k << 7; - int k1 = anIntArrayArrayArray440[i][j][k] - 1; - int l1 = k1 - 120; - int i2 = k1 - 230; - int j2 = k1 - 238; - if (l < 16) { - if (l == 1) { - if (i1 > eyeX) { - if (!method324(i1, k1, j1)) { + + int x = stx << 7; + int z = stz << 7; + int y = planeHeightmaps[plane][stx][stz] - 1; + int y0 = y - 120; + int y1 = y - 230; + int y2 = y - 238; + + if (type < 16) { + if (type == 1) { + if (x > eyeX) { + if (!occluded(x, y, z)) { return false; } - if (!method324(i1, k1, j1 + 128)) { + if (!occluded(x, y, z + 128)) { return false; } } - if (i > 0) { - if (!method324(i1, l1, j1)) { + if (plane > 0) { + if (!occluded(x, y0, z)) { return false; } - if (!method324(i1, l1, j1 + 128)) { + if (!occluded(x, y0, z + 128)) { return false; } } - if (!method324(i1, i2, j1)) { + if (!occluded(x, y1, z)) { return false; } - return method324(i1, i2, j1 + 128); + return occluded(x, y1, z + 128); } - if (l == 2) { - if (j1 < eyeZ) { - if (!method324(i1, k1, j1 + 128)) { + if (type == 2) { + if (z < eyeZ) { + if (!occluded(x, y, z + 128)) { return false; } - if (!method324(i1 + 128, k1, j1 + 128)) { + if (!occluded(x + 128, y, z + 128)) { return false; } } - if (i > 0) { - if (!method324(i1, l1, j1 + 128)) { + if (plane > 0) { + if (!occluded(x, y0, z + 128)) { return false; } - if (!method324(i1 + 128, l1, j1 + 128)) { + if (!occluded(x + 128, y0, z + 128)) { return false; } } - if (!method324(i1, i2, j1 + 128)) { + if (!occluded(x, y1, z + 128)) { return false; } - return method324(i1 + 128, i2, j1 + 128); + return occluded(x + 128, y1, z + 128); } - if (l == 4) { - if (i1 < eyeX) { - if (!method324(i1 + 128, k1, j1)) { + if (type == 4) { + if (x < eyeX) { + if (!occluded(x + 128, y, z)) { return false; } - if (!method324(i1 + 128, k1, j1 + 128)) { + if (!occluded(x + 128, y, z + 128)) { return false; } } - if (i > 0) { - if (!method324(i1 + 128, l1, j1)) { + if (plane > 0) { + if (!occluded(x + 128, y0, z)) { return false; } - if (!method324(i1 + 128, l1, j1 + 128)) { + if (!occluded(x + 128, y0, z + 128)) { return false; } } - if (!method324(i1 + 128, i2, j1)) { + if (!occluded(x + 128, y1, z)) { return false; } - return method324(i1 + 128, i2, j1 + 128); + return occluded(x + 128, y1, z + 128); } - if (l == 8) { - if (j1 > eyeZ) { - if (!method324(i1, k1, j1)) { + if (type == 8) { + if (z > eyeZ) { + if (!occluded(x, y, z)) { return false; } - if (!method324(i1 + 128, k1, j1)) { + if (!occluded(x + 128, y, z)) { return false; } } - if (i > 0) { - if (!method324(i1, l1, j1)) { + if (plane > 0) { + if (!occluded(x, y0, z)) { return false; } - if (!method324(i1 + 128, l1, j1)) { + if (!occluded(x + 128, y0, z)) { return false; } } - if (!method324(i1, i2, j1)) { + if (!occluded(x, y1, z)) { return false; } - return method324(i1 + 128, i2, j1); + return occluded(x + 128, y1, z); } } - if (!method324(i1 + 64, j2, j1 + 64)) { + + if (!occluded(x + 64, y2, z + 64)) { return false; } - if (l == 16) { - return method324(i1, i2, j1 + 128); + + if (type == 16) { + return occluded(x, y1, z + 128); } - if (l == 32) { - return method324(i1 + 128, i2, j1 + 128); + + if (type == 32) { + return occluded(x + 128, y1, z + 128); } - if (l == 64) { - return method324(i1 + 128, i2, j1); + + if (type == 64) { + return occluded(x + 128, y1, z); } - if (l == 128) { - return method324(i1, i2, j1); + + if (type == 128) { + return occluded(x, y1, z); } else { System.out.println("Warning unsupported wall type"); return true; } } - public boolean method322(int i, int j, int k, int l) { - if (!method320(i, j, k)) { + public boolean occluded(int plane, int tx, int tz, int y) { + if (!tileOccluded(plane, tx, tz)) { return false; } - int i1 = j << 7; - int j1 = k << 7; - return method324(i1 + 1, anIntArrayArrayArray440[i][j][k] - l, j1 + 1) && method324((i1 + 128) - 1, anIntArrayArrayArray440[i][j + 1][k] - l, j1 + 1) && method324((i1 + 128) - 1, anIntArrayArrayArray440[i][j + 1][k + 1] - l, (j1 + 128) - 1) && method324(i1 + 1, anIntArrayArrayArray440[i][j][k + 1] - l, (j1 + 128) - 1); + int x = tx << 7; + int z = tz << 7; + return occluded(x + 1, planeHeightmaps[plane][tx][tz] - y, z + 1) && occluded((x + 128) - 1, planeHeightmaps[plane][tx + 1][tz] - y, z + 1) && occluded((x + 128) - 1, planeHeightmaps[plane][tx + 1][tz + 1] - y, (z + 128) - 1) && occluded(x + 1, planeHeightmaps[plane][tx][tz + 1] - y, (z + 128) - 1); } - public boolean method323(int i, int j, int k, int l, int i1, int j1) { - if ((j == k) && (l == i1)) { - if (!method320(i, j, l)) { + public boolean occluded(int plane, int tx0, int tx1, int tz0, int tz1, int y) { + if ((tx0 == tx1) && (tz0 == tz1)) { + if (!tileOccluded(plane, tx0, tz0)) { return false; } - int k1 = j << 7; - int i2 = l << 7; - return method324(k1 + 1, anIntArrayArrayArray440[i][j][l] - j1, i2 + 1) && method324((k1 + 128) - 1, anIntArrayArrayArray440[i][j + 1][l] - j1, i2 + 1) && method324((k1 + 128) - 1, anIntArrayArrayArray440[i][j + 1][l + 1] - j1, (i2 + 128) - 1) && method324(k1 + 1, anIntArrayArrayArray440[i][j][l + 1] - j1, (i2 + 128) - 1); + int x = tx0 << 7; + int z = tz0 << 7; + return occluded(x + 1, planeHeightmaps[plane][tx0][tz0] - y, z + 1) && occluded((x + 128) - 1, planeHeightmaps[plane][tx0 + 1][tz0] - y, z + 1) && occluded((x + 128) - 1, planeHeightmaps[plane][tx0 + 1][tz0 + 1] - y, (z + 128) - 1) && occluded(x + 1, planeHeightmaps[plane][tx0][tz0 + 1] - y, (z + 128) - 1); } - for (int l1 = j; l1 <= k; l1++) { - for (int j2 = l; j2 <= i1; j2++) { - if (anIntArrayArrayArray445[i][l1][j2] == -anInt448) { + + for (int stx = tx0; stx <= tx1; stx++) { + for (int stz = tz0; stz <= tz1; stz++) { + if (planeTileOcclusionCycles[plane][stx][stz] == -cycle) { return false; } } } - int k2 = (j << 7) + 1; - int l2 = (l << 7) + 2; - int i3 = anIntArrayArrayArray440[i][j][l] - j1; - if (!method324(k2, i3, l2)) { + + int x0 = (tx0 << 7) + 1; + int z0 = (tz0 << 7) + 2; + int y0 = planeHeightmaps[plane][tx0][tz0] - y; + + if (!occluded(x0, y0, z0)) { return false; } - int j3 = (k << 7) - 1; - if (!method324(j3, i3, l2)) { + + int x1 = (tx1 << 7) - 1; + + if (!occluded(x1, y0, z0)) { return false; } - int k3 = (i1 << 7) - 1; - if (!method324(k2, i3, k3)) { + + int z1 = (tz1 << 7) - 1; + + if (!occluded(x0, y0, z1)) { return false; } - return method324(j3, i3, k3); + + return occluded(x1, y0, z1); } - public boolean method324(int i, int j, int k) { - for (int l = 0; l < anInt475; l++) { - SceneOccluder occluder = A_OCCLUDER_ARRAY_476[l]; - if (occluder.anInt798 == 1) { - int i1 = occluder.anInt792 - i; - if (i1 > 0) { - int j2 = occluder.anInt794 + ((occluder.anInt801 * i1) >> 8); - int k3 = occluder.anInt795 + ((occluder.anInt802 * i1) >> 8); - int l4 = occluder.anInt796 + ((occluder.anInt803 * i1) >> 8); - int i6 = occluder.anInt797 + ((occluder.anInt804 * i1) >> 8); - if ((k >= j2) && (k <= k3) && (j >= l4) && (j <= i6)) { - return true; - } + public boolean occluded(int x, int y, int z) { + for (int i = 0; i < activeOccluderCount; i++) { + SceneOccluder occluder = activeOccluders[i]; + if (occluder.mode == 1) { + int i1 = occluder.anInt792 - x; + if (i1 <= 0) { + continue; } - } else if (occluder.anInt798 == 2) { - int j1 = i - occluder.anInt792; - if (j1 > 0) { - int k2 = occluder.anInt794 + ((occluder.anInt801 * j1) >> 8); - int l3 = occluder.anInt795 + ((occluder.anInt802 * j1) >> 8); - int i5 = occluder.anInt796 + ((occluder.anInt803 * j1) >> 8); - int j6 = occluder.anInt797 + ((occluder.anInt804 * j1) >> 8); - if ((k >= k2) && (k <= l3) && (j >= i5) && (j <= j6)) { - return true; - } + int j2 = occluder.anInt794 + ((occluder.anInt801 * i1) >> 8); + int k3 = occluder.anInt795 + ((occluder.anInt802 * i1) >> 8); + int l4 = occluder.anInt796 + ((occluder.anInt803 * i1) >> 8); + int i6 = occluder.anInt797 + ((occluder.anInt804 * i1) >> 8); + if ((z >= j2) && (z <= k3) && (y >= l4) && (y <= i6)) { + return true; } - } else if (occluder.anInt798 == 3) { - int k1 = occluder.anInt794 - k; - if (k1 > 0) { - int l2 = occluder.anInt792 + ((occluder.anInt799 * k1) >> 8); - int i4 = occluder.anInt793 + ((occluder.anInt800 * k1) >> 8); - int j5 = occluder.anInt796 + ((occluder.anInt803 * k1) >> 8); - int k6 = occluder.anInt797 + ((occluder.anInt804 * k1) >> 8); - if ((i >= l2) && (i <= i4) && (j >= j5) && (j <= k6)) { - return true; - } + } else if (occluder.mode == 2) { + int j1 = x - occluder.anInt792; + if (j1 <= 0) { + continue; } - } else if (occluder.anInt798 == 4) { - int l1 = k - occluder.anInt794; - if (l1 > 0) { - int i3 = occluder.anInt792 + ((occluder.anInt799 * l1) >> 8); - int j4 = occluder.anInt793 + ((occluder.anInt800 * l1) >> 8); - int k5 = occluder.anInt796 + ((occluder.anInt803 * l1) >> 8); - int l6 = occluder.anInt797 + ((occluder.anInt804 * l1) >> 8); - if ((i >= i3) && (i <= j4) && (j >= k5) && (j <= l6)) { - return true; - } + int k2 = occluder.anInt794 + ((occluder.anInt801 * j1) >> 8); + int l3 = occluder.anInt795 + ((occluder.anInt802 * j1) >> 8); + int i5 = occluder.anInt796 + ((occluder.anInt803 * j1) >> 8); + int j6 = occluder.anInt797 + ((occluder.anInt804 * j1) >> 8); + if ((z >= k2) && (z <= l3) && (y >= i5) && (y <= j6)) { + return true; } - } else if (occluder.anInt798 == 5) { - int i2 = j - occluder.anInt796; - if (i2 > 0) { - int j3 = occluder.anInt792 + ((occluder.anInt799 * i2) >> 8); - int k4 = occluder.anInt793 + ((occluder.anInt800 * i2) >> 8); - int l5 = occluder.anInt794 + ((occluder.anInt801 * i2) >> 8); - int i7 = occluder.anInt795 + ((occluder.anInt802 * i2) >> 8); - if ((i >= j3) && (i <= k4) && (k >= l5) && (k <= i7)) { - return true; - } + } else if (occluder.mode == 3) { + int k1 = occluder.anInt794 - z; + if (k1 <= 0) { + continue; + } + int l2 = occluder.anInt792 + ((occluder.anInt799 * k1) >> 8); + int i4 = occluder.anInt793 + ((occluder.anInt800 * k1) >> 8); + int j5 = occluder.anInt796 + ((occluder.anInt803 * k1) >> 8); + int k6 = occluder.anInt797 + ((occluder.anInt804 * k1) >> 8); + if ((x >= l2) && (x <= i4) && (y >= j5) && (y <= k6)) { + return true; + } + } else if (occluder.mode == 4) { + int l1 = z - occluder.anInt794; + if (l1 <= 0) { + continue; + } + int i3 = occluder.anInt792 + ((occluder.anInt799 * l1) >> 8); + int j4 = occluder.anInt793 + ((occluder.anInt800 * l1) >> 8); + int k5 = occluder.anInt796 + ((occluder.anInt803 * l1) >> 8); + int l6 = occluder.anInt797 + ((occluder.anInt804 * l1) >> 8); + if ((x >= i3) && (x <= j4) && (y >= k5) && (y <= l6)) { + return true; + } + } else if (occluder.mode == 5) { + int i2 = y - occluder.anInt796; + if (i2 <= 0) { + continue; + } + int j3 = occluder.anInt792 + ((occluder.anInt799 * i2) >> 8); + int k4 = occluder.anInt793 + ((occluder.anInt800 * i2) >> 8); + int l5 = occluder.anInt794 + ((occluder.anInt801 * i2) >> 8); + int i7 = occluder.anInt795 + ((occluder.anInt802 * i2) >> 8); + if ((x >= j3) && (x <= k4) && (z >= l5) && (z <= i7)) { + return true; } } } diff --git a/src/main/java/SceneBuilder.java b/src/main/java/SceneBuilder.java index 3e9fa50..ed89c36 100644 --- a/src/main/java/SceneBuilder.java +++ b/src/main/java/SceneBuilder.java @@ -5,9 +5,9 @@ public class SceneBuilder { public static final int[] anIntArray137 = {1, 0, -1, 0}; - public static final int[] anIntArray140 = {16, 32, 64, 128}; + public static final int[] WALL_TYPE_1 = {16, 32, 64, 128}; public static final int[] anIntArray144 = {0, -1, 0, 1}; - public static final int[] anIntArray152 = {1, 2, 4, 8}; + 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; @@ -102,193 +102,206 @@ public class SceneBuilder { return (i & 0xff80) + i_225_; } - public static void method188(Scene scene, int i, int i_226_, int i_227_, int i_228_, SceneCollisionMap collisionMap, int[][][] is, int i_229_, int i_230_, int i_231_) { - int i_233_ = is[i_228_][i_229_][i_226_]; - int i_234_ = is[i_228_][i_229_ + 1][i_226_]; - int i_235_ = is[i_228_][i_229_ + 1][i_226_ + 1]; - int i_236_ = is[i_228_][i_229_][i_226_ + 1]; - int i_237_ = (i_233_ + i_234_ + i_235_ + i_236_) >> 2; - LocType type = LocType.method572(i_230_); - int i_238_ = i_229_ + (i_226_ << 7) + (i_230_ << 14) + 1073741824; - if (!type.aBoolean778) { - i_238_ += -2147483648; + public static void method188(Scene scene, int rotation, 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; + + LocType loc = LocType.method572(locId); + int bitset = stx + (stz << 7) + (locId << 14) + 1073741824; + + if (!loc.aBoolean778) { + bitset += -2147483648; } - byte i_239_ = (byte) ((i << 6) + i_227_); - if (i_227_ == 22) { + + byte info = (byte) ((rotation << 6) + type); + + if (type == 22) { Entity entity; - if ((type.anInt781 == -1) && (type.anIntArray759 == null)) { - entity = type.method578(22, i, i_233_, i_234_, i_235_, i_236_, -1); + + if ((loc.anInt781 == -1) && (loc.anIntArray759 == null)) { + entity = loc.method578(22, rotation, y00, y10, y11, y01, -1); } else { - entity = new LocEntity(i_230_, i, 22, i_234_, i_235_, i_233_, i_236_, type.anInt781, true); + entity = new LocEntity(locId, rotation, 22, y10, y11, y00, y01, loc.anInt781, true); } - scene.method280(i_231_, i_237_, i_226_, entity, i_239_, i_238_, i_229_); - if (type.aBoolean767 && type.aBoolean778) { - collisionMap.method213(i_226_, i_229_); + + scene.addGroundDecoration(entity, locPlane, stx, stz, y, bitset, info); + + if (loc.aBoolean767 && loc.aBoolean778) { + collisionMap.method213(stz, stx); } - } else if ((i_227_ == 10) || (i_227_ == 11)) { + } else if ((type == 10) || (type == 11)) { Entity entity; - if ((type.anInt781 == -1) && (type.anIntArray759 == null)) { - entity = type.method578(10, i, i_233_, i_234_, i_235_, i_236_, -1); + + if ((loc.anInt781 == -1) && (loc.anIntArray759 == null)) { + entity = loc.method578(10, rotation, y00, y10, y11, y01, -1); } else { - entity = new LocEntity(i_230_, i, 10, i_234_, i_235_, i_233_, i_236_, type.anInt781, true); + entity = new LocEntity(locId, rotation, 10, y10, y11, y00, y01, loc.anInt781, true); } + if (entity != null) { int i_240_ = 0; - if (i_227_ == 11) { + + if (type == 11) { i_240_ += 256; } + int i_241_; int i_242_; - if ((i == 1) || (i == 3)) { - i_241_ = type.anInt761; - i_242_ = type.anInt744; + + if ((rotation == 1) || (rotation == 3)) { + i_241_ = loc.anInt761; + i_242_ = loc.anInt744; } else { - i_241_ = type.anInt744; - i_242_ = type.anInt761; + i_241_ = loc.anInt744; + i_242_ = loc.anInt761; } - scene.method284(i_238_, i_239_, i_237_, i_242_, entity, i_241_, i_231_, i_240_, i_226_, i_229_); + + scene.add(entity, locPlane, stx, stz, y, i_241_, i_242_, i_240_, bitset, info); } - if (type.aBoolean767) { - collisionMap.method212(type.aBoolean757, type.anInt744, type.anInt761, i_229_, i_226_, i); + if (loc.aBoolean767) { + collisionMap.method212(loc.aBoolean757, loc.anInt744, loc.anInt761, stx, stz, rotation); } - } else if (i_227_ >= 12) { + } else if (type >= 12) { Entity entity; - if ((type.anInt781 == -1) && (type.anIntArray759 == null)) { - entity = type.method578(i_227_, i, i_233_, i_234_, i_235_, i_236_, -1); + if ((loc.anInt781 == -1) && (loc.anIntArray759 == null)) { + entity = loc.method578(type, rotation, y00, y10, y11, y01, -1); } else { - entity = new LocEntity(i_230_, i, i_227_, i_234_, i_235_, i_233_, i_236_, type.anInt781, true); + entity = new LocEntity(locId, rotation, type, y10, y11, y00, y01, loc.anInt781, true); } - scene.method284(i_238_, i_239_, i_237_, 1, entity, 1, i_231_, 0, i_226_, i_229_); - if (type.aBoolean767) { - collisionMap.method212(type.aBoolean757, type.anInt744, type.anInt761, i_229_, i_226_, i); + scene.add(entity, locPlane, stx, stz, y, 1, 1, 0, bitset, info); + if (loc.aBoolean767) { + collisionMap.method212(loc.aBoolean757, loc.anInt744, loc.anInt761, stx, stz, rotation); } - } else if (i_227_ == 0) { + } else if (type == 0) { Entity entity; - if ((type.anInt781 == -1) && (type.anIntArray759 == null)) { - entity = type.method578(0, i, i_233_, i_234_, i_235_, i_236_, -1); + if ((loc.anInt781 == -1) && (loc.anIntArray759 == null)) { + entity = loc.method578(0, rotation, y00, y10, y11, y01, -1); } else { - entity = new LocEntity(i_230_, i, 0, i_234_, i_235_, i_233_, i_236_, type.anInt781, true); + entity = new LocEntity(locId, rotation, 0, y10, y11, y00, y01, loc.anInt781, true); } - scene.method282(anIntArray152[i], entity, i_238_, i_226_, i_239_, i_229_, null, i_237_, 0, i_231_); - if (type.aBoolean767) { - collisionMap.method211(i_226_, i, i_229_, i_227_, type.aBoolean757); + scene.addWall(WALL_TYPE_0[rotation], entity, 0, null, locPlane, stx, stz, y, bitset, info); + if (loc.aBoolean767) { + collisionMap.method211(stz, rotation, stx, type, loc.aBoolean757); } - } else if (i_227_ == 1) { + } else if (type == 1) { Entity entity; - if ((type.anInt781 == -1) && (type.anIntArray759 == null)) { - entity = type.method578(1, i, i_233_, i_234_, i_235_, i_236_, -1); + if ((loc.anInt781 == -1) && (loc.anIntArray759 == null)) { + entity = loc.method578(1, rotation, y00, y10, y11, y01, -1); } else { - entity = new LocEntity(i_230_, i, 1, i_234_, i_235_, i_233_, i_236_, type.anInt781, true); + entity = new LocEntity(locId, rotation, 1, y10, y11, y00, y01, loc.anInt781, true); } - scene.method282(anIntArray140[i], entity, i_238_, i_226_, i_239_, i_229_, null, i_237_, 0, i_231_); - if (type.aBoolean767) { - collisionMap.method211(i_226_, i, i_229_, i_227_, type.aBoolean757); + scene.addWall(WALL_TYPE_1[rotation], entity, 0, null, locPlane, stx, stz, y, bitset, info); + if (loc.aBoolean767) { + collisionMap.method211(stz, rotation, stx, type, loc.aBoolean757); } - } else if (i_227_ == 2) { - int i_243_ = (i + 1) & 0x3; + } else if (type == 2) { + int i_243_ = (rotation + 1) & 0x3; Entity entity; Entity entity_244_; - if ((type.anInt781 == -1) && (type.anIntArray759 == null)) { - entity = type.method578(2, 4 + i, i_233_, i_234_, i_235_, i_236_, -1); - entity_244_ = type.method578(2, i_243_, i_233_, i_234_, i_235_, i_236_, -1); + if ((loc.anInt781 == -1) && (loc.anIntArray759 == null)) { + entity = loc.method578(2, 4 + rotation, y00, y10, y11, y01, -1); + entity_244_ = loc.method578(2, i_243_, y00, y10, y11, y01, -1); } else { - entity = new LocEntity(i_230_, 4 + i, 2, i_234_, i_235_, i_233_, i_236_, type.anInt781, true); - entity_244_ = new LocEntity(i_230_, i_243_, 2, i_234_, i_235_, i_233_, i_236_, type.anInt781, true); + entity = new LocEntity(locId, 4 + rotation, 2, y10, y11, y00, y01, loc.anInt781, true); + entity_244_ = new LocEntity(locId, i_243_, 2, y10, y11, y00, y01, loc.anInt781, true); } - scene.method282(anIntArray152[i], entity, i_238_, i_226_, i_239_, i_229_, entity_244_, i_237_, anIntArray152[i_243_], i_231_); - if (type.aBoolean767) { - collisionMap.method211(i_226_, i, i_229_, i_227_, type.aBoolean757); + scene.addWall(WALL_TYPE_0[rotation], entity, WALL_TYPE_0[i_243_], entity_244_, locPlane, stx, stz, y, bitset, info); + if (loc.aBoolean767) { + collisionMap.method211(stz, rotation, stx, type, loc.aBoolean757); } - } else if (i_227_ == 3) { + } else if (type == 3) { Entity entity; - if ((type.anInt781 == -1) && (type.anIntArray759 == null)) { - entity = type.method578(3, i, i_233_, i_234_, i_235_, i_236_, -1); + if ((loc.anInt781 == -1) && (loc.anIntArray759 == null)) { + entity = loc.method578(3, rotation, y00, y10, y11, y01, -1); } else { - entity = new LocEntity(i_230_, i, 3, i_234_, i_235_, i_233_, i_236_, type.anInt781, true); + entity = new LocEntity(locId, rotation, 3, y10, y11, y00, y01, loc.anInt781, true); } - scene.method282(anIntArray140[i], entity, i_238_, i_226_, i_239_, i_229_, null, i_237_, 0, i_231_); - if (type.aBoolean767) { - collisionMap.method211(i_226_, i, i_229_, i_227_, type.aBoolean757); + scene.addWall(WALL_TYPE_1[rotation], entity, 0, null, locPlane, stx, stz, y, bitset, info); + if (loc.aBoolean767) { + collisionMap.method211(stz, rotation, stx, type, loc.aBoolean757); } - } else if (i_227_ == 9) { + } else if (type == 9) { Entity entity; - if ((type.anInt781 == -1) && (type.anIntArray759 == null)) { - entity = type.method578(i_227_, i, i_233_, i_234_, i_235_, i_236_, -1); + if ((loc.anInt781 == -1) && (loc.anIntArray759 == null)) { + entity = loc.method578(type, rotation, y00, y10, y11, y01, -1); } else { - entity = new LocEntity(i_230_, i, i_227_, i_234_, i_235_, i_233_, i_236_, type.anInt781, true); + entity = new LocEntity(locId, rotation, type, y10, y11, y00, y01, loc.anInt781, true); } - scene.method284(i_238_, i_239_, i_237_, 1, entity, 1, i_231_, 0, i_226_, i_229_); - if (type.aBoolean767) { - collisionMap.method212(type.aBoolean757, type.anInt744, type.anInt761, i_229_, i_226_, i); + scene.add(entity, locPlane, stx, stz, y, 1, 1, 0, bitset, info); + if (loc.aBoolean767) { + collisionMap.method212(loc.aBoolean757, loc.anInt744, loc.anInt761, stx, stz, rotation); } } else { - if (type.aBoolean762) { - if (i == 1) { - int i_245_ = i_236_; - i_236_ = i_235_; - i_235_ = i_234_; - i_234_ = i_233_; - i_233_ = i_245_; - } else if (i == 2) { - int i_246_ = i_236_; - i_236_ = i_234_; - i_234_ = i_246_; - i_246_ = i_235_; - i_235_ = i_233_; - i_233_ = i_246_; - } else if (i == 3) { - int i_247_ = i_236_; - i_236_ = i_233_; - i_233_ = i_234_; - i_234_ = i_235_; - i_235_ = i_247_; + if (loc.aBoolean762) { + if (rotation == 1) { + int i_245_ = y01; + y01 = y11; + y11 = y10; + y10 = y00; + y00 = i_245_; + } else if (rotation == 2) { + int i_246_ = y01; + y01 = y10; + y10 = i_246_; + i_246_ = y11; + y11 = y00; + y00 = i_246_; + } else if (rotation == 3) { + int i_247_ = y01; + y01 = y00; + y00 = y10; + y10 = y11; + y11 = i_247_; } } - if (i_227_ == 4) { + if (type == 4) { Entity entity; - if ((type.anInt781 == -1) && (type.anIntArray759 == null)) { - entity = type.method578(4, 0, i_233_, i_234_, i_235_, i_236_, -1); + if ((loc.anInt781 == -1) && (loc.anIntArray759 == null)) { + entity = loc.method578(4, 0, y00, y10, y11, y01, -1); } else { - entity = new LocEntity(i_230_, 0, 4, i_234_, i_235_, i_233_, i_236_, type.anInt781, true); + entity = new LocEntity(locId, 0, 4, y10, y11, y00, y01, loc.anInt781, true); } - scene.method283(i_238_, i_226_, i * 512, i_231_, 0, i_237_, entity, i_229_, i_239_, 0, anIntArray152[i]); - } else if (i_227_ == 5) { + scene.addWallDecoration(WALL_TYPE_0[rotation], entity, locPlane, stx, stz, y, rotation * 512, 0, 0, bitset, info); + } else if (type == 5) { int i_248_ = 16; - int i_249_ = scene.method300(i_231_, i_229_, i_226_); + int i_249_ = scene.getWallBitset(locPlane, stx, stz); if (i_249_ > 0) { i_248_ = LocType.method572((i_249_ >> 14) & 0x7fff).anInt775; } Entity entity; - if ((type.anInt781 == -1) && (type.anIntArray759 == null)) { - entity = type.method578(4, 0, i_233_, i_234_, i_235_, i_236_, -1); + if ((loc.anInt781 == -1) && (loc.anIntArray759 == null)) { + entity = loc.method578(4, 0, y00, y10, y11, y01, -1); } else { - entity = new LocEntity(i_230_, 0, 4, i_234_, i_235_, i_233_, i_236_, type.anInt781, true); + entity = new LocEntity(locId, 0, 4, y10, y11, y00, y01, loc.anInt781, true); } - scene.method283(i_238_, i_226_, i * 512, i_231_, anIntArray137[i] * i_248_, i_237_, entity, i_229_, i_239_, anIntArray144[i] * i_248_, anIntArray152[i]); - } else if (i_227_ == 6) { + scene.addWallDecoration(WALL_TYPE_0[rotation], entity, locPlane, stx, stz, y, rotation * 512, anIntArray137[rotation] * i_248_, anIntArray144[rotation] * i_248_, bitset, info); + } else if (type == 6) { Entity entity; - if ((type.anInt781 == -1) && (type.anIntArray759 == null)) { - entity = type.method578(4, 0, i_233_, i_234_, i_235_, i_236_, -1); + if ((loc.anInt781 == -1) && (loc.anIntArray759 == null)) { + entity = loc.method578(4, 0, y00, y10, y11, y01, -1); } else { - entity = new LocEntity(i_230_, 0, 4, i_234_, i_235_, i_233_, i_236_, type.anInt781, true); + entity = new LocEntity(locId, 0, 4, y10, y11, y00, y01, loc.anInt781, true); } - scene.method283(i_238_, i_226_, i, i_231_, 0, i_237_, entity, i_229_, i_239_, 0, 256); - } else if (i_227_ == 7) { + scene.addWallDecoration(256, entity, locPlane, stx, stz, y, rotation, 0, 0, bitset, info); + } else if (type == 7) { Entity entity; - if ((type.anInt781 == -1) && (type.anIntArray759 == null)) { - entity = type.method578(4, 0, i_233_, i_234_, i_235_, i_236_, -1); + if ((loc.anInt781 == -1) && (loc.anIntArray759 == null)) { + entity = loc.method578(4, 0, y00, y10, y11, y01, -1); } else { - entity = new LocEntity(i_230_, 0, 4, i_234_, i_235_, i_233_, i_236_, type.anInt781, true); + entity = new LocEntity(locId, 0, 4, y10, y11, y00, y01, loc.anInt781, true); } - scene.method283(i_238_, i_226_, i, i_231_, 0, i_237_, entity, i_229_, i_239_, 0, 512); - } else if (i_227_ == 8) { + scene.addWallDecoration(512, entity, locPlane, stx, stz, y, rotation, 0, 0, bitset, info); + } else if (type == 8) { Entity entity; - if ((type.anInt781 == -1) && (type.anIntArray759 == null)) { - entity = type.method578(4, 0, i_233_, i_234_, i_235_, i_236_, -1); + if ((loc.anInt781 == -1) && (loc.anIntArray759 == null)) { + entity = loc.method578(4, 0, y00, y10, y11, y01, -1); } else { - entity = new LocEntity(i_230_, 0, 4, i_234_, i_235_, i_233_, i_236_, type.anInt781, true); + entity = new LocEntity(locId, 0, 4, y10, y11, y00, y01, loc.anInt781, true); } - scene.method283(i_238_, i_226_, i, i_231_, 0, i_237_, entity, i_229_, i_239_, 0, 768); + scene.addWallDecoration(768, entity, locPlane, stx, stz, y, rotation, 0, 0, bitset, info); } } } @@ -340,45 +353,45 @@ public class SceneBuilder { public final int[] anIntArray126; public final int[] anIntArray127; public final int[] anIntArray128; - public final int[][][] anIntArrayArrayArray129; + 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 anInt146; - public final int anInt147; + public final int maxTileX; + public final int maxTileZ; public final byte[][][] aByteArrayArrayArray148; - public final byte[][][] aByteArrayArrayArray149; + public final byte[][][] planeTileFlags; - public SceneBuilder(byte[][][] is, int i_0_, int i_1_, int[][][] is_2_) { + public SceneBuilder(byte[][][] planeTileFlags, int maxTileZ, int maxTileX, int[][][] planeHeightmap) { anInt145 = 99; - anInt146 = i_1_; - anInt147 = i_0_; - anIntArrayArrayArray129 = is_2_; - aByteArrayArrayArray149 = is; - aByteArrayArrayArray142 = new byte[4][anInt146][anInt147]; - aByteArrayArrayArray130 = new byte[4][anInt146][anInt147]; - aByteArrayArrayArray136 = new byte[4][anInt146][anInt147]; - aByteArrayArrayArray148 = new byte[4][anInt146][anInt147]; - anIntArrayArrayArray135 = new int[4][anInt146 + 1][anInt147 + 1]; - aByteArrayArrayArray134 = new byte[4][anInt146 + 1][anInt147 + 1]; - anIntArrayArray139 = new int[anInt146 + 1][anInt147 + 1]; - anIntArray124 = new int[anInt147]; - anIntArray125 = new int[anInt147]; - anIntArray126 = new int[anInt147]; - anIntArray127 = new int[anInt147]; - anIntArray128 = new int[anInt147]; + 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]; } 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 ((aByteArrayArrayArray149[i_6_][i_7_][i_8_] & 0x1) == 1) { + if ((planeTileFlags[i_6_][i_7_][i_8_] & 0x1) == 1) { int i_9_ = i_6_; - if ((aByteArrayArrayArray149[1][i_7_][i_8_] & 0x2) == 2) { + if ((planeTileFlags[1][i_7_][i_8_] & 0x2) == 2) { i_9_--; } if (i_9_ >= 0) { @@ -402,8 +415,8 @@ public class SceneBuilder { if (anInt133 > 16) { anInt133 = 16; } - for (int i_10_ = 0; i_10_ < 4; i_10_++) { - byte[][] is = aByteArrayArrayArray134[i_10_]; + for (int plane = 0; plane < 4; plane++) { + byte[][] is = aByteArrayArrayArray134[plane]; int i_11_ = 96; int i_12_ = 768; int i_13_ = -50; @@ -411,10 +424,10 @@ public class SceneBuilder { 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_ < (anInt147 - 1); i_18_++) { - for (int i_19_ = 1; i_19_ < (anInt146 - 1); i_19_++) { - int i_20_ = (anIntArrayArrayArray129[i_10_][i_19_ + 1][i_18_] - anIntArrayArrayArray129[i_10_][i_19_ - 1][i_18_]); - int i_21_ = (anIntArrayArrayArray129[i_10_][i_19_][i_18_ + 1] - anIntArrayArrayArray129[i_10_][i_19_][i_18_ - 1]); + 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_; @@ -424,18 +437,18 @@ public class SceneBuilder { anIntArrayArray139[i_19_][i_18_] = i_26_ - i_27_; } } - for (int i_28_ = 0; i_28_ < anInt147; i_28_++) { + 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_ < (anInt146 + 5); i_29_++) { - for (int i_30_ = 0; i_30_ < anInt147; i_30_++) { + 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_ < anInt146)) { - int i_32_ = aByteArrayArrayArray142[i_10_][i_31_][i_30_] & 0xff; + 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; @@ -446,8 +459,8 @@ public class SceneBuilder { } } int i_33_ = i_29_ - 5; - if ((i_33_ >= 0) && (i_33_ < anInt146)) { - int i_34_ = aByteArrayArrayArray142[i_10_][i_33_][i_30_] & 0xff; + 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; @@ -458,15 +471,15 @@ public class SceneBuilder { } } } - if ((i_29_ >= 1) && (i_29_ < (anInt146 - 1))) { + 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_ < (anInt147 + 5); i_40_++) { + for (int i_40_ = -5; i_40_ < (maxTileZ + 5); i_40_++) { int i_41_ = i_40_ + 5; - if ((i_41_ >= 0) && (i_41_ < anInt147)) { + if ((i_41_ >= 0) && (i_41_ < maxTileZ)) { i_35_ += anIntArray124[i_41_]; i_36_ += anIntArray125[i_41_]; i_37_ += anIntArray126[i_41_]; @@ -474,24 +487,24 @@ public class SceneBuilder { i_39_ += anIntArray128[i_41_]; } int i_42_ = i_40_ - 5; - if ((i_42_ >= 0) && (i_42_ < anInt147)) { + 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_ < (anInt147 - 1)) && (!lowmem || ((aByteArrayArrayArray149[0][i_29_][i_40_] & 0x2) != 0) || (((aByteArrayArrayArray149[i_10_][i_29_][i_40_] & 0x10) == 0) && (method182(i_40_, i_10_, i_29_, 0) == anInt131)))) { - if (i_10_ < anInt145) { - anInt145 = i_10_; + 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[i_10_][i_29_][i_40_] & 0xff); - int i_44_ = (aByteArrayArrayArray130[i_10_][i_29_][i_40_] & 0xff); + 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_ = anIntArrayArrayArray129[i_10_][i_29_][i_40_]; - int i_46_ = (anIntArrayArrayArray129[i_10_][i_29_ + 1][i_40_]); - int i_47_ = (anIntArrayArrayArray129[i_10_][i_29_ + 1][i_40_ + 1]); - int i_48_ = (anIntArrayArrayArray129[i_10_][i_29_][i_40_ + 1]); + 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]; @@ -512,16 +525,16 @@ public class SceneBuilder { } i_54_ = method177(i_55_, i_56_, i_57_); } - if (i_10_ > 0) { + if (plane > 0) { boolean bool = true; - if ((i_43_ == 0) && ((aByteArrayArrayArray136[i_10_][i_29_][i_40_]) != 0)) { + 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[i_10_][i_29_][i_40_] |= 0x924; + anIntArrayArrayArray135[plane][i_29_][i_40_] |= 0x924; } } int i_58_ = 0; @@ -529,10 +542,10 @@ public class SceneBuilder { i_58_ = (Draw3D.palette[method187(i_54_, 96)]); } if (i_44_ == 0) { - scene.method279(i_10_, 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); + 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[i_10_][i_29_][i_40_]) + 1); - byte i_60_ = (aByteArrayArrayArray148[i_10_][i_29_][i_40_]); + int i_59_ = ((aByteArrayArrayArray136[plane][i_29_][i_40_]) + 1); + byte i_60_ = (aByteArrayArrayArray148[plane][i_29_][i_40_]); FloType type = FloType.instances[i_44_ - 1]; int i_61_ = type.anInt391; int i_62_; @@ -548,24 +561,24 @@ public class SceneBuilder { i_63_ = method177(type.anInt394, type.anInt395, type.anInt396); i_62_ = (Draw3D.palette[method185(type.anInt399, 96)]); } - scene.method279(i_10_, i_29_, i_40_, i_59_, i_60_, i_61_, i_45_, i_46_, i_47_, i_48_, method187(i_53_, i_49_), method187(i_53_, i_50_), method187(i_53_, i_51_), method187(i_53_, i_52_), method185(i_63_, i_49_), method185(i_63_, i_50_), method185(i_63_, i_51_), method185(i_63_, i_52_), i_58_, i_62_); + scene.method279(plane, i_29_, i_40_, i_59_, i_60_, i_61_, i_45_, i_46_, i_47_, i_48_, method187(i_53_, i_49_), method187(i_53_, i_50_), method187(i_53_, i_51_), method187(i_53_, i_52_), method185(i_63_, i_49_), method185(i_63_, i_50_), method185(i_63_, i_51_), method185(i_63_, i_52_), i_58_, i_62_); } } } } } } - for (int i_64_ = 1; i_64_ < (anInt147 - 1); i_64_++) { - for (int i_65_ = 1; i_65_ < (anInt146 - 1); i_65_++) { - scene.method278(i_10_, i_65_, i_64_, method182(i_64_, i_10_, i_65_, 0)); + 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_ < anInt146; i_66_++) { - for (int i_67_ = 0; i_67_ < anInt147; i_67_++) { - if ((aByteArrayArrayArray149[1][i_66_][i_67_] & 0x2) == 2) { - scene.method276(i_67_, i_66_); + 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_); } } } @@ -579,8 +592,8 @@ public class SceneBuilder { i_70_ <<= 3; } for (int i_72_ = 0; i_72_ <= i_71_; i_72_++) { - for (int i_73_ = 0; i_73_ <= anInt147; i_73_++) { - for (int i_74_ = 0; i_74_ <= anInt146; i_74_++) { + 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_; @@ -591,7 +604,7 @@ public class SceneBuilder { break; } } - for (/**/; i_76_ < anInt147; i_76_++) { + for (/**/; i_76_ < maxTileZ; i_76_++) { if (((anIntArrayArrayArray135[i_72_][i_74_][i_76_ + 1]) & i_68_) == 0) { break; } @@ -615,8 +628,8 @@ public class SceneBuilder { int i_81_ = ((i_78_ + 1) - i_77_) * ((i_76_ - i_75_) + 1); if (i_81_ >= 8) { int i_82_ = 240; - int i_83_ = (anIntArrayArrayArray129[i_78_][i_74_][i_75_] - i_82_); - int i_84_ = anIntArrayArrayArray129[i_77_][i_74_][i_75_]; + 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_++) { @@ -635,7 +648,7 @@ public class SceneBuilder { break; } } - for (/**/; i_88_ < anInt146; i_88_++) { + for (/**/; i_88_ < maxTileX; i_88_++) { if (((anIntArrayArrayArray135[i_72_][i_88_ + 1][i_73_]) & i_69_) == 0) { break; } @@ -659,8 +672,8 @@ public class SceneBuilder { int i_93_ = ((i_90_ + 1) - i_89_) * ((i_88_ - i_87_) + 1); if (i_93_ >= 8) { int i_94_ = 240; - int i_95_ = (anIntArrayArrayArray129[i_90_][i_87_][i_73_] - i_94_); - int i_96_ = anIntArrayArrayArray129[i_89_][i_87_][i_73_]; + 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_++) { @@ -679,7 +692,7 @@ public class SceneBuilder { break; } } - for (/**/; i_102_ < anInt147; i_102_++) { + for (/**/; i_102_ < maxTileZ; i_102_++) { if (((anIntArrayArrayArray135[i_72_][i_74_][i_102_ + 1]) & i_70_) == 0) { break; } @@ -693,7 +706,7 @@ public class SceneBuilder { } } while_5_: - for (/**/; i_100_ < anInt146; i_100_++) { + 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_; @@ -701,7 +714,7 @@ public class SceneBuilder { } } if ((((i_100_ - i_99_) + 1) * ((i_102_ - i_101_) + 1)) >= 4) { - int i_105_ = anIntArrayArrayArray129[i_72_][i_99_][i_101_]; + 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_++) { @@ -719,19 +732,19 @@ public class SceneBuilder { 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_ < anInt146) && (i_117_ >= 0) && (i_117_ < anInt147)) { + 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)) { - anIntArrayArrayArray129[0][i_118_][i_117_] = anIntArrayArrayArray129[0][i_118_ - 1][i_117_]; + planeHeightmap[0][i_118_][i_117_] = planeHeightmap[0][i_118_ - 1][i_117_]; } - if ((i_118_ == (i_116_ + i_115_)) && (i_118_ < (anInt146 - 1))) { - anIntArrayArrayArray129[0][i_118_][i_117_] = anIntArrayArrayArray129[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)) { - anIntArrayArrayArray129[0][i_118_][i_117_] = anIntArrayArrayArray129[0][i_118_][i_117_ - 1]; + planeHeightmap[0][i_118_][i_117_] = planeHeightmap[0][i_118_][i_117_ - 1]; } - if ((i_117_ == (i + i_113_)) && (i_117_ < (anInt147 - 1))) { - anIntArrayArrayArray129[0][i_118_][i_117_] = anIntArrayArrayArray129[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]; } } } @@ -739,16 +752,16 @@ public class SceneBuilder { } 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 && ((aByteArrayArrayArray149[0][i_121_][i] & 0x2) == 0) && (((aByteArrayArrayArray149[i_120_][i_121_][i] & 0x10) != 0) || (method182(i, i_120_, i_121_, 0) != anInt131))) { + 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_ = anIntArrayArrayArray129[i_120_][i_121_][i]; - int i_125_ = anIntArrayArrayArray129[i_120_][i_121_ + 1][i]; - int i_126_ = anIntArrayArrayArray129[i_120_][i_121_ + 1][i + 1]; - int i_127_ = anIntArrayArrayArray129[i_120_][i_121_][i + 1]; + 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.method572(i_122_); int i_129_ = i_121_ + (i << 7) + (i_122_ << 14) + 1073741824; @@ -765,7 +778,7 @@ public class SceneBuilder { } else { entity = new LocEntity(i_122_, i_123_, 22, i_125_, i_126_, i_124_, i_127_, type.anInt781, true); } - scene.method280(i_120_, i_128_, i, entity, i_130_, i_129_, i_121_); + scene.addGroundDecoration(entity, i_120_, i_121_, i, i_128_, i_129_, i_130_); if (type.aBoolean767 && type.aBoolean778 && (collisionMap != null)) { collisionMap.method213(i, i_121_); } @@ -791,7 +804,7 @@ public class SceneBuilder { i_132_ = type.anInt744; i_133_ = type.anInt761; } - if (scene.method284(i_129_, i_130_, i_128_, i_133_, entity, i_132_, i_120_, i_131_, i, i_121_) && type.aBoolean779) { + if (scene.add(entity, i_120_, i_121_, i, i_128_, i_132_, i_133_, i_131_, i_129_, i_130_) && type.aBoolean779) { Model model; if (entity instanceof Model) { model = (Model) entity; @@ -823,7 +836,7 @@ public class SceneBuilder { } else { entity = new LocEntity(i_122_, i_123_, i_119_, i_125_, i_126_, i_124_, i_127_, type.anInt781, true); } - scene.method284(i_129_, i_130_, i_128_, 1, entity, 1, i_120_, 0, i, i_121_); + 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; } @@ -837,7 +850,7 @@ public class SceneBuilder { } else { entity = new LocEntity(i_122_, i_123_, 0, i_125_, i_126_, i_124_, i_127_, type.anInt781, true); } - scene.method282(anIntArray152[i_123_], entity, i_129_, i, i_130_, i_121_, null, i_128_, 0, i_120_); + 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.aBoolean779) { aByteArrayArrayArray134[i_120_][i_121_][i] = (byte) 50; @@ -875,7 +888,7 @@ public class SceneBuilder { collisionMap.method211(i, i_123_, i_121_, i_119_, type.aBoolean757); } if (type.anInt775 != 16) { - scene.method290(i, type.anInt775, i_121_, i_120_); + scene.setWallDecorationOffset(i_120_, i_121_, i, type.anInt775); } } else if (i_119_ == 1) { Entity entity; @@ -884,7 +897,7 @@ public class SceneBuilder { } else { entity = new LocEntity(i_122_, i_123_, 1, i_125_, i_126_, i_124_, i_127_, type.anInt781, true); } - scene.method282(anIntArray140[i_123_], entity, i_129_, i, i_130_, i_121_, null, i_128_, 0, i_120_); + scene.addWall(WALL_TYPE_1[i_123_], entity, 0, null, i_120_, i_121_, i, i_128_, i_129_, i_130_); if (type.aBoolean779) { if (i_123_ == 0) { aByteArrayArrayArray134[i_120_][i_121_][i + 1] = (byte) 50; @@ -910,7 +923,7 @@ public class SceneBuilder { entity = new LocEntity(i_122_, 4 + i_123_, 2, i_125_, i_126_, i_124_, i_127_, type.anInt781, true); entity_138_ = new LocEntity(i_122_, i_137_, 2, i_125_, i_126_, i_124_, i_127_, type.anInt781, true); } - scene.method282(anIntArray152[i_123_], entity, i_129_, i, i_130_, i_121_, entity_138_, i_128_, anIntArray152[i_137_], i_120_); + 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.aBoolean764) { if (i_123_ == 0) { anIntArrayArrayArray135[i_120_][i_121_][i] |= 0x249; @@ -930,7 +943,7 @@ public class SceneBuilder { collisionMap.method211(i, i_123_, i_121_, i_119_, type.aBoolean757); } if (type.anInt775 != 16) { - scene.method290(i, type.anInt775, i_121_, i_120_); + scene.setWallDecorationOffset(i_120_, i_121_, i, type.anInt775); } } else if (i_119_ == 3) { Entity entity; @@ -939,7 +952,7 @@ public class SceneBuilder { } else { entity = new LocEntity(i_122_, i_123_, 3, i_125_, i_126_, i_124_, i_127_, type.anInt781, true); } - scene.method282(anIntArray140[i_123_], entity, i_129_, i, i_130_, i_121_, null, i_128_, 0, i_120_); + scene.addWall(WALL_TYPE_1[i_123_], entity, 0, null, i_120_, i_121_, i, i_128_, i_129_, i_130_); if (type.aBoolean779) { if (i_123_ == 0) { aByteArrayArrayArray134[i_120_][i_121_][i + 1] = (byte) 50; @@ -961,7 +974,7 @@ public class SceneBuilder { } else { entity = new LocEntity(i_122_, i_123_, i_119_, i_125_, i_126_, i_124_, i_127_, type.anInt781, true); } - scene.method284(i_129_, i_130_, i_128_, 1, entity, 1, i_120_, 0, i, i_121_); + scene.add(entity, i_120_, i_121_, i, i_128_, 1, 1, 0, i_129_, i_130_); if (type.aBoolean767 && (collisionMap != null)) { collisionMap.method212(type.aBoolean757, type.anInt744, type.anInt761, i_121_, i, i_123_); } @@ -995,10 +1008,10 @@ public class SceneBuilder { } else { entity = new LocEntity(i_122_, 0, 4, i_125_, i_126_, i_124_, i_127_, type.anInt781, true); } - scene.method283(i_129_, i, i_123_ * 512, i_120_, 0, i_128_, entity, i_121_, i_130_, 0, anIntArray152[i_123_]); + 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.method300(i_120_, i_121_, i); + int i_143_ = scene.getWallBitset(i_120_, i_121_, i); if (i_143_ > 0) { i_142_ = LocType.method572((i_143_ >> 14) & 0x7fff).anInt775; } @@ -1008,7 +1021,7 @@ public class SceneBuilder { } else { entity = new LocEntity(i_122_, 0, 4, i_125_, i_126_, i_124_, i_127_, type.anInt781, true); } - scene.method283(i_129_, i, i_123_ * 512, i_120_, anIntArray137[i_123_] * i_142_, i_128_, entity, i_121_, i_130_, anIntArray144[i_123_] * i_142_, anIntArray152[i_123_]); + 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.anInt781 == -1) && (type.anIntArray759 == null)) { @@ -1016,7 +1029,7 @@ public class SceneBuilder { } else { entity = new LocEntity(i_122_, 0, 4, i_125_, i_126_, i_124_, i_127_, type.anInt781, true); } - scene.method283(i_129_, i, i_123_, i_120_, 0, i_128_, entity, i_121_, i_130_, 0, 256); + 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.anInt781 == -1) && (type.anIntArray759 == null)) { @@ -1024,7 +1037,7 @@ public class SceneBuilder { } else { entity = new LocEntity(i_122_, 0, 4, i_125_, i_126_, i_124_, i_127_, type.anInt781, true); } - scene.method283(i_129_, i, i_123_, i_120_, 0, i_128_, entity, i_121_, i_130_, 0, 512); + 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.anInt781 == -1) && (type.anIntArray759 == null)) { @@ -1032,7 +1045,7 @@ public class SceneBuilder { } else { entity = new LocEntity(i_122_, 0, 4, i_125_, i_126_, i_124_, i_127_, type.anInt781, true); } - scene.method283(i_129_, i, i_123_, i_120_, 0, i_128_, entity, i_121_, i_130_, 0, 768); + scene.addWallDecoration(768, entity, i_120_, i_121_, i, i_128_, i_123_, 0, 0, i_129_, i_130_); } } } @@ -1058,7 +1071,7 @@ public class SceneBuilder { 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_].anIntArrayArray294[i_164_ + i_169_][(i_168_ + i_170_)] &= ~0x1000000; + collisionMaps[i_167_].flags[i_164_ + i_169_][(i_168_ + i_170_)] &= ~0x1000000; } } } @@ -1081,7 +1094,7 @@ public class SceneBuilder { 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_].anIntArrayArray294[i_175_ + i_180_][i + i_181_] &= ~0x1000000; + collisionMaps[i_179_].flags[i_175_ + i_180_][i + i_181_] &= ~0x1000000; } } } @@ -1098,14 +1111,14 @@ public class SceneBuilder { 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)) { - aByteArrayArrayArray149[i_187_][i_186_][i] = (byte) 0; + planeTileFlags[i_187_][i_186_][i] = (byte) 0; for (; ; ) { int i_191_ = buffer.get1U(); if (i_191_ == 0) { if (i_187_ == 0) { - anIntArrayArrayArray129[0][i_186_][i] = -method172(932731 + i_186_ + i_190_, 556238 + i + i_185_) * 8; + planeHeightmap[0][i_186_][i] = -method172(932731 + i_186_ + i_190_, 556238 + i + i_185_) * 8; } else { - anIntArrayArrayArray129[i_187_][i_186_][i] = anIntArrayArrayArray129[i_187_ - 1][i_186_][i] - 240; + planeHeightmap[i_187_][i_186_][i] = planeHeightmap[i_187_ - 1][i_186_][i] - 240; break; } break; @@ -1116,9 +1129,9 @@ public class SceneBuilder { i_192_ = 0; } if (i_187_ == 0) { - anIntArrayArrayArray129[0][i_186_][i] = -i_192_ * 8; + planeHeightmap[0][i_186_][i] = -i_192_ * 8; } else { - anIntArrayArrayArray129[i_187_][i_186_][i] = (anIntArrayArrayArray129[i_187_ - 1][i_186_][i] - (i_192_ * 8)); + planeHeightmap[i_187_][i_186_][i] = (planeHeightmap[i_187_ - 1][i_186_][i] - (i_192_ * 8)); break; } break; @@ -1128,7 +1141,7 @@ public class SceneBuilder { 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) { - aByteArrayArrayArray149[i_187_][i_186_][i] = (byte) (i_191_ - 49); + planeTileFlags[i_187_][i_186_][i] = (byte) (i_191_ - 49); } else { aByteArrayArrayArray142[i_187_][i_186_][i] = (byte) (i_191_ - 81); } @@ -1150,17 +1163,14 @@ public class SceneBuilder { } } - public int method182(int i, int i_194_, int i_195_, int i_196_) { - if (i_196_ != 0) { - return 2; - } - if ((aByteArrayArrayArray149[i_194_][i_195_][i] & 0x8) != 0) { + public int getDrawPlane(int plane, int stx, int stz) { + if ((planeTileFlags[plane][stx][stz] & 0x8) != 0) { return 0; } - if ((i_194_ > 0) && ((aByteArrayArrayArray149[1][i_195_][i] & 0x2) != 0)) { - return i_194_ - 1; + if ((plane > 0) && ((planeTileFlags[1][stx][stz] & 0x2) != 0)) { + return plane - 1; } - return i_194_; + 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_) { @@ -1191,7 +1201,7 @@ public class SceneBuilder { int i_214_ = i_202_ + ZoneUtil.method158(i_207_ & 0x7, type.anInt761, i_201_, type.anInt744, i_208_ & 0x7); if ((i_213_ > 0) && (i_214_ > 0) && (i_213_ < 103) && (i_214_ < 103)) { int i_215_ = i_209_; - if ((aByteArrayArrayArray149[1][i_213_][i_214_] & 0x2) == 2) { + if ((planeTileFlags[1][i_213_][i_214_] & 0x2) == 2) { i_215_--; } SceneCollisionMap collisionMap = null; @@ -1253,7 +1263,7 @@ public class SceneBuilder { 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 ((aByteArrayArrayArray149[1][i_275_][i_276_] & 0x2) == 2) { + if ((planeTileFlags[1][i_275_][i_276_] & 0x2) == 2) { i_277_--; } SceneCollisionMap collisionMap = null; diff --git a/src/main/java/SceneCollisionMap.java b/src/main/java/SceneCollisionMap.java index 082e27c..4672053 100644 --- a/src/main/java/SceneCollisionMap.java +++ b/src/main/java/SceneCollisionMap.java @@ -8,12 +8,12 @@ public class SceneCollisionMap { public final int anInt291 = 0; public final int anInt292; public final int anInt293; - public final int[][] anIntArrayArray294; + public final int[][] flags; public SceneCollisionMap(int i, int j) { anInt292 = i; anInt293 = j; - anIntArrayArray294 = new int[anInt292][anInt293]; + flags = new int[anInt292][anInt293]; method210(); } @@ -21,9 +21,9 @@ public class SceneCollisionMap { for (int i = 0; i < anInt292; i++) { for (int j = 0; j < anInt293; j++) { if ((i == 0) || (j == 0) || (i == (anInt292 - 1)) || (j == (anInt293 - 1))) { - anIntArrayArray294[i][j] = 0xffffff; + flags[i][j] = 0xffffff; } else { - anIntArrayArray294[i][j] = 0x1000000; + flags[i][j] = 0x1000000; } } } @@ -178,11 +178,11 @@ public class SceneCollisionMap { public void method213(int i, int k) { k -= anInt290; i -= anInt291; - anIntArrayArray294[k][i] |= 0x200000; + flags[k][i] |= 0x200000; } public void method214(int i, int j, int k) { - anIntArrayArray294[i][j] |= k; + flags[i][j] |= k; } public void method215(int i, int j, boolean flag, int k, int l) { @@ -332,13 +332,13 @@ public class SceneCollisionMap { } public void method217(int i, int j, int k) { - anIntArrayArray294[j][k] &= 0xffffff - i; + flags[j][k] &= 0xffffff - i; } public void method218(int j, int k) { k -= anInt290; j -= anInt291; - anIntArrayArray294[k][j] &= 0xdfffff; + flags[k][j] &= 0xdfffff; } public boolean method219(int i, int j, int k, int i1, int j1, int k1) { @@ -354,40 +354,40 @@ public class SceneCollisionMap { if ((j == (i - 1)) && (k == k1)) { return true; } - if ((j == i) && (k == (k1 + 1)) && ((anIntArrayArray294[j][k] & 0x1280120) == 0)) { + if ((j == i) && (k == (k1 + 1)) && ((flags[j][k] & 0x1280120) == 0)) { return true; } - if ((j == i) && (k == (k1 - 1)) && ((anIntArrayArray294[j][k] & 0x1280102) == 0)) { + if ((j == i) && (k == (k1 - 1)) && ((flags[j][k] & 0x1280102) == 0)) { return true; } } else if (i1 == 1) { if ((j == i) && (k == (k1 + 1))) { return true; } - if ((j == (i - 1)) && (k == k1) && ((anIntArrayArray294[j][k] & 0x1280108) == 0)) { + if ((j == (i - 1)) && (k == k1) && ((flags[j][k] & 0x1280108) == 0)) { return true; } - if ((j == (i + 1)) && (k == k1) && ((anIntArrayArray294[j][k] & 0x1280180) == 0)) { + if ((j == (i + 1)) && (k == k1) && ((flags[j][k] & 0x1280180) == 0)) { return true; } } else if (i1 == 2) { if ((j == (i + 1)) && (k == k1)) { return true; } - if ((j == i) && (k == (k1 + 1)) && ((anIntArrayArray294[j][k] & 0x1280120) == 0)) { + if ((j == i) && (k == (k1 + 1)) && ((flags[j][k] & 0x1280120) == 0)) { return true; } - if ((j == i) && (k == (k1 - 1)) && ((anIntArrayArray294[j][k] & 0x1280102) == 0)) { + if ((j == i) && (k == (k1 - 1)) && ((flags[j][k] & 0x1280102) == 0)) { return true; } } else if (i1 == 3) { if ((j == i) && (k == (k1 - 1))) { return true; } - if ((j == (i - 1)) && (k == k1) && ((anIntArrayArray294[j][k] & 0x1280108) == 0)) { + if ((j == (i - 1)) && (k == k1) && ((flags[j][k] & 0x1280108) == 0)) { return true; } - if ((j == (i + 1)) && (k == k1) && ((anIntArrayArray294[j][k] & 0x1280180) == 0)) { + if ((j == (i + 1)) && (k == k1) && ((flags[j][k] & 0x1280180) == 0)) { return true; } } @@ -400,14 +400,14 @@ public class SceneCollisionMap { if ((j == i) && (k == (k1 + 1))) { return true; } - if ((j == (i + 1)) && (k == k1) && ((anIntArrayArray294[j][k] & 0x1280180) == 0)) { + if ((j == (i + 1)) && (k == k1) && ((flags[j][k] & 0x1280180) == 0)) { return true; } - if ((j == i) && (k == (k1 - 1)) && ((anIntArrayArray294[j][k] & 0x1280102) == 0)) { + if ((j == i) && (k == (k1 - 1)) && ((flags[j][k] & 0x1280102) == 0)) { return true; } } else if (i1 == 1) { - if ((j == (i - 1)) && (k == k1) && ((anIntArrayArray294[j][k] & 0x1280108) == 0)) { + if ((j == (i - 1)) && (k == k1) && ((flags[j][k] & 0x1280108) == 0)) { return true; } if ((j == i) && (k == (k1 + 1))) { @@ -416,14 +416,14 @@ public class SceneCollisionMap { if ((j == (i + 1)) && (k == k1)) { return true; } - if ((j == i) && (k == (k1 - 1)) && ((anIntArrayArray294[j][k] & 0x1280102) == 0)) { + if ((j == i) && (k == (k1 - 1)) && ((flags[j][k] & 0x1280102) == 0)) { return true; } } else if (i1 == 2) { - if ((j == (i - 1)) && (k == k1) && ((anIntArrayArray294[j][k] & 0x1280108) == 0)) { + if ((j == (i - 1)) && (k == k1) && ((flags[j][k] & 0x1280108) == 0)) { return true; } - if ((j == i) && (k == (k1 + 1)) && ((anIntArrayArray294[j][k] & 0x1280120) == 0)) { + if ((j == i) && (k == (k1 + 1)) && ((flags[j][k] & 0x1280120) == 0)) { return true; } if ((j == (i + 1)) && (k == k1)) { @@ -436,10 +436,10 @@ public class SceneCollisionMap { if ((j == (i - 1)) && (k == k1)) { return true; } - if ((j == i) && (k == (k1 + 1)) && ((anIntArrayArray294[j][k] & 0x1280120) == 0)) { + if ((j == i) && (k == (k1 + 1)) && ((flags[j][k] & 0x1280120) == 0)) { return true; } - if ((j == (i + 1)) && (k == k1) && ((anIntArrayArray294[j][k] & 0x1280180) == 0)) { + if ((j == (i + 1)) && (k == k1) && ((flags[j][k] & 0x1280180) == 0)) { return true; } if ((j == i) && (k == (k1 - 1))) { @@ -448,16 +448,16 @@ public class SceneCollisionMap { } } if (j1 == 9) { - if ((j == i) && (k == (k1 + 1)) && ((anIntArrayArray294[j][k] & 0x20) == 0)) { + if ((j == i) && (k == (k1 + 1)) && ((flags[j][k] & 0x20) == 0)) { return true; } - if ((j == i) && (k == (k1 - 1)) && ((anIntArrayArray294[j][k] & 2) == 0)) { + if ((j == i) && (k == (k1 - 1)) && ((flags[j][k] & 2) == 0)) { return true; } - if ((j == (i - 1)) && (k == k1) && ((anIntArrayArray294[j][k] & 8) == 0)) { + if ((j == (i - 1)) && (k == k1) && ((flags[j][k] & 8) == 0)) { return true; } - return (j == (i + 1)) && (k == k1) && ((anIntArrayArray294[j][k] & 0x80) == 0); + return (j == (i + 1)) && (k == k1) && ((flags[j][k] & 0x80) == 0); } return false; } @@ -475,46 +475,46 @@ public class SceneCollisionMap { i1 = (i1 + 2) & 3; } if (i1 == 0) { - if ((j1 == (i + 1)) && (k == j) && ((anIntArrayArray294[j1][k] & 0x80) == 0)) { + if ((j1 == (i + 1)) && (k == j) && ((flags[j1][k] & 0x80) == 0)) { return true; } - if ((j1 == i) && (k == (j - 1)) && ((anIntArrayArray294[j1][k] & 2) == 0)) { + if ((j1 == i) && (k == (j - 1)) && ((flags[j1][k] & 2) == 0)) { return true; } } else if (i1 == 1) { - if ((j1 == (i - 1)) && (k == j) && ((anIntArrayArray294[j1][k] & 8) == 0)) { + if ((j1 == (i - 1)) && (k == j) && ((flags[j1][k] & 8) == 0)) { return true; } - if ((j1 == i) && (k == (j - 1)) && ((anIntArrayArray294[j1][k] & 2) == 0)) { + if ((j1 == i) && (k == (j - 1)) && ((flags[j1][k] & 2) == 0)) { return true; } } else if (i1 == 2) { - if ((j1 == (i - 1)) && (k == j) && ((anIntArrayArray294[j1][k] & 8) == 0)) { + if ((j1 == (i - 1)) && (k == j) && ((flags[j1][k] & 8) == 0)) { return true; } - if ((j1 == i) && (k == (j + 1)) && ((anIntArrayArray294[j1][k] & 0x20) == 0)) { + if ((j1 == i) && (k == (j + 1)) && ((flags[j1][k] & 0x20) == 0)) { return true; } } else if (i1 == 3) { - if ((j1 == (i + 1)) && (k == j) && ((anIntArrayArray294[j1][k] & 0x80) == 0)) { + if ((j1 == (i + 1)) && (k == j) && ((flags[j1][k] & 0x80) == 0)) { return true; } - if ((j1 == i) && (k == (j + 1)) && ((anIntArrayArray294[j1][k] & 0x20) == 0)) { + if ((j1 == i) && (k == (j + 1)) && ((flags[j1][k] & 0x20) == 0)) { return true; } } } if (l == 8) { - if ((j1 == i) && (k == (j + 1)) && ((anIntArrayArray294[j1][k] & 0x20) == 0)) { + if ((j1 == i) && (k == (j + 1)) && ((flags[j1][k] & 0x20) == 0)) { return true; } - if ((j1 == i) && (k == (j - 1)) && ((anIntArrayArray294[j1][k] & 2) == 0)) { + if ((j1 == i) && (k == (j - 1)) && ((flags[j1][k] & 2) == 0)) { return true; } - if ((j1 == (i - 1)) && (k == j) && ((anIntArrayArray294[j1][k] & 8) == 0)) { + if ((j1 == (i - 1)) && (k == j) && ((flags[j1][k] & 8) == 0)) { return true; } - return (j1 == (i + 1)) && (k == j) && ((anIntArrayArray294[j1][k] & 0x80) == 0); + return (j1 == (i + 1)) && (k == j) && ((flags[j1][k] & 0x80) == 0); } return false; } @@ -525,16 +525,16 @@ public class SceneCollisionMap { if ((k >= j) && (k <= l1) && (k1 >= i) && (k1 <= i2)) { return true; } - if ((k == (j - 1)) && (k1 >= i) && (k1 <= i2) && ((anIntArrayArray294[k - anInt290][k1 - anInt291] & 8) == 0) && ((i1 & 8) == 0)) { + if ((k == (j - 1)) && (k1 >= i) && (k1 <= i2) && ((flags[k - anInt290][k1 - anInt291] & 8) == 0) && ((i1 & 8) == 0)) { return true; } - if ((k == (l1 + 1)) && (k1 >= i) && (k1 <= i2) && ((anIntArrayArray294[k - anInt290][k1 - anInt291] & 0x80) == 0) && ((i1 & 2) == 0)) { + if ((k == (l1 + 1)) && (k1 >= i) && (k1 <= i2) && ((flags[k - anInt290][k1 - anInt291] & 0x80) == 0) && ((i1 & 2) == 0)) { return true; } - if ((k1 == (i - 1)) && (k >= j) && (k <= l1) && ((anIntArrayArray294[k - anInt290][k1 - anInt291] & 2) == 0) && ((i1 & 4) == 0)) { + if ((k1 == (i - 1)) && (k >= j) && (k <= l1) && ((flags[k - anInt290][k1 - anInt291] & 2) == 0) && ((i1 & 4) == 0)) { return true; } - return (k1 == (i2 + 1)) && (k >= j) && (k <= l1) && ((anIntArrayArray294[k - anInt290][k1 - anInt291] & 0x20) == 0) && ((i1 & 1) == 0); + return (k1 == (i2 + 1)) && (k >= j) && (k <= l1) && ((flags[k - anInt290][k1 - anInt291] & 0x20) == 0) && ((i1 & 1) == 0); } } diff --git a/src/main/java/SceneGroundDecoration.java b/src/main/java/SceneGroundDecoration.java index 2a47a93..b0ae7b3 100644 --- a/src/main/java/SceneGroundDecoration.java +++ b/src/main/java/SceneGroundDecoration.java @@ -4,12 +4,12 @@ public class SceneGroundDecoration { - public int anInt811; - public int anInt812; - public int anInt813; - public Entity aEntity_814; - public int anInt815; - public byte aByte816; + public int y; + public int x; + public int z; + public Entity entity; + public int bitset; + public byte info; public SceneGroundDecoration() { } diff --git a/src/main/java/SceneLoc.java b/src/main/java/SceneLoc.java index 6f273d6..be8e047 100644 --- a/src/main/java/SceneLoc.java +++ b/src/main/java/SceneLoc.java @@ -4,20 +4,20 @@ public class SceneLoc { - public int anInt517; - public int anInt518; - public int anInt519; - public int anInt520; - public Entity aEntity_521; - public int anInt522; - public int anInt523; - public int anInt524; - public int anInt525; - public int anInt526; - public int anInt527; - public int anInt528; - public int anInt529; - public byte aByte530; + public int plane; + public int y; + public int x; + public int z; + public Entity entity; + public int yaw; + public int minSceneTileX; + public int maxSceneTileX; + public int minSceneTileZ; + public int maxSceneTileZ; + public int distance; + public int cycle; + public int bitset; + public byte info; public SceneLoc() { } diff --git a/src/main/java/SceneObjStack.java b/src/main/java/SceneObjStack.java index 36b1b2b..dd50cb3 100644 --- a/src/main/java/SceneObjStack.java +++ b/src/main/java/SceneObjStack.java @@ -4,14 +4,14 @@ public class SceneObjStack { - public int anInt45; - public int anInt46; - public int anInt47; - public Entity aEntity_48; - public Entity aEntity_49; - public Entity aEntity_50; - public int anInt51; - public int anInt52; + public int y; + public int x; + public int z; + public Entity entity0; + public Entity entity1; + public Entity entity2; + public int bitset; + public int offset; public SceneObjStack() { } diff --git a/src/main/java/SceneOccluder.java b/src/main/java/SceneOccluder.java index 16e275d..a6a2d9f 100644 --- a/src/main/java/SceneOccluder.java +++ b/src/main/java/SceneOccluder.java @@ -15,7 +15,7 @@ public class SceneOccluder { public int anInt795; public int anInt796; public int anInt797; - public int anInt798; + public int mode; public int anInt799; public int anInt800; public int anInt801; diff --git a/src/main/java/SceneTile.java b/src/main/java/SceneTile.java index 0d25890..7019cc0 100644 --- a/src/main/java/SceneTile.java +++ b/src/main/java/SceneTile.java @@ -7,18 +7,18 @@ public class SceneTile extends DoublyLinkedList.Node { public final int anInt1308; public final int anInt1309; public final int anInt1310; - public final SceneLoc[] aLocArray1318 = new SceneLoc[5]; - public final int[] anIntArray1319 = new int[5]; + public final SceneLoc[] locs = new SceneLoc[5]; + public final int[] locFlags = new int[5]; public int anInt1307; - public SceneTileUnderlay aUnderlay_1311; - public SceneTileOverlay aOverlay_1312; - public SceneWall aWall_1313; - public SceneWallDecoration aWallDecoration_1314; - public SceneGroundDecoration aGroundDecoration_1315; - public SceneObjStack aObjStack_1316; - public int anInt1317; - public int anInt1320; - public int anInt1321; + public SceneTileUnderlay underlay; + public SceneTileOverlay overlay; + public SceneWall wall; + public SceneWallDecoration wallDecoration; + public SceneGroundDecoration groundDecoration; + public SceneObjStack objStack; + public int locCount; + public int flags; + public int drawPlane; public boolean aBoolean1322; public boolean aBoolean1323; public boolean aBoolean1324; @@ -26,7 +26,7 @@ public class SceneTile extends DoublyLinkedList.Node { public int anInt1326; public int anInt1327; public int anInt1328; - public SceneTile aTile_1329; + public SceneTile bridge; public SceneTile(int i, int j, int k) { anInt1310 = anInt1307 = i; diff --git a/src/main/java/SceneWall.java b/src/main/java/SceneWall.java index 9190430..317ebeb 100644 --- a/src/main/java/SceneWall.java +++ b/src/main/java/SceneWall.java @@ -4,15 +4,15 @@ public class SceneWall { - public int anInt273; - public int anInt274; - public int anInt275; - public int anInt276; - public int anInt277; - public Entity aEntity_278; - public Entity aEntity_279; - public int anInt280; - public byte aByte281; + public int y; + public int x; + public int z; + public int type0; + public int type1; + public Entity entity0; + public Entity entity1; + public int bitset; + public byte info; public SceneWall() { } diff --git a/src/main/java/SceneWallDecoration.java b/src/main/java/SceneWallDecoration.java index 96df4b2..142065b 100644 --- a/src/main/java/SceneWallDecoration.java +++ b/src/main/java/SceneWallDecoration.java @@ -1,17 +1,13 @@ -// Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov. -// Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) - public class SceneWallDecoration { - public int anInt499; - public int anInt500; - public int anInt501; - public int anInt502; - public int anInt503; - public Entity aEntity_504; - public int anInt505; - public byte aByte506; + public int y; + public int x; + public int z; + public int type; + public int yaw; + public Entity entity; + public int bitset; + public byte info; public SceneWallDecoration() { } diff --git a/src/main/java/SeqType.java b/src/main/java/SeqType.java index a85e5e8..15fe1e1 100644 --- a/src/main/java/SeqType.java +++ b/src/main/java/SeqType.java @@ -6,26 +6,29 @@ import java.io.IOException; public class SeqType { - public static int anInt350; + public static int count; public static SeqType[] instances; public static void unpack(FileArchive archive) throws IOException { Buffer buffer = new Buffer(archive.read("seq.dat")); - anInt350 = buffer.get2U(); + count = buffer.get2U(); + if (instances == null) { - instances = new SeqType[anInt350]; + instances = new SeqType[count]; } - for (int j = 0; j < anInt350; j++) { - if (instances[j] == null) { - instances[j] = new SeqType(); + + for (int i = 0; i < count; i++) { + if (instances[i] == null) { + instances[i] = new SeqType(); } - instances[j].method259(buffer); + instances[i].load(buffer); } } - public int anInt352; - public int[] anIntArray353; - public int[] anIntArray354; - public int[] anIntArray355; + + public int frameCount; + public int[] primaryFrames; + public int[] secondaryFrames; + public int[] frameDelays; public int anInt356 = -1; public int[] anIntArray357; public boolean aBoolean358 = false; @@ -41,79 +44,81 @@ public class SeqType { public SeqType() { } - public int method258(int i) { - int j = anIntArray355[i]; - if (j == 0) { - SeqFrame transform = SeqFrame.get(anIntArray353[i]); + public int getFrameDelay(int frame) { + int delay = frameDelays[frame]; + if (delay == 0) { + SeqFrame transform = SeqFrame.get(primaryFrames[frame]); + if (transform != null) { - j = anIntArray355[i] = transform.delay; + delay = frameDelays[frame] = transform.delay; } } - if (j == 0) { - j = 1; + if (delay == 0) { + delay = 1; } - return j; + return delay; } - public void method259(Buffer buffer) { + public void load(Buffer buffer) { do { - int i = buffer.get1U(); - if (i == 0) { + int op = buffer.get1U(); + if (op == 0) { break; - } - if (i == 1) { - anInt352 = buffer.get1U(); - anIntArray353 = new int[anInt352]; - anIntArray354 = new int[anInt352]; - anIntArray355 = new int[anInt352]; - for (int j = 0; j < anInt352; j++) { - anIntArray353[j] = buffer.get2U(); - anIntArray354[j] = buffer.get2U(); - if (anIntArray354[j] == 65535) { - anIntArray354[j] = -1; + } else if (op == 1) { + frameCount = buffer.get1U(); + primaryFrames = new int[frameCount]; + secondaryFrames = new int[frameCount]; + frameDelays = new int[frameCount]; + for (int j = 0; j < frameCount; j++) { + primaryFrames[j] = buffer.get2U(); + secondaryFrames[j] = buffer.get2U(); + if (secondaryFrames[j] == 65535) { + secondaryFrames[j] = -1; } - anIntArray355[j] = buffer.get2U(); + frameDelays[j] = buffer.get2U(); } - } else if (i == 2) { + } else if (op == 2) { anInt356 = buffer.get2U(); - } else if (i == 3) { + } else if (op == 3) { int k = buffer.get1U(); anIntArray357 = new int[k + 1]; for (int l = 0; l < k; l++) { anIntArray357[l] = buffer.get1U(); } anIntArray357[k] = 9999999; - } else if (i == 4) { + } else if (op == 4) { aBoolean358 = true; - } else if (i == 5) { + } else if (op == 5) { anInt359 = buffer.get1U(); - } else if (i == 6) { + } else if (op == 6) { anInt360 = buffer.get2U(); - } else if (i == 7) { + } else if (op == 7) { anInt361 = buffer.get2U(); - } else if (i == 8) { + } else if (op == 8) { anInt362 = buffer.get1U(); - } else if (i == 9) { + } else if (op == 9) { anInt363 = buffer.get1U(); - } else if (i == 10) { + } else if (op == 10) { anInt364 = buffer.get1U(); - } else if (i == 11) { + } else if (op == 11) { anInt365 = buffer.get1U(); - } else if (i == 12) { + } else if (op == 12) { unusedInt = buffer.get4(); } else { - System.out.println("Error unrecognised seq config code: " + i); + System.out.println("Error unrecognised seq config code: " + op); } } while (true); - if (anInt352 == 0) { - anInt352 = 1; - anIntArray353 = new int[1]; - anIntArray353[0] = -1; - anIntArray354 = new int[1]; - anIntArray354[0] = -1; - anIntArray355 = new int[1]; - anIntArray355[0] = -1; + + if (frameCount == 0) { + frameCount = 1; + primaryFrames = new int[1]; + primaryFrames[0] = -1; + secondaryFrames = new int[1]; + secondaryFrames[0] = -1; + frameDelays = new int[1]; + frameDelays[0] = -1; } + if (anInt363 == -1) { if (anIntArray357 != null) { anInt363 = 2; @@ -121,6 +126,7 @@ public class SeqType { anInt363 = 0; } } + if (anInt364 == -1) { if (anIntArray357 != null) { anInt364 = 2; diff --git a/src/main/java/SpotAnimEntity.java b/src/main/java/SpotAnimEntity.java index b01fd55..4b0868b 100644 --- a/src/main/java/SpotAnimEntity.java +++ b/src/main/java/SpotAnimEntity.java @@ -29,7 +29,7 @@ public class SpotAnimEntity extends Entity { if (model == null) { return null; } - int j = aType_1568.aType_407.anIntArray353[anInt1569]; + int j = aType_1568.seq.primaryFrames[anInt1569]; Model model_1 = new Model(true, SeqFrame.isNull(j), false, model); if (!aBoolean1567) { model_1.createLabelReferences(); @@ -59,10 +59,10 @@ public class SpotAnimEntity extends Entity { } public void method454(int i) { - for (anInt1570 += i; anInt1570 > aType_1568.aType_407.method258(anInt1569); ) { - anInt1570 -= aType_1568.aType_407.method258(anInt1569) + 1; + for (anInt1570 += i; anInt1570 > aType_1568.seq.getFrameDelay(anInt1569); ) { + anInt1570 -= aType_1568.seq.getFrameDelay(anInt1569) + 1; anInt1569++; - if ((anInt1569 >= aType_1568.aType_407.anInt352) && ((anInt1569 < 0) || (anInt1569 >= aType_1568.aType_407.anInt352))) { + if ((anInt1569 >= aType_1568.seq.frameCount) && ((anInt1569 < 0) || (anInt1569 >= aType_1568.seq.frameCount))) { anInt1569 = 0; aBoolean1567 = true; } diff --git a/src/main/java/SpotAnimType.java b/src/main/java/SpotAnimType.java index 27713f0..b69bcf3 100644 --- a/src/main/java/SpotAnimType.java +++ b/src/main/java/SpotAnimType.java @@ -31,7 +31,7 @@ public class SpotAnimType { public int anInt404; public int anInt405; public int anInt406 = -1; - public SeqType aType_407; + public SeqType seq; public int anInt410 = 128; public int anInt411 = 128; public int anInt412; @@ -52,7 +52,7 @@ public class SpotAnimType { } else if (i == 2) { anInt406 = buffer.get2U(); if (SeqType.instances != null) { - aType_407 = SeqType.instances[anInt406]; + seq = SeqType.instances[anInt406]; } } else if (i == 4) { anInt410 = buffer.get2U(); diff --git a/src/main/java/VarbitType.java b/src/main/java/VarbitType.java index 8dd3c2e..ac6d257 100644 --- a/src/main/java/VarbitType.java +++ b/src/main/java/VarbitType.java @@ -6,59 +6,66 @@ import java.io.IOException; public class VarbitType { - public static int anInt645; - public static VarbitType[] aVarbitArray646; + public static VarbitType[] instances; public static void unpack(FileArchive archive) throws IOException { Buffer buffer = new Buffer(archive.read("varbit.dat")); - anInt645 = buffer.get2U(); - if (aVarbitArray646 == null) { - aVarbitArray646 = new VarbitType[anInt645]; + int count = buffer.get2U(); + + if (instances == null) { + instances = new VarbitType[count]; } - for (int j = 0; j < anInt645; j++) { - if (aVarbitArray646[j] == null) { - aVarbitArray646[j] = new VarbitType(); + + for (int j = 0; j < count; j++) { + if (instances[j] == null) { + instances[j] = new VarbitType(); } - aVarbitArray646[j].method534(buffer); - if (aVarbitArray646[j].aBoolean651) { - VarpType.instances[aVarbitArray646[j].anInt648].unusedBool3 = true; + instances[j].read(buffer); + if (instances[j].unusedBool) { + VarpType.instances[instances[j].varp].unusedBool3 = true; } } if (buffer.position != buffer.data.length) { System.out.println("varbit load mismatch"); } } + public String unusedString; - public int anInt648; - public int anInt649; - public int anInt650; - public boolean aBoolean651 = false; + public int varp; + /** + * The least significant bit. + */ + public int lsb; + /** + * The most significant bit. + */ + public int msb; + public boolean unusedBool = false; public int unusedInt0 = -1; public int unusedInt1; public VarbitType() { } - public void method534(Buffer buffer) { + public void read(Buffer buffer) { do { - int j = buffer.get1U(); - if (j == 0) { + int op = buffer.get1U(); + if (op == 0) { return; - } - if (j == 1) { - anInt648 = buffer.get2U(); - anInt649 = buffer.get1U(); - anInt650 = buffer.get1U(); - } else if (j == 10) { + } else if (op == 1) { + varp = buffer.get2U(); + lsb = buffer.get1U(); + msb = buffer.get1U(); + } else if (op == 10) { unusedString = buffer.getString(); - } else if (j == 2) { - aBoolean651 = true; - } else if (j == 3) { + } else if (op == 2) { + unusedBool = true; + } else if (op == 3) { unusedInt0 = buffer.get4(); - } else if (j == 4) { + } else if (op == 4) { unusedInt1 = buffer.get4(); } else { - System.out.println("Error unrecognised config code: " + j); + System.out.println("Error unrecognised config code: " + op); } } while (true); } diff --git a/src/main/java/VarpType.java b/src/main/java/VarpType.java index be2b891..ff72827 100644 --- a/src/main/java/VarpType.java +++ b/src/main/java/VarpType.java @@ -25,12 +25,13 @@ public class VarpType { if (instances[j] == null) { instances[j] = new VarpType(); } - instances[j].method547(buffer, j); + instances[j].read(buffer, j); } if (buffer.position != buffer.data.length) { System.out.println("varptype load mismatch"); } } + public String unusedString; public int unusedInt0; public int unusedInt1; @@ -46,40 +47,39 @@ public class VarpType { public VarpType() { } - public void method547(Buffer buffer, int i) { + public void read(Buffer buffer, int i) { do { - int j = buffer.get1U(); - if (j == 0) { + int op = buffer.get1U(); + if (op == 0) { return; - } - if (j == 1) { + } else if (op == 1) { unusedInt0 = buffer.get1U(); - } else if (j == 2) { + } else if (op == 2) { unusedInt1 = buffer.get1U(); - } else if (j == 3) { + } else if (op == 3) { unusedBool0 = true; anIntArray703[anInt702++] = i; - } else if (j == 4) { + } else if (op == 4) { unusedBool1 = false; - } else if (j == 5) { + } else if (op == 5) { anInt709 = buffer.get2U(); - } else if (j == 6) { + } else if (op == 6) { unusedBool2 = true; - } else if (j == 7) { + } else if (op == 7) { unusedInt2 = buffer.get4(); - } else if (j == 8) { + } else if (op == 8) { unusedInt3 = 1; unusedBool3 = true; - } else if (j == 10) { + } else if (op == 10) { unusedString = buffer.getString(); - } else if (j == 11) { + } else if (op == 11) { unusedBool3 = true; - } else if (j == 12) { + } else if (op == 12) { unusedInt4 = buffer.get4(); - } else if (j == 13) { + } else if (op == 13) { unusedInt3 = 2; } else { - System.out.println("Error unrecognised config code: " + j); + System.out.println("Error unrecognised config code: " + op); } } while (true); }