]> granicus.if.org Git - nethack/commitdiff
Don't shop-donate non-empty bags dropped in sellobj_state SELL_DONTSELL
authorTung Nguyen <tungtn3@gmail.com>
Wed, 9 Mar 2016 03:20:58 +0000 (14:20 +1100)
committerTung Nguyen <tungtn3@gmail.com>
Fri, 11 Mar 2016 07:35:26 +0000 (18:35 +1100)
For a shop to NOT charge for an object, two conditions apply:

 1. The object's `no_charge` flag must be set.
 2. That `no_charge` flag must be set regardless of whether or not the
    shop typically sells the object in question.

There are two places in `sellobj()` which ignore the second condition,
thus transferring object ownership from the player to the shop without
the player's consent:

 1. A container is dropped in a shop that typically sells such
    containers and `sellobj_state` is `SELL_DONTSELL`.
 2. A zero-cost container holding nothing but gold is dropped in a shop
    that typically sells such containers.

Neither occurs currently in NetHack: the latter because NetHack has no
zero-cost containers, but the former is needed for an upcoming bug fix.

This may be related to SC343-21: "Accounting is incorrect for containers
dropped in a shop that does not sell them."

Based on DynaHack commit 4e79b6a (Don't shop-donate non-empty bags
dropped in sellobj_state SELL_DONTSELL) by me.

src/shk.c

index 6cf62f2c0ea910328f40d766ebea5949aaf87f47..0699d36e384ab816b7f2259baa59d1449c1a1894 100644 (file)
--- a/src/shk.c
+++ b/src/shk.c
@@ -2885,7 +2885,7 @@ xchar x, y;
 
         if (container) {
             dropped_container(obj, shkp, FALSE);
-            if (!obj->unpaid && !saleitem)
+            if (!obj->unpaid)
                 obj->no_charge = 1;
             if (unpaid)
                 subfrombill(obj, shkp);
@@ -2960,7 +2960,7 @@ xchar x, y;
             if (!isgold) {
                 if (container)
                     dropped_container(obj, shkp, FALSE);
-                if (!obj->unpaid && !saleitem)
+                if (!obj->unpaid)
                     obj->no_charge = 1;
                 subfrombill(obj, shkp);
             }