]> granicus.if.org Git - nethack/commitdiff
'showscore' vs containers
authorPatR <rankin@nethack.org>
Sun, 22 Nov 2020 01:37:01 +0000 (17:37 -0800)
committerPatR <rankin@nethack.org>
Sun, 22 Nov 2020 01:37:01 +0000 (17:37 -0800)
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.

doc/fixes37.0
include/extern.h
src/botl.c
src/detect.c
src/dokick.c
src/end.c
src/shk.c
src/topten.c
src/u_init.c
src/vault.c

index f3c9134a9a6a68b79a97068db9e96186438ec7c1..aa20413660328f0e56e02c119f565ad25719c172 100644 (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
 -----------------------------------
@@ -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
        or sensed becomes discovered but was doing so even for a concealed
        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
index 843cb73ebaf58ee83ac0125c10c170df6265109b..ce3d3bd874f48c9e88bb276063a0670e4766c3b7 100644 (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.                              */
 /* 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 long FDECL(contained_cost,
              (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(gem_learned, (int));
 E void FDECL(alter_cost, (struct obj *, long));
@@ -2823,7 +2823,7 @@ E void FDECL(uleftvault, (struct monst *));
 E void NDECL(invault);
 E int FDECL(gd_move, (struct monst *));
 E void FDECL(paygd, (BOOLEAN_P));
-E long NDECL(hidden_gold);
+E long FDECL(hidden_gold, (BOOLEAN_P));
 E boolean NDECL(gd_sound);
 E void FDECL(vault_gd_watching, (unsigned int));
 
index f2771409145e39b66b6a7644f43cb697dfd27f76..4fc411e74d13070915094af232a538bd578ae31f 100644 (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) Michael Allison, 2006. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -398,7 +398,8 @@ botl_score()
     long deepest = deepest_lev_reached(FALSE);
     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)
         utotal = 0L;
     utotal += u.urexp + (50 * (deepest - 1))
index 29acd7a18676f2360ab4595179e61fe2a7909d6b..575082e20eb51fb98eede951d36b60c16bc17dab 100644 (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) Robert Patrick Rankin, 2018. */
 /* 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])
                 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,
                    "You feel worried about your future financial situation.");
             else if (steedgold)
index 80cdcaa5061fdd69277de831d1252136811afc1d..65cb6f4e6e36ddf94a5dd6d2f67b6ef88c63673e 100644 (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. */
 /* 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
                could try fighting, then weasle out of being
                killed by throwing his/her gold when losing. */
-            verbalize(
-                umoney
-                    ? "Drop the rest and follow me."
-                    : hidden_gold()
-                          ? "You still have hidden gold.  Drop it now."
-                          : mtmp->mpeaceful
-                                ? "I'll take care of that; please move along."
-                                : "I'll take that; now get moving.");
+            verbalize(umoney ? "Drop the rest and follow me."
+                      : hidden_gold(TRUE)
+                        ? "You still have hidden gold.  Drop it now."
+                        : mtmp->mpeaceful
+                          ? "I'll take care of that; please move along."
+                          : "I'll take that; now get moving.");
         } else if (is_mercenary(mtmp->data)) {
             long goldreqd = 0L;
 
index bdce05a8800a6522a49330cfc310f6c07009f8f2..ba489f9a489a9c924042bad8fae0b2ff7c019c32 100644 (file)
--- a/src/end.c
+++ b/src/end.c
@@ -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) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1382,8 +1382,8 @@ int how;
 
         umoney = money_cnt(g.invent);
         tmp = u.umoney0;
-        umoney += hidden_gold(); /* accumulate gold from containers */
-        tmp = umoney - tmp;      /* net gain */
+        umoney += hidden_gold(TRUE); /* accumulate gold from containers */
+        tmp = umoney - tmp;          /* net gain */
 
         if (tmp < 0L)
             tmp = 0L;
index f393daab916c022ed198dd7465f47b3de9580b0d..5ad0fb07a6f78c4f0901b9b09e0db530b243bb3b 100644 (file)
--- a/src/shk.c
+++ b/src/shk.c
@@ -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) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1245,7 +1245,7 @@ dopay()
     long ltmp;
     long umoney;
     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;
 
@@ -1595,7 +1595,8 @@ boolean itemize;
     long ltmp, quan, save_quan;
     long umoney = money_cnt(g.invent);
     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) {
         impossible("Paid object on bill??");
@@ -2226,8 +2227,9 @@ boolean unpaid_only;
 
 /* count amount of gold inside container 'obj' and any nested containers */
 long
-contained_gold(obj)
+contained_gold(obj, even_if_unknown)
 struct obj *obj;
+boolean even_if_unknown; /* True: all gold; False: limit to known contents */
 {
     register struct obj *otmp;
     register long value = 0L;
@@ -2236,8 +2238,8 @@ struct obj *obj;
     for (otmp = obj->cobj; otmp; otmp = otmp->nobj)
         if (otmp->oclass == COIN_CLASS)
             value += otmp->quan;
-        else if (Has_contents(otmp))
-            value += contained_gold(otmp);
+        else if (Has_contents(otmp) && (otmp->cknown || even_if_unknown))
+            value += contained_gold(otmp, even_if_unknown);
 
     return value;
 }
@@ -2611,7 +2613,7 @@ boolean reset_nocharge;
     /* outer container might be marked no_charge but still have contents
        which should be charged for; clear no_charge when picking things up */
     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,
                                                      !reset_nocharge) == 0L))
             shkp = 0; /* not billable */
@@ -2661,7 +2663,7 @@ boolean ininv, dummy, silent;
 
     if (container) {
         cltmp = contained_cost(obj, shkp, cltmp, FALSE, FALSE);
-        gltmp = contained_gold(obj);
+        gltmp = contained_gold(obj, TRUE);
 
         if (ltmp)
             add_one_tobill(obj, dummy, shkp);
@@ -2936,7 +2938,7 @@ boolean peaceful, silent;
 
             value += stolen_container(obj, shkp, 0L, 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 */
         cltmp = contained_cost(obj, shkp, cltmp, TRUE, FALSE);
         /* find the value of contained gold */
-        gltmp += contained_gold(obj);
+        gltmp += contained_gold(obj, TRUE);
         cgold = (gltmp > 0L);
     }
 
index 284d31ef58d41068852ac51ad089888572a599a1..db9208114e334d41a8df8d7b5b6ce1a6ca4480af 100644 (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) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -374,7 +374,8 @@ int how;
             genders[flags.initgend].filecode, XLOG_SEP,
             aligns[1 - u.ualignbase[A_ORIGINAL]].filecode);
     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, "%carti_wish_cnt=%ld", XLOG_SEP, u.uconduct.wisharti);
     Fprintf(rfile, "\n");
index a0cb5bb68650779c0298ee6ce3fe03919d70ee47..81927ed9f07b849c06af48388ab8b77f1e6a1e10 100644 (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) Robert Patrick Rankin, 2017. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -876,7 +876,7 @@ u_init()
 
     if (u.umoney0)
         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 */
     init_attr(75); /* init attribute values */
index a15e4eff64afac893f8b87276b37b3a3191b31c9..c59ffd433e25cf8d1852789624a30be8cb2efc46 100644 (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) Robert Patrick Rankin, 2011. */
 /* 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,
        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)) {
         if (grd->mpeaceful) {
             if (canspotmon(grd)) /* see or sense via telepathy */
@@ -487,7 +487,7 @@ invault()
         else
             verbalize("I don't know you.");
         umoney = money_cnt(g.invent);
-        if (!umoney && !hidden_gold()) {
+        if (!umoney && !hidden_gold(TRUE)) {
             if (Deaf)
                 pline("%s stomps%s.", noit_Monnam(guard),
                       (Blind) ? "" : " and beckons");
@@ -795,7 +795,7 @@ register struct monst *grd;
     }
 
     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 (u_in_vault && (u_carry_gold || um_dist(grd->mx, grd->my, 1))) {
             if (egrd->warncnt == 3 && !Deaf)
@@ -1107,15 +1107,17 @@ boolean silently;
     return;
 }
 
+/* amount of gold in carried containers */
 long
-hidden_gold()
+hidden_gold(even_if_unknown)
+boolean even_if_unknown; /* True: all gold; False: limit to known contents */
 {
     long value = 0L;
     struct obj *obj;
 
     for (obj = g.invent; obj; obj = obj->nobj)
-        if (Has_contents(obj))
-            value += contained_gold(obj);
+        if (Has_contents(obj) && (obj->cknown || even_if_unknown))
+            value += contained_gold(obj, even_if_unknown);
     /* unknown gold stuck inside statues may cause some consternation... */
 
     return value;