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

View File

@@ -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;