From: PatR Date: Fri, 8 Jul 2022 18:07:36 +0000 (-0700) Subject: maybe fix #K3634 - failed migrating mov arrival X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c536c6920d5fb684f53623c1fb0940ff0601982d;p=nethack maybe fix #K3634 - failed migrating mov arrival 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. --- diff --git a/src/mon.c b/src/mon.c index 61fdb17c8..0613aafe8 100644 --- 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); }