MCPcopy Create free account
hub / github.com/NetHack/NetHack / wornarm_destroyed

Function wornarm_destroyed

src/do_wear.c:3143–3182  ·  view source on GitHub ↗

take off the specific worn object and if it still exists after that, destroy it (taking off the item might already destroy it by dunking hero into lava) */

Source from the content-addressed store, hash-verified

3141 destroy it (taking off the item might already destroy it by dunking
3142 hero into lava) */
3143staticfn void
3144wornarm_destroyed(struct obj *wornarm)
3145{
3146 struct obj *invobj, *nextobj;
3147 unsigned wornoid = wornarm->o_id;
3148
3149 /* cancel_don() resets 'afternmv' when appropriate but doesn't reset
3150 uarmc/uarm/&c so doing this now won't interfere with the tests in
3151 'if (wornarm==uarmc) ... else if (wornarm==uarm) ... else ...' */
3152 if (donning(wornarm))
3153 cancel_don();
3154
3155 if (wornarm == uarmc)
3156 (void) Cloak_off();
3157 else if (wornarm == uarm)
3158 (void) Armor_off();
3159 else if (wornarm == uarmu)
3160 (void) Shirt_off();
3161 else if (wornarm == uarmh)
3162 (void) Helmet_off();
3163 else if (wornarm == uarmg)
3164 (void) Gloves_off();
3165 else if (wornarm == uarmf)
3166 (void) Boots_off();
3167 else if (wornarm == uarms)
3168 (void) Shield_off();
3169
3170 /* 'wornarm' might be destroyed as a side-effect of xxx_off() so
3171 using carried() to check wornarm->where==OBJ_INVENT is not viable;
3172 scan invent instead; if already freed it shouldn't be possible to
3173 have re-used the stale memory for a new item yet but verify o_id
3174 just in case */
3175 for (invobj = gi.invent; invobj; invobj = nextobj) {
3176 nextobj = invobj->nobj;
3177 if (invobj == wornarm && invobj->o_id == wornoid) {
3178 useup(wornarm);
3179 break;
3180 }
3181 }
3182}
3183
3184/*
3185 * returns impacted armor with its in_use bit set,

Callers 1

disintegrate_armFunction · 0.85

Calls 10

donningFunction · 0.85
cancel_donFunction · 0.85
Cloak_offFunction · 0.85
Armor_offFunction · 0.85
Shirt_offFunction · 0.85
Helmet_offFunction · 0.85
Gloves_offFunction · 0.85
Boots_offFunction · 0.85
Shield_offFunction · 0.85
useupFunction · 0.85

Tested by

no test coverage detected