diff --git a/src/do_wear.c b/src/do_wear.c index 197e69e80..2d16d34d1 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 do_wear.c $NHDT-Date: 1496547229 2017/06/04 03:33:49 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.96 $ */ +/* NetHack 3.6 do_wear.c $NHDT-Date: 1496614914 2017/06/04 22:21:54 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.97 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1200,53 +1200,30 @@ struct obj *obj; /* if null, do all worn items; otherwise just obj itself */ } /* check whether the target object is currently being put on (or taken off-- - also checks for doffing) */ + also checks for doffing--[why?]) */ boolean donning(otmp) struct obj *otmp; { - /* long what = (occupation == take_off) ? context.takeoff.what : 0L; */ - long what = context.takeoff.what; /* if nonzero, occupation is implied */ boolean result = FALSE; /* 'W' and 'T' set afternmv, 'A' sets context.takeoff.what */ - if (otmp == uarm) - result = (afternmv == Armor_on || afternmv == Armor_off - || what == WORN_ARMOR); + if (doffing(otmp)) + result = TRUE; + else if (otmp == uarm) + result = (afternmv == Armor_on); else if (otmp == uarmu) - result = (afternmv == Shirt_on || afternmv == Shirt_off - || what == WORN_SHIRT); + result = (afternmv == Shirt_on); else if (otmp == uarmc) - result = (afternmv == Cloak_on || afternmv == Cloak_off - || what == WORN_CLOAK); + result = (afternmv == Cloak_on); else if (otmp == uarmf) - result = (afternmv == Boots_on || afternmv == Boots_off - || what == WORN_BOOTS); + result = (afternmv == Boots_on); else if (otmp == uarmh) - result = (afternmv == Helmet_on || afternmv == Helmet_off - || what == WORN_HELMET); + result = (afternmv == Helmet_on); else if (otmp == uarmg) - result = (afternmv == Gloves_on || afternmv == Gloves_off - || what == WORN_GLOVES); + result = (afternmv == Gloves_on); else if (otmp == uarms) - result = (afternmv == Shield_on || afternmv == Shield_off - || what == WORN_SHIELD); - /* these 1-turn items don't need 'afternmv' checks - [and may not actually need 'what' checks] */ - else if (otmp == uamul) - result = (what == WORN_AMUL); - else if (otmp == uleft) - result = (what == LEFT_RING); - else if (otmp == uright) - result = (what == RIGHT_RING); - else if (otmp == ublindf) - result = (what == WORN_BLINDF); - else if (otmp == uwep) - result = (what == W_WEP); - else if (otmp == uswapwep) - result = (what == W_SWAPWEP); - else if (otmp == uquiver) - result = (what == W_QUIVER); + result = (afternmv == Shield_on); return result; } diff --git a/src/steal.c b/src/steal.c index a973bf7a2..203bf331a 100644 --- a/src/steal.c +++ b/src/steal.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 steal.c $NHDT-Date: 1456618998 2016/02/28 00:23:18 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.67 $ */ +/* NetHack 3.6 steal.c $NHDT-Date: 1496614914 2017/06/04 22:21:54 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.69 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -560,18 +560,19 @@ struct monst *mtmp; /* take off outer gear if we're targetting [hypothetical] quest artifact suit, shirt, gloves, or rings */ if ((otmp == uarm || otmp == uarmu) && uarmc) - (void) Cloak_off(); + remove_worn_item(uarmc, FALSE); if (otmp == uarmu && uarm) - (void) Armor_off(); + remove_worn_item(uarm, FALSE); if ((otmp == uarmg || ((otmp == uright || otmp == uleft) && uarmg)) && uwep) { /* gloves are about to be unworn; unwield weapon(s) first */ - if (u.twoweap) - uswapwepgone(); /* will clear u.twoweap */ - uwepgone(); + if (u.twoweap) /* remove_worn_item(uswapwep) indirectly */ + remove_worn_item(uswapwep, FALSE); /* clears u.twoweap */ + remove_worn_item(uwep, FALSE); } if ((otmp == uright || otmp == uleft) && uarmg) - (void) Gloves_off(); /* handles wielded cockatrice corpse */ + /* calls Gloves_off() to handle wielded cockatrice corpse */ + remove_worn_item(uarmg, FALSE); /* finally, steal the target item */ if (otmp->owornmask) diff --git a/src/wield.c b/src/wield.c index 585e971c9..d2f51a2ee 100644 --- a/src/wield.c +++ b/src/wield.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 wield.c $NHDT-Date: 1461967849 2016/04/29 22:10:49 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.49 $ */ +/* NetHack 3.6 wield.c $NHDT-Date: 1496614915 2017/06/04 22:21:55 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.53 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -676,6 +676,10 @@ uwepgone() pline("%s shining.", Tobjnam(uwep, "stop")); } setworn((struct obj *) 0, W_WEP); + /* update takeoff mask in case uwep has just gone away while + its removal via 'A' was pending, similar to what the various + Xyzzy_off(do_wear.c) routines do for armor and accessories */ + context.takeoff.mask &= ~W_WEP; unweapon = TRUE; update_inventory(); } @@ -686,6 +690,7 @@ uswapwepgone() { if (uswapwep) { setworn((struct obj *) 0, W_SWAPWEP); + context.takeoff.mask &= ~W_SWAPWEP; update_inventory(); } } @@ -695,6 +700,7 @@ uqwepgone() { if (uquiver) { setworn((struct obj *) 0, W_QUIVER); + context.takeoff.mask &= ~W_QUIVER; update_inventory(); } }