igniting unpaid potions of oil (trunk only)

From another many year old news posting:  if you picked up a stack
of potions of oil in a shop and then applied them, one potion was split
off and started burning but you were forced to pay for all of them.
Split the to-be-lit one off first so that the remainder of the stack
stays as ordinary unpaid shop goods.

     This also fixes an old bug with bill_dummy_object sometimes charging
a different price than the player got quoted when an object was picked up.
This commit is contained in:
nethack.rankin
2007-06-03 02:33:34 +00:00
parent 66f95ef37c
commit e08b97597c
3 changed files with 18 additions and 13 deletions

View File

@@ -1265,6 +1265,7 @@ light_cocktail(obj)
struct obj *obj; /* obj is a potion of oil */
{
char buf[BUFSZ];
boolean split1off;
if (u.uswallow) {
You(no_elbow_room);
@@ -1287,8 +1288,12 @@ light_cocktail(obj)
return;
}
split1off = (obj->quan > 1L);
if (split1off) obj = splitobj(obj, 1L);
You("light %spotion.%s", shk_your(buf, obj),
Blind ? "" : " It gives off a dim light.");
if (obj->unpaid && costly_spot(u.ux, u.uy)) {
/* Normally, we shouldn't both partially and fully charge
* for an item, but (Yendorian Fuel) Taxes are inevitable...
@@ -1299,16 +1304,14 @@ light_cocktail(obj)
}
makeknown(obj->otyp);
if (obj->quan > 1L) {
obj = splitobj(obj, 1L);
begin_burn(obj, FALSE); /* burn before free to get position */
begin_burn(obj, FALSE); /* after shop billing */
if (split1off) {
obj_extract_self(obj); /* free from inv */
/* shouldn't merge */
obj->nomerge = 1;
obj = hold_another_object(obj, "You drop %s!",
doname(obj), (const char *)0);
} else
begin_burn(obj, FALSE);
if (obj) obj->nomerge = 0;
}
}
static NEARDATA const char cuddly[] = { TOOL_CLASS, GEM_CLASS, 0 };

View File

@@ -465,11 +465,6 @@ struct obj *otmp;
* an object which is different from what it started out as; the "I x"
* command needs to display the original object.
*
* [BUG: The cost might end up being different if item originally had a
* surcharge but doesn't get one now or vice versa. Having the dummy keep
* the same o_id value as the original would avoid this; is that viable?
* (Mustn't give the original itself a new o_id, so can't just swap them.)]
*
* The caller is responsible for checking otmp->unpaid and
* costly_spot(u.ux, u.uy). This function will make otmp no charge.
*
@@ -481,9 +476,12 @@ bill_dummy_object(otmp)
register struct obj *otmp;
{
register struct obj *dummy;
long cost = 0L;
if (otmp->unpaid)
if (otmp->unpaid) {
cost = unpaid_cost(otmp, FALSE);
subfrombill(otmp, shop_keeper(*u.ushops));
}
dummy = newobj();
*dummy = *otmp;
dummy->oextra = (struct oextra *)0;
@@ -495,6 +493,7 @@ register struct obj *otmp;
if (has_omid(dummy)) free_omid(dummy); /* only one association with m_id*/
if (Is_candle(dummy)) dummy->lamplit = 0;
addtobill(dummy, FALSE, TRUE, TRUE);
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;