Fix billing/credit when hero nests their containers on a shop floor

This fixes a bug where the hero could accidentally donate the contents
of their bag to a shopkeeper if they put it in another bag on the shop
floor that also belonged to the hero.  To reproduce:

 1. Drop a sack on the floor, but don't sell it.
 2. Get another sack and put in hero-owned objects.
 3. Put the sack with objects into the sack on the shop floor.
 4. Take out the sack with the objects from the sack on the shop floor.

The shopkeeper will claim you owe them for the objects in the sack, and
view the contents of the sack will show them as belonging to the
shopkeeper.

This fix is what those previous fixes for `SELL_DONTSELL` were for.

Based on DynaHack commit f91ce0b (Fix billing/credit when hero nests
their containers on a shop floor) by me.
This commit is contained in:
Tung Nguyen
2016-03-09 15:18:15 +11:00
parent 8ccdea6d8d
commit 82386643a0

View File

@@ -2025,15 +2025,14 @@ register struct obj *obj;
(void) snuff_lit(obj);
if (floor_container && costly_spot(u.ux, u.uy)) {
if (obj->oclass == COIN_CLASS) {
; /* defer gold until after put-in message */
} else if (current_container->no_charge && !obj->unpaid) {
/* don't sell when putting the item into your own container */
obj->no_charge = 1;
} else {
/* defer gold until after put-in message */
if (obj->oclass != COIN_CLASS) {
/* sellobj() will take an unpaid item off the shop bill */
was_unpaid = obj->unpaid ? TRUE : FALSE;
sellobj_state(SELL_DELIBERATE);
/* don't sell when putting the item into your own container,
* but handle billing correctly */
sellobj_state(current_container->no_charge
? SELL_DONTSELL : SELL_DELIBERATE);
sellobj(obj, u.ux, u.uy);
sellobj_state(SELL_NORMAL);
}