From: Pasi Kallinen Date: Thu, 12 Mar 2020 17:13:08 +0000 (+0200) Subject: Fix priest generated inside temple wall X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2ff852348194f4751f20d6ed6a40dcd8c479b297;p=nethack Fix priest generated inside temple wall In a rare case, a random room's width can be 2 tiles, and if that room was converted into a temple, the priest ended up inside the wall. Try to put the priest on a random valid position around the altar, or on it. --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index f1b16f3f5..e4bbf7ace 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -75,6 +75,7 @@ when punished, involuntarily teleporting and landing within chain range of "remove_object: obj not on floor" panic on hero's next move inventory cursing caused by "this water's no good" effect when drinking from a fountain didn't update persistent inventory window +fix priest created inside temple wall Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/include/extern.h b/include/extern.h index c859bbb34..c2f891b93 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2490,6 +2490,7 @@ E void FDECL(selection_free, (struct selectionvar *, BOOLEAN_P)); E void FDECL(set_selection_floodfillchk, (int FDECL((*), (int,int)))); E void FDECL(selection_floodfill, (struct selectionvar *, int, int, BOOLEAN_P)); +E boolean FDECL(pm_good_location, (int, int, struct permonst *)); E void FDECL(get_location_coord, (schar *, schar *, int, struct mkroom *, long)); E void FDECL(selection_setpoint, (int, int, struct selectionvar *, XCHAR_P)); diff --git a/src/priest.c b/src/priest.c index 581e2af9f..50ac0127d 100644 --- a/src/priest.c +++ b/src/priest.c @@ -232,12 +232,22 @@ boolean sanctum; /* is it the seat of the high priest? */ struct monst *priest; struct obj *otmp; int cnt; + int px, py, i, si = rn2(8); + struct permonst *prim = &mons[sanctum ? PM_HIGH_PRIEST : PM_ALIGNED_PRIEST]; - if (MON_AT(sx + 1, sy)) - (void) rloc(m_at(sx + 1, sy), FALSE); /* insurance */ + for (i = 0; i < 8; i++) { + px = sx + xdir[(i+si) % 8]; + py = sy + ydir[(i+si) % 8]; + if (pm_good_location(px, py, prim)) + break; + } + if (i == 8) + px = sx, py = sy; + + if (MON_AT(px, py)) + (void) rloc(m_at(px, py), FALSE); /* insurance */ - priest = makemon(&mons[sanctum ? PM_HIGH_PRIEST : PM_ALIGNED_PRIEST], - sx + 1, sy, MM_EPRI); + priest = makemon(prim, px, py, MM_EPRI); if (priest) { EPRI(priest)->shroom = (schar) ((sroom - g.rooms) + ROOMOFFSET); EPRI(priest)->shralign = Amask2align(levl[sx][sy].altarmask); diff --git a/src/sp_lev.c b/src/sp_lev.c index 25f55fa22..6cbd35be1 100755 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -1084,6 +1084,14 @@ register int humidity; return FALSE; } +boolean +pm_good_location(x, y, pm) +int x, y; +struct permonst *pm; +{ + return is_ok_location(x, y, pm_to_humidity(pm)); +} + static unpacked_coord get_unpacked_coord(loc, defhumidity) long loc;