Skip to content

Commit 1f3acbe

Browse files
committed
refactor: rename statics and move inits from constructor to definition
1 parent a2b15c9 commit 1f3acbe

File tree

1 file changed

+18
-26
lines changed

1 file changed

+18
-26
lines changed

src/main/java/org/runejs/client/scene/Scene.java

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ public class Scene {
3131
public static int[] WALL_CORNER_TYPE_64_BLOCK_OBJ_SPANS = new int[]{0, 4, 4, 8, 0, 0, 8, 0, 0};
3232
public static int[] WALL_CORNER_TYPE_128_BLOCK_OBJ_SPANS = new int[]{1, 1, 0, 0, 0, 8, 0, 0, 8};
3333

34+
public static boolean lowMemory = true;
35+
public static int cycle;
36+
3437
public static int cameraPosX;
3538
public static int cameraPositionTileX;
3639
public static int renderCameraPitchSine;
3740
public static int mapBoundsX;
38-
public static int cycle;
3941
public static int currentPositionY;
40-
public static boolean lowMemory = true;
4142
public static int cameraPosZ;
4243
public static int anInt90 = 4;
4344
public static int currentPositionX;
@@ -68,17 +69,14 @@ public class Scene {
6869
public static int[] viewspaceY = new int[6];
6970

7071
public SceneTile[][][] tileArray;
71-
public int[][][] anIntArrayArrayArray83;
72-
public int sceneSpawnRequestsCacheCurrentPos;
72+
public int[][][] tileOcclusionCycles;
73+
public int sceneSpawnRequestsCacheCurrentPos = 0;
7374
public InteractiveObject[] sceneSpawnRequestsCache = new InteractiveObject[5000];
74-
public int mapSizeX;
7575
public int currentPositionZ = 0;
7676
public int[][][] heightMap;
77-
public int mapSizeZ;
78-
public int mapSizeY;
79-
public int[] mergeIndexB;
80-
public int anInt126;
81-
public int[] mergeIndexA;
77+
public int anInt126 = 0;
78+
public int[] mergeIndexA = new int[10000];
79+
public int[] mergeIndexB = new int[10000];
8280

8381
private boolean clicked = false;
8482
private int clickX = 0;
@@ -102,19 +100,13 @@ public class Scene {
102100
*/
103101
public int hoveredTileY = -1;
104102

103+
public int mapSizeX = 104;
104+
public int mapSizeY = 104;
105+
public int mapSizeZ = 4;
106+
105107
public Scene(int[][][] heightMap) {
106-
final int length = 104;// was parameter
107-
final int width = 104;// was parameter
108-
final int height = 4;// was parameter
109-
sceneSpawnRequestsCacheCurrentPos = 0;
110-
mergeIndexB = new int[10000];
111-
anInt126 = 0;
112-
mergeIndexA = new int[10000];
113-
mapSizeZ = height;
114-
mapSizeX = width;
115-
mapSizeY = length;
116-
tileArray = new SceneTile[height][width][length];
117-
anIntArrayArrayArray83 = new int[height][width + 1][length + 1];
108+
tileArray = new SceneTile[mapSizeZ][mapSizeX][mapSizeY];
109+
tileOcclusionCycles = new int[mapSizeZ][mapSizeX + 1][mapSizeY + 1];
118110
this.heightMap = heightMap;
119111
initToNull();
120112
}
@@ -622,7 +614,7 @@ public WallDecoration getWallDecoration(int level, int x, int y) {
622614
}
623615

624616
public boolean isTileOccluded(int x, int y, int z) {
625-
int i = anIntArrayArrayArray83[z][x][y];
617+
int i = tileOcclusionCycles[z][x][y];
626618
if (i == -cycle) {
627619
return false;
628620
}
@@ -632,10 +624,10 @@ public boolean isTileOccluded(int x, int y, int z) {
632624
int worldX = x << 7;
633625
int worldY = y << 7;
634626
if (isPointOccluded(worldX + 1, heightMap[z][x][y], worldY + 1) && isPointOccluded(worldX + 128 - 1, heightMap[z][x + 1][y], worldY + 1) && isPointOccluded(worldX + 128 - 1, heightMap[z][x + 1][y + 1], worldY + 128 - 1) && isPointOccluded(worldX + 1, heightMap[z][x][y + 1], worldY + 128 - 1)) {
635-
anIntArrayArrayArray83[z][x][y] = cycle;
627+
tileOcclusionCycles[z][x][y] = cycle;
636628
return true;
637629
}
638-
anIntArrayArrayArray83[z][x][y] = -cycle;
630+
tileOcclusionCycles[z][x][y] = -cycle;
639631
return false;
640632
}
641633

@@ -1469,7 +1461,7 @@ public boolean isAreaOccluded(int z, int minimumX, int maximumX, int minimumY, i
14691461
}
14701462
for (int x = minimumX; x <= maximumX; x++) {
14711463
for (int y = minimumY; y <= maximumY; y++) {
1472-
if (anIntArrayArrayArray83[z][x][y] == -cycle) {
1464+
if (tileOcclusionCycles[z][x][y] == -cycle) {
14731465
return false;
14741466
}
14751467
}

0 commit comments

Comments
 (0)