From: Pasi Kallinen Date: Sun, 29 Mar 2020 08:17:37 +0000 (+0300) Subject: Fix monsters overflowing out of rooms in special levels X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3776b7d382a391c82016b21bb75cbbcc980e27fe;p=nethack Fix monsters overflowing out of rooms in special levels In a special level, creating more monsters inside room contents than was space in the room placed monsters outside the room, possibly inside walls of rooms created afterwards. Prevent monster creation if inside room contents and there's no space for the monster. --- diff --git a/src/mkroom.c b/src/mkroom.c index 0a3319289..d5196ce1a 100644 --- a/src/mkroom.c +++ b/src/mkroom.c @@ -652,6 +652,11 @@ inside_room(croom, x, y) struct mkroom *croom; xchar x, y; { + if (croom->irregular) { + int i = (int) ((croom - g.rooms) + ROOMOFFSET); + return (!levl[x][y].edge && (int) levl[x][y].roomno == i); + } + return (boolean) (x >= croom->lx - 1 && x <= croom->hx + 1 && y >= croom->ly - 1 && y <= croom->hy + 1); } diff --git a/src/sp_lev.c b/src/sp_lev.c index f5078c7d4..d60c4a062 100755 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -1794,6 +1794,9 @@ struct mkroom *croom; if (MON_AT(x, y) && enexto(&cc, x, y, pm)) x = cc.x, y = cc.y; + if (croom && !inside_room(croom, x, y)) + return; + if (m->align != AM_SPLEV_RANDOM) mtmp = mk_roamer(pm, Amask2align(amask), x, y, m->peaceful); else if (PM_ARCHEOLOGIST <= m->id && m->id <= PM_WIZARD)