MCPcopy Index your code
hub / github.com/NetHack/NetHack / in_container

Function in_container

src/pickup.c:2557–2712  ·  view source on GitHub ↗

Returns: -1 to stop, 1 item was inserted, 0 item was not inserted. */

Source from the content-addressed store, hash-verified

2555
2556/* Returns: -1 to stop, 1 item was inserted, 0 item was not inserted. */
2557staticfn int
2558in_container(struct obj *obj)
2559{
2560 boolean floor_container = !carried(gc.current_container);
2561 boolean was_unpaid = FALSE;
2562 char buf[BUFSZ];
2563
2564 if (!gc.current_container) {
2565 impossible("<in> no gc.current_container?");
2566 return 0;
2567 } else if (obj == uball || obj == uchain) {
2568 You("must be kidding.");
2569 return 0;
2570 } else if (obj == gc.current_container) {
2571 pline("That would be an interesting topological exercise.");
2572 return 0;
2573 } else if (obj->owornmask & (W_ARMOR | W_ACCESSORY)) {
2574 Norep("You cannot %s %s you are wearing.",
2575 Icebox ? "refrigerate" : "stash", something);
2576 return 0;
2577 } else if ((obj->otyp == LOADSTONE) && obj->cursed) {
2578 set_bknown(obj, 1);
2579 pline_The("stone%s won't leave your person.", plur(obj->quan));
2580 return 0;
2581 } else if (obj->otyp == AMULET_OF_YENDOR
2582 || obj->otyp == CANDELABRUM_OF_INVOCATION
2583 || obj->otyp == BELL_OF_OPENING
2584 || obj->otyp == SPE_BOOK_OF_THE_DEAD) {
2585 /* Prohibit Amulets in containers; if you allow it, monsters can't
2586 * steal them. It also becomes a pain to check to see if someone
2587 * has the Amulet. Ditto for the Candelabrum, the Bell and the Book.
2588 */
2589 pline("%s cannot be confined in such trappings.", The(xname(obj)));
2590 return 0;
2591 } else if (obj->otyp == LEASH && obj->leashmon != 0) {
2592 pline("%s attached to your pet.", Tobjnam(obj, "are"));
2593 return 0;
2594 } else if (obj == uwep) {
2595 if (welded(obj)) {
2596 weldmsg(obj);
2597 return 0;
2598 }
2599 setuwep((struct obj *) 0);
2600 /* This uwep check is obsolete. It dates to 3.0 and earlier when
2601 * unwielding Firebrand would be fatal in hell if hero had no other
2602 * fire resistance. Life-saving would force it to be re-wielded.
2603 */
2604 if (uwep)
2605 return 0; /* unwielded, died, rewielded */
2606 } else if (obj == uswapwep) {
2607 setuswapwep((struct obj *) 0);
2608 } else if (obj == uquiver) {
2609 setuqwep((struct obj *) 0);
2610 }
2611
2612 if (fatal_corpse_mistake(obj, FALSE))
2613 return -1;
2614

Callers 2

use_containerFunction · 0.85
menu_lootFunction · 0.85

Calls 15

YouFunction · 0.85
NorepFunction · 0.85
set_bknownFunction · 0.85
pline_TheFunction · 0.85
TheFunction · 0.85
xnameFunction · 0.85
TobjnamFunction · 0.85
weldedFunction · 0.85
weldmsgFunction · 0.85
setuwepFunction · 0.85
setuswapwepFunction · 0.85
setuqwepFunction · 0.85

Tested by

no test coverage detected