fix #K3016 - kicking a bag of gold in a shop
Kicking a container that had gold in it took the gold amount away from hero's credit or added to hero's debt, then didn't give a refund if the container and its gold landed within the shop. Throwing behaved likewise, just less verbosely. The problem is caused by addtobill() treating gold specially and then subfrombill() not being able to perform a reverse operation. Actually, it may be possible for subfrombill() to do that, but verifying all its uses is too much work. This moves the gold handling for drop+selling into its own routine and adds calls to that for the throwing and kicking refunds. The other calls to subfrombill() outside of shk.c appear to be ok as-is. (The calls inside that file are the ones that still need evaluation if the gold handling is to move to there.) bill_dummy_object() now uses the same o_id assignment for its dummy object as split_object() does for its new partial stack. I don't know whether the old code led to any price glitches.
This commit is contained in:
10
src/mkobj.c
10
src/mkobj.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 mkobj.c $NHDT-Date: 1596498183 2020/08/03 23:43:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.186 $ */
|
||||
/* NetHack 3.7 mkobj.c $NHDT-Date: 1606343579 2020/11/25 22:32:59 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.191 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Derek S. Ray, 2015. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -633,9 +633,7 @@ register struct obj *otmp;
|
||||
*dummy = *otmp;
|
||||
dummy->oextra = (struct oextra *) 0;
|
||||
dummy->where = OBJ_FREE;
|
||||
dummy->o_id = g.context.ident++;
|
||||
if (!dummy->o_id)
|
||||
dummy->o_id = g.context.ident++; /* ident overflowed */
|
||||
dummy->o_id = nextoid(otmp, dummy);
|
||||
dummy->timed = 0;
|
||||
copy_oextra(dummy, otmp);
|
||||
if (has_omid(dummy))
|
||||
@@ -647,8 +645,8 @@ register struct obj *otmp;
|
||||
if (cost)
|
||||
alter_cost(dummy, -cost);
|
||||
/* no_charge is only valid for some locations */
|
||||
otmp->no_charge =
|
||||
(otmp->where == OBJ_FLOOR || otmp->where == OBJ_CONTAINED) ? 1 : 0;
|
||||
otmp->no_charge = (otmp->where == OBJ_FLOOR
|
||||
|| otmp->where == OBJ_CONTAINED) ? 1 : 0;
|
||||
otmp->unpaid = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user