]> granicus.if.org Git - nethack/commitdiff
fix #U1202 - shop robbery oversights
authornethack.rankin <nethack.rankin>
Sat, 20 Nov 2004 01:41:01 +0000 (01:41 +0000)
committernethack.rankin <nethack.rankin>
Sat, 20 Nov 2004 01:41:01 +0000 (01:41 +0000)
     A user reported that when breaking potions inside a box in a shop, he
wasn't charged for them.  The code was calling stolen_value() as intended,
but that routine only charged for types of items which the shop normally
carries.  That meant that breaking the contents of a box in a general
store would charge for them but doing so in a tool shop would, not even
though the tool shopkeeper would gladly sell such things when you picked
them up instead of causing them to go away.

     When fixing this, I noticed that stolen_value() was only charging
for single items.  Most of the time that was right, because throwing and
kicking things always split one off, but there are cases (such as zapping
a wand of teleportation at shop goods) where an entire stack gets stolen
as a group.  This makes stolen_value() handle all quantities.

doc/fixes34.4
src/shk.c

index f4982786c5b6544f7478e689bb679587f8eb9ebd..23e5fe76fead556ebb8ae4f4a00bc917f1763aaa 100644 (file)
@@ -64,6 +64,8 @@ panic on subsequent move if engulfer gets turned to stone and poly'd hero
 give more specific messages when dropping weapons due to slippery fingers
 various helmet messages changed to distinguish between "helm" and "hat"
 helmets don't protect against cockatrice eggs thrown straight up
+breaking container contents in a shop didn't always charge for them
+some types of shop theft of a stack of items only charged for a single one
 
 
 Platform- and/or Interface-Specific Fixes
index 60a74eba871e1d67cc79a1837a2620212c2b2cf5..07eb9d7ab8fc7e00641e68134c1c6cd184060f20 100644 (file)
--- a/src/shk.c
+++ b/src/shk.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)shk.c      3.4     2004/06/23      */
+/*     SCCS Id: @(#)shk.c      3.4     2004/11/17      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2412,8 +2412,11 @@ register boolean peaceful, silent;
 
            value += stolen_container(obj, shkp, value, ininv);
            if(!ininv) gvalue += contained_gold(obj);
-       } else if (!obj->no_charge && saleable(shkp, obj)) {
-           value += get_cost(obj, shkp);
+       } else if (!obj->no_charge) {
+           /* treat items inside containers as "saleable" */
+           if ((saleable(shkp, obj) || obj->where == OBJ_CONTAINED) &&
+                   (obj->oclass != FOOD_CLASS || !obj->oeaten))
+               value += obj->quan * get_cost(obj, shkp);
        }
 
        if(gvalue + value == 0L) return(0L);