fix deleting worn obj (uchain) impossibility

... 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.
This commit is contained in:
PatR
2016-04-19 11:30:11 -07:00
parent f9a47bb63d
commit daee9f3e7c
2 changed files with 7 additions and 11 deletions

View 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

View 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) {