From: nethack.rankin Date: Sat, 30 Mar 2002 09:50:59 +0000 (+0000) Subject: more wielded/quivered iron ball X-Git-Tag: MOVE2GIT~2859 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=11b18740907e64fbbaedaa8d1e9f8f28f0af8ca0;p=nethack more wielded/quivered iron ball There was at least one more special case aside from throwing (jetisoning items to reduce weight after falling in water) which have needed the same extra code. This is a more general fix. --- diff --git a/include/extern.h b/include/extern.h index 8ea329124..7a1b38010 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)extern.h 3.4 2002/03/09 */ +/* SCCS Id: @(#)extern.h 3.4 2002/03/29 */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1844,7 +1844,7 @@ E long FDECL(somegold, (long)); E long NDECL(somegold); #endif E void FDECL(stealgold, (struct monst *)); -E void FDECL(remove_worn_item, (struct obj *)); +E void FDECL(remove_worn_item, (struct obj *,BOOLEAN_P)); E int FDECL(steal, (struct monst *, char *)); E int FDECL(mpickobj, (struct monst *,struct obj *)); E void FDECL(stealamulet, (struct monst *)); diff --git a/src/dothrow.c b/src/dothrow.c index 4d528035b..8cc555036 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)dothrow.c 3.4 2002/02/21 */ +/* SCCS Id: @(#)dothrow.c 3.4 2002/03/29 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -167,13 +167,8 @@ int shotlimit; otmp = splitobj(obj, 1L); } else { otmp = obj; - if (otmp->owornmask && otmp != uball) - remove_worn_item(otmp); - else if ((obj->owornmask & (W_WEP|W_SWAPWEP|W_QUIVER)) != 0) { - /* wielded ball, special case */ - setworn((struct obj *)0, - (obj->owornmask & (W_WEP|W_SWAPWEP|W_QUIVER))); - } + if (otmp->owornmask) + remove_worn_item(otmp, FALSE); } freeinv(otmp); throwit(otmp, wep_mask, twoweap); diff --git a/src/mhitu.c b/src/mhitu.c index a70add960..b563f2c5a 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)mhitu.c 3.4 2002/02/17 */ +/* SCCS Id: @(#)mhitu.c 3.4 2002/03/29 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2350,7 +2350,7 @@ const char *str; /* obj == uarmh */ hairbuf); } - remove_worn_item(obj); + remove_worn_item(obj, TRUE); } #endif /* SEDUCE */ diff --git a/src/shk.c b/src/shk.c index 4c9b3b75e..e7c5f17e1 100644 --- a/src/shk.c +++ b/src/shk.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)shk.c 3.4 2002/01/19 */ +/* SCCS Id: @(#)shk.c 3.4 2002/03/29 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -103,8 +103,10 @@ long amount; return 0L; } - if (ygold->quan > amount) ygold = splitobj(ygold, amount); - else if (ygold->owornmask) remove_worn_item(ygold); /* quiver */ + if (ygold->quan > amount) + ygold = splitobj(ygold, amount); + else if (ygold->owornmask) + remove_worn_item(ygold, FALSE); /* quiver */ freeinv(ygold); add_to_minv(mon, ygold); flags.botl = 1; diff --git a/src/steal.c b/src/steal.c index dcff3a41c..482699d7d 100644 --- a/src/steal.c +++ b/src/steal.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)steal.c 3.4 2002/01/04 */ +/* SCCS Id: @(#)steal.c 3.4 2002/03/29 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -172,8 +172,9 @@ botm: stealoid = 0; /* An object you're wearing has been taken off by a monster (theft or seduction). Also used if a worn item gets transformed (stone to flesh). */ void -remove_worn_item(obj) +remove_worn_item(obj, unchain_ball) struct obj *obj; +boolean unchain_ball; /* whether to unpunish or just unwield */ { if (donning(obj)) cancel_don(); @@ -198,19 +199,21 @@ struct obj *obj; Ring_gone(obj); } else if (obj->owornmask & W_TOOL) { Blindf_off(obj); - } else if (obj->owornmask & (W_BALL|W_CHAIN)) { - unpunish(); } else if (obj->owornmask & (W_WEP|W_SWAPWEP|W_QUIVER)) { if (obj == uwep) uwepgone(); - else if (obj == uswapwep) + if (obj == uswapwep) uswapwepgone(); - else if (obj == uquiver) + if (obj == uquiver) uqwepgone(); } - /* catchall */ - if (obj->owornmask) setnotworn(obj); + if (obj->owornmask & (W_BALL|W_CHAIN)) { + if (unchain_ball) unpunish(); + } else if (obj->owornmask) { + /* catchall */ + setnotworn(obj); + } } /* Returns 1 when something was stolen (or at least, when N should flee now) @@ -333,19 +336,19 @@ gotobj: case AMULET_CLASS: case RING_CLASS: case FOOD_CLASS: /* meat ring */ - remove_worn_item(otmp); + remove_worn_item(otmp, TRUE); break; case ARMOR_CLASS: armordelay = objects[otmp->otyp].oc_delay; /* Stop putting on armor which has been stolen. */ if (donning(otmp)) { - remove_worn_item(otmp); + remove_worn_item(otmp, TRUE); break; } else if (monkey_business) { /* animals usually don't have enough patience to take off items which require extra time */ if (armordelay >= 1 && rn2(10)) goto cant_take; - remove_worn_item(otmp); + remove_worn_item(otmp, TRUE); break; } else { int curssv = otmp->cursed; @@ -370,7 +373,7 @@ gotobj: named++; /* the following is to set multi for later on */ nomul(-armordelay); - remove_worn_item(otmp); + remove_worn_item(otmp, TRUE); otmp->cursed = curssv; if(multi < 0){ /* @@ -391,7 +394,7 @@ gotobj: } } else if (otmp->owornmask) - remove_worn_item(otmp); + remove_worn_item(otmp, TRUE); /* do this before removing it from inventory */ if (objnambuf) Strcpy(objnambuf, yname(otmp)); @@ -487,7 +490,7 @@ struct monst *mtmp; if (otmp) { /* we have something to snatch */ if (otmp->owornmask) - remove_worn_item(otmp); + remove_worn_item(otmp, TRUE); freeinv(otmp); /* mpickobj wont merge otmp because none of the above things to steal are mergable */ diff --git a/src/trap.c b/src/trap.c index be96ae52e..6a37d7e93 100644 --- a/src/trap.c +++ b/src/trap.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)trap.c 3.4 2001/09/06 */ +/* SCCS Id: @(#)trap.c 3.4 20021/03/29 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2524,7 +2524,7 @@ boolean *lostsome; #else if (!otmp) return (FALSE); /* nothing to drop! */ #endif - if (otmp->owornmask && otmp != uball) remove_worn_item(otmp); + if (otmp->owornmask) remove_worn_item(otmp, FALSE); *lostsome = TRUE; dropx(otmp); invc--; diff --git a/src/zap.c b/src/zap.c index 318e77f66..62ba27b0c 100644 --- a/src/zap.c +++ b/src/zap.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)zap.c 3.4 2002/02/07 */ +/* SCCS Id: @(#)zap.c 3.4 2002/03/29 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1343,7 +1343,7 @@ poly_obj(obj, id) /* for now, take off worn items being polymorphed */ if (obj_location == OBJ_INVENT) { if (id == STRANGE_OBJECT) - remove_worn_item(obj); + remove_worn_item(obj, TRUE); else { /* This is called only for stone to flesh. It's a lot simpler * than it otherwise might be. We don't need to check for @@ -1351,7 +1351,7 @@ poly_obj(obj, id) * any) and only three worn masks are possible. */ otmp->owornmask = obj->owornmask; - remove_worn_item(obj); + remove_worn_item(obj, TRUE); setworn(otmp, otmp->owornmask); if (otmp->owornmask & LEFT_RING) uleft = otmp;