From 46be732d44f5bed1eb3936a4089ae4d00ff861e5 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 2 Oct 2016 16:31:47 -0400 Subject: [PATCH] v0.4.3: fixed dungeon tile map occasionaly causing crashes --- .../shatteredpixeldungeon/DungeonTilemap.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/DungeonTilemap.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/DungeonTilemap.java index 9d7734227..46d17f2ef 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/DungeonTilemap.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/DungeonTilemap.java @@ -174,10 +174,11 @@ public class DungeonTilemap extends Tilemap { @Override public synchronized void updateMapCell(int cell) { //update in a 3x3 grid to accound for neighbours which might also be affected - super.updateMapCell(cell - mapWidth - 1); - super.updateMapCell(cell + mapWidth + 1); + super.updateMapCell(Math.max( 0, cell - mapWidth - 1)); + super.updateMapCell(Math.min( size-1, cell + mapWidth + 1)); for (int i : PathFinder.NEIGHBOURS9) - data[cell+i] = getTileVisual(cell+i, map[cell+i]); + if (cell+i >= 0 && cell+i <= 1023) + data[cell+i] = getTileVisual(cell+i, map[cell+i]); } private int getTileVisual(int pos, int tile){