From 4b87e858aa422beff83020f6fa00bee451d1d85e Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 17 Oct 2019 18:45:56 -0700 Subject: [PATCH] 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. --- doc/fixes36.3 | 5 ++++- src/bones.c | 20 +++++++++++++++++++- src/shk.c | 28 +++++++++++++--------------- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/doc/fixes36.3 b/doc/fixes36.3 index b1b3b3e2c..756d69da9 100644 --- a/doc/fixes36.3 +++ b/doc/fixes36.3 @@ -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 diff --git a/src/bones.c b/src/bones.c index 0a7b81793..d5623fcde 100644 --- a/src/bones.c +++ b/src/bones.c @@ -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 */ diff --git a/src/shk.c b/src/shk.c index 5fcc70c99..a3a84d64b 100644 --- a/src/shk.c +++ b/src/shk.c @@ -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; } /**************************************************************