]> granicus.if.org Git - nethack/commitdiff
fix deleting worn obj (uchain) impossibility
authorPatR <rankin@nethack.org>
Tue, 19 Apr 2016 18:30:11 +0000 (11:30 -0700)
committerPatR <rankin@nethack.org>
Tue, 19 Apr 2016 18:30:11 +0000 (11:30 -0700)
... when exploding chest trap destroys uchain without using
unpunish() to un-wear it first.  The '!carried(uball)' clause
should be applied to the uball->ox,oy test only, not to both
uchain->ox,oy and uball->ox,oy.

doc/fixes36.1
src/trap.c

index 93a7da5653ec656ebacaa465ff746010f0be0844..b0ae56088d72b5372a5a65787791135db4ecb26d 100644 (file)
@@ -213,6 +213,7 @@ for menustyle traditional, 'D' followed by (B|U|C|X)&m presented a menu of
 for menustyles traditional or combination, 'A' (or object ID) followed by i
        displayed an inventory of everything rather than just worn items (or
        not fully identified items)
+exploding chest trap would destroy uchain while still worn if uball carried
 
 post-3.6.0: fix "object lost" panic during pickup caused by sortloot revamp
 post-3.6.0: more sortloot revisions
index 7e6987a8f5668f1a8350da1e63db217474889c72..acaa63862d1d0d483f5fd0d3c3b218ebcfecb9d1 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 trap.c  $NHDT-Date: 1457570259 2016/03/10 00:37:39 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.262 $ */
+/* NetHack 3.6 trap.c  $NHDT-Date: 1461090580 2016/04/19 18:29:40 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.266 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -4619,16 +4619,11 @@ boolean disarm;
                 loss += stolen_value(obj, ox, oy, (boolean) shkp->mpeaceful,
                                      TRUE);
             delete_contents(obj);
-            /* we're about to delete all things at this location,
-             * which could include the ball & chain.
-             * If we attempt to call unpunish() in the
-             * for-loop below we can end up with otmp2
-             * being invalid once the chain is gone.
-             * Deal with ball & chain right now instead.
-             */
-            if (Punished && !carried(uball)
-                && ((uchain->ox == u.ux && uchain->oy == u.uy)
-                    || (uball->ox == u.ux && uball->oy == u.uy)))
+            /* unpunish() in advance if either ball or chain (or both)
+               is going to be destroyed */
+            if (Punished && ((uchain->ox == u.ux && uchain->oy == u.uy)
+                             || (uball->where == OBJ_FLOOR
+                                 && uball->ox == u.ux && uball->oy == u.uy)))
                 unpunish();
 
             for (otmp = level.objects[u.ux][u.uy]; otmp; otmp = otmp2) {