Skip to content

Commit 170e698

Browse files
committed
refactor: rename matchChunkHeightmapWithSurroundings
1 parent c3df281 commit 170e698

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

src/main/java/org/runejs/client/Landscape.java

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ public void loadRegion() {
156156
}
157157
}
158158
if(loadGeneratedMap) {
159-
for(int z = 0; z < 4; z++) {
160-
for(int x = 0; x < 13; x++) {
161-
for(int y = 0; y < 13; y++) {
162-
int data = constructMapTiles[z][x][y];
163-
boolean bool_19_ = false;
159+
for(int plane = 0; plane < 4; plane++) {
160+
for(int chunkX = 0; chunkX < 13; chunkX++) {
161+
for(int chunkY = 0; chunkY < 13; chunkY++) {
162+
int data = constructMapTiles[plane][chunkX][chunkY];
163+
boolean chunkLoaded = false;
164164
if(data != -1) {
165165
int tileRotation = (0x6 & data) >> 1;
166166
int tileX = (data & 0xffd2c2) >> 14;
@@ -169,14 +169,14 @@ public void loadRegion() {
169169
int tileCoordinates = (tileX / 8 << 8) + tileY / 8;
170170
for(int pointer = 0; pointer < mapCoordinates.length; pointer++) {
171171
if(mapCoordinates[pointer] == tileCoordinates && terrainData[pointer] != null) {
172-
loadTerrainSubblock(y * 8, 8 * (tileX & 0x7), tileZ, z, x * 8, (0x7 & tileY) * 8, tileRotation, terrainData[pointer], currentCollisionMap);
173-
bool_19_ = true;
172+
loadTerrainSubblock(chunkY * 8, 8 * (tileX & 0x7), tileZ, plane, chunkX * 8, (0x7 & tileY) * 8, tileRotation, terrainData[pointer], currentCollisionMap);
173+
chunkLoaded = true;
174174
break;
175175
}
176176
}
177177
}
178-
if(!bool_19_)
179-
method455(8 * y, z, x * 8);
178+
if(!chunkLoaded)
179+
matchChunkHeightmapWithSurroundings(plane, chunkX * 8, chunkY * 8);
180180
}
181181
}
182182
}
@@ -1320,25 +1320,29 @@ private void initiateVertexHeights(int offsetY, int sizeY, int sizeX, int offset
13201320
}
13211321
}
13221322

1323-
private void method455(int arg0, int arg1, int arg3) {
1324-
for (int i = 0; i < 8; i++) {
1325-
for (int i_0_ = 0; i_0_ < 8; i_0_++)
1326-
tile_height[arg1][arg3 + i][arg0 + i_0_] = 0;
1323+
/**
1324+
* Adjusts the height of tiles around a chunk's perimeter
1325+
*/
1326+
private void matchChunkHeightmapWithSurroundings(int plane, int tileX, int tileY) {
1327+
// clear the chunk's height values
1328+
for (int x = 0; x < 8; x++) {
1329+
for (int y = 0; y < 8; y++)
1330+
tile_height[plane][tileX + x][tileY + y] = 0;
13271331
}
1328-
if (arg3 > 0) {
1329-
for (int i = 1; i < 8; i++)
1330-
tile_height[arg1][arg3][arg0 + i] = tile_height[arg1][-1 + arg3][i + arg0];
1332+
if (tileX > 0) {
1333+
for (int y = 1; y < 8; y++)
1334+
tile_height[plane][tileX][tileY + y] = tile_height[plane][tileX - 1][y + tileY];
13311335
}
1332-
if (arg0 > 0) {
1333-
for (int i = 1; i < 8; i++)
1334-
tile_height[arg1][i + arg3][arg0] = tile_height[arg1][i + arg3][-1 + arg0];
1336+
if (tileY > 0) {
1337+
for (int x = 1; x < 8; x++)
1338+
tile_height[plane][tileX + x][tileY] = tile_height[plane][tileX + x][tileY - 1];
13351339
}
1336-
if (arg3 > 0 && tile_height[arg1][-1 + arg3][arg0] != 0)
1337-
tile_height[arg1][arg3][arg0] = tile_height[arg1][arg3 - 1][arg0];
1338-
else if (arg0 > 0 && tile_height[arg1][arg3][arg0 - 1] != 0)
1339-
tile_height[arg1][arg3][arg0] = tile_height[arg1][arg3][-1 + arg0];
1340-
else if (arg3 > 0 && arg0 > 0 && tile_height[arg1][arg3 + -1][-1 + arg0] != 0)
1341-
tile_height[arg1][arg3][arg0] = tile_height[arg1][-1 + arg3][arg0 - 1];
1340+
if (tileX > 0 && tile_height[plane][tileX - 1][tileY] != 0)
1341+
tile_height[plane][tileX][tileY] = tile_height[plane][tileX - 1][tileY];
1342+
else if (tileY > 0 && tile_height[plane][tileX][tileY - 1] != 0)
1343+
tile_height[plane][tileX][tileY] = tile_height[plane][tileX][tileY - 1];
1344+
else if (tileX > 0 && tileY > 0 && tile_height[plane][tileX - 1][tileY - 1] != 0)
1345+
tile_height[plane][tileX][tileY] = tile_height[plane][tileX - 1][tileY - 1];
13421346
}
13431347

13441348
private static int generateHslBitset(int s, int l, int h) {

0 commit comments

Comments
 (0)