Fix infinite loop in makemon if no goodpos available

If the level was full of monsters, goodpos never returns TRUE,
and tryct would not get incremented.
This commit is contained in:
Pasi Kallinen
2015-10-11 16:18:03 +03:00
parent bc59da6418
commit 185515e1c7

View File

@@ -967,15 +967,19 @@ register int mmflags;
/* if caller wants random location, do it here */
if (x == 0 && y == 0) {
int tryct = 0; /* careful with bigrooms */
int tryct = 200; /* careful with bigrooms */
boolean good;
struct monst fakemon;
fakemon.data = ptr; /* set up for goodpos */
do {
x = rn1(COLNO - 3, 2);
y = rn2(ROWNO);
} while (!goodpos(x, y, ptr ? &fakemon : (struct monst *) 0, gpflags)
|| (!in_mklev && tryct++ < 50 && cansee(x, y)));
if (!in_mklev && cansee(x,y)) tryct--;
good = goodpos(x, y, ptr ? &fakemon : (struct monst *) 0, gpflags);
} while (tryct && !good);
if (!good)
return ((struct monst *) 0);
} else if (byyou && !in_mklev) {
coord bypos;