v0.9.2: added checks to reduce levelgen hanging
This commit is contained in:
parent
4cc28b269a
commit
75e8ba7fd9
|
@ -504,7 +504,8 @@ public abstract class RegularLevel extends Level {
|
|||
}
|
||||
|
||||
protected int randomDropCell( Class<?extends Room> roomType ) {
|
||||
while (true) {
|
||||
int tries = 100;
|
||||
while (tries-- > 0) {
|
||||
Room room = randomRoom( roomType );
|
||||
if (room == null){
|
||||
return -1;
|
||||
|
@ -529,6 +530,7 @@ public abstract class RegularLevel extends Level {
|
|||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,6 +34,7 @@ public abstract class PatchRoom extends StandardRoom {
|
|||
|
||||
protected void setupPatch(Level level, float fill, int clustering, boolean ensurePath){
|
||||
|
||||
int attempts = 0;
|
||||
if (ensurePath){
|
||||
PathFinder.setMapSize(width()-2, height()-2);
|
||||
boolean valid;
|
||||
|
@ -69,6 +70,11 @@ public abstract class PatchRoom extends StandardRoom {
|
|||
break;
|
||||
}
|
||||
}
|
||||
attempts++;
|
||||
if (attempts > 100){
|
||||
fill -= 0.01f;
|
||||
attempts = 0;
|
||||
}
|
||||
} while (!valid);
|
||||
PathFinder.setMapSize(level.width(), level.height());
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user