A RuneTek3 client (377) that is deobfuscated, converted to Kotlin, and includes QoL improvements.
0

Configure Feed

Select the types of activity you want to include in your feed.

replace groundArray[][][] and groundItems[][][] with a class that now handles errors

+212 -146
+28 -27
src/main/java/com/jagex/runescape/Game.java
··· 50 50 import com.jagex.runescape.util.*; 51 51 import com.jagex.runescape.config.Actions; 52 52 import com.jagex.runescape.config.Configuration; 53 + import com.jagex.runescape.world.GroundArray; 53 54 54 55 import static com.jagex.runescape.config.Configuration.*; 55 56 import static com.jagex.runescape.config.IncomingPacketIds.*; ··· 508 509 private volatile boolean aBoolean1320 = false; 509 510 private int[] soundType = new int[50]; 510 511 private int anInt1322; 511 - private LinkedList[][][] groundItems = new LinkedList[4][104][104]; 512 + private GroundArray<LinkedList> groundItems = new GroundArray(); 512 513 private int runEnergy; 513 514 public static int pulseCycle; 514 515 private int[] characterEditIdentityKits = new int[7]; ··· 1240 1241 } 1241 1242 1242 1243 private void processGroundItems(int x, int y) { 1243 - LinkedList linkedList = groundItems[plane][x][y]; 1244 + LinkedList linkedList = groundItems.getTile(plane, x, y); 1244 1245 if (linkedList == null) { 1245 1246 currentScene.clearGroundItem(plane, x, y); 1246 1247 return; ··· 1503 1504 if (anInt1053 == -1) { 1504 1505 method146((byte) 4); 1505 1506 method21(false); 1506 - method39(true); 1507 + method39(); 1507 1508 } 1508 1509 if (super.mouseButtonPressed == 1 || super.clickType == 1) 1509 1510 anInt1094++; ··· 2530 2531 placementX = buffer.getUnsignedInvertedByte(); 2531 2532 for (int x = placementX; x < placementX + 8; x++) { 2532 2533 for (int y = placementY; y < placementY + 8; y++) 2533 - if (groundItems[plane][x][y] != null) { 2534 - groundItems[plane][x][y] = null; 2534 + if (!groundItems.isTileEmpty(plane, x, y)) { 2535 + groundItems.clearTile(plane, x, y); 2535 2536 processGroundItems(x, y); 2536 2537 } 2537 2538 ··· 2894 2895 for (int j35 = byte4; j35 != byte5; j35 += byte6) { 2895 2896 int k35 = i35 + deltaX; 2896 2897 int l35 = j35 + deltaY; 2897 - for (int i36 = 0; i36 < 4; i36++) 2898 - if (k35 >= 0 && l35 >= 0 && k35 < 104 && l35 < 104) 2899 - groundItems[i36][i35][j35] = groundItems[i36][k35][l35]; 2900 - else 2901 - groundItems[i36][i35][j35] = null; 2898 + for (int i36 = 0; i36 < 4; i36++) { 2899 + if (k35 >= 0 && l35 >= 0 && k35 < 104 && l35 < 104) { 2900 + groundItems.setTile(i36, i35, j35, groundItems.getTile(i36, k35, l35)); 2901 + } else { 2902 + groundItems.clearTile(i36, i35, j35); 2903 + } 2904 + } 2902 2905 2903 2906 } 2904 2907 ··· 3503 3506 3504 3507 } 3505 3508 3506 - private void method39(boolean flag) { 3507 - if (!flag) 3508 - groundItems = null; 3509 + private void method39() { 3509 3510 if (super.clickType == 1) { 3510 3511 if (super.clickX >= 6 && super.clickX <= 106 && super.clickY >= 467 && super.clickY <= 499) { 3511 3512 publicChatMode = (publicChatMode + 1) % 4; ··· 3787 3788 method38(k1, i1, l, player1); 3788 3789 } 3789 3790 if (j1 == 3) { 3790 - LinkedList itemList = groundItems[plane][l][i1]; 3791 + LinkedList itemList = groundItems.getTile(plane, l, i1); 3791 3792 if (itemList != null) { 3792 3793 for (Item item = (Item) itemList.last(); item != null; item = (Item) itemList 3793 3794 .previous()) { ··· 3862 3863 if (k1 == 0) 3863 3864 l1 = currentScene.getWallObjectHash(j, l, i1); 3864 3865 if (k1 == 1) 3865 - l1 = currentScene.method268(j, (byte) 4, i1, l); 3866 + l1 = currentScene.getWallDecorationHash(j, i1, l); 3866 3867 if (k1 == 2) 3867 3868 l1 = currentScene.method269(i1, j, l); 3868 3869 if (k1 == 3) ··· 6427 6428 for (int l2 = 0; l2 < 4; l2++) { 6428 6429 for (int i3 = 0; i3 < 104; i3++) { 6429 6430 for (int k3 = 0; k3 < 104; k3++) 6430 - groundItems[l2][i3][k3] = null; 6431 + groundItems.clearTile(l2, i3, k3); 6431 6432 } 6432 6433 } 6433 6434 ··· 7237 7238 7238 7239 for (int x = 0; x < 104; x++) { 7239 7240 for (int y = 0; y < 104; y++) { 7240 - LinkedList itemList = groundItems[plane][x][y]; 7241 + LinkedList itemList = groundItems.getTile(plane, x, y); 7241 7242 7242 7243 if (itemList != null) { 7243 7244 int itemX = (x * 4 + 2) - localPlayer.worldX / 32; ··· 10546 10547 Item item = new Item(); 10547 10548 item.itemId = itemId; 10548 10549 item.itemCount = amount; 10549 - if (groundItems[plane][x][y] == null) 10550 - groundItems[plane][x][y] = new LinkedList(); 10551 - groundItems[plane][x][y].pushBack(item); 10550 + if (groundItems.isTileEmpty(plane, x, y)) 10551 + groundItems.setTile(plane, x, y, new LinkedList()); 10552 + groundItems.getTile(plane, x, y).pushBack(item); 10552 10553 processGroundItems(x, y); 10553 10554 } 10554 10555 return; ··· 10615 10616 Item item = new Item(); 10616 10617 item.itemId = itemId; 10617 10618 item.itemCount = amount; 10618 - if (groundItems[plane][x][y] == null) 10619 - groundItems[plane][x][y] = new LinkedList(); 10620 - groundItems[plane][x][y].pushBack(item); 10619 + if (groundItems.isTileEmpty(plane, x, y)) 10620 + groundItems.setTile(plane, x, y, new LinkedList()); 10621 + groundItems.getTile(plane, x, y).pushBack(item); 10621 10622 processGroundItems(x, y); 10622 10623 } 10623 10624 return; ··· 10630 10631 int oldAmount = buf.getUnsignedShortBE(); 10631 10632 int newAmount = buf.getUnsignedShortBE(); 10632 10633 if (x >= 0 && y >= 0 && x < 104 && y < 104) { 10633 - LinkedList list = groundItems[plane][x][y]; 10634 + LinkedList list = groundItems.getTile(plane, x, y); 10634 10635 if (list != null) { 10635 10636 for (Item item = (Item) list.first(); item != null; item = (Item) list.next()) { 10636 10637 if (item.itemId != (itemId & 0x7fff) || item.itemCount != oldAmount) ··· 10725 10726 int x = placementX + (offset >> 4 & 7); 10726 10727 int y = placementY + (offset & 7); 10727 10728 if (x >= 0 && y >= 0 && x < 104 && y < 104) { 10728 - LinkedList list = groundItems[plane][x][y]; 10729 + LinkedList list = groundItems.getTile(plane, x, y); 10729 10730 if (list != null) { 10730 10731 for (Item item = (Item) list.first(); item != null; item = (Item) list.next()) { 10731 10732 if (item.itemId != (itemId & 0x7fff)) ··· 10735 10736 } 10736 10737 10737 10738 if (list.first() == null) 10738 - groundItems[plane][x][y] = null; 10739 + groundItems.clearTile(plane, x, y); 10739 10740 processGroundItems(x, y); 10740 10741 } 10741 10742 } ··· 10935 10936 if (spawnObjectNode.anInt1392 == 0) 10936 10937 i = currentScene.getWallObjectHash(spawnObjectNode.anInt1393, spawnObjectNode.anInt1394, spawnObjectNode.anInt1391); 10937 10938 if (spawnObjectNode.anInt1392 == 1) 10938 - i = currentScene.method268(spawnObjectNode.anInt1393, (byte) 4, spawnObjectNode.anInt1391, 10939 + i = currentScene.getWallDecorationHash(spawnObjectNode.anInt1393, spawnObjectNode.anInt1391, 10939 10940 spawnObjectNode.anInt1394); 10940 10941 if (spawnObjectNode.anInt1392 == 2) 10941 10942 i = currentScene.method269(spawnObjectNode.anInt1391, spawnObjectNode.anInt1393, spawnObjectNode.anInt1394);
+119 -119
src/main/java/com/jagex/runescape/scene/Scene.java
··· 7 7 import com.jagex.runescape.media.renderable.Renderable; 8 8 import com.jagex.runescape.scene.tile.*; 9 9 import com.jagex.runescape.util.LinkedList; 10 + import com.jagex.runescape.world.GroundArray; 10 11 11 12 public class Scene { 12 13 ··· 15 16 private int mapSizeX; 16 17 private int mapSizeY; 17 18 private int[][][] heightMap; 18 - private SceneTile[][][] groundArray; 19 + private GroundArray<SceneTile> groundArray; 19 20 private int currentPositionZ; 20 21 private int sceneSpawnRequestsCacheCurrentPos; 21 22 private InteractiveObject[] sceneSpawnRequestsCache; ··· 95 96 mapSizeZ = height; 96 97 mapSizeX = width; 97 98 mapSizeY = length; 98 - groundArray = new SceneTile[height][width][length]; 99 + groundArray = new GroundArray<>(new SceneTile[height][width][length]); 99 100 anIntArrayArrayArray460 = new int[height][width + 1][length + 1]; 100 101 this.heightMap = heightMap; 101 102 initToNull(); ··· 115 116 for (int z = 0; z < mapSizeZ; z++) { 116 117 for (int x = 0; x < mapSizeX; x++) { 117 118 for (int y = 0; y < mapSizeY; y++) { 118 - groundArray[z][x][y] = null; 119 + groundArray.clearTile(z, x, y); 119 120 } 120 121 121 122 } ··· 145 146 currentPositionZ = z; 146 147 for (int x = 0; x < mapSizeX; x++) { 147 148 for (int y = 0; y < mapSizeY; y++) { 148 - if (groundArray[z][x][y] == null) { 149 - groundArray[z][x][y] = new SceneTile(x, y, z); 149 + if (groundArray.isTileEmpty(z, x, y)) { 150 + groundArray.setTile(z, x, y, new SceneTile(x, y, z)); 150 151 } 151 152 } 152 153 ··· 155 156 } 156 157 157 158 void setBridgeMode(int x, int y) { 158 - SceneTile scenetile = groundArray[0][x][y]; 159 + SceneTile scenetile = groundArray.getTile(0, x, y); 159 160 for (int z = 0; z < 3; z++) { 160 - SceneTile _tile = groundArray[z][x][y] = groundArray[z + 1][x][y]; 161 + SceneTile _tile = groundArray.setTile(z, x, y, groundArray.getTile(z + 1, x, y)); 161 162 if (_tile != null) { 162 163 _tile.z--; 163 164 for (int e = 0; e < _tile.entityCount; e++) { ··· 170 171 } 171 172 } 172 173 173 - if (groundArray[0][x][y] == null) { 174 - groundArray[0][x][y] = new SceneTile(x, y, 0); 174 + if (groundArray.isTileEmpty(0, x, y)) { 175 + groundArray.setTile(0, x, y, new SceneTile(x, y, 0)); 175 176 } 176 - groundArray[0][x][y].tileBelow = scenetile; 177 - groundArray[3][x][y] = null; 177 + groundArray.getTile(0, x, y).tileBelow = scenetile; 178 + groundArray.clearTile(3, x, y); 178 179 } 179 180 180 181 static void createCullingCluster(final int z, int highestX, int lowestX, int highestY, int lowestY, int highestZ, int lowestZ, int searchMask) { ··· 194 195 } 195 196 196 197 void setTileLogicHeight(int z, int x, int y, int logicHeight) { 197 - SceneTile sceneTile = groundArray[z][x][y]; 198 + SceneTile sceneTile = groundArray.getTile(z, x, y); 198 199 if (sceneTile != null) { 199 200 sceneTile.logicHeight = logicHeight; 200 201 } ··· 205 206 if (clippingPath == 0) { 206 207 GenericTile tile = new GenericTile(cA, cB, cC, cD, -1, underlayRGB, false); 207 208 for (int _z = plane; _z >= 0; _z--) { 208 - if (groundArray[_z][x][y] == null) { 209 - groundArray[_z][x][y] = new SceneTile(x, y, _z); 209 + if (groundArray.isTileEmpty(_z, x, y)) { 210 + groundArray.setTile(_z, x, y, new SceneTile(x, y, _z)); 210 211 } 211 212 } 212 213 213 - groundArray[plane][x][y].plainTile = tile; 214 + groundArray.getTile(plane, x, y).plainTile = tile; 214 215 return; 215 216 } 216 217 if (clippingPath == 1) { 217 218 GenericTile tile = new GenericTile(colourA, colourB, colourC, colourD, textureId, overlayRGB, vertexHeightSW == vertexHeightSE && vertexHeightSW == vertexHeightNE && vertexHeightSW == vertexHeightNW); 218 219 for (int _z = plane; _z >= 0; _z--) { 219 - if (groundArray[_z][x][y] == null) { 220 - groundArray[_z][x][y] = new SceneTile(x, y, _z); 220 + if (groundArray.isTileEmpty(_z, x, y)) { 221 + groundArray.setTile(_z, x, y, new SceneTile(x, y, _z)); 221 222 } 222 223 } 223 224 224 - groundArray[plane][x][y].plainTile = tile; 225 + groundArray.getTile(plane, x, y).plainTile = tile; 225 226 return; 226 227 } 227 228 ComplexTile tile = new ComplexTile(x, vertexHeightSW, vertexHeightSE, vertexHeightNW, vertexHeightNE, y, clippingPathRotation, textureId, clippingPath, cA, colourA, cB, colourB, cC, colourC, cD, colourD, overlayRGB, underlayRGB); 228 229 for (int _z = plane; _z >= 0; _z--) { 229 - if (groundArray[_z][x][y] == null) { 230 - groundArray[_z][x][y] = new SceneTile(x, y, _z); 230 + if (groundArray.isTileEmpty(_z, x, y)) { 231 + groundArray.setTile(_z, x, y, new SceneTile(x, y, _z)); 231 232 } 232 233 } 233 234 234 - groundArray[plane][x][y].shapedTile = tile; 235 + 236 + groundArray.getTile(plane, x, y).shapedTile = tile; 235 237 } 236 238 237 239 void addGroundDecoration(int x, int y, int z, int drawHeight, int uid, Renderable renderable, byte config) { ··· 245 247 floorDecoration.z = drawHeight; 246 248 floorDecoration.uid = uid; 247 249 floorDecoration.config = config; 248 - if (groundArray[z][x][y] == null) { 249 - groundArray[z][x][y] = new SceneTile(x, y, z); 250 + if (groundArray.isTileEmpty(z, x, y)) { 251 + groundArray.setTile(z, x, y, new SceneTile(x, y, z)); 250 252 } 251 - groundArray[z][x][y].floorDecoration = floorDecoration; 253 + groundArray.getTile(z, x, y).floorDecoration = floorDecoration; 252 254 } 253 255 254 256 public void addGroundItemTile(int x, int y, int z, int drawHeight, int uid, Renderable firstGroundItem, Renderable secondGroundItem, ··· 262 264 groundItemTile.secondGroundItem = secondGroundItem; 263 265 groundItemTile.thirdGroundItem = thirdGroundItem; 264 266 int k1 = 0; 265 - SceneTile sceneTile = groundArray[z][x][y]; 267 + SceneTile sceneTile = groundArray.getTile(z, x, y); 266 268 if (sceneTile != null) { 267 269 for (int e = 0; e < sceneTile.entityCount; e++) { 268 270 if (sceneTile.interactiveObjects[e].renderable instanceof Model) { ··· 275 277 276 278 } 277 279 groundItemTile.anInt180 = k1; 278 - if (groundArray[z][x][y] == null) { 279 - groundArray[z][x][y] = new SceneTile(x, y, z); 280 + if (groundArray.isTileEmpty(z, x, y)) { 281 + groundArray.setTile(z, x, y, new SceneTile(x, y, z)); 280 282 } 281 - groundArray[z][x][y].groundItemTile = groundItemTile; 283 + groundArray.getTile(z, x, y).groundItemTile = groundItemTile; 282 284 } 283 285 284 286 void addWall(int x, int y, int z, int drawHeight, int orientation, int orientation2, int uid, Renderable primary, Renderable secondary, byte config) { ··· 294 296 wall.orientation = orientation; 295 297 wall.orientation2 = orientation2; 296 298 for (int _z = z; _z >= 0; _z--) { 297 - if (groundArray[_z][x][y] == null) { 298 - groundArray[_z][x][y] = new SceneTile(x, y, _z); 299 + if (groundArray.isTileEmpty(_z, x, y)) { 300 + groundArray.setTile(_z, x, y, new SceneTile(x, y, _z)); 301 + 299 302 } 300 303 } 301 304 302 - groundArray[z][x][y].wall = wall; 305 + groundArray.getTile(z, x, y).wall = wall; 303 306 } 304 307 } 305 308 ··· 315 318 wallDecoration.configBits = faceBits; 316 319 wallDecoration.face = face; 317 320 for (int planeCounter = z; planeCounter >= 0; planeCounter--) { 318 - if (groundArray[planeCounter][x][y] == null) { 319 - groundArray[planeCounter][x][y] = new SceneTile(x, y, planeCounter); 321 + if (groundArray.isTileEmpty(planeCounter, x, y)) { 322 + groundArray.setTile(planeCounter, x, y, new SceneTile(x, y, planeCounter)); 323 + 320 324 } 321 325 } 322 326 323 - groundArray[z][x][y].wallDecoration = wallDecoration; 327 + groundArray.getTile(z, x, y).wallDecoration = wallDecoration; 324 328 } 325 329 } 326 330 ··· 378 382 if (x < 0 || y < 0 || x >= mapSizeX || y >= mapSizeY) { 379 383 return false; 380 384 } 381 - SceneTile tile = groundArray[z][x][y]; 385 + SceneTile tile = groundArray.getTile(z, x, y); 382 386 if (tile != null && tile.entityCount >= 5) { 383 387 return false; 384 388 } ··· 415 419 size += 2; 416 420 } 417 421 for (int _z = z; _z >= 0; _z--) { 418 - if (groundArray[_z][x][y] == null) { 419 - groundArray[_z][x][y] = new SceneTile(x, y, _z); 422 + if (groundArray.isTileEmpty(_z, x, y)) { 423 + groundArray.setTile(_z, x, y, new SceneTile(x, y, _z)); 420 424 } 421 425 } 422 426 423 - SceneTile sceneTile = groundArray[z][x][y]; 427 + SceneTile sceneTile = groundArray.getTile(z, x, y); 424 428 sceneTile.interactiveObjects[sceneTile.entityCount] = interactiveObject; 425 429 sceneTile.sceneSpawnRequestsSize[sceneTile.entityCount] = size; 426 430 sceneTile.interactiveObjectsSizeOR |= size; ··· 448 452 private void remove(InteractiveObject entity) { 449 453 for (int x = entity.tileLeft; x <= entity.tileRight; x++) { 450 454 for (int y = entity.tileTop; y <= entity.tileBottom; y++) { 451 - SceneTile tile = groundArray[entity.z][x][y]; 455 + SceneTile tile = groundArray.getTile(entity.z, x, y); 452 456 if (tile != null) { 453 457 for (int e = 0; e < tile.entityCount; e++) { 454 458 if (tile.interactiveObjects[e] != entity) { ··· 477 481 } 478 482 479 483 void displaceWallDecoration(int x, int y, int z, int displacement) { 480 - SceneTile sceneTile = groundArray[z][x][y]; 484 + SceneTile sceneTile = groundArray.getTile(z, x, y); 481 485 if (sceneTile == null) { 482 486 return; 483 487 } ··· 493 497 } 494 498 495 499 public void removeWallObject(int x, int y, int z) { 496 - SceneTile tile = groundArray[z][x][y]; 500 + SceneTile tile = groundArray.getTile(z, x, y); 497 501 if (tile != null) { 498 502 tile.wall = null; 499 503 } 500 504 } 501 505 502 506 public void removeWallDecoration(int x, int y, int z) { 503 - SceneTile tile = groundArray[z][x][y]; 507 + SceneTile tile = groundArray.getTile(z, x, y); 504 508 if (tile != null) { 505 509 tile.wallDecoration = null; 506 510 } 507 511 } 508 512 509 513 public void removeInteractiveObject(int x, int y, int z) { 510 - SceneTile tile = groundArray[z][x][y]; 514 + SceneTile tile = groundArray.getTile(z, x, y); 511 515 if (tile == null) { 512 516 return; 513 517 } ··· 522 526 } 523 527 524 528 public void method261(int x, int y, int z) { 525 - SceneTile sceneTile = groundArray[z][x][y]; 529 + SceneTile sceneTile = groundArray.getTile(z, x, y); 526 530 if (sceneTile == null) { 527 531 return; 528 532 } 529 533 sceneTile.floorDecoration = null; 530 534 } 531 535 532 - public void clearGroundItem(int i, int j, int k) { 533 - SceneTile sceneTile = groundArray[i][j][k]; 536 + public void clearGroundItem(int z, int x, int y) { 537 + SceneTile sceneTile = groundArray.getTile(z, x, y); 534 538 if (sceneTile != null) { 535 539 sceneTile.groundItemTile = null; 536 540 } 537 541 } 538 542 539 543 public Wall getWallObject(int level, int x, int y) { 540 - SceneTile sceneTile = groundArray[level][x][y]; 544 + SceneTile sceneTile = groundArray.getTile(level, x, y); 541 545 542 546 if (sceneTile == null) { 543 547 return null; ··· 547 551 } 548 552 549 553 public WallDecoration getWallDecoration(int level, int y, int x) { 550 - SceneTile sceneTile = groundArray[level][x][y]; 554 + SceneTile sceneTile = groundArray.getTile(level, x, y); 551 555 552 556 if (sceneTile == null) { 553 557 return null; ··· 557 561 } 558 562 559 563 public InteractiveObject method265(int x, int y, int level) { 560 - SceneTile sceneTile = groundArray[level][x][y]; 564 + SceneTile sceneTile = groundArray.getTile(level, x, y); 561 565 if (sceneTile == null) { 562 566 return null; 563 567 } ··· 572 576 } 573 577 574 578 public FloorDecoration getFloorDecoration(int level, int x, int y) { 575 - SceneTile sceneTile = groundArray[level][y][x]; 579 + SceneTile sceneTile = groundArray.getTile(level, x, y); 576 580 if (sceneTile == null || sceneTile.floorDecoration == null) { 577 581 return null; 578 582 } else { ··· 581 585 } 582 586 583 587 public int getWallObjectHash(int x, int y, int z) { 584 - SceneTile sceneTile = groundArray[z][x][y]; 588 + SceneTile sceneTile = groundArray.getTile(z, x, y); 585 589 if (sceneTile == null || sceneTile.wall == null) { 586 590 return 0; 587 591 } else { ··· 589 593 } 590 594 } 591 595 592 - public int method268(int i, byte byte0, int j, int k) { 593 - SceneTile sceneTile = groundArray[j][i][k]; 596 + public int getWallDecorationHash(int x, int z, int y) { 597 + SceneTile sceneTile = groundArray.getTile(z, x, y); 594 598 if (sceneTile == null || sceneTile.wallDecoration == null) { 595 599 return 0; 596 600 } else { ··· 598 602 } 599 603 } 600 604 601 - public int method269(int i, int j, int k) { 602 - SceneTile sceneTile = groundArray[i][j][k]; 605 + public int method269(int z, int x, int y) { 606 + SceneTile sceneTile = groundArray.getTile(z, x, y); 603 607 if (sceneTile == null) { 604 608 return 0; 605 609 } 606 610 for (int l = 0; l < sceneTile.entityCount; l++) { 607 611 InteractiveObject interactiveObject = sceneTile.interactiveObjects[l]; 608 - if ((interactiveObject.uid >> 29 & 3) == 2 && interactiveObject.tileLeft == j && interactiveObject.tileTop == k) { 612 + if ((interactiveObject.uid >> 29 & 3) == 2 && interactiveObject.tileLeft == x && interactiveObject.tileTop == y) { 609 613 return interactiveObject.uid; 610 614 } 611 615 } ··· 613 617 return 0; 614 618 } 615 619 616 - public int getFloorDecorationHash(int i, int j, int k) { 617 - SceneTile sceneTile = groundArray[i][j][k]; 620 + public int getFloorDecorationHash(int z, int x, int y) { 621 + SceneTile sceneTile = groundArray.getTile(z, x, y); 618 622 if (sceneTile == null || sceneTile.floorDecoration == null) { 619 623 return 0; 620 624 } else { ··· 622 626 } 623 627 } 624 628 625 - public int method271(int i, int j, int k, int l) { 626 - SceneTile sceneTile = groundArray[i][j][k]; 629 + public int method271(int z, int x, int y, int l) { 630 + SceneTile sceneTile = groundArray.getTile(z, x, y); 627 631 if (sceneTile == null) { 628 632 return -1; 629 633 } ··· 649 653 for (int _z = 0; _z < mapSizeZ; _z++) { 650 654 for (int _x = 0; _x < mapSizeX; _x++) { 651 655 for (int _y = 0; _y < mapSizeY; _y++) { 652 - SceneTile tile = groundArray[_z][_x][_y]; 656 + SceneTile tile = groundArray.getTile(_z, _x, _y); 653 657 if (tile != null) { 654 658 Wall wall = tile.wall; 655 659 if (wall != null && wall.primary != null ··· 689 693 690 694 } 691 695 692 - private void method273(int i, Model model, int j, int k, int l) { 696 + private void method273(int x, Model model, int y, int z, int l) { 693 697 if (l != 0) { 694 698 return; 695 699 } 696 - if (i < mapSizeX) { 697 - SceneTile sceneTile = groundArray[k][i + 1][j]; 700 + if (x < mapSizeX) { 701 + SceneTile sceneTile = groundArray.getTile(z, x + 1, y); 698 702 if (sceneTile != null && sceneTile.floorDecoration != null 699 703 && sceneTile.floorDecoration.renderable.verticesNormal != null) { 700 704 mergeNormals(model, 701 705 (Model) sceneTile.floorDecoration.renderable, 128, 0, 0, true); 702 706 } 703 707 } 704 - if (j < mapSizeX) { 705 - SceneTile sceneTile = groundArray[k][i][j + 1]; 708 + if (y < mapSizeX) { 709 + SceneTile sceneTile = groundArray.getTile(z, x, y + 1); 706 710 if (sceneTile != null && sceneTile.floorDecoration != null 707 711 && sceneTile.floorDecoration.renderable.verticesNormal != null) { 708 712 mergeNormals(model, 709 713 (Model) sceneTile.floorDecoration.renderable, 0, 0, 128, true); 710 714 } 711 715 } 712 - if (i < mapSizeX && j < mapSizeY) { 713 - SceneTile sceneTile = groundArray[k][i + 1][j + 1]; 716 + if (x < mapSizeX && y < mapSizeY) { 717 + SceneTile sceneTile = groundArray.getTile(z, x + 1, y + 1); 714 718 if (sceneTile != null && sceneTile.floorDecoration != null 715 719 && sceneTile.floorDecoration.renderable.verticesNormal != null) { 716 720 mergeNormals(model, 717 721 (Model) sceneTile.floorDecoration.renderable, 128, 0, 128, true); 718 722 } 719 723 } 720 - if (i < mapSizeX && j > 0) { 721 - SceneTile sceneTile = groundArray[k][i + 1][j - 1]; 724 + if (x < mapSizeX && y > 0) { 725 + SceneTile sceneTile = groundArray.getTile(z, x + 1, y - 1); 722 726 if (sceneTile != null && sceneTile.floorDecoration != null 723 727 && sceneTile.floorDecoration.renderable.verticesNormal != null) { 724 728 mergeNormals(model, ··· 734 738 int l1 = i1 + l; 735 739 int i2 = i - 1; 736 740 int j2 = i + j1; 737 - for (int k2 = j; k2 <= j + 1; k2++) { 738 - if (k2 != mapSizeZ) { 739 - for (int l2 = k1; l2 <= l1; l2++) { 740 - if (l2 >= 0 && l2 < mapSizeX) { 741 - for (int i3 = i2; i3 <= j2; i3++) { 742 - if (i3 >= 0 && i3 < mapSizeY && (!flag || l2 >= l1 || i3 >= j2 || i3 < i && l2 != i1)) { 743 - SceneTile class50_sub3 = groundArray[k2][l2][i3]; 741 + for (int z = j; z <= j + 1; z++) { 742 + if (z != mapSizeZ) { 743 + for (int x = k1; x <= l1; x++) { 744 + if (x >= 0 && x < mapSizeX) { 745 + for (int y = i2; y <= j2; y++) { 746 + if (y >= 0 && y < mapSizeY && (!flag || x >= l1 || y >= j2 || y < i && x != i1)) { 747 + SceneTile class50_sub3 = groundArray.getTile(z, x, y); 744 748 if (class50_sub3 != null) { 745 - int j3 = (heightMap[k2][l2][i3] 746 - + heightMap[k2][l2 + 1][i3] 747 - + heightMap[k2][l2][i3 + 1] + heightMap[k2][l2 + 1][i3 + 1]) 749 + int j3 = (heightMap[z][x][y] 750 + + heightMap[z][x + 1][y] 751 + + heightMap[z][x][y + 1] + heightMap[z][x + 1][y + 1]) 748 752 / 4 749 753 - (heightMap[j][i1][i] 750 754 + heightMap[j][i1 + 1][i] ··· 754 758 if (wall != null && wall.primary != null 755 759 && wall.primary.verticesNormal != null) { 756 760 mergeNormals(class50_sub1_sub4_sub4, 757 - (Model) wall.primary, (l2 - i1) 758 - * 128 + (1 - l) * 64, j3, (i3 - i) * 128 + (1 - j1) * 64, flag); 761 + (Model) wall.primary, (x - i1) 762 + * 128 + (1 - l) * 64, j3, (y - i) * 128 + (1 - j1) * 64, flag); 759 763 } 760 764 if (wall != null && wall.secondary != null 761 765 && wall.secondary.verticesNormal != null) { 762 766 mergeNormals(class50_sub1_sub4_sub4, 763 - (Model) wall.secondary, (l2 - i1) 764 - * 128 + (1 - l) * 64, j3, (i3 - i) * 128 + (1 - j1) * 64, flag); 767 + (Model) wall.secondary, (x - i1) 768 + * 128 + (1 - l) * 64, j3, (y - i) * 128 + (1 - j1) * 64, flag); 765 769 } 766 770 for (int k3 = 0; k3 < class50_sub3.entityCount; k3++) { 767 771 InteractiveObject interactiveObject = class50_sub3.interactiveObjects[k3]; ··· 858 862 859 863 } 860 864 861 - public void renderMinimapDot(int[] ai, int i, int j, int k, int l, int i1) { 862 - SceneTile sceneTile = groundArray[k][l][i1]; 865 + public void renderMinimapDot(int[] ai, int i, int j, int z, int x, int y) { 866 + SceneTile sceneTile = groundArray.getTile(z, x, y); 863 867 if (sceneTile == null) { 864 868 return; 865 869 } ··· 1061 1065 processCulling(); 1062 1066 anInt461 = 0; 1063 1067 for (int z = currentPositionZ; z < mapSizeZ; z++) { 1064 - SceneTile[][] tiles = groundArray[z]; 1065 1068 for (int x = currentPositionX; x < mapBoundsX; x++) { 1066 1069 for (int y = currentPositionY; y < mapBoundsY; y++) { 1067 - SceneTile tile = tiles[x][y]; 1070 + SceneTile tile = groundArray.getTile(z, x, y); 1068 1071 if (tile != null) { 1069 1072 if (tile.logicHeight > j 1070 1073 || !TILE_VISIBILITY_MAP[(x - cameraPositionTileX) + 25][(y - cameraPositionTileY) + 25] ··· 1086 1089 } 1087 1090 1088 1091 for (int z = currentPositionZ; z < mapSizeZ; z++) { 1089 - SceneTile[][] sceneTiles = groundArray[z]; 1090 1092 for (int offsetX = -25; offsetX <= 0; offsetX++) { 1091 1093 int x = cameraPositionTileX + offsetX; 1092 1094 int x2 = cameraPositionTileX - offsetX; ··· 1096 1098 int y2 = cameraPositionTileY - offsetY; 1097 1099 if (x >= currentPositionX) { 1098 1100 if (y >= currentPositionY) { 1099 - SceneTile sceneTile = sceneTiles[x][y]; 1101 + SceneTile sceneTile = groundArray.getTile(z, x, y); 1100 1102 if (sceneTile != null && sceneTile.draw) { 1101 1103 renderTile(sceneTile, true); 1102 1104 } 1103 1105 } 1104 1106 if (y2 < mapBoundsY) { 1105 - SceneTile sceneTile = sceneTiles[x][y2]; 1107 + SceneTile sceneTile = groundArray.getTile(z, x, y2); 1106 1108 if (sceneTile != null && sceneTile.draw) { 1107 1109 renderTile(sceneTile, true); 1108 1110 } ··· 1110 1112 } 1111 1113 if (x2 < mapBoundsX) { 1112 1114 if (y >= currentPositionY) { 1113 - SceneTile sceneTile = sceneTiles[x2][y]; 1115 + SceneTile sceneTile = groundArray.getTile(z, x2, y); 1114 1116 if (sceneTile != null && sceneTile.draw) { 1115 1117 renderTile(sceneTile, true); 1116 1118 } 1117 1119 } 1118 1120 if (y2 < mapBoundsY) { 1119 - SceneTile sceneTile = sceneTiles[x2][y2]; 1121 + SceneTile sceneTile = groundArray.getTile(z, x2, y2); 1120 1122 if (sceneTile != null && sceneTile.draw) { 1121 1123 renderTile(sceneTile, true); 1122 1124 } ··· 1134 1136 } 1135 1137 1136 1138 for (int z = currentPositionZ; z < mapSizeZ; z++) { 1137 - SceneTile[][] sceneTiles = groundArray[z]; 1138 1139 for (int offsetX = -25; offsetX <= 0; offsetX++) { 1139 1140 int x = cameraPositionTileX + offsetX; 1140 1141 int x2 = cameraPositionTileX - offsetX; ··· 1144 1145 int y2 = cameraPositionTileY - offsetY; 1145 1146 if (x >= currentPositionX) { 1146 1147 if (y >= currentPositionY) { 1147 - SceneTile tile = sceneTiles[x][y]; 1148 + SceneTile tile = groundArray.getTile(z, x, y); 1148 1149 if (tile != null && tile.draw) { 1149 1150 renderTile(tile, false); 1150 1151 } 1151 1152 } 1152 1153 if (y2 < mapBoundsY) { 1153 - SceneTile tile = sceneTiles[x][y2]; 1154 + SceneTile tile = groundArray.getTile(z, x, y2); 1154 1155 if (tile != null && tile.draw) { 1155 1156 renderTile(tile, false); 1156 1157 } ··· 1158 1159 } 1159 1160 if (x2 < mapBoundsX) { 1160 1161 if (y >= currentPositionY) { 1161 - SceneTile tile = sceneTiles[x2][y]; 1162 + SceneTile tile = groundArray.getTile(z, x2, y); 1162 1163 if (tile != null && tile.draw) { 1163 1164 renderTile(tile, false); 1164 1165 } 1165 1166 } 1166 1167 if (y2 < mapBoundsY) { 1167 - SceneTile tile = sceneTiles[x2][y2]; 1168 + SceneTile tile = groundArray.getTile(z, x2, y2); 1168 1169 if (tile != null && tile.draw) { 1169 1170 renderTile(tile, false); 1170 1171 } ··· 1198 1199 int y = groundTile.y; 1199 1200 int z = groundTile.z; 1200 1201 int level = groundTile.renderLevel; 1201 - SceneTile[][] tiles = groundArray[z]; 1202 1202 if (groundTile.draw) { 1203 1203 if (flag) { 1204 1204 if (z > 0) { 1205 - SceneTile tile = groundArray[z - 1][x][y]; 1205 + SceneTile tile = groundArray.getTile(z - 1, x, y); 1206 1206 if (tile != null && tile.visible) { 1207 1207 continue; 1208 1208 } 1209 1209 } 1210 1210 if (x <= cameraPositionTileX && x > currentPositionX) { 1211 - SceneTile tile = tiles[x - 1][y]; 1211 + SceneTile tile = groundArray.getTile(z, x - 1, y); 1212 1212 if (tile != null && tile.visible 1213 1213 && (tile.draw || (groundTile.interactiveObjectsSizeOR & 1) == 0)) { 1214 1214 continue; 1215 1215 } 1216 1216 } 1217 1217 if (x >= cameraPositionTileX && x < mapBoundsX - 1) { 1218 - SceneTile tile = tiles[x + 1][y]; 1218 + SceneTile tile = groundArray.getTile(z, x + 1, y); 1219 1219 if (tile != null && tile.visible 1220 1220 && (tile.draw || (groundTile.interactiveObjectsSizeOR & 4) == 0)) { 1221 1221 continue; 1222 1222 } 1223 1223 } 1224 1224 if (y <= cameraPositionTileY && y > currentPositionY) { 1225 - SceneTile tile = tiles[x][y - 1]; 1225 + SceneTile tile = groundArray.getTile(z, x, y - 1); 1226 1226 if (tile != null && tile.visible 1227 1227 && (tile.draw || (groundTile.interactiveObjectsSizeOR & 8) == 0)) { 1228 1228 continue; 1229 1229 } 1230 1230 } 1231 1231 if (y >= cameraPositionTileY && y < mapBoundsY - 1) { 1232 - SceneTile tile = tiles[x][y + 1]; 1232 + SceneTile tile = groundArray.getTile(z, x, y + 1); 1233 1233 if (tile != null && tile.visible 1234 1234 && (tile.draw || (groundTile.interactiveObjectsSizeOR & 2) == 0)) { 1235 1235 continue; ··· 1390 1390 int k4 = groundTile.interactiveObjectsSizeOR; 1391 1391 if (k4 != 0) { 1392 1392 if (x < cameraPositionTileX && (k4 & 4) != 0) { 1393 - SceneTile tile = tiles[x + 1][y]; 1393 + SceneTile tile = groundArray.getTile(z, x + 1, y); 1394 1394 if (tile != null && tile.visible) { 1395 1395 tileList.pushBack(tile); 1396 1396 } 1397 1397 } 1398 1398 if (y < cameraPositionTileY && (k4 & 2) != 0) { 1399 - SceneTile tile = tiles[x][y + 1]; 1399 + SceneTile tile = groundArray.getTile(z, x, y + 1); 1400 1400 if (tile != null && tile.visible) { 1401 1401 tileList.pushBack(tile); 1402 1402 } 1403 1403 } 1404 1404 if (x > cameraPositionTileX && (k4 & 1) != 0) { 1405 - SceneTile tile = tiles[x - 1][y]; 1405 + SceneTile tile = groundArray.getTile(z, x-1, y); 1406 1406 if (tile != null && tile.visible) { 1407 1407 tileList.pushBack(tile); 1408 1408 } 1409 1409 } 1410 1410 if (y > cameraPositionTileY && (k4 & 8) != 0) { 1411 - SceneTile tile = tiles[x][y - 1]; 1411 + SceneTile tile = groundArray.getTile(z, x, y-1); 1412 1412 if (tile != null && tile.visible) { 1413 1413 tileList.pushBack(tile); 1414 1414 } ··· 1449 1449 } 1450 1450 for (int _x = entity.tileLeft; _x <= entity.tileRight; _x++) { 1451 1451 for (int _y = entity.tileTop; _y <= entity.tileBottom; _y++) { 1452 - SceneTile tile = tiles[_x][_y]; 1452 + SceneTile tile = groundArray.getTile(z, _x, _y); 1453 1453 if (tile.draw) { 1454 1454 groundTile.drawEntities = true; 1455 1455 } else { ··· 1528 1528 } 1529 1529 for (int _x = entity.tileLeft; _x <= entity.tileRight; _x++) { 1530 1530 for (int _y = entity.tileTop; _y <= entity.tileBottom; _y++) { 1531 - SceneTile tile = tiles[_x][_y]; 1531 + SceneTile tile = groundArray.getTile(z, _x, _y); 1532 1532 if (tile.wallCullDirection != 0) { 1533 1533 tileList.pushBack(tile); 1534 1534 } else if ((_x != x || _y != y) && tile.visible) { ··· 1550 1550 continue; 1551 1551 } 1552 1552 if (x <= cameraPositionTileX && x > currentPositionX) { 1553 - SceneTile tile = tiles[x - 1][y]; 1553 + SceneTile tile = groundArray.getTile(z, x-1, y); 1554 1554 if (tile != null && tile.visible) { 1555 1555 continue; 1556 1556 } 1557 1557 } 1558 1558 if (x >= cameraPositionTileX && x < mapBoundsX - 1) { 1559 - SceneTile tile = tiles[x + 1][y]; 1559 + SceneTile tile = groundArray.getTile(z, x+1, y); 1560 1560 if (tile != null && tile.visible) { 1561 1561 continue; 1562 1562 } 1563 1563 } 1564 1564 if (y <= cameraPositionTileY && y > currentPositionY) { 1565 - SceneTile tile = tiles[x][y - 1]; 1565 + SceneTile tile = groundArray.getTile(z, x, y-1); 1566 1566 if (tile != null && tile.visible) { 1567 1567 continue; 1568 1568 } 1569 1569 } 1570 1570 if (y >= cameraPositionTileY && y < mapBoundsY - 1) { 1571 - SceneTile tile = tiles[x][y + 1]; 1571 + SceneTile tile = groundArray.getTile(z, x, y+1); 1572 1572 if (tile != null && tile.visible) { 1573 1573 continue; 1574 1574 } ··· 1646 1646 } 1647 1647 } 1648 1648 if (z < mapSizeZ - 1) { 1649 - SceneTile tile = groundArray[z + 1][x][y]; 1649 + SceneTile tile = groundArray.getTile(z+1, x, y); 1650 1650 if (tile != null && tile.visible) { 1651 1651 tileList.pushBack(tile); 1652 1652 } 1653 1653 } 1654 1654 if (x < cameraPositionTileX) { 1655 - SceneTile tile = tiles[x + 1][y]; 1655 + SceneTile tile = groundArray.getTile(z, x+1, y); 1656 1656 if (tile != null && tile.visible) { 1657 1657 tileList.pushBack(tile); 1658 1658 } 1659 1659 } 1660 1660 if (y < cameraPositionTileY) { 1661 - SceneTile tile = tiles[x][y + 1]; 1661 + SceneTile tile = groundArray.getTile(z, x, y+1); 1662 1662 if (tile != null && tile.visible) { 1663 1663 tileList.pushBack(tile); 1664 1664 } 1665 1665 } 1666 1666 if (x > cameraPositionTileX) { 1667 - SceneTile tile = tiles[x - 1][y]; 1667 + SceneTile tile = groundArray.getTile(z, x-1, y); 1668 1668 if (tile != null && tile.visible) { 1669 1669 tileList.pushBack(tile); 1670 1670 } 1671 1671 } 1672 1672 if (y > cameraPositionTileY) { 1673 - SceneTile tile = tiles[x][y - 1]; 1673 + SceneTile tile = groundArray.getTile(z, x, y-1); 1674 1674 if (tile != null && tile.visible) { 1675 1675 tileList.pushBack(tile); 1676 1676 }
+65
src/main/java/com/jagex/runescape/world/GroundArray.java
··· 1 + package com.jagex.runescape.world; 2 + 3 + 4 + public class GroundArray<T> { 5 + private static final int MAX_HEIGHT = 4; 6 + private static final int MAX_TILES = 104; 7 + private Object[][][] groundArray; 8 + 9 + public GroundArray(T[][][] groundArray) { 10 + this.groundArray = groundArray; 11 + } 12 + 13 + public GroundArray() { 14 + this.groundArray = new Object[MAX_HEIGHT][MAX_TILES][MAX_TILES]; 15 + } 16 + 17 + private boolean checkIfIndexExists(int plane, int x, int y) { 18 + if (plane < 0 || plane > this.groundArray.length - 1) { 19 + String error = String.format("Plane must be between 0 and %d, requested plane was: %d.\n", 20 + this.groundArray.length - 1, plane); 21 + new ArrayIndexOutOfBoundsException(error).printStackTrace(); 22 + return false; 23 + } 24 + if (x < 0 || x > MAX_TILES - 1) { 25 + String error = String.format("X must be between 0 and %d, requested x was: %d.\n", MAX_TILES - 1, x); 26 + new ArrayIndexOutOfBoundsException(error).printStackTrace(); 27 + return false; 28 + } 29 + if (y < 0 || y > MAX_TILES - 1) { 30 + String error = String.format("Y must be between 0 and %d, requested y was: %d.\n", MAX_TILES - 1, y); 31 + new ArrayIndexOutOfBoundsException(error).printStackTrace(); 32 + return false; 33 + } 34 + return true; 35 + } 36 + 37 + public boolean isTileEmpty(int plane, int x, int y) { 38 + if (!checkIfIndexExists(plane, x, y)) { 39 + return false; 40 + } 41 + return groundArray[plane][x][y] == null; 42 + } 43 + 44 + public void clearTile(int plane, int x, int y) { 45 + if (!checkIfIndexExists(plane, x, y)) { 46 + return; 47 + } 48 + groundArray[plane][x][y] = null; 49 + } 50 + 51 + public T getTile(int plane, int x, int y) { 52 + if (!checkIfIndexExists(plane, x, y)) { 53 + return null; 54 + } 55 + return (T) groundArray[plane][x][y]; 56 + } 57 + 58 + public T setTile(int plane, int x, int y, T tile) { 59 + if (!checkIfIndexExists(plane, x, y)) { 60 + return null; 61 + } 62 + groundArray[plane][x][y] = tile; 63 + return tile; 64 + } 65 + }