| 2969 | } |
| 2970 | |
| 2971 | int |
| 2972 | use_container( |
| 2973 | struct obj **objp, |
| 2974 | boolean held, |
| 2975 | boolean more_containers) /* True iff #loot multiple and this isn't last */ |
| 2976 | { |
| 2977 | struct obj *otmp, *obj = *objp; |
| 2978 | boolean quantum_cat, cursed_mbag, loot_out, loot_in, loot_in_first, |
| 2979 | stash_one, inokay, outokay, outmaybe; |
| 2980 | char c, emptymsg[BUFSZ], qbuf[QBUFSZ], pbuf[QBUFSZ], xbuf[QBUFSZ]; |
| 2981 | int used = ECMD_OK; |
| 2982 | long loss; |
| 2983 | |
| 2984 | ga.abort_looting = FALSE; |
| 2985 | gs.sellobj_first = TRUE; /* in_container() should call sellobj_state() */ |
| 2986 | emptymsg[0] = '\0'; |
| 2987 | |
| 2988 | if (!u_handsy()) |
| 2989 | return ECMD_OK; |
| 2990 | |
| 2991 | if (!obj->lknown) { /* do this in advance */ |
| 2992 | obj->lknown = 1; |
| 2993 | if (held) |
| 2994 | update_inventory(); |
| 2995 | } |
| 2996 | if (obj->olocked) { |
| 2997 | pline("%s locked.", Tobjnam(obj, "are")); |
| 2998 | if (held) |
| 2999 | You("must put it down to unlock."); |
| 3000 | return ECMD_OK; |
| 3001 | } else if (obj->otrapped) { |
| 3002 | if (held) |
| 3003 | You("open %s...", the(xname(obj))); |
| 3004 | (void) chest_trap(obj, HAND, FALSE); |
| 3005 | /* even if the trap fails, you've used up this turn */ |
| 3006 | if (gm.multi >= 0) { /* in case we didn't become paralyzed */ |
| 3007 | nomul(-1); |
| 3008 | gm.multi_reason = "opening a container"; |
| 3009 | gn.nomovemsg = ""; |
| 3010 | } |
| 3011 | ga.abort_looting = TRUE; |
| 3012 | return ECMD_TIME; |
| 3013 | } |
| 3014 | |
| 3015 | gc.current_container = obj; /* for use by in/out_container */ |
| 3016 | /* |
| 3017 | * From here on out, all early returns go through 'containerdone:'. |
| 3018 | */ |
| 3019 | |
| 3020 | /* check for Schroedinger's Cat */ |
| 3021 | quantum_cat = SchroedingersBox(gc.current_container); |
| 3022 | if (quantum_cat) { |
| 3023 | observe_quantum_cat(gc.current_container, TRUE, TRUE); |
| 3024 | used = ECMD_TIME; |
| 3025 | } |
| 3026 | |
| 3027 | cursed_mbag = Is_mbag(gc.current_container) |
| 3028 | && gc.current_container->cursed |
no test coverage detected