| 3685 | }; |
| 3686 | |
| 3687 | staticfn void |
| 3688 | tipcontainer(struct obj *box) /* or bag */ |
| 3689 | { |
| 3690 | coordxy ox = u.ux, oy = u.uy; /* #tip only works at hero's location */ |
| 3691 | boolean srcheld = FALSE, dstheld = FALSE, maybeshopgoods; |
| 3692 | struct obj *targetbox = (struct obj *) 0; |
| 3693 | boolean cancelled = FALSE; |
| 3694 | |
| 3695 | /* box is either held or on floor at hero's spot; no need to check for |
| 3696 | nesting; when held, we need to update its location to match hero's; |
| 3697 | for floor, the coordinate updating is redundant */ |
| 3698 | if (get_obj_location(box, &ox, &oy, 0)) |
| 3699 | box->ox = ox, box->oy = oy; |
| 3700 | |
| 3701 | /* |
| 3702 | * TODO? |
| 3703 | * if 'box' is known to be empty or known to be locked, give up |
| 3704 | * before choosing 'targetbox'. |
| 3705 | */ |
| 3706 | targetbox = tipcontainer_gettarget(box, &cancelled); |
| 3707 | if (cancelled) |
| 3708 | return; |
| 3709 | |
| 3710 | /* Shop handling: can't rely on the container's own unpaid |
| 3711 | or no_charge status because contents might differ with it. |
| 3712 | A carried container's contents will be flagged as unpaid |
| 3713 | or not, as appropriate, and need no special handling here. |
| 3714 | Items owned by the hero get sold to the shop without |
| 3715 | confirmation as with other uncontrolled drops. A floor |
| 3716 | container's contents will be marked no_charge if owned by |
| 3717 | hero, otherwise they're owned by the shop. By passing |
| 3718 | the contents through shop billing, they end up getting |
| 3719 | treated the same as in the carried case. We do so one |
| 3720 | item at a time instead of doing whole container at once |
| 3721 | to reduce the chance of exhausting shk's billing capacity. */ |
| 3722 | maybeshopgoods = !carried(box) && costly_spot(box->ox, box->oy); |
| 3723 | |
| 3724 | if (tipcontainer_checks(box, targetbox, FALSE) != TIPCHECK_OK) |
| 3725 | return; |
| 3726 | if (targetbox |
| 3727 | && tipcontainer_checks(targetbox, NULL, TRUE) != TIPCHECK_OK) |
| 3728 | return; |
| 3729 | |
| 3730 | { |
| 3731 | struct obj *otmp, *nobj; |
| 3732 | boolean terse, highdrop = !can_reach_floor(TRUE), |
| 3733 | altarizing = IS_ALTAR(levl[ox][oy].typ), |
| 3734 | cursed_mbag = (Is_mbag(box) && box->cursed); |
| 3735 | long loss = 0L; |
| 3736 | |
| 3737 | srcheld = carried(box); |
| 3738 | dstheld = (targetbox && carried(targetbox)); |
| 3739 | if (u.uswallow) |
| 3740 | highdrop = altarizing = FALSE; |
| 3741 | terse = !(highdrop || altarizing || costly_spot(box->ox, box->oy)); |
| 3742 | box->cknown = 1; |
| 3743 | /* Terse formatting is |
| 3744 | * "Objects spill out: obj1, obj2, obj3, ..., objN." |
no test coverage detected