]> granicus.if.org Git - nethack/commitdiff
fix object pickup
authorPatR <rankin@nethack.org>
Mon, 22 Jan 2018 00:30:58 +0000 (16:30 -0800)
committerPatR <rankin@nethack.org>
Mon, 22 Jan 2018 00:30:58 +0000 (16:30 -0800)
Mentioned in the newsgroup:  picked up items have stopped merging with
compatible stacks in inventory.

The commit 0c5155584975731f2c37ace88acd046a54ae5aa6 by me on January 5
|
| fix #H6713 - unpaid_cost: object not on any bill
|
| Stealing a shop object from outside the shop with a grappling hook
| would result in that item being left marked 'unpaid' after the shop's
| bill was treated as being bought and not yet paid for.  This led to
| "unpaid_cost: object wasn't on any bill" every time inventory was
| examined.  The problem was caused by handling the shop robbery after
| removing the object from the floor but before adding it to inventory,
| so it couldn't be found to have its unpaid bit cleared.
|
inadvertently caused that.  The effect was actually deliberate but it
wasn't intended to be so widespread.  Handle extract/bill/addinv/rob
sequencing differently instead of overriding inventory merging.

doc/fixes36.1
src/pickup.c

index d33e8659872329376b6a2c8ab641b9fce656cf96..3dfa88bbb124c26d10bb91142218df7d2789ee14 100644 (file)
@@ -568,6 +568,9 @@ try again to fix achievement recording bug with mines and sokoban prizes
 the fix for secret doors on special levels always having vertical orientation
        resulted in some--but not all--secret doors within vertical walls
        being displayed as horizontal walls while still hidden
+the fix intended for "a shop object stolen from outside the shop (via
+       grappling hook) would be left marked as 'unpaid'" broke normal pickup,
+       preventing any picked up item from merging with compatible stack
 
 
 Platform- and/or Interface-Specific Fixes
index d09bbbfdba320b954638996e963aa760514dcfab..0f53d8cbb78b0885501e909d96641ee4bef108ed 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 pickup.c        $NHDT-Date: 1515144225 2018/01/05 09:23:45 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.193 $ */
+/* NetHack 3.6 pickup.c        $NHDT-Date: 1516581051 2018/01/22 00:30:51 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.194 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1500,17 +1500,16 @@ struct obj *otmp;
     boolean robshop = (!u.uswallow && otmp != uball && costly_spot(ox, oy));
 
     obj_extract_self(otmp);
-    otmp->nomerge = 1;
-    result = addinv(otmp);
-    otmp->nomerge = 0;
     newsym(ox, oy);
 
-    /* this used to be done before addinv(), but remote_burglary()
-       calls rob_shop() which calls setpaid() after moving costs of
-       unpaid items to shop debt; setpaid() calls clear_unpaid() for
-       lots of object chains, but 'otmp' wasn't on any of those so
-       remained flagged as an unpaid item in inventory, triggering
-       impossible() every time inventory was examined... */
+    /* for shop items, addinv() needs to be after addtobill() (so that
+       object merger can take otmp->unpaid into account) but before
+       remote_robbery() (which calls rob_shop() which calls setpaid()
+       after moving costs of unpaid items to shop debt; setpaid()
+       calls clear_unpaid() for lots of object chains, but 'otmp' isn't
+       on any of those between obj_extract_self() and addinv(); for
+       3.6.0, 'otmp' remained flagged as an unpaid item in inventory
+       and triggered impossible() every time inventory was examined) */
     if (robshop) {
         char saveushops[5], fakeshop[2];
 
@@ -1524,10 +1523,14 @@ struct obj *otmp;
         /* sets obj->unpaid if necessary */
         addtobill(otmp, TRUE, FALSE, FALSE);
         Strcpy(u.ushops, saveushops);
-        /* if you're outside the shop, make shk notice */
-        if (!index(u.ushops, *fakeshop))
-            remote_burglary(ox, oy);
+        robshop = otmp->unpaid && !index(u.ushops, *fakeshop);
     }
+
+    result = addinv(otmp);
+    /* if you're taking a shop item from outside the shop, make shk notice */
+    if (robshop)
+        remote_burglary(ox, oy);
+
     return result;
 }