From: Tung Nguyen Date: Wed, 9 Mar 2016 04:18:15 +0000 (+1100) Subject: Fix billing/credit when hero nests their containers on a shop floor X-Git-Tag: NetHack-3.6.1_RC01~830^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=82386643a0dcf59c60869507a4e84a1690f1f1e1;p=nethack 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. --- diff --git a/src/pickup.c b/src/pickup.c index 38c7aeea7..a332e57f6 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -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); }