From 5f5f7f63f1b0923149f91d1645f2af508a0713b6 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 25 Dec 2018 16:45:41 -0800 Subject: [PATCH 1/3] stolen_value() vs containers stolen_value() treated hero-owned container holding shop-owned goods as free for the taking. The fix I'm working on which led to discovering this first added stolen_value() then eventually stopped using it so I don't have an example of where it is giving the wrong result. --- src/invent.c | 18 +++++++++++++++--- src/shk.c | 12 +++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/invent.c b/src/invent.c index 62ec70401..21fdcdf4b 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 invent.c $NHDT-Date: 1545597422 2018/12/23 20:37:02 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.245 $ */ +/* NetHack 3.6 invent.c $NHDT-Date: 1545785120 2018/12/26 00:45:20 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.246 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2892,6 +2892,7 @@ int *bcp, *ucp, *ccp, *xcp, *ocp; } } +/* count everything inside a container, or just shop-owned items inside */ long count_contents(container, nested, quantity, everything) struct obj *container; @@ -2899,13 +2900,24 @@ boolean nested, /* include contents of any nested containers */ quantity, /* count all vs count separate stacks */ everything; /* all objects vs only unpaid objects */ { - struct obj *otmp; + struct obj *otmp, *topc; + boolean shoppy = FALSE; long count = 0L; + if (!everything) { + for (topc = container; topc->ocontainer; topc = topc->ocontainer) + continue; + if (topc->where == OBJ_FLOOR) { + xchar x, y; + + (void) get_obj_location(topc, &x, &y, CONTAINED_TOO); + shoppy = costly_spot(x, y); + } + } for (otmp = container->cobj; otmp; otmp = otmp->nobj) { if (nested && Has_contents(otmp)) count += count_contents(otmp, nested, quantity, everything); - if (everything || otmp->unpaid) + if (everything || otmp->unpaid || (shoppy && !otmp->no_charge)) count += quantity ? otmp->quan : 1L; } return count; diff --git a/src/shk.c b/src/shk.c index 9f6715415..de436de87 100644 --- a/src/shk.c +++ b/src/shk.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 shk.c $NHDT-Date: 1545774524 2018/12/25 21:48:44 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.145 $ */ +/* NetHack 3.6 shk.c $NHDT-Date: 1545785119 2018/12/26 00:45:19 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.146 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2811,11 +2811,13 @@ boolean peaceful, silent; if (!billable(&shkp, obj, roomno, FALSE)) { /* things already on the bill yield a not-billable result, so we need to check bill before deciding that shk doesn't care */ - if ((bp = onbill(obj, shkp, FALSE)) == 0) + if ((bp = onbill(obj, shkp, FALSE)) != 0) { + /* shk does care; take obj off bill to avoid double billing */ + billamt = bp->bquan * bp->price; + sub_one_frombill(obj, shkp); + } + if (!bp && !u_count) return 0L; - /* shk does care; take obj off bill to avoid double billing */ - billamt = bp->bquan * bp->price; - sub_one_frombill(obj, shkp); } if (obj->oclass == COIN_CLASS) { From 96eebc195534464b8ebdbb5f5ca2877d61cdc456 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 25 Dec 2018 16:52:33 -0800 Subject: [PATCH 2/3] bill hero for magic bag explosion Exploding a bag of holding on a shop floor didn't bill for shop-owned contents which got destroyed. This puts them on the 'Ix' used up list. --- doc/fixes36.2 | 2 ++ src/pickup.c | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index 2b164de23..d5e938a76 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -305,6 +305,8 @@ life-saving while weak/starving/fainting boosted nutrition without restoring lost point of strength, making temporary loss be permanent unlike #chat in a shop, walking on an item in a shop failed to include price for hero-owned container holding shop-owned items +bag of holding explosion inside shop billed hero for unpaid contents if it + happened when applied while carried but not when looted while on floor Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository diff --git a/src/pickup.c b/src/pickup.c index a8b611454..437357896 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pickup.c $NHDT-Date: 1545597427 2018/12/23 20:37:07 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.221 $ */ +/* NetHack 3.6 pickup.c $NHDT-Date: 1545785547 2018/12/26 00:52:27 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.222 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2201,6 +2201,19 @@ register struct obj *obj; if (was_unpaid) addtobill(obj, FALSE, FALSE, TRUE); obfree(obj, (struct obj *) 0); + /* if carried, shop goods will be flagged 'unpaid' and obfree() will + handle bill issues, but if on floor, we need to put them on bill + before deleting them (non-shop items will be flagged 'no_charge') */ + if (floor_container + && costly_spot(current_container->ox, current_container->oy)) { + struct obj save_no_charge; + + save_no_charge.no_charge = current_container->no_charge; + addtobill(current_container, FALSE, FALSE, FALSE); + /* addtobill() clears no charge; we need to set it back + so that useupf() doesn't double bill */ + current_container->no_charge = save_no_charge.no_charge; + } delete_contents(current_container); if (!floor_container) useup(current_container); From cae50298b653b45fe8137caf5cd66ba172caf6a1 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 25 Dec 2018 17:07:45 -0800 Subject: [PATCH 3/3] container_contents() vs show goods Fix another inconsistency with containers in shops: prices shown when looking inside. Apply had them (because shop goods in containers are flagged as 'unpaid' when hero carries the container), and loot did not (because they aren't flagged that way). --- doc/fixes36.2 | 2 ++ src/end.c | 4 ++-- src/shk.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index d5e938a76..120e67360 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -307,6 +307,8 @@ unlike #chat in a shop, walking on an item in a shop failed to include price for hero-owned container holding shop-owned items bag of holding explosion inside shop billed hero for unpaid contents if it happened when applied while carried but not when looted while on floor +looking into an applied container with ':' showed prices of unpaid items but + looking into a looted one with ':' did not show prices for shop items Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository diff --git a/src/end.c b/src/end.c index cb966162f..ee2df7537 100644 --- a/src/end.c +++ b/src/end.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 end.c $NHDT-Date: 1545771927 2018/12/25 21:05:27 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.161 $ */ +/* NetHack 3.6 end.c $NHDT-Date: 1545786454 2018/12/26 01:07:34 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.162 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1599,7 +1599,7 @@ boolean identified, all_containers, reportempty; if (Is_container(obj) || obj->otyp == STATUE) obj->cknown = obj->lknown = 1; } - Strcpy(&buf[2], doname(obj)); + Strcpy(&buf[2], doname_with_price(obj)); putstr(tmpwin, 0, buf); } unsortloot(&sortedcobj); diff --git a/src/shk.c b/src/shk.c index de436de87..40c58adb5 100644 --- a/src/shk.c +++ b/src/shk.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 shk.c $NHDT-Date: 1545785119 2018/12/26 00:45:19 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.146 $ */ +/* NetHack 3.6 shk.c $NHDT-Date: 1545786461 2018/12/26 01:07:41 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.147 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1974,7 +1974,7 @@ register struct obj *obj; if (*u.ushops && obj->oclass != COIN_CLASS && obj != uball && obj != uchain - && get_obj_location(obj, &x, &y, 0) + && get_obj_location(obj, &x, &y, CONTAINED_TOO) && *in_rooms(u.ux, u.uy, SHOPBASE) == *in_rooms(x, y, SHOPBASE) && (shkp = shop_keeper(inside_shop(x, y))) != 0 && inhishop(shkp)) { cost = obj->no_charge ? 0L : obj->quan * get_cost(obj, shkp);