-/* SCCS Id: @(#)dokick.c 3.5 2005/12/02 */
+/* SCCS Id: @(#)dokick.c 3.5 2006/06/21 */
/* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */
/* NetHack may be freely redistributed. See license for details. */
if(unpaid || shop_floor_obj) {
if(unpaid) {
- subfrombill(otmp, shop_keeper(*u.ushops));
(void)stolen_value(otmp, u.ux, u.uy, TRUE, FALSE);
} else {
ox = otmp->ox;
-/* SCCS Id: @(#)dothrow.c 3.5 2006/04/14 */
+/* SCCS Id: @(#)dothrow.c 3.5 2006/06/21 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
if(!shkp) return;
if(broken) {
- if (obj->unpaid) {
+ if (obj->unpaid)
(void)stolen_value(obj, u.ux, u.uy,
(boolean)shkp->mpeaceful, FALSE);
- costly_alteration(obj, COST_DSTROY);
- /* costly_alteration() probably already called
- subfrombill() for the object, but just in case it
- didn't, call it again. If it did, this is a NOOP. */
- subfrombill(obj, shkp);
- }
obj->no_charge = 1;
return;
}
if (!costly_spot(x, y) || *in_rooms(x, y, SHOPBASE) != *u.ushops) {
/* thrown out of a shop or into a different shop */
- if (obj->unpaid) {
+ if (obj->unpaid)
(void)stolen_value(obj, u.ux, u.uy,
(boolean)shkp->mpeaceful, FALSE);
- subfrombill(obj, shkp);
- }
} else {
if (costly_spot(u.ux, u.uy) && costly_spot(x, y)) {
- if(obj->unpaid) subfrombill(obj, shkp);
- else if(!(x == shkp->mx && y == shkp->my))
- sellobj(obj, x, y);
+ if (obj->unpaid)
+ subfrombill(obj, shkp);
+ else if (x != shkp->mx || y != shkp->my)
+ sellobj(obj, x, y);
}
}
}
-/* SCCS Id: @(#)potion.c 3.5 2005/12/05 */
+/* SCCS Id: @(#)potion.c 3.5 2006/06/21 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
!objects[obj->otyp].oc_uname && cansee(mon->mx,mon->my))
docall(obj);
if(*u.ushops && obj->unpaid) {
- register struct monst *shkp =
- shop_keeper(*in_rooms(u.ux, u.uy, SHOPBASE));
+ struct monst *shkp =
+ shop_keeper(*in_rooms(u.ux, u.uy, SHOPBASE));
- if(!shkp)
- obj->unpaid = 0;
- else {
+ if (shkp)
(void)stolen_value(obj, u.ux, u.uy,
(boolean)shkp->mpeaceful, FALSE);
- subfrombill(obj, shkp);
- }
+ else
+ obj->unpaid = 0;
}
obfree(obj, (struct obj *)0);
}
-/* SCCS Id: @(#)shk.c 3.5 2006/06/17 */
+/* SCCS Id: @(#)shk.c 3.5 2006/06/21 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
/* the price of contained objects, if any */
for(otmp = obj->cobj; otmp; otmp = otmp->nobj) {
if (otmp->oclass == COIN_CLASS) continue;
- if (!billable(&shkp, otmp, ESHK(shkp)->shoproom, TRUE)) continue;
+ if (!billable(&shkp, otmp, ESHK(shkp)->shoproom, TRUE)) {
+ /* billable() returns false for objects already on bill */
+ if (!onbill(obj, shkp, FALSE)) continue;
+ /* this assumes that we're being called by stolen_value()
+ (or by a recursive call to self on behalf of it) where
+ the cost of this object is about to be added to shop
+ debt in place of having it remain on the current bill */
+ subfrombill(obj, shkp); /* avoid doubling billing */
+ }
if (!Has_contents(otmp)) {
if (otmp->unpaid || !ininv)
char roomno = *in_rooms(x, y, SHOPBASE);
struct monst *shkp = 0;
- if (!billable(&shkp, obj, roomno, FALSE))
- return 0L;
+ if (!billable(&shkp, obj, roomno, FALSE)) {
+ /* things already on the bill yield a not-billable result, so
+ we need to check bill before deciding that shk doesn't care */
+ if (!onbill(obj, shkp, FALSE)) return 0L;
+ /* shk does care; take obj off bill to avoid double billing */
+ subfrombill(obj, shkp);
+ }
if(obj->oclass == COIN_CLASS) {
gvalue += obj->quan;