fix #H9312 - partly eaten food in bones shop

Dying in a shop while carrying partly eaten food would place that food
on the floor without marking it no_charge.  But marking it that way
wouldn't have helped because as bones data gets saved, every object on
the level has its no_charge flag cleared.  So 'no_charge' needs to be
explicitly set for partly eaten food in tended shops as a bones level
gets loaded.

Most of the shk.c diff is reformatting, but it does change the
get_pricing_units() routine to lie that the quantity is zero for
partly eaten food so that when multiplying with price it won't matter
whether the price has been forced to zero or been left non-zero.
This commit is contained in:
PatR
2019-10-17 18:45:56 -07:00
parent 74dc97866b
commit 4b87e858aa
3 changed files with 36 additions and 17 deletions

View File

@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.140 $ $NHDT-Date: 1571352531 2019/10/17 22:48:51 $
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.141 $ $NHDT-Date: 1571363147 2019/10/18 01:45:47 $
This fixes36.3 file is here to capture information about updates in the 3.6.x
lineage following the release of 3.6.2 in May 2019. Please note, however,
@@ -188,6 +188,9 @@ fix monster stepping on a land mine code accessing deleted trap
revise 'O' to show symbol sets in the same order they appear in the symbols
file and order the sets in dat/symbols to yield a sensible symset menu
yellow dragons had green breath
partly eaten food in a bones level shop would show a non-zero sale price
while on the floor but not be placed on shop bill if picked up;
sale price should have been "no charge"
Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 bones.c $NHDT-Date: 1557092711 2019/05/05 21:45:11 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.75 $ */
/* NetHack 3.6 bones.c $NHDT-Date: 1571363147 2019/10/18 01:45:47 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.76 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985,1993. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -85,6 +85,24 @@ boolean restore;
} else if (has_oname(otmp)) {
sanitize_name(ONAME(otmp));
}
/* 3.6.3: set no_charge for partly eaten food in shop;
all other items become goods for sale if in a shop */
if (otmp->oclass == FOOD_CLASS && otmp->oeaten) {
struct obj *top;
char *p;
xchar ox, oy;
for (top = otmp; top->where == OBJ_CONTAINED;
top = top->ocontainer)
continue;
otmp->no_charge = (top->where == OBJ_FLOOR
&& get_obj_location(top, &ox, &oy, 0)
/* can't use costly_spot() since its
result depends upon hero's location */
&& inside_shop(ox, oy)
&& *(p = in_rooms(ox, oy, SHOPBASE))
&& tended_shop(&rooms[*p - ROOMOFFSET]));
}
} else { /* saving */
/* do not zero out o_ids for ghost levels anymore */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 shk.c $NHDT-Date: 1570236762 2019/10/05 00:52:42 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.168 $ */
/* NetHack 3.6 shk.c $NHDT-Date: 1571363148 2019/10/18 01:45:48 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.169 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -55,9 +55,10 @@ STATIC_DCL long FDECL(stolen_container, (struct obj *, struct monst *,
STATIC_DCL long FDECL(getprice, (struct obj *, BOOLEAN_P));
STATIC_DCL void FDECL(shk_names_obj, (struct monst *, struct obj *,
const char *, long, const char *));
STATIC_DCL struct obj *FDECL(bp_to_obj, (struct bill_x *));
STATIC_DCL boolean FDECL(inherits, (struct monst *, int, int, BOOLEAN_P));
STATIC_DCL void FDECL(set_repo_loc, (struct monst *));
STATIC_DCL struct obj *FDECL(bp_to_obj, (struct bill_x *));
STATIC_DCL long FDECL(get_pricing_units, (struct obj *));
STATIC_DCL boolean NDECL(angry_shk_exists);
STATIC_DCL void FDECL(rile_shk, (struct monst *));
STATIC_DCL void FDECL(rouse_shk, (struct monst *, BOOLEAN_P));
@@ -75,7 +76,6 @@ STATIC_DCL void FDECL(deserted_shop, (char *));
STATIC_DCL boolean FDECL(special_stock, (struct obj *, struct monst *,
BOOLEAN_P));
STATIC_DCL const char *FDECL(cad, (BOOLEAN_P));
STATIC_DCL long FDECL(get_pricing_units, (struct obj *obj));
/*
invariants: obj->unpaid iff onbill(obj) [unless bp->useup]
@@ -2033,7 +2033,9 @@ struct obj *obj;
{
long units = obj->quan;
if (obj->globby) {
if (obj->oclass == FOOD_CLASS && obj->oeaten) {
units = 0L;
} else if (obj->globby) {
/* globs must be sold by weight not by volume */
long unit_weight = (long) objects[obj->otyp].oc_weight,
wt = (obj->owt > 0) ? (long) obj->owt : (long) weight(obj);
@@ -4866,7 +4868,7 @@ struct obj *obj_absorber, *obj_absorbed;
* Scenario 1. Shop-owned glob absorbing into shop-owned glob
**************************************************************/
if (bp && (!obj_absorber->no_charge
|| billable(&shkp, obj_absorber, eshkp->shoproom, FALSE))) {
|| billable(&shkp, obj_absorber, eshkp->shoproom, FALSE))) {
/* the glob being absorbed has a billing record */
amount = bp->price;
eshkp->billct--;
@@ -4939,18 +4941,14 @@ struct obj *obj_absorber, *obj_absorbed;
/**************************************************************
* Scenario 3. shop_owned glob merging into player_owned glob
**************************************************************/
if (bp &&
(obj_absorber->no_charge
|| (floor_absorber && !costly_spot(x, y)))) {
if (bp && (obj_absorber->no_charge
|| (floor_absorber && !costly_spot(x, y)))) {
amount = bp->price;
bill_dummy_object(obj_absorbed);
verbalize(
"You owe me %ld %s for my %s that you %s with your%s",
amount, currency(amount), obj_typename(obj_absorbed->otyp),
ANGRY(shkp) ? "had the audacity to mix" :
"just mixed",
ANGRY(shkp) ? " stinking batch!" :
"s.");
verbalize("You owe me %ld %s for my %s that you %s with your%s",
amount, currency(amount), obj_typename(obj_absorbed->otyp),
ANGRY(shkp) ? "had the audacity to mix" : "just mixed",
ANGRY(shkp) ? " stinking batch!" : "s.");
return;
}
/**************************************************************