]> granicus.if.org Git - nethack/commitdiff
fix B18010 fatal exploding chest at ball & chain
authornethack.allison <nethack.allison>
Sat, 8 Feb 2003 22:00:58 +0000 (22:00 +0000)
committernethack.allison <nethack.allison>
Sat, 8 Feb 2003 22:00:58 +0000 (22:00 +0000)
doc/fixes34.1
src/trap.c

index 2ff6f30ae33de6694b43837eab46aafa0f92e0af..0777903f4c55604419bd20ef80013a284997a34b 100644 (file)
@@ -372,6 +372,8 @@ monks lose their to-hit bonus for bare-handed attacking if wearing a shield
 fix case on leading character in "Crunched in the head..." in ball.c
 using travel mode to move next to a known trap and then trying to step onto
        that trap required an extra step; the first one ended up as a no-op
+punished with ball and chain on the same floor square as a trapped chest
+       when it exploded resulted in panic "remove_object: obj not on floor"
 
 
 Platform- and/or Interface-Specific Fixes
index 74f88b1a3c391bd9033f5d978a85d81454132576..9e555dea7674e26f2afcb48a29e6acc6f4565ad2 100644 (file)
@@ -3479,6 +3479,18 @@ 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();
+
                          for(otmp = level.objects[u.ux][u.uy];
                                                        otmp; otmp = otmp2) {
                              otmp2 = otmp->nexthere;