Skip to content

Commit

Permalink
Fix everything by swapping the nested loops around. This in turn fixe…
Browse files Browse the repository at this point in the history
…s the error on HTML5 version because the catch block was not working.
  • Loading branch information
SonicGDX committed Dec 31, 2022
1 parent 23ae690 commit ec84147
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions core/src/main/java/com/sonicgdx/sonicswirl/TileMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,12 @@ public enum TileMap {

public static Tile getTile(int chunkX, int chunkY, int tileX, int tileY)
{
if (chunkX < map.length && chunkY < map[chunkX].length && tileX < map[chunkX][chunkY].length && tileY < map[chunkX][chunkY][tileX].length)
if (chunkX >= 0 && chunkY >= 0 && tileX >= 0 && tileY >= 0) return map[chunkX][chunkY][tileX][tileY];
if(chunkX >= 0 && chunkY >= 0 && tileX >= 0 && tileY >= 0) {
if (chunkX < map.length && chunkY < map[chunkX].length && tileX < map[chunkX][chunkY].length && tileY < map[chunkX][chunkY][tileX].length)
return map[chunkX][chunkY][tileX][tileY];
else return TILE_MAP.EMPTY;
else {
//Gdx.app.error("getTile() Error","ArrayIndexOutOfBounds");
return TILE_MAP.EMPTY;
}

else return TILE_MAP.EMPTY;
//OLD try catch version
/*try {
return map[chunkX][chunkY][tileX][tileY];
Expand Down

0 comments on commit ec84147

Please sign in to comment.