v2.4.0: fixed rare cases of visible traps being in halls in caves

This commit is contained in:
Evan Debenham
2024-04-05 13:09:36 -04:00
parent 6e5d221200
commit d76667a0e2
@@ -58,10 +58,13 @@ public class CavesPainter extends RegularPainter {
int s = room.square(); 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) { if (Random.Int( s ) > 8) {
int corner = (room.left + 1) + (room.top + 1) * w; int corner = (room.left + 1) + (room.top + 1) * w;
if (map[corner-1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-1)) 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; map[corner] = Terrain.WALL;
level.traps.remove(corner); level.traps.remove(corner);
} }
@@ -70,7 +73,8 @@ public class CavesPainter extends RegularPainter {
if (Random.Int( s ) > 8) { if (Random.Int( s ) > 8) {
int corner = (room.right - 1) + (room.top + 1) * w; int corner = (room.right - 1) + (room.top + 1) * w;
if (map[corner+1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+1)) 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; map[corner] = Terrain.WALL;
level.traps.remove(corner); level.traps.remove(corner);
} }
@@ -79,7 +83,8 @@ public class CavesPainter extends RegularPainter {
if (Random.Int( s ) > 8) { if (Random.Int( s ) > 8) {
int corner = (room.left + 1) + (room.bottom - 1) * w; int corner = (room.left + 1) + (room.bottom - 1) * w;
if (map[corner-1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-1)) 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; map[corner] = Terrain.WALL;
level.traps.remove(corner); level.traps.remove(corner);
} }
@@ -88,7 +93,8 @@ public class CavesPainter extends RegularPainter {
if (Random.Int( s ) > 8) { if (Random.Int( s ) > 8) {
int corner = (room.right - 1) + (room.bottom - 1) * w; int corner = (room.right - 1) + (room.bottom - 1) * w;
if (map[corner+1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+1)) 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; map[corner] = Terrain.WALL;
level.traps.remove(corner); level.traps.remove(corner);
} }