Returns: -1 to stop, 1 item was removed, 0 item was not removed. */
| 2724 | |
| 2725 | /* Returns: -1 to stop, 1 item was removed, 0 item was not removed. */ |
| 2726 | staticfn int |
| 2727 | out_container(struct obj *obj) |
| 2728 | { |
| 2729 | struct obj *otmp; |
| 2730 | int res; |
| 2731 | long count; |
| 2732 | boolean is_gold = (obj->oclass == COIN_CLASS); |
| 2733 | |
| 2734 | if (!gc.current_container) { |
| 2735 | impossible("<out> no gc.current_container?"); |
| 2736 | return -1; |
| 2737 | } else if (is_gold) { |
| 2738 | obj->owt = weight(obj); |
| 2739 | } |
| 2740 | |
| 2741 | if (obj->oartifact && !touch_artifact(obj, &gy.youmonst)) |
| 2742 | return 0; |
| 2743 | |
| 2744 | if (fatal_corpse_mistake(obj, FALSE)) |
| 2745 | return -1; |
| 2746 | |
| 2747 | count = obj->quan; |
| 2748 | if ((res = lift_object(obj, gc.current_container, &count, FALSE)) <= 0) |
| 2749 | return res; |
| 2750 | |
| 2751 | if (obj->quan != count && obj->otyp != LOADSTONE) |
| 2752 | obj = splitobj(obj, count); |
| 2753 | |
| 2754 | /* Remove the object from the list. */ |
| 2755 | obj_extract_self(obj); |
| 2756 | gc.current_container->owt = weight(gc.current_container); |
| 2757 | |
| 2758 | if (Icebox) |
| 2759 | removed_from_icebox(obj); |
| 2760 | |
| 2761 | if (!obj->unpaid && !carried(gc.current_container) |
| 2762 | && costly_spot(gc.current_container->ox, gc.current_container->oy)) { |
| 2763 | obj->ox = gc.current_container->ox; |
| 2764 | obj->oy = gc.current_container->oy; |
| 2765 | addtobill(obj, FALSE, FALSE, FALSE); |
| 2766 | } |
| 2767 | if (is_pick(obj)) |
| 2768 | pick_pick(obj); /* shopkeeper feedback */ |
| 2769 | |
| 2770 | otmp = addinv(obj); |
| 2771 | pickup_prinv(otmp, count, "removing"); |
| 2772 | |
| 2773 | if (is_gold) { |
| 2774 | bot(); /* update character's gold piece count immediately */ |
| 2775 | } |
| 2776 | return 1; |
| 2777 | } |
| 2778 | |
| 2779 | /* taking a corpse out of an ice box needs a couple of adjustments */ |
| 2780 | void |
no test coverage detected