]> granicus.if.org Git - nethack/commitdiff
Fix vault guard not considering monsters in walls
authorPasi Kallinen <paxed@alt.org>
Sat, 17 Nov 2018 17:59:09 +0000 (19:59 +0200)
committerPasi Kallinen <paxed@alt.org>
Mon, 19 Nov 2018 19:20:43 +0000 (21:20 +0200)
Two different cases here: a) Vault guard did not move away monsters
except if they were standing on gold, and b) moving away monsters
on a completely filled level did not work

src/vault.c

index eea24737d72ad149f9b12cd9610774078ea7ceb6..32bffdb7abf7b291c966319d8951750a0cf251fe 100644 (file)
@@ -13,6 +13,7 @@ STATIC_DCL void FDECL(restfakecorr, (struct monst *));
 STATIC_DCL boolean FDECL(in_fcorridor, (struct monst *, int, int));
 STATIC_DCL void FDECL(move_gold, (struct obj *, int));
 STATIC_DCL void FDECL(wallify_vault, (struct monst *));
+STATIC_DCL void FDECL(gd_mv_monaway, (struct monst *, int, int));
 
 void
 newegd(mtmp)
@@ -577,6 +578,19 @@ struct monst *grd;
     }
 }
 
+STATIC_OVL void
+gd_mv_monaway(grd, nx,ny)
+register struct monst *grd;
+int nx,ny;
+{
+    if (MON_AT(nx, ny) && nx != grd->mx && ny != grd->my) {
+        if (!Deaf)
+            verbalize("Out of my way, scum!");
+        if (!rloc(m_at(nx, ny), FALSE))
+            m_into_limbo(m_at(nx, ny));
+    }
+}
+
 /*
  * return  1: guard moved,  0: guard didn't,  -1: let m_move do it,  -2: died
  */
@@ -745,11 +759,7 @@ register struct monst *grd;
             mpickgold(grd); /* does a newsym */
         } else {
             /* just for insurance... */
-            if (MON_AT(m, n) && m != grd->mx && n != grd->my) {
-                if (!Deaf)
-                    verbalize("Out of my way, scum!");
-                (void) rloc(m_at(m, n), FALSE);
-            }
+            gd_mv_monaway(grd, m,n);
             remove_monster(grd->mx, grd->my);
             newsym(grd->mx, grd->my);
             place_monster(grd, m, n);
@@ -869,6 +879,7 @@ proceed:
     fcp->fy = ny;
     fcp->ftyp = typ;
 newpos:
+    gd_mv_monaway(grd, nx,ny);
     if (egrd->gddone) {
         /* The following is a kludge.  We need to keep    */
         /* the guard around in order to be able to make   */