diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/CavesPainter.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/CavesPainter.java index 7e5b676d6..54c84aab6 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/CavesPainter.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/CavesPainter.java @@ -57,11 +57,14 @@ public class CavesPainter extends RegularPainter { } int s = room.square(); - + + //for each corner, we have a chance to fill based on room size + //but not if filling that corner blocks a connection or places a visible trap next to a wall if (Random.Int( s ) > 8) { int corner = (room.left + 1) + (room.top + 1) * w; if (map[corner-1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-1)) - && map[corner-w] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-w))) { + && map[corner-w] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-w)) + && map[corner+1] != Terrain.TRAP && map[corner+w] != Terrain.TRAP) { map[corner] = Terrain.WALL; level.traps.remove(corner); } @@ -70,7 +73,8 @@ public class CavesPainter extends RegularPainter { if (Random.Int( s ) > 8) { int corner = (room.right - 1) + (room.top + 1) * w; if (map[corner+1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+1)) - && map[corner-w] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-w))) { + && map[corner-w] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-w)) + && map[corner-1] != Terrain.TRAP && map[corner+w] != Terrain.TRAP) { map[corner] = Terrain.WALL; level.traps.remove(corner); } @@ -79,7 +83,8 @@ public class CavesPainter extends RegularPainter { if (Random.Int( s ) > 8) { int corner = (room.left + 1) + (room.bottom - 1) * w; if (map[corner-1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-1)) - && map[corner+w] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+w))) { + && map[corner+w] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+w)) + && map[corner+1] != Terrain.TRAP && map[corner-w] != Terrain.TRAP) { map[corner] = Terrain.WALL; level.traps.remove(corner); } @@ -88,14 +93,15 @@ public class CavesPainter extends RegularPainter { if (Random.Int( s ) > 8) { int corner = (room.right - 1) + (room.bottom - 1) * w; if (map[corner+1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+1)) - && map[corner+w] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+w))) { + && map[corner+w] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+w)) + && map[corner-1] != Terrain.TRAP && map[corner-w] != Terrain.TRAP) { map[corner] = Terrain.WALL; level.traps.remove(corner); } } } - + for (int i=w + 1; i < l - w; i++) { if (map[i] == Terrain.EMPTY) { int n = 0;