]> granicus.if.org Git - nethack/commitdiff
fix Rider revival without corpse removal
authorPatR <rankin@nethack.org>
Sun, 24 Apr 2022 22:20:45 +0000 (15:20 -0700)
committerPatR <rankin@nethack.org>
Sun, 24 Apr 2022 22:20:45 +0000 (15:20 -0700)
Reported directly to devteam:  when a Rider revived, its corpse
didn't get used up.

The change to have delobj() never destroy Rider corpses, like it
won't destroy the Amulet or invocation items, didn't take into
account that they should be destroyed when Riders revive from them.
Add delobj_core() to be able to do that without changing existing
delobj() usage.

I'm surprised hardfought players haven't been all over this one.

doc/fixes3-7-0.txt
include/extern.h
src/invent.c
src/zap.c

index 147e07fafc03bcdc794c989b1526918c0c239145..f5de4645a3cdf433ea0ab050c22165f1293fe216 100644 (file)
@@ -1,4 +1,4 @@
-HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.890 $ $NHDT-Date: 1650836671 2022/04/24 21:44:31 $
+HDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.891 $ $NHDT-Date: 1650838834 2022/04/24 22:20:34 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -1175,6 +1175,8 @@ worn ring of slow digestion blocks per-turn hunger but not the hunger caused
        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"
+the change to protect Rider corpses from being destroyed by exploding chests
+       inadvertently prevented them from being used up when Riders revived
 
 curses: 'msg_window' option wasn't functional for curses unless the binary
        also included tty support
index 534f2a3ed335b7720992e581d481e29e0568a2c5..ed62059142e803b67fd1dfb9f5a30eeb380416a2 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 extern.h        $NHDT-Date: 1646870811 2022/03/10 00:06:51 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1069 $ */
+/* NetHack 3.7 extern.h        $NHDT-Date: 1650838834 2022/04/24 22:20:34 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1108 $ */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1095,6 +1095,7 @@ extern void freeinv_core(struct obj *);
 extern void freeinv(struct obj *);
 extern void delallobj(int, int);
 extern void delobj(struct obj *);
+extern void delobj_core(struct obj *, boolean);
 extern struct obj *sobj_at(int, int, int);
 extern struct obj *nxtobj(struct obj *, int, boolean);
 extern struct obj *carrying(int);
index 43ea03fc212b48b93adb37c58d759bd6e5bc237a..6348b9ab15e7e592e3d312006000945ac5b41927 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 invent.c        $NHDT-Date: 1648428942 2022/03/28 00:55:42 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.359 $ */
+/* NetHack 3.7 invent.c        $NHDT-Date: 1650838836 2022/04/24 22:20:36 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.384 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1201,15 +1201,25 @@ delallobj(int x, int y)
     }
 }
 
-/* destroy object in fobj chain (if unpaid, it remains on the bill) */
+/* normal object deletion (if unpaid, it remains on the bill) */
 void
 delobj(struct obj *obj)
+{
+    delobj_core(obj, FALSE);
+}
+
+/* destroy object; caller has control over whether to destroy something
+   that ordinarily shouldn't be destroyed */
+void
+delobj_core(
+    struct obj *obj,
+    boolean force) /* 'force==TRUE' used when reviving Rider corpses */
 {
     boolean update_map;
 
     /* obj_resists(obj,0,0) protects the Amulet, the invocation tools,
        and Rider corspes */
-    if (obj_resists(obj, 0, 0)) {
+    if (!force && obj_resists(obj, 0, 0)) {
         /* player might be doing something stupid, but we
          * can't guarantee that.  assume special artifacts
          * are indestructible via drawbridges, and exploding
@@ -1220,7 +1230,7 @@ delobj(struct obj *obj)
     }
     update_map = (obj->where == OBJ_FLOOR);
     obj_extract_self(obj);
-    if (update_map) {
+    if (update_map) { /* floor object's coordinates are always up to date */
         maybe_unhide_at(obj->ox, obj->oy);
         newsym(obj->ox, obj->oy);
     }
index 26a2317c525b02b32024111eaeb5aec14472b05a..06509cd8666464f2e3bf17ec079fd2ad115573ca 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -1,4 +1,4 @@
-/* NetHack 3.7 zap.c   $NHDT-Date: 1646870848 2022/03/10 00:07:28 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.402 $ */
+/* NetHack 3.7 zap.c   $NHDT-Date: 1650838839 2022/04/24 22:20:39 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.408 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2013. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -993,7 +993,7 @@ revive(struct obj *corpse, boolean by_hero)
         /* not useupf(), which charges */
         if (corpse->quan > 1L)
             corpse = splitobj(corpse, 1L);
-        delobj(corpse);
+        delobj_core(corpse, TRUE);
         newsym(x, y);
         break;
     case OBJ_MINVENT: