]> granicus.if.org Git - nethack/commitdiff
#loot in shop
authornethack.rankin <nethack.rankin>
Wed, 15 May 2002 23:15:39 +0000 (23:15 +0000)
committernethack.rankin <nethack.rankin>
Wed, 15 May 2002 23:15:39 +0000 (23:15 +0000)
     Fix the reported bug of being double-billed for a bag of
holding destroyed if #loot is used to put a wand of cancellation
into it while it's on a shop floor.  (The bug report neglected
to mention a second aspect of the situation:  you wouldn't get
billed for the wand if you used an unpaid one to trigger this.)

doc/fixes34.1
src/pickup.c

index ebf4b1a5817cf356e85b7614b7ad320ef1b021f5..cf27d2da9376d2b50b176e89a72335a111fa38d3 100644 (file)
@@ -104,6 +104,7 @@ suppress redundant message when stoning effect transforms a golem
 clear worn bits of any object grabbed by shopkeeper to avoid extract_nobj panic
 looting any container on a location should suppress looting nearby monsters
 give more specific message when forbidden role attempts to use twoweapon mode
+avoid double billing if #loot causes a shop's bag of holding to explode
 
 
 Platform- and/or Interface-Specific Fixes
index b62d1c85d7d3e9ce3459628e9d018d8a31786c4c..4d6c6b614f910c84493608d2ac8cfa1b3518305e 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)pickup.c   3.4     2002/04/07      */
+/*     SCCS Id: @(#)pickup.c   3.4     2002/05/15      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1671,6 +1671,7 @@ in_container(obj)
 register struct obj *obj;
 {
        boolean floor_container = !carried(current_container);
+       boolean was_unpaid = FALSE;
        char buf[BUFSZ];
 
        if (!current_container) {
@@ -1755,9 +1756,16 @@ register struct obj *obj;
                (void) snuff_lit(obj);
 
        if (floor_container && costly_spot(u.ux, u.uy)) {
+           if (current_container->no_charge && !obj->unpaid) {
+               /* don't sell when putting the item into your own container */
+               obj->no_charge = 1;
+           } else {
+               /* sellobj() will take an unpaid item off the shop bill */
+               was_unpaid = obj->unpaid ? TRUE : FALSE;
                sellobj_state(SELL_DELIBERATE);
                sellobj(obj, u.ux, u.uy);
                sellobj_state(SELL_NORMAL);
+           }
        }
        if (Icebox && obj->otyp != OIL_LAMP && obj->otyp != BRASS_LANTERN
                        && !Is_candle(obj)) {
@@ -1768,21 +1776,11 @@ register struct obj *obj;
                        (void) stop_timer(REVIVE_MON, (genericptr_t)obj);
                        /* mark a non-reviving corpse as such */
                        if (rot_alarm) obj->norevive = 1;
-               }
-       }
-
-       else if (Is_mbag(current_container) && mbag_explodes(obj, 0)) {
-               You("are blasted by a magical explosion!");
-
-               /* the !floor_container case is taken care of */
-               if(*u.ushops && costly_spot(u.ux, u.uy) && floor_container) {
-                   register struct monst *shkp;
-
-                   if ((shkp = shop_keeper(*u.ushops)) != 0)
-                       (void)stolen_value(current_container, u.ux, u.uy,
-                                          (boolean)shkp->mpeaceful, FALSE);
                }
+       } else if (Is_mbag(current_container) && mbag_explodes(obj, 0)) {
+               You("are blasted by a magical explosion!");
                /* did not actually insert obj yet */
+               if (was_unpaid) addtobill(obj, FALSE, FALSE, TRUE);
                obfree(obj, (struct obj *)0);
                delete_contents(current_container);
                if (!floor_container)