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) */
| 3141 | destroy it (taking off the item might already destroy it by dunking |
| 3142 | hero into lava) */ |
| 3143 | staticfn void |
| 3144 | wornarm_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, |
no test coverage detected