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:
+2
-2
@@ -1478,7 +1478,7 @@ mktrap(
|
|||||||
return;
|
return;
|
||||||
if (mktrapflags & MKTRAP_MAZEFLAG)
|
if (mktrapflags & MKTRAP_MAZEFLAG)
|
||||||
mazexy(&m);
|
mazexy(&m);
|
||||||
else if (!somexy(croom, &m))
|
else if (!somexyspace(croom, &m))
|
||||||
return;
|
return;
|
||||||
} while (occupied(m.x, m.y)
|
} while (occupied(m.x, m.y)
|
||||||
|| (avoid_boulder && sobj_at(BOULDER, 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 {
|
do {
|
||||||
if (++tryct > 200)
|
if (++tryct > 200)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!somexy(croom, crd))
|
if (!somexyspace(croom, crd))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} while (occupied(crd->x, crd->y) || bydoor(crd->x, crd->y));
|
} while (occupied(crd->x, crd->y) || bydoor(crd->x, crd->y));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|||||||
+8
-3
@@ -281,7 +281,7 @@ fill_zoo(struct mkroom* sroom)
|
|||||||
}
|
}
|
||||||
i = 100;
|
i = 100;
|
||||||
do { /* don't place throne on top of stairs */
|
do { /* don't place throne on top of stairs */
|
||||||
(void) somexy(sroom, &mm);
|
(void) somexyspace(sroom, &mm);
|
||||||
tx = mm.x;
|
tx = mm.x;
|
||||||
ty = mm.y;
|
ty = mm.y;
|
||||||
} while (occupied((coordxy) tx, (coordxy) ty) && --i > 0);
|
} while (occupied((coordxy) tx, (coordxy) ty) && --i > 0);
|
||||||
@@ -294,7 +294,7 @@ fill_zoo(struct mkroom* sroom)
|
|||||||
if (sroom->irregular) {
|
if (sroom->irregular) {
|
||||||
/* center might not be valid, so put queen elsewhere */
|
/* center might not be valid, so put queen elsewhere */
|
||||||
if ((int) levl[tx][ty].roomno != rmno || levl[tx][ty].edge) {
|
if ((int) levl[tx][ty].roomno != rmno || levl[tx][ty].edge) {
|
||||||
(void) somexy(sroom, &mm);
|
(void) somexyspace(sroom, &mm);
|
||||||
tx = mm.x;
|
tx = mm.x;
|
||||||
ty = mm.y;
|
ty = mm.y;
|
||||||
}
|
}
|
||||||
@@ -403,7 +403,7 @@ fill_zoo(struct mkroom* sroom)
|
|||||||
case COURT: {
|
case COURT: {
|
||||||
struct obj *chest, *gold;
|
struct obj *chest, *gold;
|
||||||
levl[tx][ty].typ = THRONE;
|
levl[tx][ty].typ = THRONE;
|
||||||
(void) somexy(sroom, &mm);
|
(void) somexyspace(sroom, &mm);
|
||||||
gold = mksobj(GOLD_PIECE, TRUE, FALSE);
|
gold = mksobj(GOLD_PIECE, TRUE, FALSE);
|
||||||
gold->quan = (long) rn1(50 * level_difficulty(), 10);
|
gold->quan = (long) rn1(50 * level_difficulty(), 10);
|
||||||
gold->owt = weight(gold);
|
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);
|
&& 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
|
boolean
|
||||||
somexy(struct mkroom* croom,coord * c)
|
somexy(struct mkroom* croom,coord * c)
|
||||||
{
|
{
|
||||||
@@ -716,6 +720,7 @@ somexy(struct mkroom* croom,coord * c)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* like somexy(), but returns an accessible location */
|
||||||
boolean
|
boolean
|
||||||
somexyspace(struct mkroom* croom, coord *c)
|
somexyspace(struct mkroom* croom, coord *c)
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-2
@@ -500,7 +500,7 @@ vault_tele(void)
|
|||||||
register struct mkroom *croom = search_special(VAULT);
|
register struct mkroom *croom = search_special(VAULT);
|
||||||
coord c;
|
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);
|
teleds(c.x, c.y, TELEDS_TELEPORT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1465,7 +1465,7 @@ mvault_tele(struct monst* mtmp)
|
|||||||
struct mkroom *croom = search_special(VAULT);
|
struct mkroom *croom = search_special(VAULT);
|
||||||
coord c;
|
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);
|
rloc_to(mtmp, c.x, c.y);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user