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). */
| 210 | /* An object you're wearing has been taken off by a monster (theft or |
| 211 | seduction). Also used if a worn item gets transformed (stone to flesh). */ |
| 212 | void |
| 213 | remove_worn_item( |
| 214 | struct obj *obj, |
| 215 | boolean unchain_ball) /* whether to unpunish or just unwield */ |
| 216 | { |
| 217 | unsigned oldinuse; |
| 218 | |
| 219 | if (donning(obj)) |
| 220 | cancel_don(); |
| 221 | if (!obj->owornmask) |
| 222 | return; |
| 223 | |
| 224 | /* |
| 225 | * Losing worn gear might drop hero into water or lava or onto a |
| 226 | * location-changing trap or take away the ability to breathe in water. |
| 227 | * Marking it 'in_use' prevents emergency_disrobe() from dropping it |
| 228 | * and lava_effects() from destroying it; other cases impacting object |
| 229 | * location (or destruction) might still have issues. |
| 230 | * |
| 231 | * Note: if a hangup save occurs when 'in_use' is set, the item will |
| 232 | * be destroyed via useup() during restore. Maybe remove_worn_item() |
| 233 | * and emergency_disrobe() should switch to using obj->bypass instead |
| 234 | * but that would need a lot more cooperation by callers. It's a |
| 235 | * tradeoff between protecting the player against unintentional hangup |
| 236 | * and defending the game against deliberate hangup when player sees a |
| 237 | * message about something undesirable followed by --More--. |
| 238 | */ |
| 239 | oldinuse = obj->in_use; |
| 240 | obj->in_use = 1; |
| 241 | |
| 242 | if (obj->owornmask & W_ARMOR) { |
| 243 | if (obj == uskin) { |
| 244 | impossible("Removing embedded scales?"); |
| 245 | skinback(TRUE); /* uarm = uskin; uskin = 0; */ |
| 246 | } |
| 247 | if (obj == uarm) |
| 248 | (void) Armor_off(); |
| 249 | else if (obj == uarmc) |
| 250 | (void) Cloak_off(); |
| 251 | else if (obj == uarmf) |
| 252 | (void) Boots_off(); |
| 253 | else if (obj == uarmg) |
| 254 | (void) Gloves_off(); |
| 255 | else if (obj == uarmh) |
| 256 | (void) Helmet_off(); |
| 257 | else if (obj == uarms) |
| 258 | (void) Shield_off(); |
| 259 | else if (obj == uarmu) |
| 260 | (void) Shirt_off(); |
| 261 | /* catchall -- should never happen */ |
| 262 | else |
| 263 | setworn((struct obj *) 0, obj->owornmask & W_ARMOR); |
| 264 | } else if (obj->owornmask & W_AMUL) { |
| 265 | Amulet_off(); |
| 266 | } else if (obj->owornmask & W_RING) { |
| 267 | Ring_gone(obj); |
| 268 | } else if (obj->owornmask & W_TOOL) { |
| 269 | Blindf_off(obj); |
no test coverage detected