Fix traps generated inside walls
When fuzzing, noticed a trap generated inside a wall. Culprit was one of the themed rooms that generates a rectangular room and then puts freestanding wall columns inside. Note in somexy that it can return a non-accessible location, and change the places that used it and absolutely needed a space to somexyspace.
This commit is contained in:
@@ -1478,7 +1478,7 @@ mktrap(
|
||||
return;
|
||||
if (mktrapflags & MKTRAP_MAZEFLAG)
|
||||
mazexy(&m);
|
||||
else if (!somexy(croom, &m))
|
||||
else if (!somexyspace(croom, &m))
|
||||
return;
|
||||
} while (occupied(m.x, m.y)
|
||||
|| (avoid_boulder && sobj_at(BOULDER, m.x, m.y)));
|
||||
@@ -1778,7 +1778,7 @@ find_okay_roompos(struct mkroom *croom, coord *crd)
|
||||
do {
|
||||
if (++tryct > 200)
|
||||
return FALSE;
|
||||
if (!somexy(croom, crd))
|
||||
if (!somexyspace(croom, crd))
|
||||
return FALSE;
|
||||
} while (occupied(crd->x, crd->y) || bydoor(crd->x, crd->y));
|
||||
return TRUE;
|
||||
|
||||
11
src/mkroom.c
11
src/mkroom.c
@@ -281,7 +281,7 @@ fill_zoo(struct mkroom* sroom)
|
||||
}
|
||||
i = 100;
|
||||
do { /* don't place throne on top of stairs */
|
||||
(void) somexy(sroom, &mm);
|
||||
(void) somexyspace(sroom, &mm);
|
||||
tx = mm.x;
|
||||
ty = mm.y;
|
||||
} while (occupied((coordxy) tx, (coordxy) ty) && --i > 0);
|
||||
@@ -294,7 +294,7 @@ fill_zoo(struct mkroom* sroom)
|
||||
if (sroom->irregular) {
|
||||
/* center might not be valid, so put queen elsewhere */
|
||||
if ((int) levl[tx][ty].roomno != rmno || levl[tx][ty].edge) {
|
||||
(void) somexy(sroom, &mm);
|
||||
(void) somexyspace(sroom, &mm);
|
||||
tx = mm.x;
|
||||
ty = mm.y;
|
||||
}
|
||||
@@ -403,7 +403,7 @@ fill_zoo(struct mkroom* sroom)
|
||||
case COURT: {
|
||||
struct obj *chest, *gold;
|
||||
levl[tx][ty].typ = THRONE;
|
||||
(void) somexy(sroom, &mm);
|
||||
(void) somexyspace(sroom, &mm);
|
||||
gold = mksobj(GOLD_PIECE, TRUE, FALSE);
|
||||
gold->quan = (long) rn1(50 * level_difficulty(), 10);
|
||||
gold->owt = weight(gold);
|
||||
@@ -667,6 +667,10 @@ inside_room(struct mkroom* croom, coordxy x, coordxy y)
|
||||
&& y >= croom->ly - 1 && y <= croom->hy + 1);
|
||||
}
|
||||
|
||||
/* return a coord c inside mkroom croom, but not in a subroom.
|
||||
returns TRUE if any such space found.
|
||||
can return a non-accessible location, eg. inside a wall
|
||||
if a themed room is not irregular, but has some non-room terrain */
|
||||
boolean
|
||||
somexy(struct mkroom* croom,coord * c)
|
||||
{
|
||||
@@ -716,6 +720,7 @@ somexy(struct mkroom* croom,coord * c)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* like somexy(), but returns an accessible location */
|
||||
boolean
|
||||
somexyspace(struct mkroom* croom, coord *c)
|
||||
{
|
||||
|
||||
@@ -500,7 +500,7 @@ vault_tele(void)
|
||||
register struct mkroom *croom = search_special(VAULT);
|
||||
coord c;
|
||||
|
||||
if (croom && somexy(croom, &c) && teleok(c.x, c.y, FALSE)) {
|
||||
if (croom && somexyspace(croom, &c) && teleok(c.x, c.y, FALSE)) {
|
||||
teleds(c.x, c.y, TELEDS_TELEPORT);
|
||||
return;
|
||||
}
|
||||
@@ -1465,7 +1465,7 @@ mvault_tele(struct monst* mtmp)
|
||||
struct mkroom *croom = search_special(VAULT);
|
||||
coord c;
|
||||
|
||||
if (croom && somexy(croom, &c) && goodpos(c.x, c.y, mtmp, 0)) {
|
||||
if (croom && somexyspace(croom, &c) && goodpos(c.x, c.y, mtmp, 0)) {
|
||||
rloc_to(mtmp, c.x, c.y);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user