Skip to content

Commit ece137d

Browse files
committed
refactor: rename drawFrom/To tile and make private on instance
1 parent 52e6948 commit ece137d

File tree

1 file changed

+42
-40
lines changed

1 file changed

+42
-40
lines changed

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

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ public class Scene {
4343
public static int cameraPosX;
4444
public static int cameraPositionTileX;
4545
public static int renderCameraPitchSine;
46-
public static int mapBoundsX;
47-
public static int currentPositionY;
4846
public static int cameraPosZ;
49-
public static int currentPositionX;
5047
public static int activeOccluderCount = 0;
5148
public static int cameraPosY;
5249
public static int renderCameraYawCosine;
@@ -57,7 +54,6 @@ public class Scene {
5754
public static LinkedList tileList = new LinkedList();
5855
public static int anInt109 = 0;
5956
public static int renderCameraPitchCosine;
60-
public static int mapBoundsY;
6157
public static int drawWidthMidpoint;
6258
public static int drawHeight;
6359
public static int drawHeightMidpoint;
@@ -101,6 +97,12 @@ public class Scene {
10197
*/
10298
public int hoveredTileY = -1;
10399

100+
private int drawFromTileX;
101+
private int drawFromTileY;
102+
103+
private int drawToTileX;
104+
private int drawToTileY;
105+
104106
public int mapSizeX = 104;
105107
public int mapSizeY = 104;
106108
public int mapSizeZ = 4;
@@ -429,28 +431,28 @@ public void render(Camera camera, int plane) {
429431
Scene.cameraPosY = cameraPosY;
430432
cameraPositionTileX = cameraPosX / 128;
431433
cameraPositionTileY = cameraPosY / 128;
432-
currentPositionX = cameraPositionTileX - TILE_DRAW_DISTANCE;
433-
if (currentPositionX < 0) {
434-
currentPositionX = 0;
434+
drawFromTileX = cameraPositionTileX - TILE_DRAW_DISTANCE;
435+
if (drawFromTileX < 0) {
436+
drawFromTileX = 0;
435437
}
436-
currentPositionY = cameraPositionTileY - TILE_DRAW_DISTANCE;
437-
if (currentPositionY < 0) {
438-
currentPositionY = 0;
438+
drawFromTileY = cameraPositionTileY - TILE_DRAW_DISTANCE;
439+
if (drawFromTileY < 0) {
440+
drawFromTileY = 0;
439441
}
440-
mapBoundsX = cameraPositionTileX + TILE_DRAW_DISTANCE;
441-
if (mapBoundsX > mapSizeX) {
442-
mapBoundsX = mapSizeX;
442+
drawToTileX = cameraPositionTileX + TILE_DRAW_DISTANCE;
443+
if (drawToTileX > mapSizeX) {
444+
drawToTileX = mapSizeX;
443445
}
444-
mapBoundsY = cameraPositionTileY + TILE_DRAW_DISTANCE;
445-
if (mapBoundsY > mapSizeY) {
446-
mapBoundsY = mapSizeY;
446+
drawToTileY = cameraPositionTileY + TILE_DRAW_DISTANCE;
447+
if (drawToTileY > mapSizeY) {
448+
drawToTileY = mapSizeY;
447449
}
448450
processCulling(plane);
449451
anInt109 = 0;
450452
for (int z = this.plane; z < mapSizeZ; z++) {
451453
SceneTile[][] sceneTiles = tileArray[z];
452-
for (int x = currentPositionX; x < mapBoundsX; x++) {
453-
for (int y = currentPositionY; y < mapBoundsY; y++) {
454+
for (int x = drawFromTileX; x < drawToTileX; x++) {
455+
for (int y = drawFromTileY; y < drawToTileY; y++) {
454456
SceneTile sceneTile = sceneTiles[x][y];
455457
if (sceneTile != null) {
456458
if (sceneTile.drawLevel > plane || !TILE_VISIBILITY_MAP[x - cameraPositionTileX + TILE_DRAW_DISTANCE][y - cameraPositionTileY + TILE_DRAW_DISTANCE] && heightMap[z][x][y] - cameraPosZ < 70000) {
@@ -472,32 +474,32 @@ public void render(Camera camera, int plane) {
472474
for (int i_25_ = -TILE_DRAW_DISTANCE; i_25_ <= 0; i_25_++) {
473475
int i_26_ = cameraPositionTileX + i_25_;
474476
int i_27_ = cameraPositionTileX - i_25_;
475-
if (i_26_ >= currentPositionX || i_27_ < mapBoundsX) {
477+
if (i_26_ >= drawFromTileX || i_27_ < drawToTileX) {
476478
for (int i_28_ = -TILE_DRAW_DISTANCE; i_28_ <= 0; i_28_++) {
477479
int i_29_ = cameraPositionTileY + i_28_;
478480
int i_30_ = cameraPositionTileY - i_28_;
479-
if (i_26_ >= currentPositionX) {
480-
if (i_29_ >= currentPositionY) {
481+
if (i_26_ >= drawFromTileX) {
482+
if (i_29_ >= drawFromTileY) {
481483
SceneTile sceneTile = sceneTiles[i_26_][i_29_];
482484
if (sceneTile != null && sceneTile.draw) {
483485
renderTile(sceneTile, true);
484486
}
485487
}
486-
if (i_30_ < mapBoundsY) {
488+
if (i_30_ < drawToTileY) {
487489
SceneTile sceneTile = sceneTiles[i_26_][i_30_];
488490
if (sceneTile != null && sceneTile.draw) {
489491
renderTile(sceneTile, true);
490492
}
491493
}
492494
}
493-
if (i_27_ < mapBoundsX) {
494-
if (i_29_ >= currentPositionY) {
495+
if (i_27_ < drawToTileX) {
496+
if (i_29_ >= drawFromTileY) {
495497
SceneTile sceneTile = sceneTiles[i_27_][i_29_];
496498
if (sceneTile != null && sceneTile.draw) {
497499
renderTile(sceneTile, true);
498500
}
499501
}
500-
if (i_30_ < mapBoundsY) {
502+
if (i_30_ < drawToTileY) {
501503
SceneTile sceneTile = sceneTiles[i_27_][i_30_];
502504
if (sceneTile != null && sceneTile.draw) {
503505
renderTile(sceneTile, true);
@@ -517,32 +519,32 @@ public void render(Camera camera, int plane) {
517519
for (int i_31_ = -TILE_DRAW_DISTANCE; i_31_ <= 0; i_31_++) {
518520
int i_32_ = cameraPositionTileX + i_31_;
519521
int i_33_ = cameraPositionTileX - i_31_;
520-
if (i_32_ >= currentPositionX || i_33_ < mapBoundsX) {
522+
if (i_32_ >= drawFromTileX || i_33_ < drawToTileX) {
521523
for (int i_34_ = -TILE_DRAW_DISTANCE; i_34_ <= 0; i_34_++) {
522524
int i_35_ = cameraPositionTileY + i_34_;
523525
int i_36_ = cameraPositionTileY - i_34_;
524-
if (i_32_ >= currentPositionX) {
525-
if (i_35_ >= currentPositionY) {
526+
if (i_32_ >= drawFromTileX) {
527+
if (i_35_ >= drawFromTileY) {
526528
SceneTile sceneTile = sceneTiles[i_32_][i_35_];
527529
if (sceneTile != null && sceneTile.draw) {
528530
renderTile(sceneTile, false);
529531
}
530532
}
531-
if (i_36_ < mapBoundsY) {
533+
if (i_36_ < drawToTileY) {
532534
SceneTile sceneTile = sceneTiles[i_32_][i_36_];
533535
if (sceneTile != null && sceneTile.draw) {
534536
renderTile(sceneTile, false);
535537
}
536538
}
537539
}
538-
if (i_33_ < mapBoundsX) {
539-
if (i_35_ >= currentPositionY) {
540+
if (i_33_ < drawToTileX) {
541+
if (i_35_ >= drawFromTileY) {
540542
SceneTile sceneTile = sceneTiles[i_33_][i_35_];
541543
if (sceneTile != null && sceneTile.draw) {
542544
renderTile(sceneTile, false);
543545
}
544546
}
545-
if (i_36_ < mapBoundsY) {
547+
if (i_36_ < drawToTileY) {
546548
SceneTile sceneTile = sceneTiles[i_33_][i_36_];
547549
if (sceneTile != null && sceneTile.draw) {
548550
renderTile(sceneTile, false);
@@ -871,25 +873,25 @@ public void renderTile(SceneTile _tile, boolean arg1) {
871873
continue;
872874
}
873875
}
874-
if (x <= cameraPositionTileX && x > currentPositionX) {
876+
if (x <= cameraPositionTileX && x > drawFromTileX) {
875877
SceneTile tile = sceneTiles[x - 1][y];
876878
if (tile != null && tile.visible && (tile.draw || (groundTile.interactiveObjectsSizeOR & 0x1) == 0)) {
877879
continue;
878880
}
879881
}
880-
if (x >= cameraPositionTileX && x < mapBoundsX - 1) {
882+
if (x >= cameraPositionTileX && x < drawToTileX - 1) {
881883
SceneTile tile = sceneTiles[x + 1][y];
882884
if (tile != null && tile.visible && (tile.draw || (groundTile.interactiveObjectsSizeOR & 0x4) == 0)) {
883885
continue;
884886
}
885887
}
886-
if (y <= cameraPositionTileY && y > currentPositionY) {
888+
if (y <= cameraPositionTileY && y > drawFromTileY) {
887889
SceneTile tile = sceneTiles[x][y - 1];
888890
if (tile != null && tile.visible && (tile.draw || (groundTile.interactiveObjectsSizeOR & 0x8) == 0)) {
889891
continue;
890892
}
891893
}
892-
if (y >= cameraPositionTileY && y < mapBoundsY - 1) {
894+
if (y >= cameraPositionTileY && y < drawToTileY - 1) {
893895
SceneTile tile = sceneTiles[x][y + 1];
894896
if (tile != null && tile.visible && (tile.draw || (groundTile.interactiveObjectsSizeOR & 0x2) == 0)) {
895897
continue;
@@ -1174,25 +1176,25 @@ public void renderTile(SceneTile _tile, boolean arg1) {
11741176
}
11751177
if (groundTile.visible) {
11761178
if (groundTile.wallCullDirection == 0) {
1177-
if (x <= cameraPositionTileX && x > currentPositionX) {
1179+
if (x <= cameraPositionTileX && x > drawFromTileX) {
11781180
SceneTile sceneTile_125_ = sceneTiles[x - 1][y];
11791181
if (sceneTile_125_ != null && sceneTile_125_.visible) {
11801182
continue;
11811183
}
11821184
}
1183-
if (x >= cameraPositionTileX && x < mapBoundsX - 1) {
1185+
if (x >= cameraPositionTileX && x < drawToTileX - 1) {
11841186
SceneTile sceneTile_126_ = sceneTiles[x + 1][y];
11851187
if (sceneTile_126_ != null && sceneTile_126_.visible) {
11861188
continue;
11871189
}
11881190
}
1189-
if (y <= cameraPositionTileY && y > currentPositionY) {
1191+
if (y <= cameraPositionTileY && y > drawFromTileY) {
11901192
SceneTile sceneTile_127_ = sceneTiles[x][y - 1];
11911193
if (sceneTile_127_ != null && sceneTile_127_.visible) {
11921194
continue;
11931195
}
11941196
}
1195-
if (y >= cameraPositionTileY && y < mapBoundsY - 1) {
1197+
if (y >= cameraPositionTileY && y < drawToTileY - 1) {
11961198
SceneTile sceneTile_128_ = sceneTiles[x][y + 1];
11971199
if (sceneTile_128_ != null && sceneTile_128_.visible) {
11981200
continue;

0 commit comments

Comments
 (0)