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.
This commit is contained in:
Pasi Kallinen
2020-03-12 19:13:08 +02:00
parent a6c600fd61
commit 2ff8523481
4 changed files with 24 additions and 4 deletions

View File

@@ -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

View File

@@ -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));

View File

@@ -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;
priest = makemon(&mons[sanctum ? PM_HIGH_PRIEST : PM_ALIGNED_PRIEST],
sx + 1, sy, MM_EPRI);
if (MON_AT(px, py))
(void) rloc(m_at(px, py), FALSE); /* insurance */
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);

View File

@@ -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;