]> granicus.if.org Git - nethack/commitdiff
Fix priest generated inside temple wall
authorPasi Kallinen <paxed@alt.org>
Thu, 12 Mar 2020 17:13:08 +0000 (19:13 +0200)
committerPasi Kallinen <paxed@alt.org>
Thu, 12 Mar 2020 17:17:06 +0000 (19:17 +0200)
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.

doc/fixes37.0
include/extern.h
src/priest.c
src/sp_lev.c

index f1b16f3f5ea9ee1b1d944e1ea09fb425900b24bb..e4bbf7ace0e570446190c3889ad5e93709f1db95 100644 (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
index c859bbb3466de216a01583c51d5153187ecc84a3..c2f891b939f00d9be6b5679420ec6bb5d4b92dff 100644 (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));
index 581e2af9f55cbbaab864af730dfd40a30d11bfff..50ac0127df9dd3782e03aa31748bd4d49385b5e3 100644 (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;
+
+    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);
index 25f55fa2238315fb4b37ba1d7596eab8d8309e32..6cbd35be1f4cf7e95039379993e6da2af2b3c870 100755 (executable)
@@ -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;