]> granicus.if.org Git - nethack/commitdiff
maybe fix #K3634 - failed migrating mov arrival
authorPatR <rankin@nethack.org>
Fri, 8 Jul 2022 18:07:36 +0000 (11:07 -0700)
committerPatR <rankin@nethack.org>
Fri, 8 Jul 2022 18:07:36 +0000 (11:07 -0700)
place_monster() sanity check complained that a long worm was being
put at the same location as another monster.  The long worm wasn't
on the map prior to that place attempt.  This probably fixes it but
I don't a test case so am not sure.

src/mon.c

index 61fdb17c8edc1c7af11a0edd4598488ff0ebca0a..0613aafe87825805d272a3a26b9d508cc3ba6d80 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -3292,16 +3292,23 @@ m_into_limbo(struct monst *mtmp)
 }
 
 static void
-migrate_mon(struct monst *mtmp, xint16 target_lev, xint16 xyloc)
+migrate_mon(
+    struct monst *mtmp,
+    xint16 target_lev, /* destination level */
+    xint16 xyloc)      /* MIGR_xxx flag for location within destination */
 {
-    if (!mtmp->mx) {
-        /* this was a failed arrival attempt from a prior migration;
-           force mtmp to temporarily have a valid location when starting
-           its new migration */
-        mtmp->mx = u.ux, mtmp->my = u.uy;
-    }
-    unstuck(mtmp);
-    mdrop_special_objs(mtmp);
+    /*
+     * If mtmp->mx is zero, this was a failed arrival attempt from a
+     * prior migration and mtmp isn't on the map.  In that situation
+     * it can't be engulfing or holding the hero or held by same and
+     * should have dropped any special objects during that earlier
+     * migration back when it had a valid map location.  So only
+     * perform some actions when mx is non-zero.
+     */
+    if (mtmp->mx) {
+        unstuck(mtmp);
+        mdrop_special_objs(mtmp);
+    }
     migrate_to_level(mtmp, target_lev, xyloc, (coord *) 0);
 }