From 3a49b4c4630d532beaa9427c9e24fd7947652a7d Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 24 May 2024 16:21:10 -0700 Subject: [PATCH] fix #K4179 - failed sanity check for mimic When mnearto() places a monster, it might remove another one to make room, then try to put that second one back. If it can't do that, it puts that other monster onto the migrating monsters list. But having it already be off the map interferred with regular take-mon-off-map handling that happens when setting up a migration. If the other monster was a hider or concealed mimic, it wouldn't be brought out of hiding. With 'sanity_check' enabled, that triggers a warning when the occupants of migrating_mons get checked. Testing this requires more effort than I'm willing to expend so there might be unexpected consequences. --- src/mon.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/mon.c b/src/mon.c index 993cb32a6..b028308bc 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 mon.c $NHDT-Date: 1706079843 2024/01/24 07:04:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.549 $ */ +/* NetHack 3.7 mon.c $NHDT-Date: 1716588803 2024/05/24 22:13:23 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.568 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -3896,11 +3896,9 @@ mnearto( return res; if (move_other && (othermon = m_at(x, y)) != 0) { - if (othermon->wormno) - remove_worm(othermon); - else - remove_monster(x, y); - + /* take othermon off the map; it might end up immediately returning + but for the moment it is leaving */ + mon_leaving_level(othermon); othermon->mx = othermon->my = 0; /* 'othermon' is not on the map */ othermon->mstate |= MON_OFFMAP; }