]> granicus.if.org Git - nethack/commitdiff
fix mon_leaving_level
authorPatR <rankin@nethack.org>
Sun, 24 Apr 2022 21:44:40 +0000 (14:44 -0700)
committerPatR <rankin@nethack.org>
Sun, 24 Apr 2022 21:44:40 +0000 (14:44 -0700)
Reported directly to devteam:  changing levels while riding gave an
impossible warning, "no monster to remove".

mon_leaving_level() was trying to take hero's steed off the map but
that isn't on the map in the first place.  Only noticable if built
with EXTRA_SANITY_CHECKS enabled.  Normally remove_monster(x,y) just
sets level.monsters[x,y] to Null but with extra checks enabled it
first checks whether that is already Null.

doc/fixes3-7-0.txt
src/mon.c

index 5b31b29d7d0193c6f7ef91a12769ff14decddfa4..147e07fafc03bcdc794c989b1526918c0c239145 100644 (file)
@@ -1,4 +1,4 @@
-HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.870 $ $NHDT-Date: 1649530942 2022/04/09 19:02:22 $
+HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.890 $ $NHDT-Date: 1650836671 2022/04/24 21:44:31 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -1173,6 +1173,8 @@ one-shot food testing ability conferred by blessed scroll of food detection
 worn ring of slow digestion blocks per-turn hunger but not the hunger caused
        by wearing it; white dragon scales/mail was blocking per-turn hunger
        and didn't cause any hunger itself; change to treat it like the ring
+if the progarm was built with EXTRA_SANITY_CHECKS enabled, changing levels
+       while riding would give impossible warning "no monster to remove"
 
 curses: 'msg_window' option wasn't functional for curses unless the binary
        also included tty support
index c7ea09be52aea2a02a85cacf0d4a310a82524c62..ed5060b99dc40b9fcba0bc66db7bae91d1dfc7a0 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1,4 +1,4 @@
-/* NetHack 3.7 mon.c   $NHDT-Date: 1647911478 2022/03/22 01:11:18 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.419 $ */
+/* NetHack 3.7 mon.c   $NHDT-Date: 1650836671 2022/04/24 21:44:31 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.423 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -2310,7 +2310,7 @@ static void
 mon_leaving_level(struct monst *mon)
 {
     int mx = mon->mx, my = mon->my;
-    boolean onmap = mx > 0;
+    boolean onmap = (mx > 0 && mon != u.usteed);
 
     /* to prevent an infinite relobj-flooreffects-hmon-killed loop */
     mon->mtrapped = 0;