v2.5.1: added safety checks to other potentially small entry/exit rooms
This commit is contained in:
+15
-1
@@ -56,10 +56,24 @@ public class CaveEntranceRoom extends CaveRoom {
|
|||||||
super.paint(level);
|
super.paint(level);
|
||||||
|
|
||||||
int entrance;
|
int entrance;
|
||||||
|
int tries = 30;
|
||||||
|
boolean valid;
|
||||||
do {
|
do {
|
||||||
entrance = level.pointToCell(random(2));
|
entrance = level.pointToCell(random(2));
|
||||||
|
|
||||||
} while (level.map[entrance] == Terrain.WALL || level.findMob(entrance) != null);
|
//need extra logic here as these rooms can spawn small and cramped in very rare cases
|
||||||
|
if (tries-- > 0){
|
||||||
|
valid = level.map[entrance] != Terrain.WALL && level.findMob(entrance) == null;
|
||||||
|
} else {
|
||||||
|
valid = false;
|
||||||
|
for (int i : PathFinder.NEIGHBOURS4){
|
||||||
|
if (level.map[entrance+i] != Terrain.WALL){
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
valid = valid && level.findMob(entrance) == null;
|
||||||
|
}
|
||||||
|
} while (!valid);
|
||||||
Painter.set( level, entrance, Terrain.ENTRANCE );
|
Painter.set( level, entrance, Terrain.ENTRANCE );
|
||||||
|
|
||||||
for (int i : PathFinder.NEIGHBOURS8){
|
for (int i : PathFinder.NEIGHBOURS8){
|
||||||
|
|||||||
+15
-1
@@ -55,10 +55,24 @@ public class ChasmEntranceRoom extends ChasmRoom {
|
|||||||
super.paint(level);
|
super.paint(level);
|
||||||
|
|
||||||
int entrance;
|
int entrance;
|
||||||
|
int tries = 30;
|
||||||
|
boolean valid;
|
||||||
do {
|
do {
|
||||||
entrance = level.pointToCell(random(2));
|
entrance = level.pointToCell(random(2));
|
||||||
|
|
||||||
} while (level.map[entrance] == Terrain.CHASM || level.findMob(entrance) != null);
|
//need extra logic here as these rooms can spawn small and cramped in very rare cases
|
||||||
|
if (tries-- > 0){
|
||||||
|
valid = level.map[entrance] != Terrain.CHASM && level.findMob(entrance) == null;
|
||||||
|
} else {
|
||||||
|
valid = false;
|
||||||
|
for (int i : PathFinder.NEIGHBOURS4){
|
||||||
|
if (level.map[entrance+i] != Terrain.CHASM){
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
valid = valid && level.findMob(entrance) == null;
|
||||||
|
}
|
||||||
|
} while (!valid);
|
||||||
Painter.set( level, entrance, Terrain.ENTRANCE );
|
Painter.set( level, entrance, Terrain.ENTRANCE );
|
||||||
|
|
||||||
for (int i : PathFinder.NEIGHBOURS8){
|
for (int i : PathFinder.NEIGHBOURS8){
|
||||||
|
|||||||
+15
-1
@@ -55,10 +55,24 @@ public class ChasmExitRoom extends ChasmRoom {
|
|||||||
super.paint(level);
|
super.paint(level);
|
||||||
|
|
||||||
int exit;
|
int exit;
|
||||||
|
int tries = 30;
|
||||||
|
boolean valid;
|
||||||
do {
|
do {
|
||||||
exit = level.pointToCell(random(2));
|
exit = level.pointToCell(random(2));
|
||||||
|
|
||||||
} while (level.map[exit] == Terrain.CHASM || level.findMob(exit) != null);
|
//need extra logic here as these rooms can spawn small and cramped in very rare cases
|
||||||
|
if (tries-- > 0){
|
||||||
|
valid = level.map[exit] != Terrain.CHASM && level.findMob(exit) == null;
|
||||||
|
} else {
|
||||||
|
valid = false;
|
||||||
|
for (int i : PathFinder.NEIGHBOURS4){
|
||||||
|
if (level.map[exit+i] != Terrain.CHASM){
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
valid = valid && level.findMob(exit) == null;
|
||||||
|
}
|
||||||
|
} while (!valid);
|
||||||
Painter.set( level, exit, Terrain.EXIT );
|
Painter.set( level, exit, Terrain.EXIT );
|
||||||
|
|
||||||
for (int i : PathFinder.NEIGHBOURS8){
|
for (int i : PathFinder.NEIGHBOURS8){
|
||||||
|
|||||||
Reference in New Issue
Block a user