'showscore' vs containers

When SCORE_ON_BOTL is enabled, you could tell how much gold is
inside a container with unknown contents by having 'showsore' On
and watching how much the score changed on the status line when
picking the container up.
This commit is contained in:
PatR
2020-11-21 17:37:01 -08:00
parent d48e730700
commit 3e9d8f9aa5
10 changed files with 47 additions and 41 deletions
+3 -1
View File
@@ -1,4 +1,4 @@
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.358 $ $NHDT-Date: 1605959203 2020/11/21 11:46:43 $ NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.359 $ $NHDT-Date: 1606008997 2020/11/22 01:36:37 $
General Fixes and Modified Features General Fixes and Modified Features
----------------------------------- -----------------------------------
@@ -303,6 +303,8 @@ since ki-rin look quite a bit like unicorns, make them be more like one:
wand or scroll of create monster that makes a new monster which can be seen wand or scroll of create monster that makes a new monster which can be seen
or sensed becomes discovered but was doing so even for a concealed or sensed becomes discovered but was doing so even for a concealed
mimic seen as furniture or an object mimic seen as furniture or an object
'showscore' could be used to determine how much gold was inside a container
whose contents were unknown
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
+3 -3
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 extern.h $NHDT-Date: 1605493683 2020/11/16 02:28:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.878 $ */ /* NetHack 3.7 extern.h $NHDT-Date: 1606008997 2020/11/22 01:36:37 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.880 $ */
/* Copyright (c) Steve Creps, 1988. */ /* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -2396,7 +2396,7 @@ E void NDECL(finish_paybill);
E struct obj *FDECL(find_oid, (unsigned)); E struct obj *FDECL(find_oid, (unsigned));
E long FDECL(contained_cost, E long FDECL(contained_cost,
(struct obj *, struct monst *, long, BOOLEAN_P, BOOLEAN_P)); (struct obj *, struct monst *, long, BOOLEAN_P, BOOLEAN_P));
E long FDECL(contained_gold, (struct obj *)); E long FDECL(contained_gold, (struct obj *, BOOLEAN_P));
E void FDECL(picked_container, (struct obj *)); E void FDECL(picked_container, (struct obj *));
E void FDECL(gem_learned, (int)); E void FDECL(gem_learned, (int));
E void FDECL(alter_cost, (struct obj *, long)); E void FDECL(alter_cost, (struct obj *, long));
@@ -2823,7 +2823,7 @@ E void FDECL(uleftvault, (struct monst *));
E void NDECL(invault); E void NDECL(invault);
E int FDECL(gd_move, (struct monst *)); E int FDECL(gd_move, (struct monst *));
E void FDECL(paygd, (BOOLEAN_P)); E void FDECL(paygd, (BOOLEAN_P));
E long NDECL(hidden_gold); E long FDECL(hidden_gold, (BOOLEAN_P));
E boolean NDECL(gd_sound); E boolean NDECL(gd_sound);
E void FDECL(vault_gd_watching, (unsigned int)); E void FDECL(vault_gd_watching, (unsigned int));
+3 -2
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 botl.c $NHDT-Date: 1596498152 2020/08/03 23:42:32 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.191 $ */ /* NetHack 3.7 botl.c $NHDT-Date: 1606008998 2020/11/22 01:36:38 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.192 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2006. */ /*-Copyright (c) Michael Allison, 2006. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -398,7 +398,8 @@ botl_score()
long deepest = deepest_lev_reached(FALSE); long deepest = deepest_lev_reached(FALSE);
long utotal; long utotal;
utotal = money_cnt(g.invent) + hidden_gold(); /* hidden_gold(False): only gold in containers whose contents are known */
utotal = money_cnt(g.invent) + hidden_gold(FALSE);
if ((utotal -= u.umoney0) < 0L) if ((utotal -= u.umoney0) < 0L)
utotal = 0L; utotal = 0L;
utotal += u.urexp + (50 * (deepest - 1)) utotal += u.urexp + (50 * (deepest - 1))
+2 -2
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 detect.c $NHDT-Date: 1596498155 2020/08/03 23:42:35 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.121 $ */ /* NetHack 3.7 detect.c $NHDT-Date: 1606009000 2020/11/22 01:36:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.123 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2018. */ /*-Copyright (c) Robert Patrick Rankin, 2018. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -357,7 +357,7 @@ register struct obj *sobj;
if (g.youmonst.data == &mons[PM_GOLD_GOLEM]) if (g.youmonst.data == &mons[PM_GOLD_GOLEM])
Sprintf(buf, "You feel like a million %s!", currency(2L)); Sprintf(buf, "You feel like a million %s!", currency(2L));
else if (money_cnt(g.invent) || hidden_gold()) else if (money_cnt(g.invent) || hidden_gold(TRUE))
Strcpy(buf, Strcpy(buf,
"You feel worried about your future financial situation."); "You feel worried about your future financial situation.");
else if (steedgold) else if (steedgold)
+7 -9
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 dokick.c $NHDT-Date: 1596498160 2020/08/03 23:42:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.155 $ */ /* NetHack 3.7 dokick.c $NHDT-Date: 1606009001 2020/11/22 01:36:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.159 $ */
/* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */ /* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -341,14 +341,12 @@ register struct obj *gold;
out of the vault. If he did do that, player out of the vault. If he did do that, player
could try fighting, then weasle out of being could try fighting, then weasle out of being
killed by throwing his/her gold when losing. */ killed by throwing his/her gold when losing. */
verbalize( verbalize(umoney ? "Drop the rest and follow me."
umoney : hidden_gold(TRUE)
? "Drop the rest and follow me." ? "You still have hidden gold. Drop it now."
: hidden_gold() : mtmp->mpeaceful
? "You still have hidden gold. Drop it now." ? "I'll take care of that; please move along."
: mtmp->mpeaceful : "I'll take that; now get moving.");
? "I'll take care of that; please move along."
: "I'll take that; now get moving.");
} else if (is_mercenary(mtmp->data)) { } else if (is_mercenary(mtmp->data)) {
long goldreqd = 0L; long goldreqd = 0L;
+3 -3
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 end.c $NHDT-Date: 1603534633 2020/10/24 10:17:13 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.214 $ */ /* NetHack 3.7 end.c $NHDT-Date: 1606009001 2020/11/22 01:36:41 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.215 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1382,8 +1382,8 @@ int how;
umoney = money_cnt(g.invent); umoney = money_cnt(g.invent);
tmp = u.umoney0; tmp = u.umoney0;
umoney += hidden_gold(); /* accumulate gold from containers */ umoney += hidden_gold(TRUE); /* accumulate gold from containers */
tmp = umoney - tmp; /* net gain */ tmp = umoney - tmp; /* net gain */
if (tmp < 0L) if (tmp < 0L)
tmp = 0L; tmp = 0L;
+12 -10
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 shk.c $NHDT-Date: 1596498208 2020/08/03 23:43:28 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.189 $ */ /* NetHack 3.7 shk.c $NHDT-Date: 1606009003 2020/11/22 01:36:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.191 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1245,7 +1245,7 @@ dopay()
long ltmp; long ltmp;
long umoney; long umoney;
int pass, tmp, sk = 0, seensk = 0; int pass, tmp, sk = 0, seensk = 0;
boolean paid = FALSE, stashed_gold = (hidden_gold() > 0L); boolean paid = FALSE, stashed_gold = (hidden_gold(TRUE) > 0L);
g.multi = 0; g.multi = 0;
@@ -1595,7 +1595,8 @@ boolean itemize;
long ltmp, quan, save_quan; long ltmp, quan, save_quan;
long umoney = money_cnt(g.invent); long umoney = money_cnt(g.invent);
int buy; int buy;
boolean stashed_gold = (hidden_gold() > 0L), consumed = (which == 0); boolean stashed_gold = (hidden_gold(TRUE) > 0L),
consumed = (which == 0);
if (!obj->unpaid && !bp->useup) { if (!obj->unpaid && !bp->useup) {
impossible("Paid object on bill??"); impossible("Paid object on bill??");
@@ -2226,8 +2227,9 @@ boolean unpaid_only;
/* count amount of gold inside container 'obj' and any nested containers */ /* count amount of gold inside container 'obj' and any nested containers */
long long
contained_gold(obj) contained_gold(obj, even_if_unknown)
struct obj *obj; struct obj *obj;
boolean even_if_unknown; /* True: all gold; False: limit to known contents */
{ {
register struct obj *otmp; register struct obj *otmp;
register long value = 0L; register long value = 0L;
@@ -2236,8 +2238,8 @@ struct obj *obj;
for (otmp = obj->cobj; otmp; otmp = otmp->nobj) for (otmp = obj->cobj; otmp; otmp = otmp->nobj)
if (otmp->oclass == COIN_CLASS) if (otmp->oclass == COIN_CLASS)
value += otmp->quan; value += otmp->quan;
else if (Has_contents(otmp)) else if (Has_contents(otmp) && (otmp->cknown || even_if_unknown))
value += contained_gold(otmp); value += contained_gold(otmp, even_if_unknown);
return value; return value;
} }
@@ -2611,7 +2613,7 @@ boolean reset_nocharge;
/* outer container might be marked no_charge but still have contents /* outer container might be marked no_charge but still have contents
which should be charged for; clear no_charge when picking things up */ which should be charged for; clear no_charge when picking things up */
if (obj->no_charge) { if (obj->no_charge) {
if (!Has_contents(obj) || (contained_gold(obj) == 0L if (!Has_contents(obj) || (contained_gold(obj, TRUE) == 0L
&& contained_cost(obj, shkp, 0L, FALSE, && contained_cost(obj, shkp, 0L, FALSE,
!reset_nocharge) == 0L)) !reset_nocharge) == 0L))
shkp = 0; /* not billable */ shkp = 0; /* not billable */
@@ -2661,7 +2663,7 @@ boolean ininv, dummy, silent;
if (container) { if (container) {
cltmp = contained_cost(obj, shkp, cltmp, FALSE, FALSE); cltmp = contained_cost(obj, shkp, cltmp, FALSE, FALSE);
gltmp = contained_gold(obj); gltmp = contained_gold(obj, TRUE);
if (ltmp) if (ltmp)
add_one_tobill(obj, dummy, shkp); add_one_tobill(obj, dummy, shkp);
@@ -2936,7 +2938,7 @@ boolean peaceful, silent;
value += stolen_container(obj, shkp, 0L, ininv); value += stolen_container(obj, shkp, 0L, ininv);
if (!ininv) if (!ininv)
gvalue += contained_gold(obj); gvalue += contained_gold(obj, TRUE);
} }
} }
@@ -3043,7 +3045,7 @@ xchar x, y;
/* find the price of content before subfrombill */ /* find the price of content before subfrombill */
cltmp = contained_cost(obj, shkp, cltmp, TRUE, FALSE); cltmp = contained_cost(obj, shkp, cltmp, TRUE, FALSE);
/* find the value of contained gold */ /* find the value of contained gold */
gltmp += contained_gold(obj); gltmp += contained_gold(obj, TRUE);
cgold = (gltmp > 0L); cgold = (gltmp > 0L);
} }
+3 -2
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 topten.c $NHDT-Date: 1596498218 2020/08/03 23:43:38 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.73 $ */ /* NetHack 3.7 topten.c $NHDT-Date: 1606009004 2020/11/22 01:36:44 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.74 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -374,7 +374,8 @@ int how;
genders[flags.initgend].filecode, XLOG_SEP, genders[flags.initgend].filecode, XLOG_SEP,
aligns[1 - u.ualignbase[A_ORIGINAL]].filecode); aligns[1 - u.ualignbase[A_ORIGINAL]].filecode);
Fprintf(rfile, "%cflags=0x%lx", XLOG_SEP, encodexlogflags()); Fprintf(rfile, "%cflags=0x%lx", XLOG_SEP, encodexlogflags());
Fprintf(rfile, "%cgold=%ld", XLOG_SEP, money_cnt(g.invent) + hidden_gold()); Fprintf(rfile, "%cgold=%ld", XLOG_SEP,
money_cnt(g.invent) + hidden_gold(TRUE));
Fprintf(rfile, "%cwish_cnt=%ld", XLOG_SEP, u.uconduct.wishes); Fprintf(rfile, "%cwish_cnt=%ld", XLOG_SEP, u.uconduct.wishes);
Fprintf(rfile, "%carti_wish_cnt=%ld", XLOG_SEP, u.uconduct.wisharti); Fprintf(rfile, "%carti_wish_cnt=%ld", XLOG_SEP, u.uconduct.wisharti);
Fprintf(rfile, "\n"); Fprintf(rfile, "\n");
+2 -2
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 u_init.c $NHDT-Date: 1596498222 2020/08/03 23:43:42 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.70 $ */ /* NetHack 3.7 u_init.c $NHDT-Date: 1606009005 2020/11/22 01:36:45 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.72 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2017. */ /*-Copyright (c) Robert Patrick Rankin, 2017. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -876,7 +876,7 @@ u_init()
if (u.umoney0) if (u.umoney0)
ini_inv(Money); ini_inv(Money);
u.umoney0 += hidden_gold(); /* in case sack has gold in it */ u.umoney0 += hidden_gold(TRUE); /* in case sack has gold in it */
find_ac(); /* get initial ac value */ find_ac(); /* get initial ac value */
init_attr(75); /* init attribute values */ init_attr(75); /* init attribute values */
+9 -7
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 vault.c $NHDT-Date: 1596498223 2020/08/03 23:43:43 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.76 $ */ /* NetHack 3.7 vault.c $NHDT-Date: 1606009006 2020/11/22 01:36:46 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.77 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -249,7 +249,7 @@ struct monst *grd;
} }
/* if carrying gold and arriving anywhere other than next to the guard, /* if carrying gold and arriving anywhere other than next to the guard,
set the guard loose */ set the guard loose */
if ((money_cnt(g.invent) || hidden_gold()) if ((money_cnt(g.invent) || hidden_gold(TRUE))
&& um_dist(grd->mx, grd->my, 1)) { && um_dist(grd->mx, grd->my, 1)) {
if (grd->mpeaceful) { if (grd->mpeaceful) {
if (canspotmon(grd)) /* see or sense via telepathy */ if (canspotmon(grd)) /* see or sense via telepathy */
@@ -487,7 +487,7 @@ invault()
else else
verbalize("I don't know you."); verbalize("I don't know you.");
umoney = money_cnt(g.invent); umoney = money_cnt(g.invent);
if (!umoney && !hidden_gold()) { if (!umoney && !hidden_gold(TRUE)) {
if (Deaf) if (Deaf)
pline("%s stomps%s.", noit_Monnam(guard), pline("%s stomps%s.", noit_Monnam(guard),
(Blind) ? "" : " and beckons"); (Blind) ? "" : " and beckons");
@@ -795,7 +795,7 @@ register struct monst *grd;
} }
umoney = money_cnt(g.invent); umoney = money_cnt(g.invent);
u_carry_gold = umoney > 0L || hidden_gold() > 0L; u_carry_gold = (umoney > 0L || hidden_gold(TRUE) > 0L);
if (egrd->fcend == 1) { if (egrd->fcend == 1) {
if (u_in_vault && (u_carry_gold || um_dist(grd->mx, grd->my, 1))) { if (u_in_vault && (u_carry_gold || um_dist(grd->mx, grd->my, 1))) {
if (egrd->warncnt == 3 && !Deaf) if (egrd->warncnt == 3 && !Deaf)
@@ -1107,15 +1107,17 @@ boolean silently;
return; return;
} }
/* amount of gold in carried containers */
long long
hidden_gold() hidden_gold(even_if_unknown)
boolean even_if_unknown; /* True: all gold; False: limit to known contents */
{ {
long value = 0L; long value = 0L;
struct obj *obj; struct obj *obj;
for (obj = g.invent; obj; obj = obj->nobj) for (obj = g.invent; obj; obj = obj->nobj)
if (Has_contents(obj)) if (Has_contents(obj) && (obj->cknown || even_if_unknown))
value += contained_gold(obj); value += contained_gold(obj, even_if_unknown);
/* unknown gold stuck inside statues may cause some consternation... */ /* unknown gold stuck inside statues may cause some consternation... */
return value; return value;