From e08b97597c5e967dd2175328509ce7533289cd75 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Sun, 3 Jun 2007 02:33:34 +0000 Subject: [PATCH] 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. --- doc/fixes35.0 | 3 +++ src/apply.c | 17 ++++++++++------- src/mkobj.c | 11 +++++------ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/doc/fixes35.0 b/doc/fixes35.0 index 964392143..848785534 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -242,6 +242,9 @@ unicorn horn restoration no longer overrides sustain ability characteristic hider monster revived from corpse would start out hidden (even if own corpse was only object around to hide under) fix sequencing issues with dropping #invoked Heart of Ahriman +applying an unpaid stack of potions of oil forced hero to buy all of them + instead of just the one which got split off and lit +sometimes when hero is forced to buy an unpaid shop item its price changed Platform- and/or Interface-Specific Fixes diff --git a/src/apply.c b/src/apply.c index 22907e49c..7b3acf82c 100644 --- a/src/apply.c +++ b/src/apply.c @@ -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 }; diff --git a/src/mkobj.c b/src/mkobj.c index 780b84dee..8bcdcc81c 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -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;