···199199200200 }
201201202202- public void drawImage(int y, int x) {
202202+ public void drawImage(int x, int y) {
203203 x += offsetX;
204204 y += offsetY;
205205 int rasterizerOffset = x + y * Rasterizer.width;
+2-2
src/com/jagex/runescape/cache/media/Widget.java
···2828 public int itemAmounts[];
2929 public int unknownOne;
3030 public int enabledHoveredColor;
3131- public int anInt227;
3131+ public int animationDuration;
3232 public int xOffset;
3333 public boolean isInventory;
3434 public String disabledText;
···3636 public int childrenX[];
3737 public boolean unknownTwo;
3838 public int opcodes[][];
3939- public int anInt235;
3939+ public int animationFrame;
4040 public int type;
4141 public TypeFace typeFaces;
4242 public int height;
+20-20
src/com/jagex/runescape/media/Rasterizer3D.java
···99 public static int anInt1525;
1010 public static boolean aBoolean1526;
1111 public static boolean lowMemory = true;
1212- public static boolean aBoolean1528;
1212+ public static boolean restrictEdges;
1313 public static boolean aBoolean1529;
1414 public static boolean approximateAlphaBlending = true;
1515- public static int anInt1531;
1515+ public static int alpha;
1616 public static int centerX;
1717 public static int centerY;
1818 public static int[] anIntArray1534 = new int[512];
···2828 public static int anIntArrayArray1544[][];
2929 public static int anIntArrayArray1545[][] = new int[50][];
3030 public static int anIntArray1546[] = new int[50];
3131- public static int anInt1547;
3131+ public static int textureGetCount;
3232 public static int getRgbLookupTableId[] = new int[0x10000];
3333 public static int anIntArrayArray1549[][] = new int[50][];
3434···140140 }
141141142142 public static int[] method500(int i) {
143143- anIntArray1546[i] = anInt1547++;
143143+ anIntArray1546[i] = textureGetCount++;
144144 if (anIntArrayArray1545[i] != null)
145145 return anIntArrayArray1545[i];
146146 int ai[];
···293293 return (j << 16) + (k << 8) + l;
294294 }
295295296296- public static void method503(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2) {
296296+ public static void drawShadedTriangle(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2) {
297297 int j2 = 0;
298298 int k2 = 0;
299299 if (j != i) {
···680680 public static void method504(int ai[], int i, int j, int k, int l, int i1, int j1, int k1) {
681681 if (approximateAlphaBlending) {
682682 int l1;
683683- if (aBoolean1528) {
683683+ if (restrictEdges) {
684684 if (i1 - l > 3)
685685 l1 = (k1 - j1) / (i1 - l);
686686 else
···706706 else
707707 l1 = 0;
708708 }
709709- if (anInt1531 == 0) {
709709+ if (alpha == 0) {
710710 while (--k >= 0) {
711711 j = getRgbLookupTableId[j1 >> 8];
712712 j1 += l1;
···724724 return;
725725 }
726726 } else {
727727- int j2 = anInt1531;
728728- int l2 = 256 - anInt1531;
727727+ int j2 = alpha;
728728+ int l2 = 256 - alpha;
729729 while (--k >= 0) {
730730 j = getRgbLookupTableId[j1 >> 8];
731731 j1 += l1;
···749749 if (l >= i1)
750750 return;
751751 int i2 = (k1 - j1) / (i1 - l);
752752- if (aBoolean1528) {
752752+ if (restrictEdges) {
753753 if (i1 > Rasterizer.virtualBottomX)
754754 i1 = Rasterizer.virtualBottomX;
755755 if (l < 0) {
···761761 }
762762 i += l;
763763 k = i1 - l;
764764- if (anInt1531 == 0) {
764764+ if (alpha == 0) {
765765 do {
766766 ai[i++] = getRgbLookupTableId[j1 >> 8];
767767 j1 += i2;
768768 } while (--k > 0);
769769 return;
770770 }
771771- int k2 = anInt1531;
772772- int i3 = 256 - anInt1531;
771771+ int k2 = alpha;
772772+ int i3 = 256 - alpha;
773773 do {
774774 j = getRgbLookupTableId[j1 >> 8];
775775 j1 += i2;
···10761076 }
1077107710781078 public static void method506(int ai[], int i, int j, int k, int l, int i1) {
10791079- if (aBoolean1528) {
10791079+ if (restrictEdges) {
10801080 if (i1 > Rasterizer.virtualBottomX)
10811081 i1 = Rasterizer.virtualBottomX;
10821082 if (l < 0)
···10861086 return;
10871087 i += l;
10881088 k = i1 - l >> 2;
10891089- if (anInt1531 == 0) {
10891089+ if (alpha == 0) {
10901090 while (--k >= 0) {
10911091 ai[i++] = j;
10921092 ai[i++] = j;
···1098109810991099 return;
11001100 }
11011101- int j1 = anInt1531;
11021102- int k1 = 256 - anInt1531;
11011101+ int j1 = alpha;
11021102+ int k1 = 256 - alpha;
11031103 j = ((j & 0xff00ff) * k1 >> 8 & 0xff00ff) + ((j & 0xff00) * k1 >> 8 & 0xff00);
11041104 while (--k >= 0) {
11051105 ai[i++] = j + ((ai[i] & 0xff00ff) * j1 >> 8 & 0xff00ff) + ((ai[i] & 0xff00) * j1 >> 8 & 0xff00);
···1112111211131113 }
1114111411151115- public static void method507(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2, int j2, int k2,
11161116- int l2, int i3, int j3, int k3, int l3, int i4, int j4, int k4) {
11151115+ public static void drawTexturedTriangle(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2, int j2, int k2,
11161116+ int l2, int i3, int j3, int k3, int l3, int i4, int j4, int k4) {
11171117 int ai[] = method500(k4);
11181118 aBoolean1529 = !aBooleanArray1541[k4];
11191119 k2 = j2 - k2;
···16521652 return;
16531653 int j3;
16541654 int k3;
16551655- if (aBoolean1528) {
16551655+ if (restrictEdges) {
16561656 j3 = (k1 - j1) / (i1 - l);
16571657 if (i1 > Rasterizer.virtualBottomX)
16581658 i1 = Rasterizer.virtualBottomX;
···11-package com.jagex.runescape.scene;
22-33-import com.jagex.runescape.media.renderable.Renderable;
44-55-public class CameraAngle {
66-77- public CameraAngle() {
88- }
99-1010- public int x;
1111- public int y;
1212- public int z;
1313- public Renderable aRenderable150;
1414- public Renderable aRenderable151;
1515- public Renderable aRenderable152;
1616- public int anInt179;
1717- public int anInt180;
1818-}
+18
src/com/jagex/runescape/scene/GroundItemTile.java
···11+package com.jagex.runescape.scene;
22+33+import com.jagex.runescape.media.renderable.Renderable;
44+55+public class GroundItemTile {
66+77+ public GroundItemTile() {
88+ }
99+1010+ public int z;
1111+ public int x;
1212+ public int y;
1313+ public Renderable firstGroundItem;
1414+ public Renderable secondGroundItem;
1515+ public Renderable thirdGroundItem;
1616+ public int uid;
1717+ public int anInt180;
1818+}
···11+package com.jagex.runescape.scene;
22+33+import com.jagex.runescape.media.renderable.Renderable;
44+55+public class InteractiveObject {
66+77+ public int z;
88+ public int worldZ;
99+ public int worldX;
1010+ public int worldY;
1111+ public Renderable renderable;
1212+ public int rotation;
1313+ public int tileLeft;
1414+ public int tileRight;
1515+ public int tileTop;
1616+ public int tileBottom;
1717+ public int anInt123;
1818+ public int cycle;
1919+ public int uid;
2020+ public byte config;
2121+}
···10101111public class Scene {
12121313- public static int anInt444;
1414- public int anInt450;
1515- public static boolean lowMemory = true;
1616- public int anInt452;
1717- public int anInt453;
1818- public int anInt454;
1919- public int anIntArrayArrayArray455[][][];
2020- public SceneTile tiles[][][];
2121- public int anInt457;
2222- public int anInt458;
2323- public SceneSpawnRequest aSceneSpawnRequestArray459[];
2424- public int anIntArrayArrayArray460[][][];
2525- public static int anInt461;
2626- public static int anInt462;
2727- public static int anInt463;
2828- public static int anInt464;
2929- public static int anInt465;
3030- public static int anInt466;
3131- public static int anInt467;
3232- public static int anInt468;
3333- public static int anInt469;
3434- public static int anInt470;
3535- public static int anInt471;
3636- public static int anInt472;
3737- public static int anInt473;
3838- public static int anInt474;
3939- public static int anInt475;
4040- public static int anInt476;
4141- public static SceneSpawnRequest aSceneSpawnRequestArray477[] = new SceneSpawnRequest[100];
4242- public static final int anIntArray478[] = { 53, -53, -53, 53 };
4343- public static final int anIntArray479[] = { -53, -53, 53, 53 };
4444- public static final int anIntArray480[] = { -45, 45, 45, -45 };
4545- public static final int anIntArray481[] = { 45, 45, -45, -45 };
4646- public static boolean aBoolean482;
4747- public static int anInt483;
4848- public static int anInt484;
4949- public static int clickedTileX = -1;
5050- public static int anInt486 = -1;
5151- public static int anInt487 = 4;
5252- public static int anIntArray488[] = new int[anInt487];
5353- public static SceneCluster aSceneClusterArrayArray554[][] = new SceneCluster[anInt487][500];
5454- public static int anInt490;
5555- public static SceneCluster aClass39Array491[] = new SceneCluster[500];
5656- public static LinkedList aClass6_492 = new LinkedList();
5757- public static final int anIntArray493[] = { 19, 55, 38, 155, 255, 110, 137, 205, 76 };
5858- public static final int anIntArray494[] = { 160, 192, 80, 96, 0, 144, 80, 48, 160 };
5959- public static final int anIntArray495[] = { 76, 8, 137, 4, 0, 1, 38, 2, 19 };
6060- public static final int anIntArray496[] = { 0, 0, 2, 0, 0, 2, 1, 1, 0 };
6161- public static final int anIntArray497[] = { 2, 0, 0, 2, 0, 0, 0, 4, 4 };
6262- public static final int anIntArray498[] = { 0, 4, 4, 8, 0, 0, 8, 0, 0 };
6363- public static final int anIntArray499[] = { 1, 1, 0, 0, 0, 8, 0, 0, 8 };
6464- public static final int anIntArray500[] = { 41, 39248, 41, 4643, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 43086,
6565- 41, 41, 41, 41, 41, 41, 41, 8602, 41, 28992, 41, 41, 41, 41, 41, 5056, 41, 41, 41, 7079, 41, 41, 41, 41,
6666- 41, 41, 41, 41, 41, 41, 3131, 41, 41, 41 };
6767- public int anIntArray501[];
6868- public int anIntArray502[];
6969- public int anInt503;
7070- public int anIntArrayArray504[][] = { new int[16], { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
7171- { 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 },
7272- { 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 },
7373- { 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 },
7474- { 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 },
7575- { 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 },
7676- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1 } };
7777- public int anIntArrayArray505[][] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
7878- { 12, 8, 4, 0, 13, 9, 5, 1, 14, 10, 6, 2, 15, 11, 7, 3 },
7979- { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 },
8080- { 3, 7, 11, 15, 2, 6, 10, 14, 1, 5, 9, 13, 0, 4, 8, 12 } };
8181- public static boolean aBooleanArrayArrayArrayArray506[][][][] = new boolean[8][32][51][51];
8282- public static boolean aBooleanArrayArray507[][];
8383- public static int anInt508;
8484- public static int anInt509;
8585- public static int anInt510;
8686- public static int anInt511;
8787- public static int anInt512;
8888- public static int anInt513;
1313+ public static boolean lowMemory = true;
1414+ private int mapSizeZ;
1515+ private int mapSizeX;
1616+ private int mapSizeY;
1717+ private int[][][] heightMap;
1818+ private SceneTile[][][] groundArray;
1919+ private int currentPositionZ;
2020+ private int sceneSpawnRequestsCacheCurrentPos;
2121+ private InteractiveObject[] sceneSpawnRequestsCache;
2222+ private int[][][] anIntArrayArrayArray460;
2323+ private static int anInt461;
2424+ private static int plane;
2525+ private static int cycle;
2626+ private static int currentPositionX;
2727+ private static int mapBoundsX;
2828+ private static int currentPositionY;
2929+ private static int mapBoundsY;
3030+ private static int cameraPositionTileX;
3131+ private static int cameraPositionTileY;
3232+ private static int cameraPosX;
3333+ private static int cameraPosZ;
3434+ private static int cameraPosY;
3535+ private static int curveSineY;
3636+ private static int curveCosineY;
3737+ private static int curveSineX;
3838+ private static int curveCosineX;
3939+ private static InteractiveObject[] interactiveObjects = new InteractiveObject[100];
4040+ private static final int[] faceOffsetX2 = {53, -53, -53, 53};
4141+ private static final int[] faceOffsetY2 = {-53, -53, 53, 53};
4242+ private static final int[] faceOffsetX3 = {-45, 45, 45, -45};
4343+ private static final int[] faceOffsetY3 = {45, 45, -45, -45};
4444+ private static boolean clicked;
4545+ private static int clickX;
4646+ private static int clickY;
4747+ public static int clickedTileX = -1;
4848+ public static int clickedTileY = -1;
4949+ private static int anInt487 = 4;
5050+ private static int[] cullingClusterPointer = new int[anInt487];
5151+ private static SceneCluster[][] cullingClusters = new SceneCluster[anInt487][500];
5252+ private static int processedCullingClustersPointer;
5353+ private static SceneCluster[] processedCullingClusters = new SceneCluster[500];
5454+ private static LinkedList tileList = new LinkedList();
5555+ private static final int[] anIntArray493 = {19, 55, 38, 155, 255, 110, 137, 205, 76};
5656+ private static final int[] anIntArray494 = {160, 192, 80, 96, 0, 144, 80, 48, 160};
5757+ private static final int[] TILE_WALL_DRAW_FLAGS_1 = {76, 8, 137, 4, 0, 1, 38, 2, 19};
5858+ private static final int[] WALL_UNCULL_FLAGS_0 = {0, 0, 2, 0, 0, 2, 1, 1, 0};
5959+ private static final int[] anIntArray497 = {2, 0, 0, 2, 0, 0, 0, 4, 4};
6060+ private static final int[] anIntArray498 = {0, 4, 4, 8, 0, 0, 8, 0, 0};
6161+ private static final int[] anIntArray499 = {1, 1, 0, 0, 0, 8, 0, 0, 8};
6262+ private static final int[] textureRGB = {41, 39248, 41, 4643, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 43086,
6363+ 41, 41, 41, 41, 41, 41, 41, 8602, 41, 28992, 41, 41, 41, 41, 41, 5056, 41, 41, 41, 7079, 41, 41, 41, 41,
6464+ 41, 41, 41, 41, 41, 41, 3131, 41, 41, 41};
6565+ private int[] anIntArray501;
6666+ private int[] anIntArray502;
6767+ private int anInt503;
6868+ private int[][] tileShapePoints = {new int[16], {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
6969+ {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},
7070+ {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},
7171+ {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},
7272+ {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},
7373+ {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},
7474+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1}};
7575+ private int[][] tileShapeIndices = {{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
7676+ {12, 8, 4, 0, 13, 9, 5, 1, 14, 10, 6, 2, 15, 11, 7, 3},
7777+ {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0},
7878+ {3, 7, 11, 15, 2, 6, 10, 14, 1, 5, 9, 13, 0, 4, 8, 12}};
7979+ private static boolean[][][][] TILE_VISIBILITY_MAPS = new boolean[8][32][51][51];
8080+ private static boolean[][] TILE_VISIBILITY_MAP;
8181+ private static int anInt508;
8282+ private static int anInt509;
8383+ private static int anInt510;
8484+ private static int anInt511;
8585+ private static int anInt512;
8686+ private static int anInt513;
89879090- public Scene(int ai[][][], int i, int j, int k, byte byte0) {
9191- aSceneSpawnRequestArray459 = new SceneSpawnRequest[5000];
9292- anIntArray501 = new int[10000];
9393- anIntArray502 = new int[10000];
9494- anInt452 = j;
9595- anInt453 = k;
9696- anInt454 = i;
9797- tiles = new SceneTile[j][k][i];
9898- anIntArrayArrayArray460 = new int[j][k + 1][i + 1];
9999- anIntArrayArrayArray455 = ai;
100100- method241();
101101- }
8888+ public Scene(int[][][] heightMap) {
8989+ final int length = 104;// was parameter
9090+ final int width = 104;// was parameter
9191+ final int height = 4;// was parameter
9292+ sceneSpawnRequestsCache = new InteractiveObject[5000];
9393+ anIntArray501 = new int[10000];
9494+ anIntArray502 = new int[10000];
9595+ mapSizeZ = height;
9696+ mapSizeX = width;
9797+ mapSizeY = length;
9898+ groundArray = new SceneTile[height][width][length];
9999+ anIntArrayArrayArray460 = new int[height][width + 1][length + 1];
100100+ this.heightMap = heightMap;
101101+ initToNull();
102102+ }
102103103103- public static void method240() {
104104- aSceneSpawnRequestArray477 = null;
105105- anIntArray488 = null;
106106- aSceneClusterArrayArray554 = null;
107107- aClass6_492 = null;
108108- aBooleanArrayArrayArrayArray506 = null;
109109- aBooleanArrayArray507 = null;
104104+ public static void nullLoader() {
105105+ interactiveObjects = null;
106106+ cullingClusterPointer = null;
107107+ cullingClusters = null;
108108+ tileList = null;
109109+ TILE_VISIBILITY_MAPS = null;
110110+ TILE_VISIBILITY_MAP = null;
110111111111- }
112112+ }
112113113113- public void method241() {
114114- for (int i = 0; i < anInt452; i++) {
115115- for (int j = 0; j < anInt453; j++) {
116116- for (int i1 = 0; i1 < anInt454; i1++)
117117- tiles[i][j][i1] = null;
114114+ public void initToNull() {
115115+ for (int z = 0; z < mapSizeZ; z++) {
116116+ for (int x = 0; x < mapSizeX; x++) {
117117+ for (int y = 0; y < mapSizeY; y++) {
118118+ groundArray[z][x][y] = null;
119119+ }
118120119119- }
121121+ }
120122121121- }
123123+ }
122124123123- for (int l = 0; l < anInt487; l++) {
124124- for (int j1 = 0; j1 < anIntArray488[l]; j1++)
125125- aSceneClusterArrayArray554[l][j1] = null;
125125+ for (int l = 0; l < anInt487; l++) {
126126+ for (int j1 = 0; j1 < cullingClusterPointer[l]; j1++) {
127127+ cullingClusters[l][j1] = null;
128128+ }
126129127127- anIntArray488[l] = 0;
128128- }
130130+ cullingClusterPointer[l] = 0;
131131+ }
129132130130- for (int k1 = 0; k1 < anInt458; k1++)
131131- aSceneSpawnRequestArray459[k1] = null;
133133+ for (int k1 = 0; k1 < sceneSpawnRequestsCacheCurrentPos; k1++) {
134134+ sceneSpawnRequestsCache[k1] = null;
135135+ }
132136133133- anInt458 = 0;
134134- for (int l1 = 0; l1 < aSceneSpawnRequestArray477.length; l1++)
135135- aSceneSpawnRequestArray477[l1] = null;
137137+ sceneSpawnRequestsCacheCurrentPos = 0;
138138+ for (int l1 = 0; l1 < interactiveObjects.length; l1++) {
139139+ interactiveObjects[l1] = null;
140140+ }
136141137137- }
142142+ }
138143139139- public void method242(int i) {
140140- anInt457 = i;
141141- for (int j = 0; j < anInt453; j++) {
142142- for (int k = 0; k < anInt454; k++)
143143- if (tiles[i][j][k] == null)
144144- tiles[i][j][k] = new SceneTile(i, j, k);
144144+ public void setHeightLevel(int z) {
145145+ currentPositionZ = z;
146146+ for (int x = 0; x < mapSizeX; x++) {
147147+ for (int y = 0; y < mapSizeY; y++) {
148148+ if (groundArray[z][x][y] == null) {
149149+ groundArray[z][x][y] = new SceneTile(x, y, z);
150150+ }
151151+ }
145152146146- }
153153+ }
147154148148- }
155155+ }
149156150150- public void setBridgeMode(int i, int j) {
151151- SceneTile scenetile = tiles[0][i][j];
152152- for (int k = 0; k < 3; k++) {
153153- SceneTile scenetile_15_ = tiles[k][i][j] = tiles[k + 1][i][j];
154154- if (scenetile_15_ != null) {
155155- scenetile_15_.anInt1397--;
156156- for (int i1 = 0; i1 < scenetile_15_.sceneSpawnRequestCount; i1++) {
157157- SceneSpawnRequest sceneSpawnRequest = scenetile_15_.sceneSpawnRequests[i1];
158158- if ((sceneSpawnRequest.anInt125 >> 29 & 3) == 2 && sceneSpawnRequest.x == i && sceneSpawnRequest.y == j)
159159- sceneSpawnRequest.anInt113--;
160160- }
157157+ void setBridgeMode(int x, int y) {
158158+ SceneTile scenetile = groundArray[0][x][y];
159159+ for (int z = 0; z < 3; z++) {
160160+ SceneTile _tile = groundArray[z][x][y] = groundArray[z + 1][x][y];
161161+ if (_tile != null) {
162162+ _tile.z--;
163163+ for (int e = 0; e < _tile.entityCount; e++) {
164164+ InteractiveObject entity = _tile.interactiveObjects[e];
165165+ if ((entity.uid >> 29 & 3) == 2 && entity.tileLeft == x && entity.tileTop == y) {
166166+ entity.z--;
167167+ }
168168+ }
161169162162- }
163163- }
170170+ }
171171+ }
164172165165- if (tiles[0][i][j] == null)
166166- tiles[0][i][j] = new SceneTile(0, i, j);
167167- tiles[0][i][j].aClass50_Sub3_1419 = scenetile;
168168- tiles[3][i][j] = null;
169169- }
173173+ if (groundArray[0][x][y] == null) {
174174+ groundArray[0][x][y] = new SceneTile(x, y, 0);
175175+ }
176176+ groundArray[0][x][y].tileBelow = scenetile;
177177+ groundArray[3][x][y] = null;
178178+ }
170179171171- public static void createCullingOcclussionBox(int j, int k, int l, int i1, int j1, int k1, int l1, int i2) {
172172- SceneCluster scenecluster = new SceneCluster();
173173- scenecluster.anInt675 = j / 128;
174174- scenecluster.anInt676 = l / 128;
175175- scenecluster.anInt677 = k1 / 128;
176176- scenecluster.anInt678 = i1 / 128;
177177- scenecluster.anInt679 = i2;
178178- scenecluster.anInt680 = j;
179179- scenecluster.anInt681 = l;
180180- scenecluster.anInt682 = k1;
181181- scenecluster.anInt683 = i1;
182182- scenecluster.anInt684 = l1;
183183- scenecluster.anInt685 = k;
184184- aSceneClusterArrayArray554[j1][anIntArray488[j1]++] = scenecluster;
185185- }
180180+ static void createCullingCluster(final int z, int highestX, int lowestX, int highestY, int lowestY, int highestZ, int lowestZ, int searchMask) {
181181+ SceneCluster scenecluster = new SceneCluster();
182182+ scenecluster.tileStartX = lowestX / 128;
183183+ scenecluster.tileEndX = highestX / 128;
184184+ scenecluster.tileStartY = lowestY / 128;
185185+ scenecluster.tileEndY = highestY / 128;
186186+ scenecluster.searchMask = searchMask;
187187+ scenecluster.worldStartX = lowestX;
188188+ scenecluster.worldEndX = highestX;
189189+ scenecluster.worldStartY = lowestY;
190190+ scenecluster.worldEndY = highestY;
191191+ scenecluster.worldEndZ = highestZ;
192192+ scenecluster.worldStartZ = lowestZ;
193193+ cullingClusters[z][cullingClusterPointer[z]++] = scenecluster;
194194+ }
186195187187- public void method245(int i, int j, int k, int l) {
188188- SceneTile sceneTile = tiles[i][j][k];
189189- if (sceneTile != null) {
190190- sceneTile.anInt1411 = l;
191191- }
192192- }
196196+ void setTileLogicHeight(int z, int x, int y, int logicHeight) {
197197+ SceneTile sceneTile = groundArray[z][x][y];
198198+ if (sceneTile != null) {
199199+ sceneTile.logicHeight = logicHeight;
200200+ }
201201+ }
193202194194- public void method246(int i, int j, int k, int l, int i1, int j1, int k1, int l1, int i2, int j2, int k2, int l2,
195195- int i3, int j3, int k3, int l3, int i4, int j4, int k4, int l4) {
196196- if (l == 0) {
197197- GenericTile genericTile = new GenericTile(k2, l2, i3, j3, -1, k4, false);
198198- for (int i5 = i; i5 >= 0; i5--)
199199- if (tiles[i5][j][k] == null)
200200- tiles[i5][j][k] = new SceneTile(i5, j, k);
203203+ void renderTile(int plane, int x, int y, int clippingPath, int clippingPathRotation, int textureId, int vertexHeightSW, int vertexHeightSE, int vertexHeightNE, int vertexHeightNW, int cA, int cB,
204204+ int cD, int cC, int colourA, int colourB, int colourD, int colourC, int underlayRGB, int overlayRGB) {
205205+ if (clippingPath == 0) {
206206+ GenericTile tile = new GenericTile(cA, cB, cC, cD, -1, underlayRGB, false);
207207+ for (int _z = plane; _z >= 0; _z--) {
208208+ if (groundArray[_z][x][y] == null) {
209209+ groundArray[_z][x][y] = new SceneTile(x, y, _z);
210210+ }
211211+ }
201212202202- tiles[i][j][k].genericTile = genericTile;
203203- return;
204204- }
205205- if (l == 1) {
206206- GenericTile genericTile_1 = new GenericTile(k3, l3, i4, j4, j1, l4, k1 == l1 && k1 == i2 && k1 == j2);
207207- for (int j5 = i; j5 >= 0; j5--)
208208- if (tiles[j5][j][k] == null)
209209- tiles[j5][j][k] = new SceneTile(j5, j, k);
213213+ groundArray[plane][x][y].plainTile = tile;
214214+ return;
215215+ }
216216+ if (clippingPath == 1) {
217217+ GenericTile tile = new GenericTile(colourA, colourB, colourC, colourD, textureId, overlayRGB, vertexHeightSW == vertexHeightSE && vertexHeightSW == vertexHeightNE && vertexHeightSW == vertexHeightNW);
218218+ for (int _z = plane; _z >= 0; _z--) {
219219+ if (groundArray[_z][x][y] == null) {
220220+ groundArray[_z][x][y] = new SceneTile(x, y, _z);
221221+ }
222222+ }
210223211211- tiles[i][j][k].genericTile = genericTile_1;
212212- return;
213213- }
214214- ComplexTile complexTile = new ComplexTile(j2, k3, i2, k1, j, i3, j3, l4, l2, i4, 0, k2, l, l1, j4, j1, k4, l3, k, i1);
215215- for (int k5 = i; k5 >= 0; k5--)
216216- if (tiles[k5][j][k] == null)
217217- tiles[k5][j][k] = new SceneTile(k5, j, k);
224224+ groundArray[plane][x][y].plainTile = tile;
225225+ return;
226226+ }
227227+ ComplexTile tile = new ComplexTile(x, vertexHeightSW, vertexHeightSE, vertexHeightNW, vertexHeightNE, y, clippingPathRotation, textureId, clippingPath, cA, colourA, cB, colourB, cC, colourC, cD, colourD, overlayRGB, underlayRGB);
228228+ for (int _z = plane; _z >= 0; _z--) {
229229+ if (groundArray[_z][x][y] == null) {
230230+ groundArray[_z][x][y] = new SceneTile(x, y, _z);
231231+ }
232232+ }
218233219219- tiles[i][j][k].complexTile = complexTile;
220220- }
234234+ groundArray[plane][x][y].shapedTile = tile;
235235+ }
221236222222- public void addGroundDecoration(int i, int j, int k, byte byte0, int l, int i1, int j1, Renderable renderable) {
223223- if (k <= 0)
224224- return;
225225- if (renderable == null)
226226- return;
227227- FloorDecoration floorDecoration = new FloorDecoration();
228228- floorDecoration.renderable = renderable;
229229- floorDecoration.y = i * 128 + 64;
230230- floorDecoration.z = j * 128 + 64;
231231- floorDecoration.x = i1;
232232- floorDecoration.hash = l;
233233- floorDecoration.config = byte0;
234234- if (tiles[j1][i][j] == null)
235235- tiles[j1][i][j] = new SceneTile(j1, i, j);
236236- tiles[j1][i][j].floorDecoration = floorDecoration;
237237- }
237237+ void addGroundDecoration(int x, int y, int z, int drawHeight, int uid, Renderable renderable, byte config) {
238238+ if (renderable == null) {
239239+ return;
240240+ }
241241+ FloorDecoration floorDecoration = new FloorDecoration();
242242+ floorDecoration.renderable = renderable;
243243+ floorDecoration.x = x * 128 + 64;
244244+ floorDecoration.y = y * 128 + 64;
245245+ floorDecoration.z = drawHeight;
246246+ floorDecoration.uid = uid;
247247+ floorDecoration.config = config;
248248+ if (groundArray[z][x][y] == null) {
249249+ groundArray[z][x][y] = new SceneTile(x, y, z);
250250+ }
251251+ groundArray[z][x][y].floorDecoration = floorDecoration;
252252+ }
238253239239- public void method248(int i, int plane, Renderable renderable_59_, Renderable renderable,
240240- int k, Renderable renderable_58_, int l, int y, int x) {
241241- CameraAngle cameraAngle = new CameraAngle();
242242- cameraAngle.aRenderable150 = renderable_59_;
243243- cameraAngle.y = x * 128 + 64;
244244- cameraAngle.z = y * 128 + 64;
245245- cameraAngle.x = i;
246246- cameraAngle.anInt179 = k;
247247- cameraAngle.aRenderable151 = renderable;
248248- cameraAngle.aRenderable152 = renderable_58_;
249249- int k1 = 0;
250250- SceneTile sceneTile = tiles[plane][x][y];
251251- if (sceneTile != null) {
252252- for (int l1 = 0; l1 < sceneTile.sceneSpawnRequestCount; l1++)
253253- if (sceneTile.sceneSpawnRequests[l1].aRenderable601 instanceof Model) {
254254- int i2 = ((Model) sceneTile.sceneSpawnRequests[l1].aRenderable601).anInt1675;
255255- if (i2 > k1)
256256- k1 = i2;
257257- }
254254+ public void addGroundItemTile(int x, int y, int z, int drawHeight, int uid, Renderable firstGroundItem, Renderable secondGroundItem,
255255+ Renderable thirdGroundItem) {
256256+ GroundItemTile groundItemTile = new GroundItemTile();
257257+ groundItemTile.firstGroundItem = firstGroundItem;
258258+ groundItemTile.x = x * 128 + 64;
259259+ groundItemTile.y = y * 128 + 64;
260260+ groundItemTile.z = drawHeight;
261261+ groundItemTile.uid = uid;
262262+ groundItemTile.secondGroundItem = secondGroundItem;
263263+ groundItemTile.thirdGroundItem = thirdGroundItem;
264264+ int k1 = 0;
265265+ SceneTile sceneTile = groundArray[z][x][y];
266266+ if (sceneTile != null) {
267267+ for (int e = 0; e < sceneTile.entityCount; e++) {
268268+ if (sceneTile.interactiveObjects[e].renderable instanceof Model) {
269269+ int i2 = ((Model) sceneTile.interactiveObjects[e].renderable).anInt1675;
270270+ if (i2 > k1) {
271271+ k1 = i2;
272272+ }
273273+ }
274274+ }
258275259259- }
260260- cameraAngle.anInt180 = k1;
261261- if (tiles[plane][x][y] == null)
262262- tiles[plane][x][y] = new SceneTile(plane, x, y);
263263- tiles[plane][x][y].cameraAngle = cameraAngle;
264264- }
276276+ }
277277+ groundItemTile.anInt180 = k1;
278278+ if (groundArray[z][x][y] == null) {
279279+ groundArray[z][x][y] = new SceneTile(x, y, z);
280280+ }
281281+ groundArray[z][x][y].groundItemTile = groundItemTile;
282282+ }
265283266266- public void method249(int faceUnknown, Renderable renderable, int hash, int y, byte config, int x, Renderable renderable_68_, int plane, int face,
267267- int l1) {
268268- if (renderable != null || renderable_68_ != null) {
269269- Wall wall = new Wall();
270270- wall.hash = hash;
271271- wall.config = config;
272272- wall.x = x * 128 + 64;
273273- wall.y = y * 128 + 64;
274274- wall.plane = plane;
275275- wall.aRenderable769 = renderable;
276276- wall.aRenderable770 = renderable_68_;
277277- wall.faceUnknown = faceUnknown;
278278- wall.face = face;
279279- for (int j2 = l1; j2 >= 0; j2--)
280280- if (tiles[j2][x][y] == null)
281281- tiles[j2][x][y] = new SceneTile(j2, x, y);
284284+ void addWall(int x, int y, int z, int drawHeight, int orientation, int orientation2, int uid, Renderable primary, Renderable secondary, byte config) {
285285+ if (primary != null || secondary != null) {
286286+ Wall wall = new Wall();
287287+ wall.uid = uid;
288288+ wall.config = config;
289289+ wall.x = x * 128 + 64;
290290+ wall.y = y * 128 + 64;
291291+ wall.z = drawHeight;
292292+ wall.primary = primary;
293293+ wall.secondary = secondary;
294294+ wall.orientation = orientation;
295295+ wall.orientation2 = orientation2;
296296+ for (int _z = z; _z >= 0; _z--) {
297297+ if (groundArray[_z][x][y] == null) {
298298+ groundArray[_z][x][y] = new SceneTile(x, y, _z);
299299+ }
300300+ }
282301283283- tiles[l1][x][y].wall = wall;
284284- }
285285- }
302302+ groundArray[z][x][y].wall = wall;
303303+ }
304304+ }
286305287287- public void addWallDecoration(int plane, int faceUnknown, int face, int hash, byte config, int x, int j1, int y, int l1, int z,
288288- Renderable renderable, int j2) {
289289- if (renderable != null) {
290290- WallDecoration wallDecoration = new WallDecoration();
291291- wallDecoration.hash = hash;
292292- wallDecoration.config = config;
293293- wallDecoration.y = x * 128 + 64 + l1;
294294- wallDecoration.x = y * 128 + 64 + j1;
295295- wallDecoration.plane = z;
296296- wallDecoration.renderable = renderable;
297297- wallDecoration.faceUnknown = faceUnknown;
298298- wallDecoration.face = face;
299299- for (int planeCounter = plane; planeCounter >= 0; planeCounter--)
300300- if (tiles[planeCounter][x][y] == null)
301301- tiles[planeCounter][x][y] = new SceneTile(planeCounter, x, y);
306306+ void addWallDecoration(int x, int y, int z, int drawHeight, int offsetX, int offsetY, int face, int uid, Renderable renderable, byte config, int faceBits) {
307307+ if (renderable != null) {
308308+ WallDecoration wallDecoration = new WallDecoration();
309309+ wallDecoration.uid = uid;
310310+ wallDecoration.config = config;
311311+ wallDecoration.x = x * 128 + 64 + offsetX;
312312+ wallDecoration.y = y * 128 + 64 + offsetY;
313313+ wallDecoration.z = drawHeight;
314314+ wallDecoration.renderable = renderable;
315315+ wallDecoration.configBits = faceBits;
316316+ wallDecoration.face = face;
317317+ for (int planeCounter = z; planeCounter >= 0; planeCounter--) {
318318+ if (groundArray[planeCounter][x][y] == null) {
319319+ groundArray[planeCounter][x][y] = new SceneTile(x, y, planeCounter);
320320+ }
321321+ }
302322303303- tiles[plane][x][y].wallDecoration = wallDecoration;
304304- }
305305- }
323323+ groundArray[z][x][y].wallDecoration = wallDecoration;
324324+ }
325325+ }
306326307307- public boolean method251(int i, int j, int k, Renderable class50_sub1_sub4, byte byte0, int l, int i1,
308308- int j1, int k1, int l1, int i2) {
309309- while (j1 >= 0)
310310- throw new NullPointerException();
311311- if (class50_sub1_sub4 == null) {
312312- return true;
313313- } else {
314314- int j2 = i1 * 128 + 64 * j;
315315- int k2 = k * 128 + 64 * k1;
316316- return method254(i, i1, k, j, k1, j2, k2, l1, class50_sub1_sub4, l, false, i2, byte0);
317317- }
318318- }
327327+ boolean addEntityB(int x, int y, int z, int worldZ, int rotation, int tileWidth, int tileHeight, int uid, Renderable entity, byte config) {
328328+ if (entity == null) {
329329+ return true;
330330+ } else {
331331+ int worldX = x * 128 + 64 * tileHeight;
332332+ int worldY = y * 128 + 64 * tileWidth;
333333+ return addRenderableC(x, y, z, worldX, worldY, worldZ, rotation, tileWidth, tileHeight, uid, entity, false, config);
334334+ }
335335+ }
319336320320- public boolean addEntity(int i, Renderable class50_sub1_sub4, int j, int k, boolean flag, int l, int i1,
321321- int j1, int k1, int l1) {
322322- if (class50_sub1_sub4 == null)
323323- return true;
324324- int i2 = j - j1;
325325- int j2 = k1 - j1;
326326- int k2 = j + j1;
327327- int l2 = k1 + j1;
328328- if (flag) {
329329- if (l1 > 640 && l1 < 1408)
330330- l2 += 128;
331331- if (l1 > 1152 && l1 < 1920)
332332- k2 += 128;
333333- if (l1 > 1664 || l1 < 384)
334334- j2 -= 128;
335335- if (l1 > 128 && l1 < 896)
336336- i2 -= 128;
337337- }
338338- i2 /= 128;
339339- j2 /= 128;
340340- k2 /= 128;
341341- l2 /= 128;
342342- return method254(i1, i2, j2, (k2 - i2) + 1, (l2 - j2) + 1, j, k1, k, class50_sub1_sub4, l1, true, i, (byte) 0);
343343- }
337337+ public boolean addEntity(int z, int worldX, int worldY, int worldZ, Renderable entity, int uid, int delta, boolean accountForYaw,
338338+ int yaw) {
339339+ if (entity == null) {
340340+ return true;
341341+ }
342342+ int minX = worldX - delta;
343343+ int minY = worldY - delta;
344344+ int maxX = worldX + delta;
345345+ int maxY = worldY + delta;
346346+ if (accountForYaw) {
347347+ if (yaw > 640 && yaw < 1408) {
348348+ maxY += 128;
349349+ }
350350+ if (yaw > 1152 && yaw < 1920) {
351351+ maxX += 128;
352352+ }
353353+ if (yaw > 1664 || yaw < 384) {
354354+ minY -= 128;
355355+ }
356356+ if (yaw > 128 && yaw < 896) {
357357+ minX -= 128;
358358+ }
359359+ }
360360+ minX /= 128;
361361+ minY /= 128;
362362+ maxX /= 128;
363363+ maxY /= 128;
364364+ return addRenderableC(minX, minY, z, worldX, worldY, worldZ, yaw, (maxY - minY) + 1, (maxX - minX) + 1, uid, entity, true, (byte) 0);
365365+ }
344366345345- public boolean addRenderable(int i, int j, int k, int l, Renderable class50_sub1_sub4, int i1, int j1, int k1,
346346- int l1, int i2, int j2, int k2, int l2) {
347347- if (class50_sub1_sub4 == null)
348348- return true;
349349- else
350350- return method254(k2, i1, j, (j2 - i1) + 1, (k1 - j) + 1, l1, j1, i, class50_sub1_sub4, i2, true, l2,
351351- (byte) 0);
352352- }
367367+ public boolean addEntity(int x, int y, int z, int worldX, int worldY, int worldZ, int rotation, int tileWidth, int tileHeight, Renderable entity,
368368+ int uid) {
353369354354- public boolean method254(int i, int j, int k, int l, int i1, int j1, int k1, int l1,
355355- Renderable renderable, int i2, boolean flag, int j2, byte byte0) {
356356- for (int k2 = j; k2 < j + l; k2++) {
357357- for (int l2 = k; l2 < k + i1; l2++) {
358358- if (k2 < 0 || l2 < 0 || k2 >= anInt453 || l2 >= anInt454)
359359- return false;
360360- SceneTile class50_sub3 = tiles[i][k2][l2];
361361- if (class50_sub3 != null && class50_sub3.sceneSpawnRequestCount >= 5)
362362- return false;
363363- }
370370+ return entity == null || addRenderableC(x, y, z, worldX, worldY, worldZ, rotation, (tileWidth - y) + 1, (tileHeight - x) + 1, uid, entity, true,
371371+ (byte) 0);
372372+ }
364373365365- }
374374+ private boolean addRenderableC(int minX, int minY, int z, int worldX, int worldY, int worldZ, int rotation, int tileWidth, int tileHeight,
375375+ int uid, Renderable renderable, boolean isDynamic, byte config) {
376376+ for (int x = minX; x < minX + tileHeight; x++) {
377377+ for (int y = minY; y < minY + tileWidth; y++) {
378378+ if (x < 0 || y < 0 || x >= mapSizeX || y >= mapSizeY) {
379379+ return false;
380380+ }
381381+ SceneTile tile = groundArray[z][x][y];
382382+ if (tile != null && tile.entityCount >= 5) {
383383+ return false;
384384+ }
385385+ }
366386367367- SceneSpawnRequest sceneSpawnRequest = new SceneSpawnRequest();
368368- sceneSpawnRequest.anInt125 = j2;
369369- sceneSpawnRequest.config = byte0;
370370- sceneSpawnRequest.anInt113 = i;
371371- sceneSpawnRequest.anInt115 = j1;
372372- sceneSpawnRequest.anInt116 = k1;
373373- sceneSpawnRequest.anInt114 = l1;
374374- sceneSpawnRequest.aRenderable601 = renderable;
375375- sceneSpawnRequest.anInt118 = i2;
376376- sceneSpawnRequest.x = j;
377377- sceneSpawnRequest.y = k;
378378- sceneSpawnRequest.anInt120 = (j + l) - 1;
379379- sceneSpawnRequest.anInt122 = (k + i1) - 1;
380380- for (int i3 = j; i3 < j + l; i3++) {
381381- for (int j3 = k; j3 < k + i1; j3++) {
382382- int k3 = 0;
383383- if (i3 > j)
384384- k3++;
385385- if (i3 < (j + l) - 1)
386386- k3 += 4;
387387- if (j3 > k)
388388- k3 += 8;
389389- if (j3 < (k + i1) - 1)
390390- k3 += 2;
391391- for (int l3 = i; l3 >= 0; l3--)
392392- if (tiles[l3][i3][j3] == null)
393393- tiles[l3][i3][j3] = new SceneTile(l3, i3, j3);
387387+ }
394388395395- SceneTile sceneTile = tiles[i][i3][j3];
396396- sceneTile.sceneSpawnRequests[sceneTile.sceneSpawnRequestCount] = sceneSpawnRequest;
397397- sceneTile.anIntArray1409[sceneTile.sceneSpawnRequestCount] = k3;
398398- sceneTile.anInt1410 |= k3;
399399- sceneTile.sceneSpawnRequestCount++;
400400- }
389389+ InteractiveObject interactiveObject = new InteractiveObject();
390390+ interactiveObject.uid = uid;
391391+ interactiveObject.config = config;
392392+ interactiveObject.z = z;
393393+ interactiveObject.worldX = worldX;
394394+ interactiveObject.worldY = worldY;
395395+ interactiveObject.worldZ = worldZ;
396396+ interactiveObject.renderable = renderable;
397397+ interactiveObject.rotation = rotation;
398398+ interactiveObject.tileLeft = minX;
399399+ interactiveObject.tileTop = minY;
400400+ interactiveObject.tileRight = (minX + tileHeight) - 1;
401401+ interactiveObject.tileBottom = (minY + tileWidth) - 1;
402402+ for (int x = minX; x < minX + tileHeight; x++) {
403403+ for (int y = minY; y < minY + tileWidth; y++) {
404404+ int size = 0;
405405+ if (x > minX) {
406406+ size++;
407407+ }
408408+ if (x < (minX + tileHeight) - 1) {
409409+ size += 4;
410410+ }
411411+ if (y > minY) {
412412+ size += 8;
413413+ }
414414+ if (y < (minY + tileWidth) - 1) {
415415+ size += 2;
416416+ }
417417+ for (int _z = z; _z >= 0; _z--) {
418418+ if (groundArray[_z][x][y] == null) {
419419+ groundArray[_z][x][y] = new SceneTile(x, y, _z);
420420+ }
421421+ }
401422402402- }
423423+ SceneTile sceneTile = groundArray[z][x][y];
424424+ sceneTile.interactiveObjects[sceneTile.entityCount] = interactiveObject;
425425+ sceneTile.sceneSpawnRequestsSize[sceneTile.entityCount] = size;
426426+ sceneTile.interactiveObjectsSizeOR |= size;
427427+ sceneTile.entityCount++;
428428+ }
403429404404- if (flag)
405405- aSceneSpawnRequestArray459[anInt458++] = sceneSpawnRequest;
406406- return true;
407407- }
430430+ }
408431409409- public void method255() {
410410- for (int j = 0; j < anInt458; j++) {
411411- SceneSpawnRequest sceneSpawnRequest = aSceneSpawnRequestArray459[j];
412412- method256(sceneSpawnRequest);
413413- aSceneSpawnRequestArray459[j] = null;
414414- }
432432+ if (isDynamic) {
433433+ sceneSpawnRequestsCache[sceneSpawnRequestsCacheCurrentPos++] = interactiveObject;
434434+ }
435435+ return true;
436436+ }
415437416416- anInt458 = 0;
417417- }
438438+ public void clearInteractiveObjectCache() {
439439+ for (int j = 0; j < sceneSpawnRequestsCacheCurrentPos; j++) {
440440+ InteractiveObject interactiveObject = sceneSpawnRequestsCache[j];
441441+ remove(interactiveObject);
442442+ sceneSpawnRequestsCache[j] = null;
443443+ }
418444419419- public void method256(SceneSpawnRequest sceneSpawnRequest) {
420420- for (int j = sceneSpawnRequest.x; j <= sceneSpawnRequest.anInt120; j++) {
421421- for (int k = sceneSpawnRequest.y; k <= sceneSpawnRequest.anInt122; k++) {
422422- SceneTile class50_sub3 = tiles[sceneSpawnRequest.anInt113][j][k];
423423- if (class50_sub3 != null) {
424424- for (int l = 0; l < class50_sub3.sceneSpawnRequestCount; l++) {
425425- if (class50_sub3.sceneSpawnRequests[l] != sceneSpawnRequest)
426426- continue;
427427- class50_sub3.sceneSpawnRequestCount--;
428428- for (int i1 = l; i1 < class50_sub3.sceneSpawnRequestCount; i1++) {
429429- class50_sub3.sceneSpawnRequests[i1] = class50_sub3.sceneSpawnRequests[i1 + 1];
430430- class50_sub3.anIntArray1409[i1] = class50_sub3.anIntArray1409[i1 + 1];
431431- }
445445+ sceneSpawnRequestsCacheCurrentPos = 0;
446446+ }
432447433433- class50_sub3.sceneSpawnRequests[class50_sub3.sceneSpawnRequestCount] = null;
434434- break;
435435- }
448448+ private void remove(InteractiveObject entity) {
449449+ for (int x = entity.tileLeft; x <= entity.tileRight; x++) {
450450+ for (int y = entity.tileTop; y <= entity.tileBottom; y++) {
451451+ SceneTile tile = groundArray[entity.z][x][y];
452452+ if (tile != null) {
453453+ for (int e = 0; e < tile.entityCount; e++) {
454454+ if (tile.interactiveObjects[e] != entity) {
455455+ continue;
456456+ }
457457+ tile.entityCount--;
458458+ for (int e2 = e; e2 < tile.entityCount; e2++) {
459459+ tile.interactiveObjects[e2] = tile.interactiveObjects[e2 + 1];
460460+ tile.sceneSpawnRequestsSize[e2] = tile.sceneSpawnRequestsSize[e2 + 1];
461461+ }
436462437437- class50_sub3.anInt1410 = 0;
438438- for (int j1 = 0; j1 < class50_sub3.sceneSpawnRequestCount; j1++)
439439- class50_sub3.anInt1410 |= class50_sub3.anIntArray1409[j1];
463463+ tile.interactiveObjects[tile.entityCount] = null;
464464+ break;
465465+ }
440466441441- }
442442- }
467467+ tile.interactiveObjectsSizeOR = 0;
468468+ for (int j1 = 0; j1 < tile.entityCount; j1++) {
469469+ tile.interactiveObjectsSizeOR |= tile.sceneSpawnRequestsSize[j1];
470470+ }
443471444444- }
472472+ }
473473+ }
445474446446- }
475475+ }
447476448448- public void method257(int i, int j, int k, int l) {
449449- SceneTile sceneTile = tiles[k][l][i];
450450- if (sceneTile == null)
451451- return;
452452- WallDecoration wallDecoration = sceneTile.wallDecoration;
453453- if (wallDecoration == null)
454454- return;
455455- int j1 = l * 128 + 64;
456456- int k1 = i * 128 + 64;
457457- wallDecoration.y = j1 + ((wallDecoration.y - j1) * j) / 16;
458458- wallDecoration.x = k1 + ((wallDecoration.x - k1) * j) / 16;
477477+ }
459478460460- }
479479+ void displaceWallDecoration(int x, int y, int z, int displacement) {
480480+ SceneTile sceneTile = groundArray[z][x][y];
481481+ if (sceneTile == null) {
482482+ return;
483483+ }
484484+ WallDecoration wallDecoration = sceneTile.wallDecoration;
485485+ if (wallDecoration == null) {
486486+ return;
487487+ }
488488+ int absX = x * 128 + 64;
489489+ int absY = y * 128 + 64;
490490+ wallDecoration.x = absX + ((wallDecoration.x - absX) * displacement) / 16;
491491+ wallDecoration.y = absY + ((wallDecoration.y - absY) * displacement) / 16;
461492462462- public void method258(int i, int j, int k, boolean flag) {
463463- SceneTile class50_sub3 = tiles[j][k][i];
464464- if (class50_sub3 == null)
465465- return;
466466- class50_sub3.wall = null;
467467- }
493493+ }
468494469469- public void method259(boolean flag, int i, int j, int k) {
470470- SceneTile class50_sub3 = tiles[k][i][j];
471471- if (flag)
472472- return;
473473- if (class50_sub3 == null) {
474474- return;
475475- } else {
476476- class50_sub3.wallDecoration = null;
477477- return;
478478- }
479479- }
495495+ public void removeWallObject(int x, int y, int z) {
496496+ SceneTile tile = groundArray[z][x][y];
497497+ if (tile != null) {
498498+ tile.wall = null;
499499+ }
500500+ }
480501481481- public void method260(int i, int j, int k, int l) {
482482- if (k >= 0)
483483- return;
484484- SceneTile class50_sub3 = tiles[j][l][i];
485485- if (class50_sub3 == null)
486486- return;
487487- for (int i1 = 0; i1 < class50_sub3.sceneSpawnRequestCount; i1++) {
488488- SceneSpawnRequest sceneSpawnRequest = class50_sub3.sceneSpawnRequests[i1];
489489- if ((sceneSpawnRequest.anInt125 >> 29 & 3) == 2 && sceneSpawnRequest.x == l && sceneSpawnRequest.y == i) {
490490- method256(sceneSpawnRequest);
491491- return;
492492- }
493493- }
502502+ public void removeWallDecoration(int x, int y, int z) {
503503+ SceneTile tile = groundArray[z][x][y];
504504+ if (tile != null) {
505505+ tile.wallDecoration = null;
506506+ }
507507+ }
494508495495- }
509509+ public void removeInteractiveObject(int x, int y, int z) {
510510+ SceneTile tile = groundArray[z][x][y];
511511+ if (tile == null) {
512512+ return;
513513+ }
514514+ for (int e = 0; e < tile.entityCount; e++) {
515515+ InteractiveObject interactiveObject = tile.interactiveObjects[e];
516516+ if ((interactiveObject.uid >> 29 & 3) == 2 && interactiveObject.tileLeft == x && interactiveObject.tileTop == y) {
517517+ remove(interactiveObject);
518518+ return;
519519+ }
520520+ }
496521497497- public void method261(int i, int j, boolean flag, int k) {
498498- SceneTile class50_sub3 = tiles[k][i][j];
499499- if (class50_sub3 == null)
500500- return;
501501- class50_sub3.floorDecoration = null;
502502- if (!flag) {
503503- for (int l = 1; l > 0; l++);
504504- }
505505- }
522522+ }
506523507507- public void clearGroundItem(int i, int j, int k) {
508508- SceneTile class50_sub3 = tiles[i][j][k];
509509- if (class50_sub3 == null) {
510510- return;
511511- } else {
512512- class50_sub3.cameraAngle = null;
513513- return;
514514- }
515515- }
524524+ public void method261(int x, int y, int z) {
525525+ SceneTile tile = groundArray[z][x][y];
526526+ if (tile == null) {
527527+ return;
528528+ }
529529+ tile.floorDecoration = null;
530530+ }
516531517517- public Wall method263(int i, int j, int k, int l) {
518518- SceneTile class50_sub3 = tiles[i][k][l];
519519- if (j != 17734)
520520- throw new NullPointerException();
521521- if (class50_sub3 == null)
522522- return null;
523523- else
524524- return class50_sub3.wall;
525525- }
532532+ public void clearGroundItem(int i, int j, int k) {
533533+ SceneTile class50_sub3 = groundArray[i][j][k];
534534+ if (class50_sub3 != null) {
535535+ class50_sub3.groundItemTile = null;
536536+ }
537537+ }
526538527527- public WallDecoration method264(int i, int j, int k, boolean flag) {
528528- SceneTile class50_sub3 = tiles[i][k][j];
529529- if (flag)
530530- throw new NullPointerException();
531531- if (class50_sub3 == null)
532532- return null;
533533- else
534534- return class50_sub3.wallDecoration;
535535- }
539539+ public Wall method263(int i, int j, int k, int l) {
540540+ SceneTile class50_sub3 = groundArray[i][k][l];
541541+ if (j != 17734) {
542542+ throw new NullPointerException();
543543+ }
544544+ if (class50_sub3 == null) {
545545+ return null;
546546+ } else {
547547+ return class50_sub3.wall;
548548+ }
549549+ }
536550537537- public SceneSpawnRequest method265(int i, byte byte0, int j, int k) {
538538- if (byte0 != 32) {
539539- for (int l = 1; l > 0; l++);
540540- }
541541- SceneTile class50_sub3 = tiles[k][i][j];
542542- if (class50_sub3 == null)
543543- return null;
544544- for (int i1 = 0; i1 < class50_sub3.sceneSpawnRequestCount; i1++) {
545545- SceneSpawnRequest sceneSpawnRequest = class50_sub3.sceneSpawnRequests[i1];
546546- if ((sceneSpawnRequest.anInt125 >> 29 & 3) == 2 && sceneSpawnRequest.x == i && sceneSpawnRequest.y == j)
547547- return sceneSpawnRequest;
548548- }
551551+ public WallDecoration method264(int i, int j, int k, boolean flag) {
552552+ SceneTile class50_sub3 = groundArray[i][k][j];
553553+ if (flag) {
554554+ throw new NullPointerException();
555555+ }
556556+ if (class50_sub3 == null) {
557557+ return null;
558558+ } else {
559559+ return class50_sub3.wallDecoration;
560560+ }
561561+ }
549562550550- return null;
551551- }
563563+ public InteractiveObject method265(int i, byte byte0, int j, int k) {
564564+ if (byte0 != 32) {
565565+ for (int l = 1; l > 0; l++) {
566566+ }
567567+ }
568568+ SceneTile class50_sub3 = groundArray[k][i][j];
569569+ if (class50_sub3 == null) {
570570+ return null;
571571+ }
572572+ for (int i1 = 0; i1 < class50_sub3.entityCount; i1++) {
573573+ InteractiveObject interactiveObject = class50_sub3.interactiveObjects[i1];
574574+ if ((interactiveObject.uid >> 29 & 3) == 2 && interactiveObject.tileLeft == i && interactiveObject.tileTop == j) {
575575+ return interactiveObject;
576576+ }
577577+ }
552578553553- public FloorDecoration method266(int i, int j, int k, int l) {
554554- if (k != 0)
555555- throw new NullPointerException();
556556- SceneTile class50_sub3 = tiles[i][l][j];
557557- if (class50_sub3 == null || class50_sub3.floorDecoration == null)
558558- return null;
559559- else
560560- return class50_sub3.floorDecoration;
561561- }
579579+ return null;
580580+ }
562581563563- public int method267(int i, int j, int k) {
564564- SceneTile class50_sub3 = tiles[i][j][k];
565565- if (class50_sub3 == null || class50_sub3.wall == null)
566566- return 0;
567567- else
568568- return class50_sub3.wall.hash;
569569- }
582582+ public FloorDecoration method266(int i, int j, int k, int l) {
583583+ if (k != 0) {
584584+ throw new NullPointerException();
585585+ }
586586+ SceneTile class50_sub3 = groundArray[i][l][j];
587587+ if (class50_sub3 == null || class50_sub3.floorDecoration == null) {
588588+ return null;
589589+ } else {
590590+ return class50_sub3.floorDecoration;
591591+ }
592592+ }
570593571571- public int method268(int i, byte byte0, int j, int k) {
572572- SceneTile class50_sub3 = tiles[j][i][k];
573573- if (class50_sub3 == null || class50_sub3.wallDecoration == null)
574574- return 0;
575575- else
576576- return class50_sub3.wallDecoration.hash;
577577- }
594594+ public int method267(int i, int j, int k) {
595595+ SceneTile class50_sub3 = groundArray[i][j][k];
596596+ if (class50_sub3 == null || class50_sub3.wall == null) {
597597+ return 0;
598598+ } else {
599599+ return class50_sub3.wall.uid;
600600+ }
601601+ }
578602579579- public int method269(int i, int j, int k) {
580580- SceneTile class50_sub3 = tiles[i][j][k];
581581- if (class50_sub3 == null)
582582- return 0;
583583- for (int l = 0; l < class50_sub3.sceneSpawnRequestCount; l++) {
584584- SceneSpawnRequest sceneSpawnRequest = class50_sub3.sceneSpawnRequests[l];
585585- if ((sceneSpawnRequest.anInt125 >> 29 & 3) == 2 && sceneSpawnRequest.x == j && sceneSpawnRequest.y == k)
586586- return sceneSpawnRequest.anInt125;
587587- }
603603+ public int method268(int i, byte byte0, int j, int k) {
604604+ SceneTile class50_sub3 = groundArray[j][i][k];
605605+ if (class50_sub3 == null || class50_sub3.wallDecoration == null) {
606606+ return 0;
607607+ } else {
608608+ return class50_sub3.wallDecoration.uid;
609609+ }
610610+ }
588611589589- return 0;
590590- }
612612+ public int method269(int i, int j, int k) {
613613+ SceneTile class50_sub3 = groundArray[i][j][k];
614614+ if (class50_sub3 == null) {
615615+ return 0;
616616+ }
617617+ for (int l = 0; l < class50_sub3.entityCount; l++) {
618618+ InteractiveObject interactiveObject = class50_sub3.interactiveObjects[l];
619619+ if ((interactiveObject.uid >> 29 & 3) == 2 && interactiveObject.tileLeft == j && interactiveObject.tileTop == k) {
620620+ return interactiveObject.uid;
621621+ }
622622+ }
591623592592- public int getFloorDecorationHash(int i, int j, int k) {
593593- SceneTile class50_sub3 = tiles[i][j][k];
594594- if (class50_sub3 == null || class50_sub3.floorDecoration == null)
595595- return 0;
596596- else
597597- return class50_sub3.floorDecoration.hash;
598598- }
624624+ return 0;
625625+ }
599626600600- public int method271(int i, int j, int k, int l) {
601601- SceneTile class50_sub3 = tiles[i][j][k];
602602- if (class50_sub3 == null)
603603- return -1;
604604- if (class50_sub3.wall != null && class50_sub3.wall.hash == l)
605605- return class50_sub3.wall.config & 0xff;
606606- if (class50_sub3.wallDecoration != null && class50_sub3.wallDecoration.hash == l)
607607- return class50_sub3.wallDecoration.config & 0xff;
608608- if (class50_sub3.floorDecoration != null && class50_sub3.floorDecoration.hash == l)
609609- return class50_sub3.floorDecoration.config & 0xff;
610610- for (int i1 = 0; i1 < class50_sub3.sceneSpawnRequestCount; i1++)
611611- if (class50_sub3.sceneSpawnRequests[i1].anInt125 == l)
612612- return class50_sub3.sceneSpawnRequests[i1].config & 0xff;
627627+ public int getFloorDecorationHash(int i, int j, int k) {
628628+ SceneTile class50_sub3 = groundArray[i][j][k];
629629+ if (class50_sub3 == null || class50_sub3.floorDecoration == null) {
630630+ return 0;
631631+ } else {
632632+ return class50_sub3.floorDecoration.uid;
633633+ }
634634+ }
613635614614- return -1;
615615- }
636636+ public int method271(int i, int j, int k, int l) {
637637+ SceneTile class50_sub3 = groundArray[i][j][k];
638638+ if (class50_sub3 == null) {
639639+ return -1;
640640+ }
641641+ if (class50_sub3.wall != null && class50_sub3.wall.uid == l) {
642642+ return class50_sub3.wall.config & 0xff;
643643+ }
644644+ if (class50_sub3.wallDecoration != null && class50_sub3.wallDecoration.uid == l) {
645645+ return class50_sub3.wallDecoration.config & 0xff;
646646+ }
647647+ if (class50_sub3.floorDecoration != null && class50_sub3.floorDecoration.uid == l) {
648648+ return class50_sub3.floorDecoration.config & 0xff;
649649+ }
650650+ for (int i1 = 0; i1 < class50_sub3.entityCount; i1++) {
651651+ if (class50_sub3.interactiveObjects[i1].uid == l) {
652652+ return class50_sub3.interactiveObjects[i1].config & 0xff;
653653+ }
654654+ }
616655617617- public void method272(byte byte0, int i, int j, int k) {
618618- for (int l = 0; l < anInt452; l++) {
619619- for (int i1 = 0; i1 < anInt453; i1++) {
620620- for (int j1 = 0; j1 < anInt454; j1++) {
621621- SceneTile class50_sub3 = tiles[l][i1][j1];
622622- if (class50_sub3 != null) {
623623- Wall wall = class50_sub3.wall;
624624- if (wall != null && wall.aRenderable769 != null
625625- && wall.aRenderable769.verticesNormal != null) {
626626- method274(j1, l, 0, 1, (Model) wall.aRenderable769, i1, 1);
627627- if (wall.aRenderable770 != null
628628- && wall.aRenderable770.verticesNormal != null) {
629629- method274(j1, l, 0, 1, (Model) wall.aRenderable770, i1, 1);
630630- method275((Model) wall.aRenderable769,
631631- (Model) wall.aRenderable770, 0, 0, 0, false);
632632- ((Model) wall.aRenderable770).method595(i, j, 0, k);
633633- }
634634- ((Model) wall.aRenderable769).method595(i, j, 0, k);
635635- }
636636- for (int k1 = 0; k1 < class50_sub3.sceneSpawnRequestCount; k1++) {
637637- SceneSpawnRequest sceneSpawnRequest = class50_sub3.sceneSpawnRequests[k1];
638638- if (sceneSpawnRequest != null && sceneSpawnRequest.aRenderable601 != null
639639- && sceneSpawnRequest.aRenderable601.verticesNormal != null) {
640640- method274(j1, l, 0, (sceneSpawnRequest.anInt120 - sceneSpawnRequest.x) + 1,
641641- (Model) sceneSpawnRequest.aRenderable601, i1,
642642- (sceneSpawnRequest.anInt122 - sceneSpawnRequest.y) + 1);
643643- ((Model) sceneSpawnRequest.aRenderable601).method595(i, j, 0, k);
644644- }
645645- }
656656+ return -1;
657657+ }
646658647647- FloorDecoration floorDecoration = class50_sub3.floorDecoration;
648648- if (floorDecoration != null && floorDecoration.renderable.verticesNormal != null) {
649649- method273(i1, (Model) floorDecoration.renderable, j1, l, 0);
650650- ((Model) floorDecoration.renderable).method595(i, j, 0, k);
651651- }
652652- }
653653- }
659659+ void shadeModels(int i, int j, int k) {
660660+ for (int _z = 0; _z < mapSizeZ; _z++) {
661661+ for (int _x = 0; _x < mapSizeX; _x++) {
662662+ for (int _y = 0; _y < mapSizeY; _y++) {
663663+ SceneTile tile = groundArray[_z][_x][_y];
664664+ if (tile != null) {
665665+ Wall wall = tile.wall;
666666+ if (wall != null && wall.primary != null
667667+ && wall.primary.verticesNormal != null) {
668668+ method274(_y, _z, 0, 1, (Model) wall.primary, _x, 1);
669669+ if (wall.secondary != null
670670+ && wall.secondary.verticesNormal != null) {
671671+ method274(_y, _z, 0, 1, (Model) wall.secondary, _x, 1);
672672+ mergeNormals((Model) wall.primary,
673673+ (Model) wall.secondary, 0, 0, 0, false);
674674+ ((Model) wall.secondary).handleShading(i, j, 0, k);
675675+ }
676676+ ((Model) wall.primary).handleShading(i, j, 0, k);
677677+ }
678678+ for (int k1 = 0; k1 < tile.entityCount; k1++) {
679679+ InteractiveObject interactiveObject = tile.interactiveObjects[k1];
680680+ if (interactiveObject != null && interactiveObject.renderable != null
681681+ && interactiveObject.renderable.verticesNormal != null) {
682682+ method274(_y, _z, 0, (interactiveObject.tileRight - interactiveObject.tileLeft) + 1,
683683+ (Model) interactiveObject.renderable, _x,
684684+ (interactiveObject.tileBottom - interactiveObject.tileTop) + 1);
685685+ ((Model) interactiveObject.renderable).handleShading(i, j, 0, k);
686686+ }
687687+ }
654688655655- }
689689+ FloorDecoration floorDecoration = tile.floorDecoration;
690690+ if (floorDecoration != null && floorDecoration.renderable.verticesNormal != null) {
691691+ method273(_x, (Model) floorDecoration.renderable, _y, _z, 0);
692692+ ((Model) floorDecoration.renderable).handleShading(i, j, 0, k);
693693+ }
694694+ }
695695+ }
656696657657- }
697697+ }
658698659659- if (byte0 == 2)
660660- byte0 = 0;
661661- }
699699+ }
662700663663- public void method273(int i, Model class50_sub1_sub4_sub4, int j, int k, int l) {
664664- if (l != 0)
665665- return;
666666- if (i < anInt453) {
667667- SceneTile class50_sub3 = tiles[k][i + 1][j];
668668- if (class50_sub3 != null && class50_sub3.floorDecoration != null
669669- && class50_sub3.floorDecoration.renderable.verticesNormal != null)
670670- method275(class50_sub1_sub4_sub4,
671671- (Model) class50_sub3.floorDecoration.renderable, 128, 0, 0, true);
672672- }
673673- if (j < anInt453) {
674674- SceneTile class50_sub3_1 = tiles[k][i][j + 1];
675675- if (class50_sub3_1 != null && class50_sub3_1.floorDecoration != null
676676- && class50_sub3_1.floorDecoration.renderable.verticesNormal != null)
677677- method275(class50_sub1_sub4_sub4,
678678- (Model) class50_sub3_1.floorDecoration.renderable, 0, 0, 128, true);
679679- }
680680- if (i < anInt453 && j < anInt454) {
681681- SceneTile class50_sub3_2 = tiles[k][i + 1][j + 1];
682682- if (class50_sub3_2 != null && class50_sub3_2.floorDecoration != null
683683- && class50_sub3_2.floorDecoration.renderable.verticesNormal != null)
684684- method275(class50_sub1_sub4_sub4,
685685- (Model) class50_sub3_2.floorDecoration.renderable, 128, 0, 128, true);
686686- }
687687- if (i < anInt453 && j > 0) {
688688- SceneTile class50_sub3_3 = tiles[k][i + 1][j - 1];
689689- if (class50_sub3_3 != null && class50_sub3_3.floorDecoration != null
690690- && class50_sub3_3.floorDecoration.renderable.verticesNormal != null)
691691- method275(class50_sub1_sub4_sub4,
692692- (Model) class50_sub3_3.floorDecoration.renderable, 128, 0, -128,
693693- true);
694694- }
695695- }
701701+ }
696702697697- public void method274(int i, int j, int k, int l, Model class50_sub1_sub4_sub4, int i1, int j1) {
698698- boolean flag = true;
699699- int k1 = i1;
700700- int l1 = i1 + l;
701701- int i2 = i - 1;
702702- int j2 = i + j1;
703703- for (int k2 = j; k2 <= j + 1; k2++)
704704- if (k2 != anInt452) {
705705- for (int l2 = k1; l2 <= l1; l2++)
706706- if (l2 >= 0 && l2 < anInt453) {
707707- for (int i3 = i2; i3 <= j2; i3++)
708708- if (i3 >= 0 && i3 < anInt454 && (!flag || l2 >= l1 || i3 >= j2 || i3 < i && l2 != i1)) {
709709- SceneTile class50_sub3 = tiles[k2][l2][i3];
710710- if (class50_sub3 != null) {
711711- int j3 = (anIntArrayArrayArray455[k2][l2][i3]
712712- + anIntArrayArrayArray455[k2][l2 + 1][i3]
713713- + anIntArrayArrayArray455[k2][l2][i3 + 1] + anIntArrayArrayArray455[k2][l2 + 1][i3 + 1])
714714- / 4
715715- - (anIntArrayArrayArray455[j][i1][i]
716716- + anIntArrayArrayArray455[j][i1 + 1][i]
717717- + anIntArrayArrayArray455[j][i1][i + 1] + anIntArrayArrayArray455[j][i1 + 1][i + 1])
718718- / 4;
719719- Wall wall = class50_sub3.wall;
720720- if (wall != null && wall.aRenderable769 != null
721721- && wall.aRenderable769.verticesNormal != null)
722722- method275(class50_sub1_sub4_sub4,
723723- (Model) wall.aRenderable769, (l2 - i1)
724724- * 128 + (1 - l) * 64, j3, (i3 - i) * 128 + (1 - j1) * 64, flag);
725725- if (wall != null && wall.aRenderable770 != null
726726- && wall.aRenderable770.verticesNormal != null)
727727- method275(class50_sub1_sub4_sub4,
728728- (Model) wall.aRenderable770, (l2 - i1)
729729- * 128 + (1 - l) * 64, j3, (i3 - i) * 128 + (1 - j1) * 64, flag);
730730- for (int k3 = 0; k3 < class50_sub3.sceneSpawnRequestCount; k3++) {
731731- SceneSpawnRequest sceneSpawnRequest = class50_sub3.sceneSpawnRequests[k3];
732732- if (sceneSpawnRequest != null && sceneSpawnRequest.aRenderable601 != null
733733- && sceneSpawnRequest.aRenderable601.verticesNormal != null) {
734734- int l3 = (sceneSpawnRequest.anInt120 - sceneSpawnRequest.x) + 1;
735735- int i4 = (sceneSpawnRequest.anInt122 - sceneSpawnRequest.y) + 1;
736736- method275(class50_sub1_sub4_sub4,
737737- (Model) sceneSpawnRequest.aRenderable601,
738738- (sceneSpawnRequest.x - i1) * 128 + (l3 - l) * 64, j3,
739739- (sceneSpawnRequest.y - i) * 128 + (i4 - j1) * 64, flag);
740740- }
741741- }
703703+ private void method273(int i, Model class50_sub1_sub4_sub4, int j, int k, int l) {
704704+ if (l != 0) {
705705+ return;
706706+ }
707707+ if (i < mapSizeX) {
708708+ SceneTile class50_sub3 = groundArray[k][i + 1][j];
709709+ if (class50_sub3 != null && class50_sub3.floorDecoration != null
710710+ && class50_sub3.floorDecoration.renderable.verticesNormal != null) {
711711+ mergeNormals(class50_sub1_sub4_sub4,
712712+ (Model) class50_sub3.floorDecoration.renderable, 128, 0, 0, true);
713713+ }
714714+ }
715715+ if (j < mapSizeX) {
716716+ SceneTile class50_sub3_1 = groundArray[k][i][j + 1];
717717+ if (class50_sub3_1 != null && class50_sub3_1.floorDecoration != null
718718+ && class50_sub3_1.floorDecoration.renderable.verticesNormal != null) {
719719+ mergeNormals(class50_sub1_sub4_sub4,
720720+ (Model) class50_sub3_1.floorDecoration.renderable, 0, 0, 128, true);
721721+ }
722722+ }
723723+ if (i < mapSizeX && j < mapSizeY) {
724724+ SceneTile class50_sub3_2 = groundArray[k][i + 1][j + 1];
725725+ if (class50_sub3_2 != null && class50_sub3_2.floorDecoration != null
726726+ && class50_sub3_2.floorDecoration.renderable.verticesNormal != null) {
727727+ mergeNormals(class50_sub1_sub4_sub4,
728728+ (Model) class50_sub3_2.floorDecoration.renderable, 128, 0, 128, true);
729729+ }
730730+ }
731731+ if (i < mapSizeX && j > 0) {
732732+ SceneTile class50_sub3_3 = groundArray[k][i + 1][j - 1];
733733+ if (class50_sub3_3 != null && class50_sub3_3.floorDecoration != null
734734+ && class50_sub3_3.floorDecoration.renderable.verticesNormal != null) {
735735+ mergeNormals(class50_sub1_sub4_sub4,
736736+ (Model) class50_sub3_3.floorDecoration.renderable, 128, 0, -128,
737737+ true);
738738+ }
739739+ }
740740+ }
741741+742742+ private void method274(int i, int j, int k, int l, Model class50_sub1_sub4_sub4, int i1, int j1) {
743743+ boolean flag = true;
744744+ int k1 = i1;
745745+ int l1 = i1 + l;
746746+ int i2 = i - 1;
747747+ int j2 = i + j1;
748748+ for (int k2 = j; k2 <= j + 1; k2++) {
749749+ if (k2 != mapSizeZ) {
750750+ for (int l2 = k1; l2 <= l1; l2++) {
751751+ if (l2 >= 0 && l2 < mapSizeX) {
752752+ for (int i3 = i2; i3 <= j2; i3++) {
753753+ if (i3 >= 0 && i3 < mapSizeY && (!flag || l2 >= l1 || i3 >= j2 || i3 < i && l2 != i1)) {
754754+ SceneTile class50_sub3 = groundArray[k2][l2][i3];
755755+ if (class50_sub3 != null) {
756756+ int j3 = (heightMap[k2][l2][i3]
757757+ + heightMap[k2][l2 + 1][i3]
758758+ + heightMap[k2][l2][i3 + 1] + heightMap[k2][l2 + 1][i3 + 1])
759759+ / 4
760760+ - (heightMap[j][i1][i]
761761+ + heightMap[j][i1 + 1][i]
762762+ + heightMap[j][i1][i + 1] + heightMap[j][i1 + 1][i + 1])
763763+ / 4;
764764+ Wall wall = class50_sub3.wall;
765765+ if (wall != null && wall.primary != null
766766+ && wall.primary.verticesNormal != null) {
767767+ mergeNormals(class50_sub1_sub4_sub4,
768768+ (Model) wall.primary, (l2 - i1)
769769+ * 128 + (1 - l) * 64, j3, (i3 - i) * 128 + (1 - j1) * 64, flag);
770770+ }
771771+ if (wall != null && wall.secondary != null
772772+ && wall.secondary.verticesNormal != null) {
773773+ mergeNormals(class50_sub1_sub4_sub4,
774774+ (Model) wall.secondary, (l2 - i1)
775775+ * 128 + (1 - l) * 64, j3, (i3 - i) * 128 + (1 - j1) * 64, flag);
776776+ }
777777+ for (int k3 = 0; k3 < class50_sub3.entityCount; k3++) {
778778+ InteractiveObject interactiveObject = class50_sub3.interactiveObjects[k3];
779779+ if (interactiveObject != null && interactiveObject.renderable != null
780780+ && interactiveObject.renderable.verticesNormal != null) {
781781+ int l3 = (interactiveObject.tileRight - interactiveObject.tileLeft) + 1;
782782+ int i4 = (interactiveObject.tileBottom - interactiveObject.tileTop) + 1;
783783+ mergeNormals(class50_sub1_sub4_sub4,
784784+ (Model) interactiveObject.renderable,
785785+ (interactiveObject.tileLeft - i1) * 128 + (l3 - l) * 64, j3,
786786+ (interactiveObject.tileTop - i) * 128 + (i4 - j1) * 64, flag);
787787+ }
788788+ }
742789743743- }
744744- }
790790+ }
791791+ }
792792+ }
745793746746- }
794794+ }
795795+ }
747796748748- k1--;
749749- flag = false;
750750- }
797797+ k1--;
798798+ flag = false;
799799+ }
800800+ }
751801752752- if (k == 0)
753753- ;
754754- }
802802+ if (k == 0) {
803803+ }
804804+ }
755805756756- public void method275(Model class50_sub1_sub4_sub4,
757757- Model class50_sub1_sub4_sub4_1, int i, int j, int k, boolean flag) {
758758- anInt503++;
759759- int l = 0;
760760- int ai[] = class50_sub1_sub4_sub4_1.verticesX;
761761- int i1 = class50_sub1_sub4_sub4_1.vertexCount;
762762- int j1 = class50_sub1_sub4_sub4_1.anInt1669 >> 16;
763763- int k1 = (class50_sub1_sub4_sub4_1.anInt1669 << 16) >> 16;
764764- int l1 = class50_sub1_sub4_sub4_1.anInt1670 >> 16;
765765- int i2 = (class50_sub1_sub4_sub4_1.anInt1670 << 16) >> 16;
766766- for (int j2 = 0; j2 < class50_sub1_sub4_sub4.vertexCount; j2++) {
767767- VertexNormal class40 = ((Renderable) (class50_sub1_sub4_sub4)).verticesNormal[j2];
768768- VertexNormal class40_1 = class50_sub1_sub4_sub4.aClass40Array1681[j2];
769769- if (class40_1.magnitude != 0) {
770770- int i3 = class50_sub1_sub4_sub4.verticesY[j2] - j;
771771- if (i3 <= class50_sub1_sub4_sub4_1.maxY) {
772772- int j3 = class50_sub1_sub4_sub4.verticesX[j2] - i;
773773- if (j3 >= j1 && j3 <= k1) {
774774- int k3 = class50_sub1_sub4_sub4.verticesZ[j2] - k;
775775- if (k3 >= i2 && k3 <= l1) {
776776- for (int l3 = 0; l3 < i1; l3++) {
777777- VertexNormal class40_2 = ((Renderable) (class50_sub1_sub4_sub4_1)).verticesNormal[l3];
778778- VertexNormal class40_3 = class50_sub1_sub4_sub4_1.aClass40Array1681[l3];
779779- if (j3 == ai[l3] && k3 == class50_sub1_sub4_sub4_1.verticesZ[l3]
780780- && i3 == class50_sub1_sub4_sub4_1.verticesY[l3] && class40_3.magnitude != 0) {
781781- class40.x += class40_3.x;
782782- class40.y += class40_3.y;
783783- class40.z += class40_3.z;
784784- class40.magnitude += class40_3.magnitude;
785785- class40_2.x += class40_1.x;
786786- class40_2.y += class40_1.y;
787787- class40_2.z += class40_1.z;
788788- class40_2.magnitude += class40_1.magnitude;
789789- l++;
790790- anIntArray501[j2] = anInt503;
791791- anIntArray502[l3] = anInt503;
792792- }
793793- }
806806+ private void mergeNormals(Model modelA,
807807+ Model modelB, int i, int j, int k, boolean flag) {
808808+ anInt503++;
809809+ int count = 0;
810810+ int[] vertices = modelB.verticesX;
811811+ int vertexCount = modelB.vertexCount;
812812+ int minX = modelB.worldX >> 16;
813813+ int maxX = (modelB.worldX << 16) >> 16;
814814+ int maxZ = modelB.worldZ >> 16;
815815+ int minZ = (modelB.worldZ << 16) >> 16;
816816+ for (int vertex = 0; vertex < modelA.vertexCount; vertex++) {
817817+ VertexNormal vertexNormal = modelA.verticesNormal[vertex];
818818+ VertexNormal offsetVertexNormal = modelA.vertexNormalOffset[vertex];
819819+ if (offsetVertexNormal.magnitude != 0) {
820820+ int y = modelA.verticesY[vertex] - j;
821821+ if (y <= modelB.maxY) {
822822+ int x = modelA.verticesX[vertex] - i;
823823+ if (x >= minX && x <= maxX) {
824824+ int z = modelA.verticesZ[vertex] - k;
825825+ if (z >= minZ && z <= maxZ) {
826826+ for (int v = 0; v < vertexCount; v++) {
827827+ VertexNormal class40_2 = modelB.verticesNormal[v];
828828+ VertexNormal class40_3 = modelB.vertexNormalOffset[v];
829829+ if (x == vertices[v] && z == modelB.verticesZ[v]
830830+ && y == modelB.verticesY[v] && class40_3.magnitude != 0) {
831831+ vertexNormal.x += class40_3.x;
832832+ vertexNormal.y += class40_3.y;
833833+ vertexNormal.z += class40_3.z;
834834+ vertexNormal.magnitude += class40_3.magnitude;
835835+ class40_2.x += offsetVertexNormal.x;
836836+ class40_2.y += offsetVertexNormal.y;
837837+ class40_2.z += offsetVertexNormal.z;
838838+ class40_2.magnitude += offsetVertexNormal.magnitude;
839839+ count++;
840840+ anIntArray501[vertex] = anInt503;
841841+ anIntArray502[v] = anInt503;
842842+ }
843843+ }
794844795795- }
796796- }
797797- }
798798- }
799799- }
845845+ }
846846+ }
847847+ }
848848+ }
849849+ }
800850801801- if (l < 3 || !flag)
802802- return;
803803- for (int k2 = 0; k2 < class50_sub1_sub4_sub4.triangleCount; k2++)
804804- if (anIntArray501[class50_sub1_sub4_sub4.trianglePointsX[k2]] == anInt503
805805- && anIntArray501[class50_sub1_sub4_sub4.trianglePointsY[k2]] == anInt503
806806- && anIntArray501[class50_sub1_sub4_sub4.trianglePointsZ[k2]] == anInt503)
807807- class50_sub1_sub4_sub4.texturePoints[k2] = -1;
851851+ if (count < 3 || !flag) {
852852+ return;
853853+ }
854854+ for (int k2 = 0; k2 < modelA.triangleCount; k2++) {
855855+ if (anIntArray501[modelA.trianglePointsX[k2]] == anInt503
856856+ && anIntArray501[modelA.trianglePointsY[k2]] == anInt503
857857+ && anIntArray501[modelA.trianglePointsZ[k2]] == anInt503) {
858858+ modelA.triangleDrawType[k2] = -1;
859859+ }
860860+ }
808861809809- for (int l2 = 0; l2 < class50_sub1_sub4_sub4_1.triangleCount; l2++)
810810- if (anIntArray502[class50_sub1_sub4_sub4_1.trianglePointsX[l2]] == anInt503
811811- && anIntArray502[class50_sub1_sub4_sub4_1.trianglePointsY[l2]] == anInt503
812812- && anIntArray502[class50_sub1_sub4_sub4_1.trianglePointsZ[l2]] == anInt503)
813813- class50_sub1_sub4_sub4_1.texturePoints[l2] = -1;
862862+ for (int l2 = 0; l2 < modelB.triangleCount; l2++) {
863863+ if (anIntArray502[modelB.trianglePointsX[l2]] == anInt503
864864+ && anIntArray502[modelB.trianglePointsY[l2]] == anInt503
865865+ && anIntArray502[modelB.trianglePointsZ[l2]] == anInt503) {
866866+ modelB.triangleDrawType[l2] = -1;
867867+ }
868868+ }
814869815815- }
870870+ }
816871817817- public void renderMinimapDot(int ai[], int i, int j, int k, int l, int i1) {
818818- SceneTile class50_sub3 = tiles[k][l][i1];
819819- if (class50_sub3 == null)
820820- return;
821821- GenericTile genericTile = class50_sub3.genericTile;
822822- if (genericTile != null) {
823823- int j1 = genericTile.rgbColor;
824824- if (j1 == 0)
825825- return;
826826- for (int k1 = 0; k1 < 4; k1++) {
827827- ai[i] = j1;
828828- ai[i + 1] = j1;
829829- ai[i + 2] = j1;
830830- ai[i + 3] = j1;
831831- i += j;
832832- }
872872+ public void renderMinimapDot(int[] ai, int i, int j, int k, int l, int i1) {
873873+ SceneTile class50_sub3 = groundArray[k][l][i1];
874874+ if (class50_sub3 == null) {
875875+ return;
876876+ }
877877+ GenericTile genericTile = class50_sub3.plainTile;
878878+ if (genericTile != null) {
879879+ int j1 = genericTile.rgbColor;
880880+ if (j1 == 0) {
881881+ return;
882882+ }
883883+ for (int k1 = 0; k1 < 4; k1++) {
884884+ ai[i] = j1;
885885+ ai[i + 1] = j1;
886886+ ai[i + 2] = j1;
887887+ ai[i + 3] = j1;
888888+ i += j;
889889+ }
833890834834- return;
835835- }
836836- ComplexTile complexTile = class50_sub3.complexTile;
837837- if (complexTile == null)
838838- return;
839839- int l1 = complexTile.anInt414;
840840- int i2 = complexTile.anInt415;
841841- int j2 = complexTile.anInt416;
842842- int k2 = complexTile.anInt417;
843843- int ai1[] = anIntArrayArray504[l1];
844844- int ai2[] = anIntArrayArray505[i2];
845845- int l2 = 0;
846846- if (j2 != 0) {
847847- for (int i3 = 0; i3 < 4; i3++) {
848848- ai[i] = ai1[ai2[l2++]] != 0 ? k2 : j2;
849849- ai[i + 1] = ai1[ai2[l2++]] != 0 ? k2 : j2;
850850- ai[i + 2] = ai1[ai2[l2++]] != 0 ? k2 : j2;
851851- ai[i + 3] = ai1[ai2[l2++]] != 0 ? k2 : j2;
852852- i += j;
853853- }
891891+ return;
892892+ }
893893+ ComplexTile complexTile = class50_sub3.shapedTile;
894894+ if (complexTile == null) {
895895+ return;
896896+ }
897897+ int l1 = complexTile.shape;
898898+ int i2 = complexTile.rotation;
899899+ int j2 = complexTile.underlayRGB;
900900+ int k2 = complexTile.overlayRGB;
901901+ int[] ai1 = tileShapePoints[l1];
902902+ int[] ai2 = tileShapeIndices[i2];
903903+ int l2 = 0;
904904+ if (j2 != 0) {
905905+ for (int i3 = 0; i3 < 4; i3++) {
906906+ ai[i] = ai1[ai2[l2++]] != 0 ? k2 : j2;
907907+ ai[i + 1] = ai1[ai2[l2++]] != 0 ? k2 : j2;
908908+ ai[i + 2] = ai1[ai2[l2++]] != 0 ? k2 : j2;
909909+ ai[i + 3] = ai1[ai2[l2++]] != 0 ? k2 : j2;
910910+ i += j;
911911+ }
854912855855- return;
856856- }
857857- for (int j3 = 0; j3 < 4; j3++) {
858858- if (ai1[ai2[l2++]] != 0)
859859- ai[i] = k2;
860860- if (ai1[ai2[l2++]] != 0)
861861- ai[i + 1] = k2;
862862- if (ai1[ai2[l2++]] != 0)
863863- ai[i + 2] = k2;
864864- if (ai1[ai2[l2++]] != 0)
865865- ai[i + 3] = k2;
866866- i += j;
867867- }
913913+ return;
914914+ }
915915+ for (int j3 = 0; j3 < 4; j3++) {
916916+ if (ai1[ai2[l2++]] != 0) {
917917+ ai[i] = k2;
918918+ }
919919+ if (ai1[ai2[l2++]] != 0) {
920920+ ai[i + 1] = k2;
921921+ }
922922+ if (ai1[ai2[l2++]] != 0) {
923923+ ai[i + 2] = k2;
924924+ }
925925+ if (ai1[ai2[l2++]] != 0) {
926926+ ai[i + 3] = k2;
927927+ }
928928+ i += j;
929929+ }
868930869869- }
931931+ }
870932871871- public static void method277(int l, int k, int i1, int i, int[] ai) {
872872- anInt510 = 0;
873873- anInt511 = 0;
874874- anInt512 = i1;
875875- anInt513 = i;
876876- anInt508 = i1 / 2;
877877- anInt509 = i / 2;
878878- boolean aflag[][][][] = new boolean[9][32][53][53];
879879- for (int j1 = 128; j1 <= 384; j1 += 32) {
880880- for (int k1 = 0; k1 < 2048; k1 += 64) {
881881- anInt473 = Model.SINE[j1];
882882- anInt474 = Model.COSINE[j1];
883883- anInt475 = Model.SINE[k1];
884884- anInt476 = Model.COSINE[k1];
885885- int i2 = (j1 - 128) / 32;
886886- int k2 = k1 / 64;
887887- for (int i3 = -26; i3 <= 26; i3++) {
888888- for (int k3 = -26; k3 <= 26; k3++) {
889889- int l3 = i3 * 128;
890890- int j4 = k3 * 128;
891891- boolean flag1 = false;
892892- for (int l4 = -l; l4 <= k; l4 += 128) {
893893- if (!method278(j4, l3, anInt444, ai[i2] + l4))
894894- continue;
895895- flag1 = true;
896896- break;
897897- }
933933+ public static void method277(int l, int k, int i1, int i, int[] ai) {
934934+ anInt510 = 0;
935935+ anInt511 = 0;
936936+ anInt512 = i1;
937937+ anInt513 = i;
938938+ anInt508 = i1 / 2;
939939+ anInt509 = i / 2;
940940+ boolean[][][][] aflag = new boolean[9][32][53][53];
941941+ for (int j1 = 128; j1 <= 384; j1 += 32) {
942942+ for (int k1 = 0; k1 < 2048; k1 += 64) {
943943+ curveSineY = Model.SINE[j1];
944944+ curveCosineY = Model.COSINE[j1];
945945+ curveSineX = Model.SINE[k1];
946946+ curveCosineX = Model.COSINE[k1];
947947+ int i2 = (j1 - 128) / 32;
948948+ int k2 = k1 / 64;
949949+ for (int i3 = -26; i3 <= 26; i3++) {
950950+ for (int k3 = -26; k3 <= 26; k3++) {
951951+ int l3 = i3 * 128;
952952+ int j4 = k3 * 128;
953953+ boolean flag1 = false;
954954+ for (int l4 = -l; l4 <= k; l4 += 128) {
955955+ if (!method278(j4, l3, ai[i2] + l4)) {
956956+ continue;
957957+ }
958958+ flag1 = true;
959959+ break;
960960+ }
898961899899- aflag[i2][k2][i3 + 25 + 1][k3 + 25 + 1] = flag1;
900900- }
962962+ aflag[i2][k2][i3 + 25 + 1][k3 + 25 + 1] = flag1;
963963+ }
901964902902- }
965965+ }
903966904904- }
967967+ }
905968906906- }
969969+ }
907970908908- for (int l1 = 0; l1 < 8; l1++) {
909909- for (int j2 = 0; j2 < 32; j2++) {
910910- for (int l2 = -25; l2 < 25; l2++) {
911911- for (int j3 = -25; j3 < 25; j3++) {
912912- boolean flag = false;
913913- label0: for (int i4 = -1; i4 <= 1; i4++) {
914914- for (int k4 = -1; k4 <= 1; k4++) {
915915- if (aflag[l1][j2][l2 + i4 + 25 + 1][j3 + k4 + 25 + 1])
916916- flag = true;
917917- else if (aflag[l1][(j2 + 1) % 31][l2 + i4 + 25 + 1][j3 + k4 + 25 + 1])
918918- flag = true;
919919- else if (aflag[l1 + 1][j2][l2 + i4 + 25 + 1][j3 + k4 + 25 + 1]) {
920920- flag = true;
921921- } else {
922922- if (!aflag[l1 + 1][(j2 + 1) % 31][l2 + i4 + 25 + 1][j3 + k4 + 25 + 1])
923923- continue;
924924- flag = true;
925925- }
926926- break label0;
927927- }
971971+ for (int l1 = 0; l1 < 8; l1++) {
972972+ for (int j2 = 0; j2 < 32; j2++) {
973973+ for (int l2 = -25; l2 < 25; l2++) {
974974+ for (int j3 = -25; j3 < 25; j3++) {
975975+ boolean flag = false;
976976+ label0:
977977+ for (int i4 = -1; i4 <= 1; i4++) {
978978+ for (int k4 = -1; k4 <= 1; k4++) {
979979+ if (aflag[l1][j2][l2 + i4 + 25 + 1][j3 + k4 + 25 + 1]) {
980980+ flag = true;
981981+ } else if (aflag[l1][(j2 + 1) % 31][l2 + i4 + 25 + 1][j3 + k4 + 25 + 1]) {
982982+ flag = true;
983983+ } else if (aflag[l1 + 1][j2][l2 + i4 + 25 + 1][j3 + k4 + 25 + 1]) {
984984+ flag = true;
985985+ } else {
986986+ if (!aflag[l1 + 1][(j2 + 1) % 31][l2 + i4 + 25 + 1][j3 + k4 + 25 + 1]) {
987987+ continue;
988988+ }
989989+ flag = true;
990990+ }
991991+ break label0;
992992+ }
928993929929- }
994994+ }
930995931931- aBooleanArrayArrayArrayArray506[l1][j2][l2 + 25][j3 + 25] = flag;
932932- }
996996+ TILE_VISIBILITY_MAPS[l1][j2][l2 + 25][j3 + 25] = flag;
997997+ }
933998934934- }
999999+ }
9351000936936- }
10011001+ }
9371002938938- }
939939- }
10031003+ }
10041004+ }
9401005941941- public static boolean method278(int i, int j, int k, int l) {
942942- int i1 = i * anInt475 + j * anInt476 >> 16;
943943- int j1 = i * anInt476 - j * anInt475 >> 16;
944944- int k1 = l * anInt473 + j1 * anInt474 >> 16;
945945- int l1 = l * anInt474 - j1 * anInt473 >> 16;
946946- if (k1 < 50 || k1 > 3500)
947947- return false;
948948- int i2 = anInt508 + (i1 << 9) / k1;
949949- int j2 = anInt509 + (l1 << 9) / k1;
950950- return i2 >= anInt510 && i2 <= anInt512 && j2 >= anInt511 && j2 <= anInt513;
951951- }
10061006+ private static boolean method278(int i, int j, int l) {
10071007+ int i1 = i * curveSineX + j * curveCosineX >> 16;
10081008+ int j1 = i * curveCosineX - j * curveSineX >> 16;
10091009+ int k1 = l * curveSineY + j1 * curveCosineY >> 16;
10101010+ int l1 = l * curveCosineY - j1 * curveSineY >> 16;
10111011+ if (k1 < 50 || k1 > 3500) {
10121012+ return false;
10131013+ }
10141014+ int i2 = anInt508 + (i1 << 9) / k1;
10151015+ int j2 = anInt509 + (l1 << 9) / k1;
10161016+ return i2 >= anInt510 && i2 <= anInt512 && j2 >= anInt511 && j2 <= anInt513;
10171017+ }
9521018953953- public void method279(int i, int j, int k) {
954954- aBoolean482 = true;
955955- anInt483 = j;
956956- anInt484 = k;
957957- clickedTileX = -1;
958958- if (i != 0) {
959959- return;
960960- } else {
961961- anInt486 = -1;
962962- return;
963963- }
964964- }
10191019+ public void method279(int i, int j, int k) {
10201020+ clicked = true;
10211021+ clickX = j;
10221022+ clickY = k;
10231023+ clickedTileX = -1;
10241024+ if (i != 0) {
10251025+ } else {
10261026+ clickedTileY = -1;
10271027+ }
10281028+ }
9651029966966- public void method280(int i, int j, int k, int l, int i1, int j1, int k1) {
967967- if (i < 0)
968968- i = 0;
969969- else if (i >= anInt453 * 128)
970970- i = anInt453 * 128 - 1;
971971- if (i1 < 0)
972972- i1 = 0;
973973- else if (i1 >= anInt454 * 128)
974974- i1 = anInt454 * 128 - 1;
975975- anInt463++;
976976- anInt473 = Model.SINE[k1];
977977- anInt474 = Model.COSINE[k1];
978978- anInt475 = Model.SINE[j1];
979979- anInt476 = Model.COSINE[j1];
980980- aBooleanArrayArray507 = aBooleanArrayArrayArrayArray506[(k1 - 128) / 32][j1 / 64];
981981- anInt470 = i;
982982- anInt471 = l;
983983- anInt472 = i1;
984984- anInt468 = i / 128;
985985- anInt469 = i1 / 128;
986986- anInt462 = j;
987987- anInt464 = anInt468 - 25;
988988- if (k != 0)
989989- return;
990990- if (anInt464 < 0)
991991- anInt464 = 0;
992992- anInt466 = anInt469 - 25;
993993- if (anInt466 < 0)
994994- anInt466 = 0;
995995- anInt465 = anInt468 + 25;
996996- if (anInt465 > anInt453)
997997- anInt465 = anInt453;
998998- anInt467 = anInt469 + 25;
999999- if (anInt467 > anInt454)
10001000- anInt467 = anInt454;
10011001- method286();
10021002- anInt461 = 0;
10031003- for (int l1 = anInt457; l1 < anInt452; l1++) {
10041004- SceneTile aclass50_sub3[][] = tiles[l1];
10051005- for (int j2 = anInt464; j2 < anInt465; j2++) {
10061006- for (int l2 = anInt466; l2 < anInt467; l2++) {
10071007- SceneTile class50_sub3 = aclass50_sub3[j2][l2];
10081008- if (class50_sub3 != null)
10091009- if (class50_sub3.anInt1411 > j
10101010- || !aBooleanArrayArray507[(j2 - anInt468) + 25][(l2 - anInt469) + 25]
10111011- && anIntArrayArrayArray455[l1][j2][l2] - l < 2000) {
10121012- class50_sub3.aBoolean1412 = false;
10131013- class50_sub3.aBoolean1413 = false;
10141014- class50_sub3.anInt1415 = 0;
10151015- } else {
10161016- class50_sub3.aBoolean1412 = true;
10171017- class50_sub3.aBoolean1413 = true;
10181018- if (class50_sub3.sceneSpawnRequestCount > 0)
10191019- class50_sub3.aBoolean1414 = true;
10201020- else
10211021- class50_sub3.aBoolean1414 = false;
10221022- anInt461++;
10231023- }
10241024- }
10301030+ public void render(int cameraPosX, int j, int k, int l, int cameraPosY, int curveX, int curveY) {
10311031+ if (cameraPosX < 0) {
10321032+ cameraPosX = 0;
10331033+ } else if (cameraPosX >= mapSizeX * 128) {
10341034+ cameraPosX = mapSizeX * 128 - 1;
10351035+ }
10361036+ if (cameraPosY < 0) {
10371037+ cameraPosY = 0;
10381038+ } else if (cameraPosY >= mapSizeY * 128) {
10391039+ cameraPosY = mapSizeY * 128 - 1;
10401040+ }
10411041+ cycle++;
10421042+ curveSineY = Model.SINE[curveY];
10431043+ curveCosineY = Model.COSINE[curveY];
10441044+ curveSineX = Model.SINE[curveX];
10451045+ curveCosineX = Model.COSINE[curveX];
10461046+ TILE_VISIBILITY_MAP = TILE_VISIBILITY_MAPS[(curveY - 128) / 32][curveX / 64];
10471047+ Scene.cameraPosX = cameraPosX;
10481048+ cameraPosZ = l;
10491049+ Scene.cameraPosY = cameraPosY;
10501050+ cameraPositionTileX = cameraPosX / 128;
10511051+ cameraPositionTileY = cameraPosY / 128;
10521052+ plane = j;
10531053+ currentPositionX = cameraPositionTileX - 25;
10541054+ if (k != 0) {
10551055+ return;
10561056+ }
10571057+ if (currentPositionX < 0) {
10581058+ currentPositionX = 0;
10591059+ }
10601060+ currentPositionY = cameraPositionTileY - 25;
10611061+ if (currentPositionY < 0) {
10621062+ currentPositionY = 0;
10631063+ }
10641064+ mapBoundsX = cameraPositionTileX + 25;
10651065+ if (mapBoundsX > mapSizeX) {
10661066+ mapBoundsX = mapSizeX;
10671067+ }
10681068+ mapBoundsY = cameraPositionTileY + 25;
10691069+ if (mapBoundsY > mapSizeY) {
10701070+ mapBoundsY = mapSizeY;
10711071+ }
10721072+ processCulling();
10731073+ anInt461 = 0;
10741074+ for (int z = currentPositionZ; z < mapSizeZ; z++) {
10751075+ SceneTile[][] tiles = groundArray[z];
10761076+ for (int x = currentPositionX; x < mapBoundsX; x++) {
10771077+ for (int y = currentPositionY; y < mapBoundsY; y++) {
10781078+ SceneTile tile = tiles[x][y];
10791079+ if (tile != null) {
10801080+ if (tile.logicHeight > j
10811081+ || !TILE_VISIBILITY_MAP[(x - cameraPositionTileX) + 25][(y - cameraPositionTileY) + 25]
10821082+ && heightMap[z][x][y] - l < 2000) {
10831083+ tile.draw = false;
10841084+ tile.visible = false;
10851085+ tile.wallCullDirection = 0;
10861086+ } else {
10871087+ tile.draw = true;
10881088+ tile.visible = true;
10891089+ tile.drawEntities = tile.entityCount > 0;
10901090+ anInt461++;
10911091+ }
10921092+ }
10931093+ }
1025109410261026- }
10951095+ }
1027109610281028- }
10971097+ }
1029109810301030- for (int i2 = anInt457; i2 < anInt452; i2++) {
10311031- SceneTile aclass50_sub3_1[][] = tiles[i2];
10321032- for (int i3 = -25; i3 <= 0; i3++) {
10331033- int j3 = anInt468 + i3;
10341034- int l3 = anInt468 - i3;
10351035- if (j3 >= anInt464 || l3 < anInt465) {
10361036- for (int j4 = -25; j4 <= 0; j4++) {
10371037- int l4 = anInt469 + j4;
10381038- int j5 = anInt469 - j4;
10391039- if (j3 >= anInt464) {
10401040- if (l4 >= anInt466) {
10411041- SceneTile class50_sub3_1 = aclass50_sub3_1[j3][l4];
10421042- if (class50_sub3_1 != null && class50_sub3_1.aBoolean1412)
10431043- method281(class50_sub3_1, true);
10441044- }
10451045- if (j5 < anInt467) {
10461046- SceneTile class50_sub3_2 = aclass50_sub3_1[j3][j5];
10471047- if (class50_sub3_2 != null && class50_sub3_2.aBoolean1412)
10481048- method281(class50_sub3_2, true);
10491049- }
10501050- }
10511051- if (l3 < anInt465) {
10521052- if (l4 >= anInt466) {
10531053- SceneTile class50_sub3_3 = aclass50_sub3_1[l3][l4];
10541054- if (class50_sub3_3 != null && class50_sub3_3.aBoolean1412)
10551055- method281(class50_sub3_3, true);
10561056- }
10571057- if (j5 < anInt467) {
10581058- SceneTile class50_sub3_4 = aclass50_sub3_1[l3][j5];
10591059- if (class50_sub3_4 != null && class50_sub3_4.aBoolean1412)
10601060- method281(class50_sub3_4, true);
10611061- }
10621062- }
10631063- if (anInt461 == 0) {
10641064- aBoolean482 = false;
10651065- return;
10661066- }
10671067- }
10991099+ for (int z = currentPositionZ; z < mapSizeZ; z++) {
11001100+ SceneTile[][] tiles = groundArray[z];
11011101+ for (int offsetX = -25; offsetX <= 0; offsetX++) {
11021102+ int x = cameraPositionTileX + offsetX;
11031103+ int x2 = cameraPositionTileX - offsetX;
11041104+ if (x >= currentPositionX || x2 < mapBoundsX) {
11051105+ for (int offsetY = -25; offsetY <= 0; offsetY++) {
11061106+ int y = cameraPositionTileY + offsetY;
11071107+ int y2 = cameraPositionTileY - offsetY;
11081108+ if (x >= currentPositionX) {
11091109+ if (y >= currentPositionY) {
11101110+ SceneTile tile = tiles[x][y];
11111111+ if (tile != null && tile.draw) {
11121112+ renderTile(tile, true);
11131113+ }
11141114+ }
11151115+ if (y2 < mapBoundsY) {
11161116+ SceneTile tile = tiles[x][y2];
11171117+ if (tile != null && tile.draw) {
11181118+ renderTile(tile, true);
11191119+ }
11201120+ }
11211121+ }
11221122+ if (x2 < mapBoundsX) {
11231123+ if (y >= currentPositionY) {
11241124+ SceneTile class50_sub3_3 = tiles[x2][y];
11251125+ if (class50_sub3_3 != null && class50_sub3_3.draw) {
11261126+ renderTile(class50_sub3_3, true);
11271127+ }
11281128+ }
11291129+ if (y2 < mapBoundsY) {
11301130+ SceneTile class50_sub3_4 = tiles[x2][y2];
11311131+ if (class50_sub3_4 != null && class50_sub3_4.draw) {
11321132+ renderTile(class50_sub3_4, true);
11331133+ }
11341134+ }
11351135+ }
11361136+ if (anInt461 == 0) {
11371137+ clicked = false;
11381138+ return;
11391139+ }
11401140+ }
1068114110691069- }
10701070- }
11421142+ }
11431143+ }
1071114410721072- }
11451145+ }
1073114610741074- for (int k2 = anInt457; k2 < anInt452; k2++) {
10751075- SceneTile aclass50_sub3_2[][] = tiles[k2];
10761076- for (int k3 = -25; k3 <= 0; k3++) {
10771077- int i4 = anInt468 + k3;
10781078- int k4 = anInt468 - k3;
10791079- if (i4 >= anInt464 || k4 < anInt465) {
10801080- for (int i5 = -25; i5 <= 0; i5++) {
10811081- int k5 = anInt469 + i5;
10821082- int l5 = anInt469 - i5;
10831083- if (i4 >= anInt464) {
10841084- if (k5 >= anInt466) {
10851085- SceneTile class50_sub3_5 = aclass50_sub3_2[i4][k5];
10861086- if (class50_sub3_5 != null && class50_sub3_5.aBoolean1412)
10871087- method281(class50_sub3_5, false);
10881088- }
10891089- if (l5 < anInt467) {
10901090- SceneTile class50_sub3_6 = aclass50_sub3_2[i4][l5];
10911091- if (class50_sub3_6 != null && class50_sub3_6.aBoolean1412)
10921092- method281(class50_sub3_6, false);
10931093- }
10941094- }
10951095- if (k4 < anInt465) {
10961096- if (k5 >= anInt466) {
10971097- SceneTile class50_sub3_7 = aclass50_sub3_2[k4][k5];
10981098- if (class50_sub3_7 != null && class50_sub3_7.aBoolean1412)
10991099- method281(class50_sub3_7, false);
11001100- }
11011101- if (l5 < anInt467) {
11021102- SceneTile class50_sub3_8 = aclass50_sub3_2[k4][l5];
11031103- if (class50_sub3_8 != null && class50_sub3_8.aBoolean1412)
11041104- method281(class50_sub3_8, false);
11051105- }
11061106- }
11071107- if (anInt461 == 0) {
11081108- aBoolean482 = false;
11091109- return;
11101110- }
11111111- }
11471147+ for (int z = currentPositionZ; z < mapSizeZ; z++) {
11481148+ SceneTile[][] tiles = groundArray[z];
11491149+ for (int offsetX = -25; offsetX <= 0; offsetX++) {
11501150+ int x = cameraPositionTileX + offsetX;
11511151+ int x2 = cameraPositionTileX - offsetX;
11521152+ if (x >= currentPositionX || x2 < mapBoundsX) {
11531153+ for (int offsetY = -25; offsetY <= 0; offsetY++) {
11541154+ int y = cameraPositionTileY + offsetY;
11551155+ int y2 = cameraPositionTileY - offsetY;
11561156+ if (x >= currentPositionX) {
11571157+ if (y >= currentPositionY) {
11581158+ SceneTile tile = tiles[x][y];
11591159+ if (tile != null && tile.draw) {
11601160+ renderTile(tile, false);
11611161+ }
11621162+ }
11631163+ if (y2 < mapBoundsY) {
11641164+ SceneTile tile = tiles[x][y2];
11651165+ if (tile != null && tile.draw) {
11661166+ renderTile(tile, false);
11671167+ }
11681168+ }
11691169+ }
11701170+ if (x2 < mapBoundsX) {
11711171+ if (y >= currentPositionY) {
11721172+ SceneTile tile = tiles[x2][y];
11731173+ if (tile != null && tile.draw) {
11741174+ renderTile(tile, false);
11751175+ }
11761176+ }
11771177+ if (y2 < mapBoundsY) {
11781178+ SceneTile tile = tiles[x2][y2];
11791179+ if (tile != null && tile.draw) {
11801180+ renderTile(tile, false);
11811181+ }
11821182+ }
11831183+ }
11841184+ if (anInt461 == 0) {
11851185+ clicked = false;
11861186+ return;
11871187+ }
11881188+ }
1112118911131113- }
11141114- }
11901190+ }
11911191+ }
1115119211161116- }
11931193+ }
1117119411181118- aBoolean482 = false;
11191119- }
11951195+ clicked = false;
11961196+ }
1120119711211121- public void method281(SceneTile class50_sub3, boolean flag) {
11221122- aClass6_492.insertBack(class50_sub3);
11231123- do {
11241124- SceneTile class50_sub3_1;
11251125- do {
11261126- class50_sub3_1 = (SceneTile) aClass6_492.removeFirst();
11271127- if (class50_sub3_1 == null)
11281128- return;
11291129- } while (!class50_sub3_1.aBoolean1413);
11301130- int i = class50_sub3_1.anInt1398;
11311131- int j = class50_sub3_1.anInt1399;
11321132- int k = class50_sub3_1.anInt1397;
11331133- int l = class50_sub3_1.anInt1400;
11341134- SceneTile aclass50_sub3[][] = tiles[k];
11351135- if (class50_sub3_1.aBoolean1412) {
11361136- if (flag) {
11371137- if (k > 0) {
11381138- SceneTile class50_sub3_2 = tiles[k - 1][i][j];
11391139- if (class50_sub3_2 != null && class50_sub3_2.aBoolean1413)
11401140- continue;
11411141- }
11421142- if (i <= anInt468 && i > anInt464) {
11431143- SceneTile class50_sub3_3 = aclass50_sub3[i - 1][j];
11441144- if (class50_sub3_3 != null && class50_sub3_3.aBoolean1413
11451145- && (class50_sub3_3.aBoolean1412 || (class50_sub3_1.anInt1410 & 1) == 0))
11461146- continue;
11471147- }
11481148- if (i >= anInt468 && i < anInt465 - 1) {
11491149- SceneTile class50_sub3_4 = aclass50_sub3[i + 1][j];
11501150- if (class50_sub3_4 != null && class50_sub3_4.aBoolean1413
11511151- && (class50_sub3_4.aBoolean1412 || (class50_sub3_1.anInt1410 & 4) == 0))
11521152- continue;
11531153- }
11541154- if (j <= anInt469 && j > anInt466) {
11551155- SceneTile class50_sub3_5 = aclass50_sub3[i][j - 1];
11561156- if (class50_sub3_5 != null && class50_sub3_5.aBoolean1413
11571157- && (class50_sub3_5.aBoolean1412 || (class50_sub3_1.anInt1410 & 8) == 0))
11581158- continue;
11591159- }
11601160- if (j >= anInt469 && j < anInt467 - 1) {
11611161- SceneTile class50_sub3_6 = aclass50_sub3[i][j + 1];
11621162- if (class50_sub3_6 != null && class50_sub3_6.aBoolean1413
11631163- && (class50_sub3_6.aBoolean1412 || (class50_sub3_1.anInt1410 & 2) == 0))
11641164- continue;
11651165- }
11661166- } else {
11671167- flag = true;
11681168- }
11691169- class50_sub3_1.aBoolean1412 = false;
11701170- if (class50_sub3_1.aClass50_Sub3_1419 != null) {
11711171- SceneTile class50_sub3_7 = class50_sub3_1.aClass50_Sub3_1419;
11721172- if (class50_sub3_7.genericTile != null) {
11731173- if (!method287(0, i, j))
11741174- method282(class50_sub3_7.genericTile, 0, anInt473, anInt474, anInt475, anInt476, i, j);
11751175- } else if (class50_sub3_7.complexTile != null && !method287(0, i, j))
11761176- method283(anInt474, anInt476, class50_sub3_7.complexTile, anInt473, j, i, anInt475, (byte) 3);
11771177- Wall wall = class50_sub3_7.wall;
11781178- if (wall != null)
11791179- wall.aRenderable769.renderAtPoint(0, anInt473, anInt474, anInt475, anInt476,
11801180- wall.x - anInt470, wall.plane - anInt471, wall.y - anInt472,
11811181- wall.hash);
11821182- for (int i2 = 0; i2 < class50_sub3_7.sceneSpawnRequestCount; i2++) {
11831183- SceneSpawnRequest sceneSpawnRequest = class50_sub3_7.sceneSpawnRequests[i2];
11841184- if (sceneSpawnRequest != null)
11851185- sceneSpawnRequest.aRenderable601.renderAtPoint(sceneSpawnRequest.anInt118, anInt473, anInt474, anInt475,
11861186- anInt476, sceneSpawnRequest.anInt115 - anInt470, sceneSpawnRequest.anInt114 - anInt471, sceneSpawnRequest.anInt116
11871187- - anInt472, sceneSpawnRequest.anInt125);
11881188- }
11981198+ private void renderTile(SceneTile _tile, boolean flag) {
11991199+ tileList.pushBack(_tile);
12001200+ do {
12011201+ SceneTile groundTile;
12021202+ do {
12031203+ groundTile = (SceneTile) tileList.pop();
12041204+ if (groundTile == null) {
12051205+ return;
12061206+ }
12071207+ } while (!groundTile.visible);
12081208+ int x = groundTile.x;
12091209+ int y = groundTile.y;
12101210+ int z = groundTile.z;
12111211+ int level = groundTile.renderLevel;
12121212+ SceneTile[][] tiles = groundArray[z];
12131213+ if (groundTile.draw) {
12141214+ if (flag) {
12151215+ if (z > 0) {
12161216+ SceneTile tile = groundArray[z - 1][x][y];
12171217+ if (tile != null && tile.visible) {
12181218+ continue;
12191219+ }
12201220+ }
12211221+ if (x <= cameraPositionTileX && x > currentPositionX) {
12221222+ SceneTile tile = tiles[x - 1][y];
12231223+ if (tile != null && tile.visible
12241224+ && (tile.draw || (groundTile.interactiveObjectsSizeOR & 1) == 0)) {
12251225+ continue;
12261226+ }
12271227+ }
12281228+ if (x >= cameraPositionTileX && x < mapBoundsX - 1) {
12291229+ SceneTile tile = tiles[x + 1][y];
12301230+ if (tile != null && tile.visible
12311231+ && (tile.draw || (groundTile.interactiveObjectsSizeOR & 4) == 0)) {
12321232+ continue;
12331233+ }
12341234+ }
12351235+ if (y <= cameraPositionTileY && y > currentPositionY) {
12361236+ SceneTile tile = tiles[x][y - 1];
12371237+ if (tile != null && tile.visible
12381238+ && (tile.draw || (groundTile.interactiveObjectsSizeOR & 8) == 0)) {
12391239+ continue;
12401240+ }
12411241+ }
12421242+ if (y >= cameraPositionTileY && y < mapBoundsY - 1) {
12431243+ SceneTile tile = tiles[x][y + 1];
12441244+ if (tile != null && tile.visible
12451245+ && (tile.draw || (groundTile.interactiveObjectsSizeOR & 2) == 0)) {
12461246+ continue;
12471247+ }
12481248+ }
12491249+ } else {
12501250+ flag = true;
12511251+ }
12521252+ groundTile.draw = false;
12531253+ if (groundTile.tileBelow != null) {
12541254+ SceneTile tile = groundTile.tileBelow;
12551255+ if (tile.plainTile != null) {
12561256+ if (!isTileOccluded(x, y, 0)) {
12571257+ renderPlainTile(tile.plainTile, x, y, 0, curveSineX, curveCosineX, curveSineY, curveCosineY);
12581258+ }
12591259+ } else if (tile.shapedTile != null && !isTileOccluded(x, y, 0)) {
12601260+ renderShapedTile(tile.shapedTile, x, y, curveSineX, curveCosineX, curveSineY, curveCosineY);
12611261+ }
12621262+ Wall wall = tile.wall;
12631263+ if (wall != null) {
12641264+ wall.primary.renderAtPoint(0, curveSineY, curveCosineY, curveSineX, curveCosineX,
12651265+ wall.x - cameraPosX, wall.z - cameraPosZ, wall.y - cameraPosY,
12661266+ wall.uid);
12671267+ }
12681268+ for (int i2 = 0; i2 < tile.entityCount; i2++) {
12691269+ InteractiveObject interactiveObject = tile.interactiveObjects[i2];
12701270+ if (interactiveObject != null) {
12711271+ interactiveObject.renderable.renderAtPoint(interactiveObject.rotation, curveSineY, curveCosineY, curveSineX,
12721272+ curveCosineX, interactiveObject.worldX - cameraPosX, interactiveObject.worldZ - cameraPosZ, interactiveObject.worldY
12731273+ - cameraPosY, interactiveObject.uid);
12741274+ }
12751275+ }
1189127611901190- }
11911191- boolean flag1 = false;
11921192- if (class50_sub3_1.genericTile != null) {
11931193- if (!method287(l, i, j)) {
11941194- flag1 = true;
11951195- method282(class50_sub3_1.genericTile, l, anInt473, anInt474, anInt475, anInt476, i, j);
11961196- }
11971197- } else if (class50_sub3_1.complexTile != null && !method287(l, i, j)) {
11981198- flag1 = true;
11991199- method283(anInt474, anInt476, class50_sub3_1.complexTile, anInt473, j, i, anInt475, (byte) 3);
12001200- }
12011201- int j1 = 0;
12021202- int j2 = 0;
12031203- Wall wall_3 = class50_sub3_1.wall;
12041204- WallDecoration wallDecoration_1 = class50_sub3_1.wallDecoration;
12051205- if (wall_3 != null || wallDecoration_1 != null) {
12061206- if (anInt468 == i)
12071207- j1++;
12081208- else if (anInt468 < i)
12091209- j1 += 2;
12101210- if (anInt469 == j)
12111211- j1 += 3;
12121212- else if (anInt469 > j)
12131213- j1 += 6;
12141214- j2 = anIntArray493[j1];
12151215- class50_sub3_1.anInt1418 = anIntArray495[j1];
12161216- }
12171217- if (wall_3 != null) {
12181218- if ((wall_3.faceUnknown & anIntArray494[j1]) != 0) {
12191219- if (wall_3.faceUnknown == 16) {
12201220- class50_sub3_1.anInt1415 = 3;
12211221- class50_sub3_1.anInt1416 = anIntArray496[j1];
12221222- class50_sub3_1.anInt1417 = 3 - class50_sub3_1.anInt1416;
12231223- } else if (wall_3.faceUnknown == 32) {
12241224- class50_sub3_1.anInt1415 = 6;
12251225- class50_sub3_1.anInt1416 = anIntArray497[j1];
12261226- class50_sub3_1.anInt1417 = 6 - class50_sub3_1.anInt1416;
12271227- } else if (wall_3.faceUnknown == 64) {
12281228- class50_sub3_1.anInt1415 = 12;
12291229- class50_sub3_1.anInt1416 = anIntArray498[j1];
12301230- class50_sub3_1.anInt1417 = 12 - class50_sub3_1.anInt1416;
12311231- } else {
12321232- class50_sub3_1.anInt1415 = 9;
12331233- class50_sub3_1.anInt1416 = anIntArray499[j1];
12341234- class50_sub3_1.anInt1417 = 9 - class50_sub3_1.anInt1416;
12351235- }
12361236- } else {
12371237- class50_sub3_1.anInt1415 = 0;
12381238- }
12391239- if ((wall_3.faceUnknown & j2) != 0 && !method288(l, i, j, wall_3.faceUnknown))
12401240- wall_3.aRenderable769.renderAtPoint(0, anInt473, anInt474, anInt475, anInt476,
12411241- wall_3.x - anInt470, wall_3.plane - anInt471, wall_3.y
12421242- - anInt472, wall_3.hash);
12431243- if ((wall_3.face & j2) != 0 && !method288(l, i, j, wall_3.face))
12441244- wall_3.aRenderable770.renderAtPoint(0, anInt473, anInt474, anInt475, anInt476,
12451245- wall_3.x - anInt470, wall_3.plane - anInt471, wall_3.y
12461246- - anInt472, wall_3.hash);
12471247- }
12481248- if (wallDecoration_1 != null && !method289(l, i, j, wallDecoration_1.renderable.modelHeight))
12491249- if ((wallDecoration_1.faceUnknown & j2) != 0)
12501250- wallDecoration_1.renderable.renderAtPoint(wallDecoration_1.face, anInt473, anInt474, anInt475,
12511251- anInt476, wallDecoration_1.y - anInt470, wallDecoration_1.plane - anInt471,
12521252- wallDecoration_1.x - anInt472, wallDecoration_1.hash);
12531253- else if ((wallDecoration_1.faceUnknown & 0x300) != 0) {
12541254- int j4 = wallDecoration_1.y - anInt470;
12551255- int l5 = wallDecoration_1.plane - anInt471;
12561256- int k6 = wallDecoration_1.x - anInt472;
12571257- int i8 = wallDecoration_1.face;
12581258- int k9;
12591259- if (i8 == 1 || i8 == 2)
12601260- k9 = -j4;
12611261- else
12621262- k9 = j4;
12631263- int k10;
12641264- if (i8 == 2 || i8 == 3)
12651265- k10 = -k6;
12661266- else
12671267- k10 = k6;
12681268- if ((wallDecoration_1.faceUnknown & 0x100) != 0 && k10 < k9) {
12691269- int i11 = j4 + anIntArray478[i8];
12701270- int k11 = k6 + anIntArray479[i8];
12711271- wallDecoration_1.renderable.renderAtPoint(i8 * 512 + 256, anInt473, anInt474, anInt475,
12721272- anInt476, i11, l5, k11, wallDecoration_1.hash);
12731273- }
12741274- if ((wallDecoration_1.faceUnknown & 0x200) != 0 && k10 > k9) {
12751275- int j11 = j4 + anIntArray480[i8];
12761276- int l11 = k6 + anIntArray481[i8];
12771277- wallDecoration_1.renderable.renderAtPoint(i8 * 512 + 1280 & 0x7ff, anInt473, anInt474,
12781278- anInt475, anInt476, j11, l5, l11, wallDecoration_1.hash);
12791279- }
12801280- }
12811281- if (flag1) {
12821282- FloorDecoration floorDecoration = class50_sub3_1.floorDecoration;
12831283- if (floorDecoration != null)
12841284- floorDecoration.renderable.renderAtPoint(0, anInt473, anInt474, anInt475, anInt476,
12851285- floorDecoration.y - anInt470, floorDecoration.x - anInt471, floorDecoration.z - anInt472,
12861286- floorDecoration.hash);
12871287- CameraAngle cameraAngle_1 = class50_sub3_1.cameraAngle;
12881288- if (cameraAngle_1 != null && cameraAngle_1.anInt180 == 0) {
12891289- if (cameraAngle_1.aRenderable151 != null)
12901290- cameraAngle_1.aRenderable151.renderAtPoint(0, anInt473, anInt474, anInt475, anInt476,
12911291- cameraAngle_1.y - anInt470, cameraAngle_1.x - anInt471, cameraAngle_1.z
12921292- - anInt472, cameraAngle_1.anInt179);
12931293- if (cameraAngle_1.aRenderable152 != null)
12941294- cameraAngle_1.aRenderable152.renderAtPoint(0, anInt473, anInt474, anInt475, anInt476,
12951295- cameraAngle_1.y - anInt470, cameraAngle_1.x - anInt471, cameraAngle_1.z
12961296- - anInt472, cameraAngle_1.anInt179);
12971297- if (cameraAngle_1.aRenderable150 != null)
12981298- cameraAngle_1.aRenderable150.renderAtPoint(0, anInt473, anInt474, anInt475, anInt476,
12991299- cameraAngle_1.y - anInt470, cameraAngle_1.x - anInt471, cameraAngle_1.z
13001300- - anInt472, cameraAngle_1.anInt179);
13011301- }
13021302- }
13031303- int k4 = class50_sub3_1.anInt1410;
13041304- if (k4 != 0) {
13051305- if (i < anInt468 && (k4 & 4) != 0) {
13061306- SceneTile class50_sub3_17 = aclass50_sub3[i + 1][j];
13071307- if (class50_sub3_17 != null && class50_sub3_17.aBoolean1413)
13081308- aClass6_492.insertBack(class50_sub3_17);
13091309- }
13101310- if (j < anInt469 && (k4 & 2) != 0) {
13111311- SceneTile class50_sub3_18 = aclass50_sub3[i][j + 1];
13121312- if (class50_sub3_18 != null && class50_sub3_18.aBoolean1413)
13131313- aClass6_492.insertBack(class50_sub3_18);
13141314- }
13151315- if (i > anInt468 && (k4 & 1) != 0) {
13161316- SceneTile class50_sub3_19 = aclass50_sub3[i - 1][j];
13171317- if (class50_sub3_19 != null && class50_sub3_19.aBoolean1413)
13181318- aClass6_492.insertBack(class50_sub3_19);
13191319- }
13201320- if (j > anInt469 && (k4 & 8) != 0) {
13211321- SceneTile class50_sub3_20 = aclass50_sub3[i][j - 1];
13221322- if (class50_sub3_20 != null && class50_sub3_20.aBoolean1413)
13231323- aClass6_492.insertBack(class50_sub3_20);
13241324- }
13251325- }
13261326- }
13271327- if (class50_sub3_1.anInt1415 != 0) {
13281328- boolean flag2 = true;
13291329- for (int k1 = 0; k1 < class50_sub3_1.sceneSpawnRequestCount; k1++) {
13301330- if (class50_sub3_1.sceneSpawnRequests[k1].anInt124 == anInt463
13311331- || (class50_sub3_1.anIntArray1409[k1] & class50_sub3_1.anInt1415) != class50_sub3_1.anInt1416)
13321332- continue;
13331333- flag2 = false;
13341334- break;
13351335- }
12771277+ }
12781278+ boolean flag1 = false;
12791279+ if (groundTile.plainTile != null) {
12801280+ if (!isTileOccluded(x, y, level)) {
12811281+ flag1 = true;
12821282+ renderPlainTile(groundTile.plainTile, x, y, level, curveSineX, curveCosineX, curveSineY, curveCosineY);
12831283+ }
12841284+ } else if (groundTile.shapedTile != null && !isTileOccluded(x, y, level)) {
12851285+ flag1 = true;
12861286+ renderShapedTile(groundTile.shapedTile, x, y, curveSineX, curveCosineX, curveSineY, curveCosineY);
12871287+ }
12881288+ int j1 = 0;
12891289+ int j2 = 0;
12901290+ Wall wallObject = groundTile.wall;
12911291+ WallDecoration wallDecoration = groundTile.wallDecoration;
12921292+ if (wallObject != null || wallDecoration != null) {
12931293+ if (cameraPositionTileX == x) {
12941294+ j1++;
12951295+ } else if (cameraPositionTileX < x) {
12961296+ j1 += 2;
12971297+ }
12981298+ if (cameraPositionTileY == y) {
12991299+ j1 += 3;
13001300+ } else if (cameraPositionTileY > y) {
13011301+ j1 += 6;
13021302+ }
13031303+ j2 = anIntArray493[j1];
13041304+ groundTile.wallDrawFlags = TILE_WALL_DRAW_FLAGS_1[j1];
13051305+ }
13061306+ if (wallObject != null) {
13071307+ if ((wallObject.orientation & anIntArray494[j1]) != 0) {
13081308+ if (wallObject.orientation == 16) {
13091309+ groundTile.wallCullDirection = 3;
13101310+ groundTile.wallUncullDirection = WALL_UNCULL_FLAGS_0[j1];
13111311+ groundTile.wallCullOppositeDirection = 3 - groundTile.wallUncullDirection;
13121312+ } else if (wallObject.orientation == 32) {
13131313+ groundTile.wallCullDirection = 6;
13141314+ groundTile.wallUncullDirection = anIntArray497[j1];
13151315+ groundTile.wallCullOppositeDirection = 6 - groundTile.wallUncullDirection;
13161316+ } else if (wallObject.orientation == 64) {
13171317+ groundTile.wallCullDirection = 12;
13181318+ groundTile.wallUncullDirection = anIntArray498[j1];
13191319+ groundTile.wallCullOppositeDirection = 12 - groundTile.wallUncullDirection;
13201320+ } else {
13211321+ groundTile.wallCullDirection = 9;
13221322+ groundTile.wallUncullDirection = anIntArray499[j1];
13231323+ groundTile.wallCullOppositeDirection = 9 - groundTile.wallUncullDirection;
13241324+ }
13251325+ } else {
13261326+ groundTile.wallCullDirection = 0;
13271327+ }
13281328+ if ((wallObject.orientation & j2) != 0 && !isWallOccluded(x, y, level, wallObject.orientation)) {
13291329+ wallObject.primary.renderAtPoint(0, curveSineY, curveCosineY, curveSineX, curveCosineX,
13301330+ wallObject.x - cameraPosX, wallObject.z - cameraPosZ, wallObject.y
13311331+ - cameraPosY, wallObject.uid);
13321332+ }
13331333+ if ((wallObject.orientation2 & j2) != 0 && !isWallOccluded(x, y, level, wallObject.orientation2)) {
13341334+ wallObject.secondary.renderAtPoint(0, curveSineY, curveCosineY, curveSineX, curveCosineX,
13351335+ wallObject.x - cameraPosX, wallObject.z - cameraPosZ, wallObject.y
13361336+ - cameraPosY, wallObject.uid);
13371337+ }
13381338+ }
13391339+ if (wallDecoration != null && !isOccluded(level, x, y, wallDecoration.renderable.modelHeight)) {
13401340+ if ((wallDecoration.configBits & j2) != 0) {
13411341+ wallDecoration.renderable.renderAtPoint(wallDecoration.face, curveSineY, curveCosineY, curveSineX,
13421342+ curveCosineX, wallDecoration.x - cameraPosX, wallDecoration.z - cameraPosZ,
13431343+ wallDecoration.y - cameraPosY, wallDecoration.uid);
13441344+ } else if ((wallDecoration.configBits & 0x300) != 0) {
13451345+ int j4 = wallDecoration.x - cameraPosX;
13461346+ int l5 = wallDecoration.z - cameraPosZ;
13471347+ int k6 = wallDecoration.y - cameraPosY;
13481348+ int i8 = wallDecoration.face;
13491349+ int k9;
13501350+ if (i8 == 1 || i8 == 2) {
13511351+ k9 = -j4;
13521352+ } else {
13531353+ k9 = j4;
13541354+ }
13551355+ int k10;
13561356+ if (i8 == 2 || i8 == 3) {
13571357+ k10 = -k6;
13581358+ } else {
13591359+ k10 = k6;
13601360+ }
13611361+ if ((wallDecoration.configBits & 0x100) != 0 && k10 < k9) {
13621362+ int i11 = j4 + faceOffsetX2[i8];
13631363+ int k11 = k6 + faceOffsetY2[i8];
13641364+ wallDecoration.renderable.renderAtPoint(i8 * 512 + 256, curveSineY, curveCosineY, curveSineX,
13651365+ curveCosineX, i11, l5, k11, wallDecoration.uid);
13661366+ }
13671367+ if ((wallDecoration.configBits & 0x200) != 0 && k10 > k9) {
13681368+ int j11 = j4 + faceOffsetX3[i8];
13691369+ int l11 = k6 + faceOffsetY3[i8];
13701370+ wallDecoration.renderable.renderAtPoint(i8 * 512 + 1280 & 0x7ff, curveSineY, curveCosineY,
13711371+ curveSineX, curveCosineX, j11, l5, l11, wallDecoration.uid);
13721372+ }
13731373+ }
13741374+ }
13751375+ if (flag1) {
13761376+ FloorDecoration floorDecoration = groundTile.floorDecoration;
13771377+ if (floorDecoration != null) {
13781378+ floorDecoration.renderable.renderAtPoint(0, curveSineY, curveCosineY, curveSineX, curveCosineX,
13791379+ floorDecoration.x - cameraPosX, floorDecoration.z - cameraPosZ, floorDecoration.y - cameraPosY,
13801380+ floorDecoration.uid);
13811381+ }
13821382+ GroundItemTile groundItemTile_1 = groundTile.groundItemTile;
13831383+ if (groundItemTile_1 != null && groundItemTile_1.anInt180 == 0) {
13841384+ if (groundItemTile_1.secondGroundItem != null) {
13851385+ groundItemTile_1.secondGroundItem.renderAtPoint(0, curveSineY, curveCosineY, curveSineX, curveCosineX,
13861386+ groundItemTile_1.x - cameraPosX, groundItemTile_1.z - cameraPosZ, groundItemTile_1.y
13871387+ - cameraPosY, groundItemTile_1.uid);
13881388+ }
13891389+ if (groundItemTile_1.thirdGroundItem != null) {
13901390+ groundItemTile_1.thirdGroundItem.renderAtPoint(0, curveSineY, curveCosineY, curveSineX, curveCosineX,
13911391+ groundItemTile_1.x - cameraPosX, groundItemTile_1.z - cameraPosZ, groundItemTile_1.y
13921392+ - cameraPosY, groundItemTile_1.uid);
13931393+ }
13941394+ if (groundItemTile_1.firstGroundItem != null) {
13951395+ groundItemTile_1.firstGroundItem.renderAtPoint(0, curveSineY, curveCosineY, curveSineX, curveCosineX,
13961396+ groundItemTile_1.x - cameraPosX, groundItemTile_1.z - cameraPosZ, groundItemTile_1.y
13971397+ - cameraPosY, groundItemTile_1.uid);
13981398+ }
13991399+ }
14001400+ }
14011401+ int k4 = groundTile.interactiveObjectsSizeOR;
14021402+ if (k4 != 0) {
14031403+ if (x < cameraPositionTileX && (k4 & 4) != 0) {
14041404+ SceneTile tile = tiles[x + 1][y];
14051405+ if (tile != null && tile.visible) {
14061406+ tileList.pushBack(tile);
14071407+ }
14081408+ }
14091409+ if (y < cameraPositionTileY && (k4 & 2) != 0) {
14101410+ SceneTile tile = tiles[x][y + 1];
14111411+ if (tile != null && tile.visible) {
14121412+ tileList.pushBack(tile);
14131413+ }
14141414+ }
14151415+ if (x > cameraPositionTileX && (k4 & 1) != 0) {
14161416+ SceneTile tile = tiles[x - 1][y];
14171417+ if (tile != null && tile.visible) {
14181418+ tileList.pushBack(tile);
14191419+ }
14201420+ }
14211421+ if (y > cameraPositionTileY && (k4 & 8) != 0) {
14221422+ SceneTile tile = tiles[x][y - 1];
14231423+ if (tile != null && tile.visible) {
14241424+ tileList.pushBack(tile);
14251425+ }
14261426+ }
14271427+ }
14281428+ }
14291429+ if (groundTile.wallCullDirection != 0) {
14301430+ boolean flag2 = true;
14311431+ for (int e = 0; e < groundTile.entityCount; e++) {
14321432+ if (groundTile.interactiveObjects[e].cycle == cycle
14331433+ || (groundTile.sceneSpawnRequestsSize[e] & groundTile.wallCullDirection) != groundTile.wallUncullDirection) {
14341434+ continue;
14351435+ }
14361436+ flag2 = false;
14371437+ break;
14381438+ }
1336143913371337- if (flag2) {
13381338- Wall wall_1 = class50_sub3_1.wall;
13391339- if (!method288(l, i, j, wall_1.faceUnknown))
13401340- wall_1.aRenderable769.renderAtPoint(0, anInt473, anInt474, anInt475, anInt476,
13411341- wall_1.x - anInt470, wall_1.plane - anInt471, wall_1.y
13421342- - anInt472, wall_1.hash);
13431343- class50_sub3_1.anInt1415 = 0;
13441344- }
13451345- }
13461346- if (class50_sub3_1.aBoolean1414)
13471347- try {
13481348- int i1 = class50_sub3_1.sceneSpawnRequestCount;
13491349- class50_sub3_1.aBoolean1414 = false;
13501350- int l1 = 0;
13511351- label0: for (int k2 = 0; k2 < i1; k2++) {
13521352- SceneSpawnRequest sceneSpawnRequest_1 = class50_sub3_1.sceneSpawnRequests[k2];
13531353- if (sceneSpawnRequest_1.anInt124 == anInt463)
13541354- continue;
13551355- for (int k3 = sceneSpawnRequest_1.x; k3 <= sceneSpawnRequest_1.anInt120; k3++) {
13561356- for (int l4 = sceneSpawnRequest_1.y; l4 <= sceneSpawnRequest_1.anInt122; l4++) {
13571357- SceneTile class50_sub3_21 = aclass50_sub3[k3][l4];
13581358- if (class50_sub3_21.aBoolean1412) {
13591359- class50_sub3_1.aBoolean1414 = true;
13601360- } else {
13611361- if (class50_sub3_21.anInt1415 == 0)
13621362- continue;
13631363- int l6 = 0;
13641364- if (k3 > sceneSpawnRequest_1.x)
13651365- l6++;
13661366- if (k3 < sceneSpawnRequest_1.anInt120)
13671367- l6 += 4;
13681368- if (l4 > sceneSpawnRequest_1.y)
13691369- l6 += 8;
13701370- if (l4 < sceneSpawnRequest_1.anInt122)
13711371- l6 += 2;
13721372- if ((l6 & class50_sub3_21.anInt1415) != class50_sub3_1.anInt1417)
13731373- continue;
13741374- class50_sub3_1.aBoolean1414 = true;
13751375- }
13761376- continue label0;
13771377- }
14401440+ if (flag2) {
14411441+ Wall wall_1 = groundTile.wall;
14421442+ if (!isWallOccluded(x, y, level, wall_1.orientation)) {
14431443+ wall_1.primary.renderAtPoint(0, curveSineY, curveCosineY, curveSineX, curveCosineX,
14441444+ wall_1.x - cameraPosX, wall_1.z - cameraPosZ, wall_1.y
14451445+ - cameraPosY, wall_1.uid);
14461446+ }
14471447+ groundTile.wallCullDirection = 0;
14481448+ }
14491449+ }
14501450+ if (groundTile.drawEntities) {
14511451+ try {
14521452+ int entityCount = groundTile.entityCount;
14531453+ groundTile.drawEntities = false;
14541454+ int l1 = 0;
14551455+ label0:
14561456+ for (int e = 0; e < entityCount; e++) {
14571457+ InteractiveObject entity = groundTile.interactiveObjects[e];
14581458+ if (entity.cycle == cycle) {
14591459+ continue;
14601460+ }
14611461+ for (int _x = entity.tileLeft; _x <= entity.tileRight; _x++) {
14621462+ for (int _y = entity.tileTop; _y <= entity.tileBottom; _y++) {
14631463+ SceneTile tile = tiles[_x][_y];
14641464+ if (tile.draw) {
14651465+ groundTile.drawEntities = true;
14661466+ } else {
14671467+ if (tile.wallCullDirection == 0) {
14681468+ continue;
14691469+ }
14701470+ int l6 = 0;
14711471+ if (_x > entity.tileLeft) {
14721472+ l6++;
14731473+ }
14741474+ if (_x < entity.tileRight) {
14751475+ l6 += 4;
14761476+ }
14771477+ if (_y > entity.tileTop) {
14781478+ l6 += 8;
14791479+ }
14801480+ if (_y < entity.tileBottom) {
14811481+ l6 += 2;
14821482+ }
14831483+ if ((l6 & tile.wallCullDirection) != groundTile.wallCullOppositeDirection) {
14841484+ continue;
14851485+ }
14861486+ groundTile.drawEntities = true;
14871487+ }
14881488+ continue label0;
14891489+ }
1378149013791379- }
14911491+ }
1380149213811381- aSceneSpawnRequestArray477[l1++] = sceneSpawnRequest_1;
13821382- int i5 = anInt468 - sceneSpawnRequest_1.x;
13831383- int i6 = sceneSpawnRequest_1.anInt120 - anInt468;
13841384- if (i6 > i5)
13851385- i5 = i6;
13861386- int i7 = anInt469 - sceneSpawnRequest_1.y;
13871387- int j8 = sceneSpawnRequest_1.anInt122 - anInt469;
13881388- if (j8 > i7)
13891389- sceneSpawnRequest_1.anInt123 = i5 + j8;
13901390- else
13911391- sceneSpawnRequest_1.anInt123 = i5 + i7;
13921392- }
14931493+ interactiveObjects[l1++] = entity;
14941494+ int i5 = cameraPositionTileX - entity.tileLeft;
14951495+ int i6 = entity.tileRight - cameraPositionTileX;
14961496+ if (i6 > i5) {
14971497+ i5 = i6;
14981498+ }
14991499+ int i7 = cameraPositionTileY - entity.tileTop;
15001500+ int j8 = entity.tileBottom - cameraPositionTileY;
15011501+ if (j8 > i7) {
15021502+ entity.anInt123 = i5 + j8;
15031503+ } else {
15041504+ entity.anInt123 = i5 + i7;
15051505+ }
15061506+ }
1393150713941394- while (l1 > 0) {
13951395- int i3 = -50;
13961396- int l3 = -1;
13971397- for (int j5 = 0; j5 < l1; j5++) {
13981398- SceneSpawnRequest sceneSpawnRequest_2 = aSceneSpawnRequestArray477[j5];
13991399- if (sceneSpawnRequest_2.anInt124 != anInt463)
14001400- if (sceneSpawnRequest_2.anInt123 > i3) {
14011401- i3 = sceneSpawnRequest_2.anInt123;
14021402- l3 = j5;
14031403- } else if (sceneSpawnRequest_2.anInt123 == i3) {
14041404- int j7 = sceneSpawnRequest_2.anInt115 - anInt470;
14051405- int k8 = sceneSpawnRequest_2.anInt116 - anInt472;
14061406- int l9 = aSceneSpawnRequestArray477[l3].anInt115 - anInt470;
14071407- int l10 = aSceneSpawnRequestArray477[l3].anInt116 - anInt472;
14081408- if (j7 * j7 + k8 * k8 > l9 * l9 + l10 * l10)
14091409- l3 = j5;
14101410- }
14111411- }
15081508+ while (l1 > 0) {
15091509+ int i3 = -50;
15101510+ int l3 = -1;
15111511+ for (int j5 = 0; j5 < l1; j5++) {
15121512+ InteractiveObject entity = interactiveObjects[j5];
15131513+ if (entity.cycle != cycle) {
15141514+ if (entity.anInt123 > i3) {
15151515+ i3 = entity.anInt123;
15161516+ l3 = j5;
15171517+ } else if (entity.anInt123 == i3) {
15181518+ int j7 = entity.worldX - cameraPosX;
15191519+ int k8 = entity.worldY - cameraPosY;
15201520+ int l9 = interactiveObjects[l3].worldX - cameraPosX;
15211521+ int l10 = interactiveObjects[l3].worldY - cameraPosY;
15221522+ if (j7 * j7 + k8 * k8 > l9 * l9 + l10 * l10) {
15231523+ l3 = j5;
15241524+ }
15251525+ }
15261526+ }
15271527+ }
1412152814131413- if (l3 == -1)
14141414- break;
14151415- SceneSpawnRequest sceneSpawnRequest_3 = aSceneSpawnRequestArray477[l3];
14161416- sceneSpawnRequest_3.anInt124 = anInt463;
14171417- if (!method290(l, sceneSpawnRequest_3.x, sceneSpawnRequest_3.anInt120, sceneSpawnRequest_3.y, sceneSpawnRequest_3.anInt122,
14181418- sceneSpawnRequest_3.aRenderable601.modelHeight))
14191419- sceneSpawnRequest_3.aRenderable601.renderAtPoint(sceneSpawnRequest_3.anInt118, anInt473, anInt474, anInt475,
14201420- anInt476, sceneSpawnRequest_3.anInt115 - anInt470, sceneSpawnRequest_3.anInt114 - anInt471,
14211421- sceneSpawnRequest_3.anInt116 - anInt472, sceneSpawnRequest_3.anInt125);
14221422- for (int k7 = sceneSpawnRequest_3.x; k7 <= sceneSpawnRequest_3.anInt120; k7++) {
14231423- for (int l8 = sceneSpawnRequest_3.y; l8 <= sceneSpawnRequest_3.anInt122; l8++) {
14241424- SceneTile class50_sub3_22 = aclass50_sub3[k7][l8];
14251425- if (class50_sub3_22.anInt1415 != 0)
14261426- aClass6_492.insertBack(class50_sub3_22);
14271427- else if ((k7 != i || l8 != j) && class50_sub3_22.aBoolean1413)
14281428- aClass6_492.insertBack(class50_sub3_22);
14291429- }
15291529+ if (l3 == -1) {
15301530+ break;
15311531+ }
15321532+ InteractiveObject entity = interactiveObjects[l3];
15331533+ entity.cycle = cycle;
15341534+ if (!isAreaOccluded(entity.tileLeft, entity.tileRight, entity.tileTop, entity.tileBottom, level,
15351535+ entity.renderable.modelHeight)) {
15361536+ entity.renderable.renderAtPoint(entity.rotation, curveSineY, curveCosineY, curveSineX,
15371537+ curveCosineX, entity.worldX - cameraPosX, entity.worldZ - cameraPosZ,
15381538+ entity.worldY - cameraPosY, entity.uid);
15391539+ }
15401540+ for (int _x = entity.tileLeft; _x <= entity.tileRight; _x++) {
15411541+ for (int _y = entity.tileTop; _y <= entity.tileBottom; _y++) {
15421542+ SceneTile tile = tiles[_x][_y];
15431543+ if (tile.wallCullDirection != 0) {
15441544+ tileList.pushBack(tile);
15451545+ } else if ((_x != x || _y != y) && tile.visible) {
15461546+ tileList.pushBack(tile);
15471547+ }
15481548+ }
1430154914311431- }
15501550+ }
1432155114331433- }
14341434- if (class50_sub3_1.aBoolean1414)
14351435- continue;
14361436- } catch (Exception _ex) {
14371437- class50_sub3_1.aBoolean1414 = false;
14381438- }
14391439- if (!class50_sub3_1.aBoolean1413 || class50_sub3_1.anInt1415 != 0)
14401440- continue;
14411441- if (i <= anInt468 && i > anInt464) {
14421442- SceneTile class50_sub3_8 = aclass50_sub3[i - 1][j];
14431443- if (class50_sub3_8 != null && class50_sub3_8.aBoolean1413)
14441444- continue;
14451445- }
14461446- if (i >= anInt468 && i < anInt465 - 1) {
14471447- SceneTile class50_sub3_9 = aclass50_sub3[i + 1][j];
14481448- if (class50_sub3_9 != null && class50_sub3_9.aBoolean1413)
14491449- continue;
14501450- }
14511451- if (j <= anInt469 && j > anInt466) {
14521452- SceneTile class50_sub3_10 = aclass50_sub3[i][j - 1];
14531453- if (class50_sub3_10 != null && class50_sub3_10.aBoolean1413)
14541454- continue;
14551455- }
14561456- if (j >= anInt469 && j < anInt467 - 1) {
14571457- SceneTile class50_sub3_11 = aclass50_sub3[i][j + 1];
14581458- if (class50_sub3_11 != null && class50_sub3_11.aBoolean1413)
14591459- continue;
14601460- }
14611461- class50_sub3_1.aBoolean1413 = false;
14621462- anInt461--;
14631463- CameraAngle cameraAngle = class50_sub3_1.cameraAngle;
14641464- if (cameraAngle != null && cameraAngle.anInt180 != 0) {
14651465- if (cameraAngle.aRenderable151 != null)
14661466- cameraAngle.aRenderable151.renderAtPoint(0, anInt473, anInt474, anInt475, anInt476,
14671467- cameraAngle.y - anInt470, cameraAngle.x - anInt471 - cameraAngle.anInt180,
14681468- cameraAngle.z - anInt472, cameraAngle.anInt179);
14691469- if (cameraAngle.aRenderable152 != null)
14701470- cameraAngle.aRenderable152.renderAtPoint(0, anInt473, anInt474, anInt475, anInt476,
14711471- cameraAngle.y - anInt470, cameraAngle.x - anInt471 - cameraAngle.anInt180,
14721472- cameraAngle.z - anInt472, cameraAngle.anInt179);
14731473- if (cameraAngle.aRenderable150 != null)
14741474- cameraAngle.aRenderable150.renderAtPoint(0, anInt473, anInt474, anInt475, anInt476,
14751475- cameraAngle.y - anInt470, cameraAngle.x - anInt471 - cameraAngle.anInt180,
14761476- cameraAngle.z - anInt472, cameraAngle.anInt179);
14771477- }
14781478- if (class50_sub3_1.anInt1418 != 0) {
14791479- WallDecoration wallDecoration = class50_sub3_1.wallDecoration;
14801480- if (wallDecoration != null && !method289(l, i, j, wallDecoration.renderable.modelHeight))
14811481- if ((wallDecoration.faceUnknown & class50_sub3_1.anInt1418) != 0)
14821482- wallDecoration.renderable.renderAtPoint(wallDecoration.face, anInt473, anInt474, anInt475,
14831483- anInt476, wallDecoration.y - anInt470, wallDecoration.plane - anInt471, wallDecoration.x
14841484- - anInt472, wallDecoration.hash);
14851485- else if ((wallDecoration.faceUnknown & 0x300) != 0) {
14861486- int l2 = wallDecoration.y - anInt470;
14871487- int j3 = wallDecoration.plane - anInt471;
14881488- int i4 = wallDecoration.x - anInt472;
14891489- int k5 = wallDecoration.face;
14901490- int j6;
14911491- if (k5 == 1 || k5 == 2)
14921492- j6 = -l2;
14931493- else
14941494- j6 = l2;
14951495- int l7;
14961496- if (k5 == 2 || k5 == 3)
14971497- l7 = -i4;
14981498- else
14991499- l7 = i4;
15001500- if ((wallDecoration.faceUnknown & 0x100) != 0 && l7 >= j6) {
15011501- int i9 = l2 + anIntArray478[k5];
15021502- int i10 = i4 + anIntArray479[k5];
15031503- wallDecoration.renderable.renderAtPoint(k5 * 512 + 256, anInt473, anInt474, anInt475,
15041504- anInt476, i9, j3, i10, wallDecoration.hash);
15051505- }
15061506- if ((wallDecoration.faceUnknown & 0x200) != 0 && l7 <= j6) {
15071507- int j9 = l2 + anIntArray480[k5];
15081508- int j10 = i4 + anIntArray481[k5];
15091509- wallDecoration.renderable.renderAtPoint(k5 * 512 + 1280 & 0x7ff, anInt473, anInt474,
15101510- anInt475, anInt476, j9, j3, j10, wallDecoration.hash);
15111511- }
15121512- }
15131513- Wall wall_2 = class50_sub3_1.wall;
15141514- if (wall_2 != null) {
15151515- if ((wall_2.face & class50_sub3_1.anInt1418) != 0 && !method288(l, i, j, wall_2.face))
15161516- wall_2.aRenderable770.renderAtPoint(0, anInt473, anInt474, anInt475, anInt476,
15171517- wall_2.x - anInt470, wall_2.plane - anInt471, wall_2.y
15181518- - anInt472, wall_2.hash);
15191519- if ((wall_2.faceUnknown & class50_sub3_1.anInt1418) != 0 && !method288(l, i, j, wall_2.faceUnknown))
15201520- wall_2.aRenderable769.renderAtPoint(0, anInt473, anInt474, anInt475, anInt476,
15211521- wall_2.x - anInt470, wall_2.plane - anInt471, wall_2.y
15221522- - anInt472, wall_2.hash);
15231523- }
15241524- }
15251525- if (k < anInt452 - 1) {
15261526- SceneTile class50_sub3_12 = tiles[k + 1][i][j];
15271527- if (class50_sub3_12 != null && class50_sub3_12.aBoolean1413)
15281528- aClass6_492.insertBack(class50_sub3_12);
15291529- }
15301530- if (i < anInt468) {
15311531- SceneTile class50_sub3_13 = aclass50_sub3[i + 1][j];
15321532- if (class50_sub3_13 != null && class50_sub3_13.aBoolean1413)
15331533- aClass6_492.insertBack(class50_sub3_13);
15341534- }
15351535- if (j < anInt469) {
15361536- SceneTile class50_sub3_14 = aclass50_sub3[i][j + 1];
15371537- if (class50_sub3_14 != null && class50_sub3_14.aBoolean1413)
15381538- aClass6_492.insertBack(class50_sub3_14);
15391539- }
15401540- if (i > anInt468) {
15411541- SceneTile class50_sub3_15 = aclass50_sub3[i - 1][j];
15421542- if (class50_sub3_15 != null && class50_sub3_15.aBoolean1413)
15431543- aClass6_492.insertBack(class50_sub3_15);
15441544- }
15451545- if (j > anInt469) {
15461546- SceneTile class50_sub3_16 = aclass50_sub3[i][j - 1];
15471547- if (class50_sub3_16 != null && class50_sub3_16.aBoolean1413)
15481548- aClass6_492.insertBack(class50_sub3_16);
15491549- }
15501550- } while (true);
15511551- }
15521552+ }
15531553+ if (groundTile.drawEntities) {
15541554+ continue;
15551555+ }
15561556+ } catch (Exception _ex) {
15571557+ groundTile.drawEntities = false;
15581558+ }
15591559+ }
15601560+ if (!groundTile.visible || groundTile.wallCullDirection != 0) {
15611561+ continue;
15621562+ }
15631563+ if (x <= cameraPositionTileX && x > currentPositionX) {
15641564+ SceneTile tile = tiles[x - 1][y];
15651565+ if (tile != null && tile.visible) {
15661566+ continue;
15671567+ }
15681568+ }
15691569+ if (x >= cameraPositionTileX && x < mapBoundsX - 1) {
15701570+ SceneTile tile = tiles[x + 1][y];
15711571+ if (tile != null && tile.visible) {
15721572+ continue;
15731573+ }
15741574+ }
15751575+ if (y <= cameraPositionTileY && y > currentPositionY) {
15761576+ SceneTile tile = tiles[x][y - 1];
15771577+ if (tile != null && tile.visible) {
15781578+ continue;
15791579+ }
15801580+ }
15811581+ if (y >= cameraPositionTileY && y < mapBoundsY - 1) {
15821582+ SceneTile tile = tiles[x][y + 1];
15831583+ if (tile != null && tile.visible) {
15841584+ continue;
15851585+ }
15861586+ }
15871587+ groundTile.visible = false;
15881588+ anInt461--;
15891589+ GroundItemTile groundItemTile = groundTile.groundItemTile;
15901590+ if (groundItemTile != null && groundItemTile.anInt180 != 0) {
15911591+ if (groundItemTile.secondGroundItem != null) {
15921592+ groundItemTile.secondGroundItem.renderAtPoint(0, curveSineY, curveCosineY, curveSineX, curveCosineX,
15931593+ groundItemTile.x - cameraPosX, groundItemTile.z - cameraPosZ - groundItemTile.anInt180,
15941594+ groundItemTile.y - cameraPosY, groundItemTile.uid);
15951595+ }
15961596+ if (groundItemTile.thirdGroundItem != null) {
15971597+ groundItemTile.thirdGroundItem.renderAtPoint(0, curveSineY, curveCosineY, curveSineX, curveCosineX,
15981598+ groundItemTile.x - cameraPosX, groundItemTile.z - cameraPosZ - groundItemTile.anInt180,
15991599+ groundItemTile.y - cameraPosY, groundItemTile.uid);
16001600+ }
16011601+ if (groundItemTile.firstGroundItem != null) {
16021602+ groundItemTile.firstGroundItem.renderAtPoint(0, curveSineY, curveCosineY, curveSineX, curveCosineX,
16031603+ groundItemTile.x - cameraPosX, groundItemTile.z - cameraPosZ - groundItemTile.anInt180,
16041604+ groundItemTile.y - cameraPosY, groundItemTile.uid);
16051605+ }
16061606+ }
16071607+ if (groundTile.wallDrawFlags != 0) {
16081608+ WallDecoration wallDecoration = groundTile.wallDecoration;
16091609+ if (wallDecoration != null && !isOccluded(level, x, y, wallDecoration.renderable.modelHeight)) {
16101610+ if ((wallDecoration.configBits & groundTile.wallDrawFlags) != 0) {
16111611+ wallDecoration.renderable.renderAtPoint(wallDecoration.face, curveSineY, curveCosineY, curveSineX,
16121612+ curveCosineX, wallDecoration.x - cameraPosX, wallDecoration.z - cameraPosZ, wallDecoration.y
16131613+ - cameraPosY, wallDecoration.uid);
16141614+ } else if ((wallDecoration.configBits & 0x300) != 0) {
16151615+ int l2 = wallDecoration.x - cameraPosX;
16161616+ int j3 = wallDecoration.z - cameraPosZ;
16171617+ int i4 = wallDecoration.y - cameraPosY;
16181618+ int k5 = wallDecoration.face;
16191619+ int j6;
16201620+ if (k5 == 1 || k5 == 2) {
16211621+ j6 = -l2;
16221622+ } else {
16231623+ j6 = l2;
16241624+ }
16251625+ int l7;
16261626+ if (k5 == 2 || k5 == 3) {
16271627+ l7 = -i4;
16281628+ } else {
16291629+ l7 = i4;
16301630+ }
16311631+ if ((wallDecoration.configBits & 0x100) != 0 && l7 >= j6) {
16321632+ int i9 = l2 + faceOffsetX2[k5];
16331633+ int i10 = i4 + faceOffsetY2[k5];
16341634+ wallDecoration.renderable.renderAtPoint(k5 * 512 + 256, curveSineY, curveCosineY, curveSineX,
16351635+ curveCosineX, i9, j3, i10, wallDecoration.uid);
16361636+ }
16371637+ if ((wallDecoration.configBits & 0x200) != 0 && l7 <= j6) {
16381638+ int j9 = l2 + faceOffsetX3[k5];
16391639+ int j10 = i4 + faceOffsetY3[k5];
16401640+ wallDecoration.renderable.renderAtPoint(k5 * 512 + 1280 & 0x7ff, curveSineY, curveCosineY,
16411641+ curveSineX, curveCosineX, j9, j3, j10, wallDecoration.uid);
16421642+ }
16431643+ }
16441644+ }
16451645+ Wall wallObject = groundTile.wall;
16461646+ if (wallObject != null) {
16471647+ if ((wallObject.orientation2 & groundTile.wallDrawFlags) != 0 && !isWallOccluded(x, y, level, wallObject.orientation2)) {
16481648+ wallObject.secondary.renderAtPoint(0, curveSineY, curveCosineY, curveSineX, curveCosineX,
16491649+ wallObject.x - cameraPosX, wallObject.z - cameraPosZ, wallObject.y
16501650+ - cameraPosY, wallObject.uid);
16511651+ }
16521652+ if ((wallObject.orientation & groundTile.wallDrawFlags) != 0 && !isWallOccluded(x, y, level, wallObject.orientation)) {
16531653+ wallObject.primary.renderAtPoint(0, curveSineY, curveCosineY, curveSineX, curveCosineX,
16541654+ wallObject.x - cameraPosX, wallObject.z - cameraPosZ, wallObject.y
16551655+ - cameraPosY, wallObject.uid);
16561656+ }
16571657+ }
16581658+ }
16591659+ if (z < mapSizeZ - 1) {
16601660+ SceneTile tile = groundArray[z + 1][x][y];
16611661+ if (tile != null && tile.visible) {
16621662+ tileList.pushBack(tile);
16631663+ }
16641664+ }
16651665+ if (x < cameraPositionTileX) {
16661666+ SceneTile tile = tiles[x + 1][y];
16671667+ if (tile != null && tile.visible) {
16681668+ tileList.pushBack(tile);
16691669+ }
16701670+ }
16711671+ if (y < cameraPositionTileY) {
16721672+ SceneTile tile = tiles[x][y + 1];
16731673+ if (tile != null && tile.visible) {
16741674+ tileList.pushBack(tile);
16751675+ }
16761676+ }
16771677+ if (x > cameraPositionTileX) {
16781678+ SceneTile tile = tiles[x - 1][y];
16791679+ if (tile != null && tile.visible) {
16801680+ tileList.pushBack(tile);
16811681+ }
16821682+ }
16831683+ if (y > cameraPositionTileY) {
16841684+ SceneTile tile = tiles[x][y - 1];
16851685+ if (tile != null && tile.visible) {
16861686+ tileList.pushBack(tile);
16871687+ }
16881688+ }
16891689+ } while (true);
16901690+ }
1552169115531553- public void method282(GenericTile genericTile, int i, int j, int k, int l, int i1, int j1, int k1) {
15541554- int l1;
15551555- int i2 = l1 = (j1 << 7) - anInt470;
15561556- int j2;
15571557- int k2 = j2 = (k1 << 7) - anInt472;
15581558- int l2;
15591559- int i3 = l2 = i2 + 128;
15601560- int j3;
15611561- int k3 = j3 = k2 + 128;
15621562- int l3 = anIntArrayArrayArray455[i][j1][k1] - anInt471;
15631563- int i4 = anIntArrayArrayArray455[i][j1 + 1][k1] - anInt471;
15641564- int j4 = anIntArrayArrayArray455[i][j1 + 1][k1 + 1] - anInt471;
15651565- int k4 = anIntArrayArrayArray455[i][j1][k1 + 1] - anInt471;
15661566- int l4 = k2 * l + i2 * i1 >> 16;
15671567- k2 = k2 * i1 - i2 * l >> 16;
15681568- i2 = l4;
15691569- l4 = l3 * k - k2 * j >> 16;
15701570- k2 = l3 * j + k2 * k >> 16;
15711571- l3 = l4;
15721572- if (k2 < 50)
15731573- return;
15741574- l4 = j2 * l + i3 * i1 >> 16;
15751575- j2 = j2 * i1 - i3 * l >> 16;
15761576- i3 = l4;
15771577- l4 = i4 * k - j2 * j >> 16;
15781578- j2 = i4 * j + j2 * k >> 16;
15791579- i4 = l4;
15801580- if (j2 < 50)
15811581- return;
15821582- l4 = k3 * l + l2 * i1 >> 16;
15831583- k3 = k3 * i1 - l2 * l >> 16;
15841584- l2 = l4;
15851585- l4 = j4 * k - k3 * j >> 16;
15861586- k3 = j4 * j + k3 * k >> 16;
15871587- j4 = l4;
15881588- if (k3 < 50)
15891589- return;
15901590- l4 = j3 * l + l1 * i1 >> 16;
15911591- j3 = j3 * i1 - l1 * l >> 16;
15921592- l1 = l4;
15931593- l4 = k4 * k - j3 * j >> 16;
15941594- j3 = k4 * j + j3 * k >> 16;
15951595- k4 = l4;
15961596- if (j3 < 50)
15971597- return;
15981598- int i5 = Rasterizer3D.centerX + (i2 << 9) / k2;
15991599- int j5 = Rasterizer3D.centerY + (l3 << 9) / k2;
16001600- int k5 = Rasterizer3D.centerX + (i3 << 9) / j2;
16011601- int l5 = Rasterizer3D.centerY + (i4 << 9) / j2;
16021602- int i6 = Rasterizer3D.centerX + (l2 << 9) / k3;
16031603- int j6 = Rasterizer3D.centerY + (j4 << 9) / k3;
16041604- int k6 = Rasterizer3D.centerX + (l1 << 9) / j3;
16051605- int l6 = Rasterizer3D.centerY + (k4 << 9) / j3;
16061606- Rasterizer3D.anInt1531 = 0;
16071607- if ((i6 - k6) * (l5 - l6) - (j6 - l6) * (k5 - k6) > 0) {
16081608- Rasterizer3D.aBoolean1528 = false;
16091609- if (i6 < 0 || k6 < 0 || k5 < 0 || i6 > Rasterizer.virtualBottomX || k6 > Rasterizer.virtualBottomX
16101610- || k5 > Rasterizer.virtualBottomX)
16111611- Rasterizer3D.aBoolean1528 = true;
16121612- if (aBoolean482 && method285(anInt483, anInt484, j6, l6, l5, i6, k6, k5)) {
16131613- clickedTileX = j1;
16141614- anInt486 = k1;
16151615- }
16161616- if (genericTile.texture == -1) {
16171617- if (genericTile.anInt97 != 0xbc614e)
16181618- Rasterizer3D.method503(j6, l6, l5, i6, k6, k5, genericTile.anInt97, genericTile.anInt98,
16191619- genericTile.anInt96);
16201620- } else if (!lowMemory) {
16211621- if (genericTile.flat)
16221622- Rasterizer3D.method507(j6, l6, l5, i6, k6, k5, genericTile.anInt97, genericTile.anInt98,
16231623- genericTile.anInt96, i2, i3, l1, l3, i4, k4, k2, j2, j3, genericTile.texture);
16241624- else
16251625- Rasterizer3D.method507(j6, l6, l5, i6, k6, k5, genericTile.anInt97, genericTile.anInt98,
16261626- genericTile.anInt96, l2, l1, i3, j4, k4, i4, k3, j3, j2, genericTile.texture);
16271627- } else {
16281628- int i7 = anIntArray500[genericTile.texture];
16291629- Rasterizer3D.method503(j6, l6, l5, i6, k6, k5, method284(genericTile.anInt97, i7, 0), method284(
16301630- genericTile.anInt98, i7, 0), method284(genericTile.anInt96, i7, 0));
16311631- }
16321632- }
16331633- if ((i5 - k5) * (l6 - l5) - (j5 - l5) * (k6 - k5) > 0) {
16341634- Rasterizer3D.aBoolean1528 = false;
16351635- if (i5 < 0 || k5 < 0 || k6 < 0 || i5 > Rasterizer.virtualBottomX || k5 > Rasterizer.virtualBottomX
16361636- || k6 > Rasterizer.virtualBottomX)
16371637- Rasterizer3D.aBoolean1528 = true;
16381638- if (aBoolean482 && method285(anInt483, anInt484, j5, l5, l6, i5, k5, k6)) {
16391639- clickedTileX = j1;
16401640- anInt486 = k1;
16411641- }
16421642- if (genericTile.texture == -1) {
16431643- if (genericTile.anInt95 != 0xbc614e) {
16441644- Rasterizer3D.method503(j5, l5, l6, i5, k5, k6, genericTile.anInt95, genericTile.anInt96,
16451645- genericTile.anInt98);
16461646- return;
16471647- }
16481648- } else {
16491649- if (!lowMemory) {
16501650- Rasterizer3D.method507(j5, l5, l6, i5, k5, k6, genericTile.anInt95, genericTile.anInt96,
16511651- genericTile.anInt98, i2, i3, l1, l3, i4, k4, k2, j2, j3, genericTile.texture);
16521652- return;
16531653- }
16541654- int j7 = anIntArray500[genericTile.texture];
16551655- Rasterizer3D.method503(j5, l5, l6, i5, k5, k6, method284(genericTile.anInt95, j7, 0), method284(
16561656- genericTile.anInt96, j7, 0), method284(genericTile.anInt98, j7, 0));
16571657- }
16581658- }
16591659- }
16921692+ private void renderPlainTile(GenericTile plainTile, int tileX, int tileY, int tileZ, int sinX, int cosineX, int sinY, int cosineY) {
16931693+ int xC;
16941694+ int xA = xC = (tileX << 7) - cameraPosX;
16951695+ int yB;
16961696+ int yA = yB = (tileY << 7) - cameraPosY;
16971697+ int xD;
16981698+ int xB = xD = xA + 128;
16991699+ int yC;
17001700+ int yD = yC = yA + 128;
17011701+ int zA = heightMap[tileZ][tileX][tileY] - cameraPosZ;
17021702+ int zB = heightMap[tileZ][tileX + 1][tileY] - cameraPosZ;
17031703+ int zC = heightMap[tileZ][tileX + 1][tileY + 1] - cameraPosZ;
17041704+ int zD = heightMap[tileZ][tileX][tileY + 1] - cameraPosZ;
17051705+ int temp = yA * sinX + xA * cosineX >> 16;
17061706+ yA = yA * cosineX - xA * sinX >> 16;
17071707+ xA = temp;
17081708+ temp = zA * cosineY - yA * sinY >> 16;
17091709+ yA = zA * sinY + yA * cosineY >> 16;
17101710+ zA = temp;
17111711+ if (yA < 50) {
17121712+ return;
17131713+ }
17141714+ temp = yB * sinX + xB * cosineX >> 16;
17151715+ yB = yB * cosineX - xB * sinX >> 16;
17161716+ xB = temp;
17171717+ temp = zB * cosineY - yB * sinY >> 16;
17181718+ yB = zB * sinY + yB * cosineY >> 16;
17191719+ zB = temp;
17201720+ if (yB < 50) {
17211721+ return;
17221722+ }
17231723+ temp = yD * sinX + xD * cosineX >> 16;
17241724+ yD = yD * cosineX - xD * sinX >> 16;
17251725+ xD = temp;
17261726+ temp = zC * cosineY - yD * sinY >> 16;
17271727+ yD = zC * sinY + yD * cosineY >> 16;
17281728+ zC = temp;
17291729+ if (yD < 50) {
17301730+ return;
17311731+ }
17321732+ temp = yC * sinX + xC * cosineX >> 16;
17331733+ yC = yC * cosineX - xC * sinX >> 16;
17341734+ xC = temp;
17351735+ temp = zD * cosineY - yC * sinY >> 16;
17361736+ yC = zD * sinY + yC * cosineY >> 16;
17371737+ zD = temp;
17381738+ if (yC < 50) {
17391739+ return;
17401740+ }
17411741+ int screenXA = Rasterizer3D.centerX + (xA << 9) / yA;
17421742+ int screenYA = Rasterizer3D.centerY + (zA << 9) / yA;
17431743+ int screenXB = Rasterizer3D.centerX + (xB << 9) / yB;
17441744+ int screenYB = Rasterizer3D.centerY + (zB << 9) / yB;
17451745+ int screenXD = Rasterizer3D.centerX + (xD << 9) / yD;
17461746+ int screenYD = Rasterizer3D.centerY + (zC << 9) / yD;
17471747+ int screenXC = Rasterizer3D.centerX + (xC << 9) / yC;
17481748+ int screenYC = Rasterizer3D.centerY + (zD << 9) / yC;
17491749+ Rasterizer3D.alpha = 0;
17501750+ if ((screenXD - screenXC) * (screenYB - screenYC) - (screenYD - screenYC) * (screenXB - screenXC) > 0) {
17511751+ Rasterizer3D.restrictEdges = screenXD < 0 || screenXC < 0 || screenXB < 0 ||
17521752+ screenXD > Rasterizer.virtualBottomX ||
17531753+ screenXC > Rasterizer.virtualBottomX ||
17541754+ screenXB > Rasterizer.virtualBottomX;
17551755+ if (clicked && isMouseWithinTriangle(clickX, clickY, screenYD, screenYC, screenYB, screenXD, screenXC, screenXB)) {
17561756+ clickedTileX = tileX;
17571757+ clickedTileY = tileY;
17581758+ }
17591759+ if (plainTile.texture == -1) {
17601760+ if (plainTile.colourD != 0xbc614e) {
17611761+ Rasterizer3D.drawShadedTriangle(screenYD, screenYC, screenYB, screenXD, screenXC, screenXB, plainTile.colourD, plainTile.colourC,
17621762+ plainTile.colourB);
17631763+ }
17641764+ } else if (!lowMemory) {
17651765+ if (plainTile.flat) {
17661766+ Rasterizer3D.drawTexturedTriangle(screenYD, screenYC, screenYB, screenXD, screenXC, screenXB, plainTile.colourD, plainTile.colourC,
17671767+ plainTile.colourB, xA, xB, xC, zA, zB, zD, yA, yB, yC, plainTile.texture);
17681768+ } else {
17691769+ Rasterizer3D.drawTexturedTriangle(screenYD, screenYC, screenYB, screenXD, screenXC, screenXB, plainTile.colourD, plainTile.colourC,
17701770+ plainTile.colourB, xD, xC, xB, zC, zD, zB, yD, yC, yB, plainTile.texture);
17711771+ }
17721772+ } else {
17731773+ int rgb = textureRGB[plainTile.texture];
17741774+ Rasterizer3D.drawShadedTriangle(screenYD, screenYC, screenYB, screenXD, screenXC, screenXB, mixColours(rgb, plainTile.colourD), mixColours(
17751775+ rgb, plainTile.colourC), mixColours(rgb, plainTile.colourB));
17761776+ }
17771777+ }
17781778+ if ((screenXA - screenXB) * (screenYC - screenYB) - (screenYA - screenYB) * (screenXC - screenXB) > 0) {
17791779+ Rasterizer3D.restrictEdges = screenXA < 0 || screenXB < 0 || screenXC < 0 || screenXA > Rasterizer.virtualBottomX || screenXB > Rasterizer.virtualBottomX
17801780+ || screenXC > Rasterizer.virtualBottomX;
17811781+ if (clicked && isMouseWithinTriangle(clickX, clickY, screenYA, screenYB, screenYC, screenXA, screenXB, screenXC)) {
17821782+ clickedTileX = tileX;
17831783+ clickedTileY = tileY;
17841784+ }
17851785+ if (plainTile.texture == -1) {
17861786+ if (plainTile.colourA != 0xbc614e) {
17871787+ Rasterizer3D.drawShadedTriangle(screenYA, screenYB, screenYC, screenXA, screenXB, screenXC, plainTile.colourA, plainTile.colourB,
17881788+ plainTile.colourC);
17891789+ }
17901790+ } else {
17911791+ if (!lowMemory) {
17921792+ Rasterizer3D.drawTexturedTriangle(screenYA, screenYB, screenYC, screenXA, screenXB, screenXC, plainTile.colourA, plainTile.colourB,
17931793+ plainTile.colourC, xA, xB, xC, zA, zB, zD, yA, yB, yC, plainTile.texture);
17941794+ return;
17951795+ }
17961796+ int rgb = textureRGB[plainTile.texture];
17971797+ Rasterizer3D.drawShadedTriangle(screenYA, screenYB, screenYC, screenXA, screenXB, screenXC, mixColours(rgb, plainTile.colourA), mixColours(
17981798+ rgb, plainTile.colourB), mixColours(rgb, plainTile.colourC));
17991799+ }
18001800+ }
18011801+ }
1660180216611661- public void method283(int i, int j, ComplexTile complexTile, int k, int l, int i1, int j1, byte byte0) {
16621662- int k1 = complexTile.anIntArray403.length;
16631663- for (int l1 = 0; l1 < k1; l1++) {
16641664- int i2 = complexTile.anIntArray403[l1] - anInt470;
16651665- int k2 = complexTile.anIntArray404[l1] - anInt471;
16661666- int i3 = complexTile.anIntArray405[l1] - anInt472;
16671667- int k3 = i3 * j1 + i2 * j >> 16;
16681668- i3 = i3 * j - i2 * j1 >> 16;
16691669- i2 = k3;
16701670- k3 = k2 * i - i3 * k >> 16;
16711671- i3 = k2 * k + i3 * i >> 16;
16721672- k2 = k3;
16731673- if (i3 < 50)
16741674- return;
16751675- if (complexTile.anIntArray412 != null) {
16761676- ComplexTile.anIntArray420[l1] = i2;
16771677- ComplexTile.anIntArray421[l1] = k2;
16781678- ComplexTile.anIntArray422[l1] = i3;
16791679- }
16801680- ComplexTile.anIntArray418[l1] = Rasterizer3D.centerX + (i2 << 9) / i3;
16811681- ComplexTile.anIntArray419[l1] = Rasterizer3D.centerY + (k2 << 9) / i3;
16821682- }
18031803+ private void renderShapedTile(ComplexTile shapedTile, int tileX, int tileY, int sineX, int cosineX, int sineY, int cosineY) {
18041804+ int triangleCount = shapedTile.originalVertexX.length;
18051805+ for (int triangle = 0; triangle < triangleCount; triangle++) {
18061806+ int viewspaceX = shapedTile.originalVertexX[triangle] - cameraPosX;
18071807+ int viewspaceY = shapedTile.originalVertexY[triangle] - cameraPosZ;
18081808+ int viewspaceZ = shapedTile.originalVertexZ[triangle] - cameraPosY;
18091809+ int temp = viewspaceZ * sineX + viewspaceX * cosineX >> 16;
18101810+ viewspaceZ = viewspaceZ * cosineX - viewspaceX * sineX >> 16;
18111811+ viewspaceX = temp;
18121812+ temp = viewspaceY * cosineY - viewspaceZ * sineY >> 16;
18131813+ viewspaceZ = viewspaceY * sineY + viewspaceZ * cosineY >> 16;
18141814+ viewspaceY = temp;
18151815+ if (viewspaceZ < 50) {
18161816+ return;
18171817+ }
18181818+ if (shapedTile.triangleTexture != null) {
18191819+ ComplexTile.viewspaceX[triangle] = viewspaceX;
18201820+ ComplexTile.viewspaceY[triangle] = viewspaceY;
18211821+ ComplexTile.viewspaceZ[triangle] = viewspaceZ;
18221822+ }
18231823+ ComplexTile.screenX[triangle] = Rasterizer3D.centerX + (viewspaceX << 9) / viewspaceZ;
18241824+ ComplexTile.screenY[triangle] = Rasterizer3D.centerY + (viewspaceY << 9) / viewspaceZ;
18251825+ }
1683182616841684- Rasterizer3D.anInt1531 = 0;
16851685- k1 = complexTile.anIntArray409.length;
16861686- if (byte0 != 3)
16871687- return;
16881688- for (int j2 = 0; j2 < k1; j2++) {
16891689- int l2 = complexTile.anIntArray409[j2];
16901690- int j3 = complexTile.anIntArray410[j2];
16911691- int l3 = complexTile.anIntArray411[j2];
16921692- int i4 = ComplexTile.anIntArray418[l2];
16931693- int j4 = ComplexTile.anIntArray418[j3];
16941694- int k4 = ComplexTile.anIntArray418[l3];
16951695- int l4 = ComplexTile.anIntArray419[l2];
16961696- int i5 = ComplexTile.anIntArray419[j3];
16971697- int j5 = ComplexTile.anIntArray419[l3];
16981698- if ((i4 - j4) * (j5 - i5) - (l4 - i5) * (k4 - j4) > 0) {
16991699- Rasterizer3D.aBoolean1528 = false;
17001700- if (i4 < 0 || j4 < 0 || k4 < 0 || i4 > Rasterizer.virtualBottomX || j4 > Rasterizer.virtualBottomX
17011701- || k4 > Rasterizer.virtualBottomX)
17021702- Rasterizer3D.aBoolean1528 = true;
17031703- if (aBoolean482 && method285(anInt483, anInt484, l4, i5, j5, i4, j4, k4)) {
17041704- clickedTileX = i1;
17051705- anInt486 = l;
17061706- }
17071707- if (complexTile.anIntArray412 == null || complexTile.anIntArray412[j2] == -1) {
17081708- if (complexTile.anIntArray406[j2] != 0xbc614e)
17091709- Rasterizer3D.method503(l4, i5, j5, i4, j4, k4, complexTile.anIntArray406[j2],
17101710- complexTile.anIntArray407[j2], complexTile.anIntArray408[j2]);
17111711- } else if (!lowMemory) {
17121712- if (complexTile.aBoolean413)
17131713- Rasterizer3D.method507(l4, i5, j5, i4, j4, k4, complexTile.anIntArray406[j2],
17141714- complexTile.anIntArray407[j2], complexTile.anIntArray408[j2], ComplexTile.anIntArray420[0],
17151715- ComplexTile.anIntArray420[1], ComplexTile.anIntArray420[3], ComplexTile.anIntArray421[0],
17161716- ComplexTile.anIntArray421[1], ComplexTile.anIntArray421[3], ComplexTile.anIntArray422[0],
17171717- ComplexTile.anIntArray422[1], ComplexTile.anIntArray422[3], complexTile.anIntArray412[j2]);
17181718- else
17191719- Rasterizer3D.method507(l4, i5, j5, i4, j4, k4, complexTile.anIntArray406[j2],
17201720- complexTile.anIntArray407[j2], complexTile.anIntArray408[j2], ComplexTile.anIntArray420[l2],
17211721- ComplexTile.anIntArray420[j3], ComplexTile.anIntArray420[l3], ComplexTile.anIntArray421[l2],
17221722- ComplexTile.anIntArray421[j3], ComplexTile.anIntArray421[l3], ComplexTile.anIntArray422[l2],
17231723- ComplexTile.anIntArray422[j3], ComplexTile.anIntArray422[l3], complexTile.anIntArray412[j2]);
17241724- } else {
17251725- int k5 = anIntArray500[complexTile.anIntArray412[j2]];
17261726- Rasterizer3D.method503(l4, i5, j5, i4, j4, k4,
17271727- method284(complexTile.anIntArray406[j2], k5, 0), method284(complexTile.anIntArray407[j2], k5, 0),
17281728- method284(complexTile.anIntArray408[j2], k5, 0));
17291729- }
17301730- }
17311731- }
18271827+ Rasterizer3D.alpha = 0;
18281828+ triangleCount = shapedTile.triangleA.length;
18291829+ for (int tirangle = 0; tirangle < triangleCount; tirangle++) {
18301830+ int a = shapedTile.triangleA[tirangle];
18311831+ int b = shapedTile.triangleB[tirangle];
18321832+ int c = shapedTile.triangleC[tirangle];
18331833+ int screenXA = ComplexTile.screenX[a];
18341834+ int screenXB = ComplexTile.screenX[b];
18351835+ int screenXC = ComplexTile.screenX[c];
18361836+ int screenYA = ComplexTile.screenY[a];
18371837+ int screenYB = ComplexTile.screenY[b];
18381838+ int screenYC = ComplexTile.screenY[c];
18391839+ if ((screenXA - screenXB) * (screenYC - screenYB) - (screenYA - screenYB) * (screenXC - screenXB) > 0) {
18401840+ Rasterizer3D.restrictEdges = screenXA < 0 || screenXB < 0 || screenXC < 0 || screenXA > Rasterizer.virtualBottomX || screenXB > Rasterizer.virtualBottomX
18411841+ || screenXC > Rasterizer.virtualBottomX;
18421842+ if (clicked && isMouseWithinTriangle(clickX, clickY, screenYA, screenYB, screenYC, screenXA, screenXB, screenXC)) {
18431843+ clickedTileX = tileX;
18441844+ clickedTileY = tileY;
18451845+ }
18461846+ if (shapedTile.triangleTexture == null || shapedTile.triangleTexture[tirangle] == -1) {
18471847+ if (shapedTile.triangleHSLA[tirangle] != 0xbc614e) {
18481848+ Rasterizer3D.drawShadedTriangle(screenYA, screenYB, screenYC, screenXA, screenXB, screenXC, shapedTile.triangleHSLA[tirangle],
18491849+ shapedTile.triangleHSLB[tirangle], shapedTile.triangleHSLC[tirangle]);
18501850+ }
18511851+ } else if (!lowMemory) {
18521852+ if (shapedTile.flat) {
18531853+ Rasterizer3D.drawTexturedTriangle(screenYA, screenYB, screenYC, screenXA, screenXB, screenXC, shapedTile.triangleHSLA[tirangle],
18541854+ shapedTile.triangleHSLB[tirangle], shapedTile.triangleHSLC[tirangle], ComplexTile.viewspaceX[0],
18551855+ ComplexTile.viewspaceX[1], ComplexTile.viewspaceX[3], ComplexTile.viewspaceY[0],
18561856+ ComplexTile.viewspaceY[1], ComplexTile.viewspaceY[3], ComplexTile.viewspaceZ[0],
18571857+ ComplexTile.viewspaceZ[1], ComplexTile.viewspaceZ[3], shapedTile.triangleTexture[tirangle]);
18581858+ } else {
18591859+ Rasterizer3D.drawTexturedTriangle(screenYA, screenYB, screenYC, screenXA, screenXB, screenXC, shapedTile.triangleHSLA[tirangle],
18601860+ shapedTile.triangleHSLB[tirangle], shapedTile.triangleHSLC[tirangle], ComplexTile.viewspaceX[a],
18611861+ ComplexTile.viewspaceX[b], ComplexTile.viewspaceX[c], ComplexTile.viewspaceY[a],
18621862+ ComplexTile.viewspaceY[b], ComplexTile.viewspaceY[c], ComplexTile.viewspaceZ[a],
18631863+ ComplexTile.viewspaceZ[b], ComplexTile.viewspaceZ[c], shapedTile.triangleTexture[tirangle]);
18641864+ }
18651865+ } else {
18661866+ int k5 = textureRGB[shapedTile.triangleTexture[tirangle]];
18671867+ Rasterizer3D.drawShadedTriangle(screenYA, screenYB, screenYC, screenXA, screenXB, screenXC,
18681868+ mixColours(k5, shapedTile.triangleHSLA[tirangle]), mixColours(k5, shapedTile.triangleHSLB[tirangle]),
18691869+ mixColours(k5, shapedTile.triangleHSLC[tirangle]));
18701870+ }
18711871+ }
18721872+ }
1732187317331733- }
18741874+ }
1734187517351735- public int method284(int i, int j, int k) {
17361736- i = 127 - i;
17371737- i = (i * (j & 0x7f)) / 160;
17381738- if (i < 2)
17391739- i = 2;
17401740- else if (i > 126)
17411741- i = 126;
17421742- return (j & 0xff80) + i;
17431743- }
18761876+ private int mixColours(int colourA, int colourB) {
18771877+ colourB = 127 - colourB;
18781878+ colourB = (colourB * (colourA & 0x7f)) / 160;
18791879+ if (colourB < 2) {
18801880+ colourB = 2;
18811881+ } else if (colourB > 126) {
18821882+ colourB = 126;
18831883+ }
18841884+ return (colourA & 0xff80) + colourB;
18851885+ }
1744188617451745- public boolean method285(int i, int j, int k, int l, int i1, int j1, int k1, int l1) {
17461746- if (j < k && j < l && j < i1)
17471747- return false;
17481748- if (j > k && j > l && j > i1)
17491749- return false;
17501750- if (i < j1 && i < k1 && i < l1)
17511751- return false;
17521752- if (i > j1 && i > k1 && i > l1)
17531753- return false;
17541754- int i2 = (j - k) * (k1 - j1) - (i - j1) * (l - k);
17551755- int j2 = (j - i1) * (j1 - l1) - (i - l1) * (k - i1);
17561756- int k2 = (j - l) * (l1 - k1) - (i - k1) * (i1 - l);
17571757- return i2 * k2 > 0 && k2 * j2 > 0;
17581758- }
18871887+ private boolean isMouseWithinTriangle(int mouseX, int mouseY, int pointAY, int pointBY, int pointCY, int pointAX, int pointBX, int pointCX) {
18881888+ if (mouseY < pointAY && mouseY < pointBY && mouseY < pointCY) {
18891889+ return false;
18901890+ }
18911891+ if (mouseY > pointAY && mouseY > pointBY && mouseY > pointCY) {
18921892+ return false;
18931893+ }
18941894+ if (mouseX < pointAX && mouseX < pointBX && mouseX < pointCX) {
18951895+ return false;
18961896+ }
18971897+ if (mouseX > pointAX && mouseX > pointBX && mouseX > pointCX) {
18981898+ return false;
18991899+ }
19001900+ int b1 = (mouseY - pointAY) * (pointBX - pointAX) - (mouseX - pointAX) * (pointBY - pointAY);
19011901+ int b2 = (mouseY - pointCY) * (pointAX - pointCX) - (mouseX - pointCX) * (pointAY - pointCY);
19021902+ int b3 = (mouseY - pointBY) * (pointCX - pointBX) - (mouseX - pointBX) * (pointCY - pointBY);
19031903+ return b1 * b3 > 0 && b3 * b2 > 0;
19041904+ }
1759190517601760- public void method286() {
17611761- int j = anIntArray488[anInt462];
17621762- SceneCluster aclass39[] = aSceneClusterArrayArray554[anInt462];
17631763- anInt490 = 0;
17641764- for (int k = 0; k < j; k++) {
17651765- SceneCluster class39 = aclass39[k];
17661766- if (class39.anInt679 == 1) {
17671767- int l = (class39.anInt675 - anInt468) + 25;
17681768- if (l < 0 || l > 50)
17691769- continue;
17701770- int k1 = (class39.anInt677 - anInt469) + 25;
17711771- if (k1 < 0)
17721772- k1 = 0;
17731773- int j2 = (class39.anInt678 - anInt469) + 25;
17741774- if (j2 > 50)
17751775- j2 = 50;
17761776- boolean flag = false;
17771777- while (k1 <= j2)
17781778- if (aBooleanArrayArray507[l][k1++]) {
17791779- flag = true;
17801780- break;
17811781- }
17821782- if (!flag)
17831783- continue;
17841784- int j3 = anInt470 - class39.anInt680;
17851785- if (j3 > 32) {
17861786- class39.anInt686 = 1;
17871787- } else {
17881788- if (j3 >= -32)
17891789- continue;
17901790- class39.anInt686 = 2;
17911791- j3 = -j3;
17921792- }
17931793- class39.anInt689 = (class39.anInt682 - anInt472 << 8) / j3;
17941794- class39.anInt690 = (class39.anInt683 - anInt472 << 8) / j3;
17951795- class39.anInt691 = (class39.anInt684 - anInt471 << 8) / j3;
17961796- class39.anInt692 = (class39.anInt685 - anInt471 << 8) / j3;
17971797- aClass39Array491[anInt490++] = class39;
17981798- continue;
17991799- }
18001800- if (class39.anInt679 == 2) {
18011801- int i1 = (class39.anInt677 - anInt469) + 25;
18021802- if (i1 < 0 || i1 > 50)
18031803- continue;
18041804- int l1 = (class39.anInt675 - anInt468) + 25;
18051805- if (l1 < 0)
18061806- l1 = 0;
18071807- int k2 = (class39.anInt676 - anInt468) + 25;
18081808- if (k2 > 50)
18091809- k2 = 50;
18101810- boolean flag1 = false;
18111811- while (l1 <= k2)
18121812- if (aBooleanArrayArray507[l1++][i1]) {
18131813- flag1 = true;
18141814- break;
18151815- }
18161816- if (!flag1)
18171817- continue;
18181818- int k3 = anInt472 - class39.anInt682;
18191819- if (k3 > 32) {
18201820- class39.anInt686 = 3;
18211821- } else {
18221822- if (k3 >= -32)
18231823- continue;
18241824- class39.anInt686 = 4;
18251825- k3 = -k3;
18261826- }
18271827- class39.anInt687 = (class39.anInt680 - anInt470 << 8) / k3;
18281828- class39.anInt688 = (class39.anInt681 - anInt470 << 8) / k3;
18291829- class39.anInt691 = (class39.anInt684 - anInt471 << 8) / k3;
18301830- class39.anInt692 = (class39.anInt685 - anInt471 << 8) / k3;
18311831- aClass39Array491[anInt490++] = class39;
18321832- } else if (class39.anInt679 == 4) {
18331833- int j1 = class39.anInt684 - anInt471;
18341834- if (j1 > 128) {
18351835- int i2 = (class39.anInt677 - anInt469) + 25;
18361836- if (i2 < 0)
18371837- i2 = 0;
18381838- int l2 = (class39.anInt678 - anInt469) + 25;
18391839- if (l2 > 50)
18401840- l2 = 50;
18411841- if (i2 <= l2) {
18421842- int i3 = (class39.anInt675 - anInt468) + 25;
18431843- if (i3 < 0)
18441844- i3 = 0;
18451845- int l3 = (class39.anInt676 - anInt468) + 25;
18461846- if (l3 > 50)
18471847- l3 = 50;
18481848- boolean flag2 = false;
18491849- label0: for (int i4 = i3; i4 <= l3; i4++) {
18501850- for (int j4 = i2; j4 <= l2; j4++) {
18511851- if (!aBooleanArrayArray507[i4][j4])
18521852- continue;
18531853- flag2 = true;
18541854- break label0;
18551855- }
19061906+ private void processCulling() {
19071907+ int clusterCount = cullingClusterPointer[plane];
19081908+ SceneCluster[] clusters = cullingClusters[plane];
19091909+ processedCullingClustersPointer = 0;
19101910+ for (int c = 0; c < clusterCount; c++) {
19111911+ SceneCluster cluster = clusters[c];
19121912+ if (cluster.searchMask == 1) {
19131913+ int distanceFromCameraStartX = (cluster.tileStartX - cameraPositionTileX) + 25;
19141914+ if (distanceFromCameraStartX < 0 || distanceFromCameraStartX > 50) {
19151915+ continue;
19161916+ }
19171917+ int distanceFromCameraStartY = (cluster.tileStartY - cameraPositionTileY) + 25;
19181918+ if (distanceFromCameraStartY < 0) {
19191919+ distanceFromCameraStartY = 0;
19201920+ }
19211921+ int cameraPositionTileY = (cluster.tileEndY - Scene.cameraPositionTileY) + 25;
19221922+ if (cameraPositionTileY > 50) {
19231923+ cameraPositionTileY = 50;
19241924+ }
19251925+ boolean visible = false;
19261926+ while (distanceFromCameraStartY <= cameraPositionTileY) {
19271927+ if (TILE_VISIBILITY_MAP[distanceFromCameraStartX][distanceFromCameraStartY++]) {
19281928+ visible = true;
19291929+ break;
19301930+ }
19311931+ }
19321932+ if (!visible) {
19331933+ continue;
19341934+ }
19351935+ int realDistanceFromCameraStartX = cameraPosX - cluster.worldStartX;
19361936+ if (realDistanceFromCameraStartX > 32) {
19371937+ cluster.tileDistanceEnum = 1;
19381938+ } else {
19391939+ if (realDistanceFromCameraStartX >= -32) {
19401940+ continue;
19411941+ }
19421942+ cluster.tileDistanceEnum = 2;
19431943+ realDistanceFromCameraStartX = -realDistanceFromCameraStartX;
19441944+ }
19451945+ cluster.worldDistanceFromCameraStartY = (cluster.worldStartY - cameraPosY << 8) / realDistanceFromCameraStartX;
19461946+ cluster.worldDistanceFromCameraEndY = (cluster.worldEndY - cameraPosY << 8) / realDistanceFromCameraStartX;
19471947+ cluster.worldDistanceFromCameraStartZ = (cluster.worldEndZ - cameraPosZ << 8) / realDistanceFromCameraStartX;
19481948+ cluster.worldDistanceFromCameraEndZ = (cluster.worldStartZ - cameraPosZ << 8) / realDistanceFromCameraStartX;
19491949+ processedCullingClusters[processedCullingClustersPointer++] = cluster;
19501950+ continue;
19511951+ }
19521952+ if (cluster.searchMask == 2) {
19531953+ int distanceFromCameraStartY = (cluster.tileStartY - cameraPositionTileY) + 25;
19541954+ if (distanceFromCameraStartY < 0 || distanceFromCameraStartY > 50) {
19551955+ continue;
19561956+ }
19571957+ int distanceFromCameraStartX = (cluster.tileStartX - cameraPositionTileX) + 25;
19581958+ if (distanceFromCameraStartX < 0) {
19591959+ distanceFromCameraStartX = 0;
19601960+ }
19611961+ int distanceFromCameraEndX = (cluster.tileEndX - cameraPositionTileX) + 25;
19621962+ if (distanceFromCameraEndX > 50) {
19631963+ distanceFromCameraEndX = 50;
19641964+ }
19651965+ boolean visible = false;
19661966+ while (distanceFromCameraStartX <= distanceFromCameraEndX) {
19671967+ if (TILE_VISIBILITY_MAP[distanceFromCameraStartX++][distanceFromCameraStartY]) {
19681968+ visible = true;
19691969+ break;
19701970+ }
19711971+ }
19721972+ if (!visible) {
19731973+ continue;
19741974+ }
19751975+ int realDistanceFromCameraStartY = cameraPosY - cluster.worldStartY;
19761976+ if (realDistanceFromCameraStartY > 32) {
19771977+ cluster.tileDistanceEnum = 3;
19781978+ } else {
19791979+ if (realDistanceFromCameraStartY >= -32) {
19801980+ continue;
19811981+ }
19821982+ cluster.tileDistanceEnum = 4;
19831983+ realDistanceFromCameraStartY = -realDistanceFromCameraStartY;
19841984+ }
19851985+ cluster.worldDistanceFromCameraStartX = (cluster.worldStartX - cameraPosX << 8) / realDistanceFromCameraStartY;
19861986+ cluster.worldDistanceFromCameraEndX = (cluster.worldEndX - cameraPosX << 8) / realDistanceFromCameraStartY;
19871987+ cluster.worldDistanceFromCameraStartZ = (cluster.worldEndZ - cameraPosZ << 8) / realDistanceFromCameraStartY;
19881988+ cluster.worldDistanceFromCameraEndZ = (cluster.worldStartZ - cameraPosZ << 8) / realDistanceFromCameraStartY;
19891989+ processedCullingClusters[processedCullingClustersPointer++] = cluster;
19901990+ } else if (cluster.searchMask == 4) {
19911991+ int realDistanceFromCameraStartZ = cluster.worldEndZ - cameraPosZ;
19921992+ if (realDistanceFromCameraStartZ > 128) {
19931993+ int distanceFromCameraStartY = (cluster.tileStartY - cameraPositionTileY) + 25;
19941994+ if (distanceFromCameraStartY < 0) {
19951995+ distanceFromCameraStartY = 0;
19961996+ }
19971997+ int distanceFromCameraEndY = (cluster.tileEndY - cameraPositionTileY) + 25;
19981998+ if (distanceFromCameraEndY > 50) {
19991999+ distanceFromCameraEndY = 50;
20002000+ }
20012001+ if (distanceFromCameraStartY <= distanceFromCameraEndY) {
20022002+ int distanceFromCameraStartX = (cluster.tileStartX - cameraPositionTileX) + 25;
20032003+ if (distanceFromCameraStartX < 0) {
20042004+ distanceFromCameraStartX = 0;
20052005+ }
20062006+ int distanceFromCameraEndX = (cluster.tileEndX - cameraPositionTileX) + 25;
20072007+ if (distanceFromCameraEndX > 50) {
20082008+ distanceFromCameraEndX = 50;
20092009+ }
20102010+ boolean visible = false;
20112011+ label0:
20122012+ for (int x = distanceFromCameraStartX; x <= distanceFromCameraEndX; x++) {
20132013+ for (int y = distanceFromCameraStartY; y <= distanceFromCameraEndY; y++) {
20142014+ if (!TILE_VISIBILITY_MAP[x][y]) {
20152015+ continue;
20162016+ }
20172017+ visible = true;
20182018+ break label0;
20192019+ }
1856202018571857- }
20212021+ }
1858202218591859- if (flag2) {
18601860- class39.anInt686 = 5;
18611861- class39.anInt687 = (class39.anInt680 - anInt470 << 8) / j1;
18621862- class39.anInt688 = (class39.anInt681 - anInt470 << 8) / j1;
18631863- class39.anInt689 = (class39.anInt682 - anInt472 << 8) / j1;
18641864- class39.anInt690 = (class39.anInt683 - anInt472 << 8) / j1;
18651865- aClass39Array491[anInt490++] = class39;
18661866- }
18671867- }
18681868- }
18691869- }
18701870- }
20232023+ if (visible) {
20242024+ cluster.tileDistanceEnum = 5;
20252025+ cluster.worldDistanceFromCameraStartX = (cluster.worldStartX - cameraPosX << 8) / realDistanceFromCameraStartZ;
20262026+ cluster.worldDistanceFromCameraEndX = (cluster.worldEndX - cameraPosX << 8) / realDistanceFromCameraStartZ;
20272027+ cluster.worldDistanceFromCameraStartY = (cluster.worldStartY - cameraPosY << 8) / realDistanceFromCameraStartZ;
20282028+ cluster.worldDistanceFromCameraEndY = (cluster.worldEndY - cameraPosY << 8) / realDistanceFromCameraStartZ;
20292029+ processedCullingClusters[processedCullingClustersPointer++] = cluster;
20302030+ }
20312031+ }
20322032+ }
20332033+ }
20342034+ }
1871203518721872- }
20362036+ }
1873203718741874- public boolean method287(int i, int j, int k) {
18751875- int l = anIntArrayArrayArray460[i][j][k];
18761876- if (l == -anInt463)
18771877- return false;
18781878- if (l == anInt463)
18791879- return true;
18801880- int i1 = j << 7;
18811881- int j1 = k << 7;
18821882- if (method291(i1 + 1, anIntArrayArrayArray455[i][j][k], j1 + 1)
18831883- && method291((i1 + 128) - 1, anIntArrayArrayArray455[i][j + 1][k], j1 + 1)
18841884- && method291((i1 + 128) - 1, anIntArrayArrayArray455[i][j + 1][k + 1], (j1 + 128) - 1)
18851885- && method291(i1 + 1, anIntArrayArrayArray455[i][j][k + 1], (j1 + 128) - 1)) {
18861886- anIntArrayArrayArray460[i][j][k] = anInt463;
18871887- return true;
18881888- } else {
18891889- anIntArrayArrayArray460[i][j][k] = -anInt463;
18901890- return false;
18911891- }
18921892- }
20382038+ private boolean isTileOccluded(int x, int y, int z) {
20392039+ int l = anIntArrayArrayArray460[z][x][y];
20402040+ if (l == -cycle) {
20412041+ return false;
20422042+ }
20432043+ if (l == cycle) {
20442044+ return true;
20452045+ }
20462046+ int worldX = x << 7;
20472047+ int worldY = y << 7;
20482048+ if (method291(worldX + 1, worldY + 1, heightMap[z][x][y])
20492049+ && method291((worldX + 128) - 1, worldY + 1, heightMap[z][x + 1][y])
20502050+ && method291((worldX + 128) - 1, (worldY + 128) - 1, heightMap[z][x + 1][y + 1])
20512051+ && method291(worldX + 1, (worldY + 128) - 1, heightMap[z][x][y + 1])) {
20522052+ anIntArrayArrayArray460[z][x][y] = cycle;
20532053+ return true;
20542054+ } else {
20552055+ anIntArrayArrayArray460[z][x][y] = -cycle;
20562056+ return false;
20572057+ }
20582058+ }
1893205918941894- public boolean method288(int i, int j, int k, int l) {
18951895- if (!method287(i, j, k))
18961896- return false;
18971897- int i1 = j << 7;
18981898- int j1 = k << 7;
18991899- int k1 = anIntArrayArrayArray455[i][j][k] - 1;
19001900- int l1 = k1 - 120;
19011901- int i2 = k1 - 230;
19021902- int j2 = k1 - 238;
19031903- if (l < 16) {
19041904- if (l == 1) {
19051905- if (i1 > anInt470) {
19061906- if (!method291(i1, k1, j1))
19071907- return false;
19081908- if (!method291(i1, k1, j1 + 128))
19091909- return false;
19101910- }
19111911- if (i > 0) {
19121912- if (!method291(i1, l1, j1))
19131913- return false;
19141914- if (!method291(i1, l1, j1 + 128))
19151915- return false;
19161916- }
19171917- if (!method291(i1, i2, j1))
19181918- return false;
19191919- return method291(i1, i2, j1 + 128);
19201920- }
19211921- if (l == 2) {
19221922- if (j1 < anInt472) {
19231923- if (!method291(i1, k1, j1 + 128))
19241924- return false;
19251925- if (!method291(i1 + 128, k1, j1 + 128))
19261926- return false;
19271927- }
19281928- if (i > 0) {
19291929- if (!method291(i1, l1, j1 + 128))
19301930- return false;
19311931- if (!method291(i1 + 128, l1, j1 + 128))
19321932- return false;
19331933- }
19341934- if (!method291(i1, i2, j1 + 128))
19351935- return false;
19361936- return method291(i1 + 128, i2, j1 + 128);
19371937- }
19381938- if (l == 4) {
19391939- if (i1 < anInt470) {
19401940- if (!method291(i1 + 128, k1, j1))
19411941- return false;
19421942- if (!method291(i1 + 128, k1, j1 + 128))
19431943- return false;
19441944- }
19451945- if (i > 0) {
19461946- if (!method291(i1 + 128, l1, j1))
19471947- return false;
19481948- if (!method291(i1 + 128, l1, j1 + 128))
19491949- return false;
19501950- }
19511951- if (!method291(i1 + 128, i2, j1))
19521952- return false;
19531953- return method291(i1 + 128, i2, j1 + 128);
19541954- }
19551955- if (l == 8) {
19561956- if (j1 > anInt472) {
19571957- if (!method291(i1, k1, j1))
19581958- return false;
19591959- if (!method291(i1 + 128, k1, j1))
19601960- return false;
19611961- }
19621962- if (i > 0) {
19631963- if (!method291(i1, l1, j1))
19641964- return false;
19651965- if (!method291(i1 + 128, l1, j1))
19661966- return false;
19671967- }
19681968- if (!method291(i1, i2, j1))
19691969- return false;
19701970- return method291(i1 + 128, i2, j1);
19711971- }
19721972- }
19731973- if (!method291(i1 + 64, j2, j1 + 64))
19741974- return false;
19751975- if (l == 16)
19761976- return method291(i1, i2, j1 + 128);
19771977- if (l == 32)
19781978- return method291(i1 + 128, i2, j1 + 128);
19791979- if (l == 64)
19801980- return method291(i1 + 128, i2, j1);
19811981- if (l == 128) {
19821982- return method291(i1, i2, j1);
19831983- } else {
19841984- System.out.println("Warning unsupported wall type");
19851985- return true;
19861986- }
19871987- }
20602060+ private boolean isWallOccluded(int x, int y, int level, int wallType) {
20612061+ if (!isTileOccluded(x, y, level)) {
20622062+ return false;
20632063+ }
20642064+ int posX = x << 7;
20652065+ int posY = y << 7;
20662066+ int posZ = heightMap[level][x][y] - 1;
20672067+ int z1 = posZ - 120;
20682068+ int z2 = posZ - 230;
20692069+ int z3 = posZ - 238;
20702070+ if (wallType < 16) {
20712071+ if (wallType == 1) {
20722072+ if (posX > cameraPosX) {
20732073+ if (!method291(posX, posY, posZ)) {
20742074+ return false;
20752075+ }
20762076+ if (!method291(posX, posY + 128, posZ)) {
20772077+ return false;
20782078+ }
20792079+ }
20802080+ if (level > 0) {
20812081+ if (!method291(posX, posY, z1)) {
20822082+ return false;
20832083+ }
20842084+ if (!method291(posX, posY + 128, z1)) {
20852085+ return false;
20862086+ }
20872087+ }
20882088+ if (!method291(posX, posY, z2)) {
20892089+ return false;
20902090+ }
20912091+ return method291(posX, posY + 128, z2);
20922092+ }
20932093+ if (wallType == 2) {
20942094+ if (posY < cameraPosY) {
20952095+ if (!method291(posX, posY + 128, posZ)) {
20962096+ return false;
20972097+ }
20982098+ if (!method291(posX + 128, posY + 128, posZ)) {
20992099+ return false;
21002100+ }
21012101+ }
21022102+ if (level > 0) {
21032103+ if (!method291(posX, posY + 128, z1)) {
21042104+ return false;
21052105+ }
21062106+ if (!method291(posX + 128, posY + 128, z1)) {
21072107+ return false;
21082108+ }
21092109+ }
21102110+ if (!method291(posX, posY + 128, z2)) {
21112111+ return false;
21122112+ }
21132113+ return method291(posX + 128, posY + 128, z2);
21142114+ }
21152115+ if (wallType == 4) {
21162116+ if (posX < cameraPosX) {
21172117+ if (!method291(posX + 128, posY, posZ)) {
21182118+ return false;
21192119+ }
21202120+ if (!method291(posX + 128, posY + 128, posZ)) {
21212121+ return false;
21222122+ }
21232123+ }
21242124+ if (level > 0) {
21252125+ if (!method291(posX + 128, posY, z1)) {
21262126+ return false;
21272127+ }
21282128+ if (!method291(posX + 128, posY + 128, z1)) {
21292129+ return false;
21302130+ }
21312131+ }
21322132+ if (!method291(posX + 128, posY, z2)) {
21332133+ return false;
21342134+ }
21352135+ return method291(posX + 128, posY + 128, z2);
21362136+ }
21372137+ if (wallType == 8) {
21382138+ if (posY > cameraPosY) {
21392139+ if (!method291(posX, posY, posZ)) {
21402140+ return false;
21412141+ }
21422142+ if (!method291(posX + 128, posY, posZ)) {
21432143+ return false;
21442144+ }
21452145+ }
21462146+ if (level > 0) {
21472147+ if (!method291(posX, posY, z1)) {
21482148+ return false;
21492149+ }
21502150+ if (!method291(posX + 128, posY, z1)) {
21512151+ return false;
21522152+ }
21532153+ }
21542154+ if (!method291(posX, posY, z2)) {
21552155+ return false;
21562156+ }
21572157+ return method291(posX + 128, posY, z2);
21582158+ }
21592159+ }
21602160+ if (!method291(posX + 64, posY + 64, z3)) {
21612161+ return false;
21622162+ }
21632163+ if (wallType == 16) {
21642164+ return method291(posX, posY + 128, z2);
21652165+ }
21662166+ if (wallType == 32) {
21672167+ return method291(posX + 128, posY + 128, z2);
21682168+ }
21692169+ if (wallType == 64) {
21702170+ return method291(posX + 128, posY, z2);
21712171+ }
21722172+ if (wallType == 128) {
21732173+ return method291(posX, posY, z2);
21742174+ } else {
21752175+ System.out.println("Warning unsupported wall type");
21762176+ return true;
21772177+ }
21782178+ }
1988217919891989- public boolean method289(int i, int j, int k, int l) {
19901990- if (!method287(i, j, k))
19911991- return false;
19921992- int i1 = j << 7;
19931993- int j1 = k << 7;
19941994- return method291(i1 + 1, anIntArrayArrayArray455[i][j][k] - l, j1 + 1)
19951995- && method291((i1 + 128) - 1, anIntArrayArrayArray455[i][j + 1][k] - l, j1 + 1)
19961996- && method291((i1 + 128) - 1, anIntArrayArrayArray455[i][j + 1][k + 1] - l, (j1 + 128) - 1)
19971997- && method291(i1 + 1, anIntArrayArrayArray455[i][j][k + 1] - l, (j1 + 128) - 1);
19981998- }
21802180+ private boolean isOccluded(int i, int j, int k, int l) {
21812181+ if (!isTileOccluded(j, k, i)) {
21822182+ return false;
21832183+ }
21842184+ int i1 = j << 7;
21852185+ int j1 = k << 7;
21862186+ return method291(i1 + 1, j1 + 1, heightMap[i][j][k] - l)
21872187+ && method291((i1 + 128) - 1, j1 + 1, heightMap[i][j + 1][k] - l)
21882188+ && method291((i1 + 128) - 1, (j1 + 128) - 1, heightMap[i][j + 1][k + 1] - l)
21892189+ && method291(i1 + 1, (j1 + 128) - 1, heightMap[i][j][k + 1] - l);
21902190+ }
1999219120002000- public boolean method290(int i, int j, int k, int l, int i1, int j1) {
20012001- if (j == k && l == i1) {
20022002- if (!method287(i, j, l))
20032003- return false;
20042004- int k1 = j << 7;
20052005- int i2 = l << 7;
20062006- return method291(k1 + 1, anIntArrayArrayArray455[i][j][l] - j1, i2 + 1)
20072007- && method291((k1 + 128) - 1, anIntArrayArrayArray455[i][j + 1][l] - j1, i2 + 1)
20082008- && method291((k1 + 128) - 1, anIntArrayArrayArray455[i][j + 1][l + 1] - j1, (i2 + 128) - 1)
20092009- && method291(k1 + 1, anIntArrayArrayArray455[i][j][l + 1] - j1, (i2 + 128) - 1);
20102010- }
20112011- for (int l1 = j; l1 <= k; l1++) {
20122012- for (int j2 = l; j2 <= i1; j2++)
20132013- if (anIntArrayArrayArray460[i][l1][j2] == -anInt463)
20142014- return false;
21922192+ private boolean isAreaOccluded(int minimumX, int maximumX, int minimumY, int maximumY, int z, int offsetZ) {
21932193+ if (minimumX == maximumX && minimumY == maximumY) {
21942194+ if (!isTileOccluded(minimumX, minimumY, z)) {
21952195+ return false;
21962196+ }
21972197+ int _x = minimumX << 7;
21982198+ int _y = minimumY << 7;
21992199+ return method291(_x + 1, _y + 1, heightMap[z][minimumX][minimumY] - offsetZ)
22002200+ && method291((_x + 128) - 1, _y + 1, heightMap[z][minimumX + 1][minimumY] - offsetZ)
22012201+ && method291((_x + 128) - 1, (_y + 128) - 1, heightMap[z][minimumX + 1][minimumY + 1] - offsetZ)
22022202+ && method291(_x + 1, (_y + 128) - 1, heightMap[z][minimumX][minimumY + 1] - offsetZ);
22032203+ }
22042204+ for (int x = minimumX; x <= maximumX; x++) {
22052205+ for (int y = minimumY; y <= maximumY; y++) {
22062206+ if (anIntArrayArrayArray460[z][x][y] == -cycle) {
22072207+ return false;
22082208+ }
22092209+ }
2015221020162016- }
22112211+ }
2017221220182018- int k2 = (j << 7) + 1;
20192019- int l2 = (l << 7) + 2;
20202020- int i3 = anIntArrayArrayArray455[i][j][l] - j1;
20212021- if (!method291(k2, i3, l2))
20222022- return false;
20232023- int j3 = (k << 7) - 1;
20242024- if (!method291(j3, i3, l2))
20252025- return false;
20262026- int k3 = (i1 << 7) - 1;
20272027- if (!method291(k2, i3, k3))
20282028- return false;
20292029- return method291(j3, i3, k3);
20302030- }
22132213+ int _x = (minimumX << 7) + 1;
22142214+ int _y = (minimumY << 7) + 2;
22152215+ int _z = heightMap[z][minimumX][minimumY] - offsetZ;
22162216+ if (!method291(_x, _y, _z)) {
22172217+ return false;
22182218+ }
22192219+ int j3 = (maximumX << 7) - 1;
22202220+ if (!method291(j3, _y, _z)) {
22212221+ return false;
22222222+ }
22232223+ int k3 = (maximumY << 7) - 1;
22242224+ if (!method291(_x, k3, _z)) {
22252225+ return false;
22262226+ }
22272227+ return method291(j3, k3, _z);
22282228+ }
2031222920322032- public boolean method291(int i, int j, int k) {
20332033- for (int l = 0; l < anInt490; l++) {
20342034- SceneCluster class39 = aClass39Array491[l];
20352035- if (class39.anInt686 == 1) {
20362036- int i1 = class39.anInt680 - i;
20372037- if (i1 > 0) {
20382038- int j2 = class39.anInt682 + (class39.anInt689 * i1 >> 8);
20392039- int k3 = class39.anInt683 + (class39.anInt690 * i1 >> 8);
20402040- int l4 = class39.anInt684 + (class39.anInt691 * i1 >> 8);
20412041- int i6 = class39.anInt685 + (class39.anInt692 * i1 >> 8);
20422042- if (k >= j2 && k <= k3 && j >= l4 && j <= i6)
20432043- return true;
20442044- }
20452045- } else if (class39.anInt686 == 2) {
20462046- int j1 = i - class39.anInt680;
20472047- if (j1 > 0) {
20482048- int k2 = class39.anInt682 + (class39.anInt689 * j1 >> 8);
20492049- int l3 = class39.anInt683 + (class39.anInt690 * j1 >> 8);
20502050- int i5 = class39.anInt684 + (class39.anInt691 * j1 >> 8);
20512051- int j6 = class39.anInt685 + (class39.anInt692 * j1 >> 8);
20522052- if (k >= k2 && k <= l3 && j >= i5 && j <= j6)
20532053- return true;
20542054- }
20552055- } else if (class39.anInt686 == 3) {
20562056- int k1 = class39.anInt682 - k;
20572057- if (k1 > 0) {
20582058- int l2 = class39.anInt680 + (class39.anInt687 * k1 >> 8);
20592059- int i4 = class39.anInt681 + (class39.anInt688 * k1 >> 8);
20602060- int j5 = class39.anInt684 + (class39.anInt691 * k1 >> 8);
20612061- int k6 = class39.anInt685 + (class39.anInt692 * k1 >> 8);
20622062- if (i >= l2 && i <= i4 && j >= j5 && j <= k6)
20632063- return true;
20642064- }
20652065- } else if (class39.anInt686 == 4) {
20662066- int l1 = k - class39.anInt682;
20672067- if (l1 > 0) {
20682068- int i3 = class39.anInt680 + (class39.anInt687 * l1 >> 8);
20692069- int j4 = class39.anInt681 + (class39.anInt688 * l1 >> 8);
20702070- int k5 = class39.anInt684 + (class39.anInt691 * l1 >> 8);
20712071- int l6 = class39.anInt685 + (class39.anInt692 * l1 >> 8);
20722072- if (i >= i3 && i <= j4 && j >= k5 && j <= l6)
20732073- return true;
20742074- }
20752075- } else if (class39.anInt686 == 5) {
20762076- int i2 = j - class39.anInt684;
20772077- if (i2 > 0) {
20782078- int j3 = class39.anInt680 + (class39.anInt687 * i2 >> 8);
20792079- int k4 = class39.anInt681 + (class39.anInt688 * i2 >> 8);
20802080- int l5 = class39.anInt682 + (class39.anInt689 * i2 >> 8);
20812081- int i7 = class39.anInt683 + (class39.anInt690 * i2 >> 8);
20822082- if (i >= j3 && i <= k4 && k >= l5 && k <= i7)
20832083- return true;
20842084- }
20852085- }
20862086- }
22302230+ private boolean method291(int posX, int posY, int posZ) {
22312231+ for (int c = 0; c < processedCullingClustersPointer; c++) {
22322232+ SceneCluster cluster = processedCullingClusters[c];
22332233+ if (cluster.tileDistanceEnum == 1) {
22342234+ int i1 = cluster.worldStartX - posX;
22352235+ if (i1 > 0) {
22362236+ int j2 = cluster.worldStartY + (cluster.worldDistanceFromCameraStartY * i1 >> 8);
22372237+ int k3 = cluster.worldEndY + (cluster.worldDistanceFromCameraEndY * i1 >> 8);
22382238+ int l4 = cluster.worldEndZ + (cluster.worldDistanceFromCameraStartZ * i1 >> 8);
22392239+ int i6 = cluster.worldStartZ + (cluster.worldDistanceFromCameraEndZ * i1 >> 8);
22402240+ if (posY >= j2 && posY <= k3 && posZ >= l4 && posZ <= i6) {
22412241+ return true;
22422242+ }
22432243+ }
22442244+ } else if (cluster.tileDistanceEnum == 2) {
22452245+ int j1 = posX - cluster.worldStartX;
22462246+ if (j1 > 0) {
22472247+ int k2 = cluster.worldStartY + (cluster.worldDistanceFromCameraStartY * j1 >> 8);
22482248+ int l3 = cluster.worldEndY + (cluster.worldDistanceFromCameraEndY * j1 >> 8);
22492249+ int i5 = cluster.worldEndZ + (cluster.worldDistanceFromCameraStartZ * j1 >> 8);
22502250+ int j6 = cluster.worldStartZ + (cluster.worldDistanceFromCameraEndZ * j1 >> 8);
22512251+ if (posY >= k2 && posY <= l3 && posZ >= i5 && posZ <= j6) {
22522252+ return true;
22532253+ }
22542254+ }
22552255+ } else if (cluster.tileDistanceEnum == 3) {
22562256+ int k1 = cluster.worldStartY - posY;
22572257+ if (k1 > 0) {
22582258+ int l2 = cluster.worldStartX + (cluster.worldDistanceFromCameraStartX * k1 >> 8);
22592259+ int i4 = cluster.worldEndX + (cluster.worldDistanceFromCameraEndX * k1 >> 8);
22602260+ int j5 = cluster.worldEndZ + (cluster.worldDistanceFromCameraStartZ * k1 >> 8);
22612261+ int k6 = cluster.worldStartZ + (cluster.worldDistanceFromCameraEndZ * k1 >> 8);
22622262+ if (posX >= l2 && posX <= i4 && posZ >= j5 && posZ <= k6) {
22632263+ return true;
22642264+ }
22652265+ }
22662266+ } else if (cluster.tileDistanceEnum == 4) {
22672267+ int l1 = posY - cluster.worldStartY;
22682268+ if (l1 > 0) {
22692269+ int i3 = cluster.worldStartX + (cluster.worldDistanceFromCameraStartX * l1 >> 8);
22702270+ int j4 = cluster.worldEndX + (cluster.worldDistanceFromCameraEndX * l1 >> 8);
22712271+ int k5 = cluster.worldEndZ + (cluster.worldDistanceFromCameraStartZ * l1 >> 8);
22722272+ int l6 = cluster.worldStartZ + (cluster.worldDistanceFromCameraEndZ * l1 >> 8);
22732273+ if (posX >= i3 && posX <= j4 && posZ >= k5 && posZ <= l6) {
22742274+ return true;
22752275+ }
22762276+ }
22772277+ } else if (cluster.tileDistanceEnum == 5) {
22782278+ int i2 = posZ - cluster.worldEndZ;
22792279+ if (i2 > 0) {
22802280+ int j3 = cluster.worldStartX + (cluster.worldDistanceFromCameraStartX * i2 >> 8);
22812281+ int k4 = cluster.worldEndX + (cluster.worldDistanceFromCameraEndX * i2 >> 8);
22822282+ int l5 = cluster.worldStartY + (cluster.worldDistanceFromCameraStartY * i2 >> 8);
22832283+ int i7 = cluster.worldEndY + (cluster.worldDistanceFromCameraEndY * i2 >> 8);
22842284+ if (posX >= j3 && posX <= k4 && posY >= l5 && posY <= i7) {
22852285+ return true;
22862286+ }
22872287+ }
22882288+ }
22892289+ }
2087229020882088- return false;
20892089- }
22912291+ return false;
22922292+ }
2090229320912294}
20922295//TODO:Needs more refactoring
+18-18
src/com/jagex/runescape/scene/SceneCluster.java
···2233public class SceneCluster {
4455- public int anInt675;
66- public int anInt676;
77- public int anInt677;
88- public int anInt678;
99- public int anInt679;
1010- public int anInt680;
1111- public int anInt681;
1212- public int anInt682;
1313- public int anInt683;
1414- public int anInt684;
1515- public int anInt685;
1616- public int anInt686;
1717- public int anInt687;
1818- public int anInt688;
1919- public int anInt689;
2020- public int anInt690;
2121- public int anInt691;
2222- public int anInt692;
55+ public int tileStartX;
66+ public int tileEndX;
77+ public int tileStartY;
88+ public int tileEndY;
99+ public int searchMask;
1010+ public int worldStartX;
1111+ public int worldEndX;
1212+ public int worldStartY;
1313+ public int worldEndY;
1414+ public int worldEndZ;
1515+ public int worldStartZ;
1616+ public int tileDistanceEnum;
1717+ public int worldDistanceFromCameraStartX;
1818+ public int worldDistanceFromCameraEndX;
1919+ public int worldDistanceFromCameraStartY;
2020+ public int worldDistanceFromCameraEndY;
2121+ public int worldDistanceFromCameraStartZ;
2222+ public int worldDistanceFromCameraEndZ;
2323}
···11-package com.jagex.runescape.scene;
22-33-import com.jagex.runescape.media.renderable.Renderable;
44-55-public class SceneSpawnRequest {
66-77- public int anInt113;
88- public int anInt114;
99- public int anInt115;
1010- public int anInt116;
1111- public Renderable aRenderable601;
1212- public int anInt118;
1313- public int x;
1414- public int anInt120;
1515- public int y;
1616- public int anInt122;
1717- public int anInt123;
1818- public int anInt124;
1919- public int anInt125;
2020- public byte config;
2121-}
···33import com.jagex.runescape.media.renderable.Renderable;
4455public class FloorDecoration {
66+ public int z;
67 public int x;
78 public int y;
88- public int z;
99 public Renderable renderable;
1010- public int hash;
1010+ public int uid;
1111 public byte config;
1212}
···2233public class GenericTile {
4455- public GenericTile(int i, int j, int k, int l, int texture, int rgbColor, boolean flat) {
66- anInt95 = i;
77- anInt96 = j;
88- anInt97 = k;
99- anInt98 = l;
55+ public GenericTile(int colourA, int colourB, int colourC, int colourD, int texture, int rgbColor, boolean flat) {
66+ this.colourA = colourA;
77+ this.colourB = colourB;
88+ this.colourC = colourC;
99+ this.colourD = colourD;
1010 this.texture = texture;
1111 this.rgbColor = rgbColor;
1212 this.flat = flat;
1313 }
14141515- public int anInt95;
1616- public int anInt96;
1717- public int anInt97;
1818- public int anInt98;
1515+ public int colourA;
1616+ public int colourB;
1717+ public int colourD;
1818+ public int colourC;
1919 public int texture;
2020 public boolean flat;
2121 public int rgbColor;
+26-26
src/com/jagex/runescape/scene/tile/SceneTile.java
···11package com.jagex.runescape.scene.tile;
22-import com.jagex.runescape.scene.CameraAngle;
33-import com.jagex.runescape.scene.SceneSpawnRequest;
22+import com.jagex.runescape.scene.GroundItemTile;
33+import com.jagex.runescape.scene.InteractiveObject;
44import com.jagex.runescape.collection.Node;
5566public class SceneTile extends Node {
7788- public SceneTile(int i, int j, int k) {
99- anInt1400 = anInt1397 = i;
1010- anInt1398 = j;
1111- anInt1399 = k;
88+ public SceneTile(int x, int y, int z) {
99+ renderLevel = this.z = z;
1010+ this.x = x;
1111+ this.y = y;
1212 }
13131414- public int anInt1397;
1515- public int anInt1398;
1616- public int anInt1399;
1717- public int anInt1400;
1818- public GenericTile genericTile;
1919- public ComplexTile complexTile;
1414+ public int z;
1515+ public int x;
1616+ public int y;
1717+ public int renderLevel;
1818+ public GenericTile plainTile;
1919+ public ComplexTile shapedTile;
2020 public Wall wall;
2121 public WallDecoration wallDecoration;
2222 public FloorDecoration floorDecoration;
2323- public CameraAngle cameraAngle;
2424- public int sceneSpawnRequestCount;
2525- public SceneSpawnRequest[] sceneSpawnRequests = new SceneSpawnRequest[5];
2626- public int[] anIntArray1409 = new int[5];
2727- public int anInt1410;
2828- public int anInt1411;
2929- public boolean aBoolean1412;
3030- public boolean aBoolean1413;
3131- public boolean aBoolean1414;
3232- public int anInt1415;
3333- public int anInt1416;
3434- public int anInt1417;
3535- public int anInt1418;
3636- public SceneTile aClass50_Sub3_1419;
2323+ public GroundItemTile groundItemTile;
2424+ public int entityCount;
2525+ public InteractiveObject[] interactiveObjects = new InteractiveObject[5];
2626+ public int[] sceneSpawnRequestsSize = new int[5];
2727+ public int interactiveObjectsSizeOR;
2828+ public int logicHeight;
2929+ public boolean draw;
3030+ public boolean visible;
3131+ public boolean drawEntities;
3232+ public int wallCullDirection;
3333+ public int wallUncullDirection;
3434+ public int wallCullOppositeDirection;
3535+ public int wallDrawFlags;
3636+ public SceneTile tileBelow;
3737}
+6-6
src/com/jagex/runescape/scene/tile/Wall.java
···4455public class Wall {
6677- public int plane;
77+ public int z;
88 public int x;
99 public int y;
1010- public int faceUnknown;
1111- public int face;
1212- public Renderable aRenderable769;
1313- public Renderable aRenderable770;
1414- public int hash;
1010+ public int orientation;
1111+ public int orientation2;
1212+ public Renderable primary;
1313+ public Renderable secondary;
1414+ public int uid;
1515 public byte config;
1616}
···77 public WallDecoration() {
88 }
991010- public int plane;
1111- public int y;
1010+ public int z;
1211 public int x;
1313- public int faceUnknown;
1212+ public int y;
1313+ public int configBits;
1414 public int face;
1515 public Renderable renderable;
1616- public int hash;
1616+ public int uid;
1717 public byte config;
1818}
+3-3
src/com/jagex/runescape/util/LinkedList.java
···1212 head.previous = head;
1313 }
14141515- public void insertBack(Node node) {
1515+ public void pushBack(Node node) {
1616 if (node.previous != null)
1717 node.remove();
1818 node.previous = head.previous;
···2121 node.next.previous = node;
2222 }
23232424- public void addFirst(Node node) {
2424+ public void push(Node node) {
2525 if (node.previous != null)
2626 node.remove();
2727 node.previous = head;
···3030 node.next.previous = node;
3131 }
32323333- public Node removeFirst() {
3333+ public Node pop() {
3434 Node node = head.next;
3535 if (node == head) {
3636 return null;