From 2cc85b20dd71c2b83046cf52a3efcb0d535a9203 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Wed, 5 Oct 2022 22:19:52 -0400 Subject: [PATCH 1/2] Make #attributes gold line match #showgold The #showgold command now mentions (known) gold socked away in containers in your inventory as of 706b1a9. Since the gold info in the attributes display and dumplog matches the output of #showgold otherwise, update it to do the same thing. Also refactored doprgold a bit to be a little more compact, as opposed to enumerating all the different combinations of gold/no gold in open inventory/containers. This eliminated some string constants that were broken up into multiple constants/lines (like "line 1 " "line 2"), which NetHack code style seems to prefer to avoid. --- src/insight.c | 21 ++++++++++++++------- src/invent.c | 29 +++++++++++++++-------------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/insight.c b/src/insight.c index d7958b576..52ce6269b 100644 --- a/src/insight.c +++ b/src/insight.c @@ -718,18 +718,25 @@ basics_enlightenment(int mode UNUSED, int final) (u.uac < 0) ? "best" : "worst"); enl_msg("Your armor class ", "is ", "was ", buf, ""); - /* gold; similar to doprgold(#seegold) but without shop billing info; - same amount as shown on status line which ignores container contents */ + /* gold; similar to doprgold (#showgold) but without shop billing info; + includes container contents, unlike status line but like doprgold */ { - static const char Your_wallet[] = "Your wallet "; - long umoney = money_cnt(g.invent); + long umoney = money_cnt(g.invent), hmoney = hidden_gold(final); if (!umoney) { - enl_msg(Your_wallet, "is ", "was ", "empty", ""); + Sprintf(buf, " Your wallet %s empty", !final ? "is" : "was"); } else { - Sprintf(buf, "%ld %s", umoney, currency(umoney)); - enl_msg(Your_wallet, "contains ", "contained ", buf, ""); + Sprintf(buf, " Your wallet contain%s %ld %s", !final ? "s" : "ed", + umoney, currency(umoney)); } + if (hmoney) { + Sprintf(eos(buf), + ", %s you %s %ld %s stashed away in your pack", + umoney ? "and" : "but", !final ? "have" : "had", + hmoney, umoney ? "more" : currency(hmoney)); + } + Strcat(buf, "."); + enlght_out(buf); } if (flags.pickup) { diff --git a/src/invent.c b/src/invent.c index ff93efa26..01794c024 100644 --- a/src/invent.c +++ b/src/invent.c @@ -4496,20 +4496,21 @@ doprgold(void) long hmoney = hidden_gold(FALSE); if (Verbose(1, doprgold)) { - if (!umoney && !hmoney) - Your("wallet is empty."); - else if (umoney && !hmoney) - Your("wallet contains %ld %s.", umoney, currency(umoney)); - else if (!umoney && hmoney) - Your("wallet is empty, but there %s %ld %s stashed away in " - "your pack.", - (hmoney == 1) ? "is" : "are", - hmoney, currency(hmoney)); - else if (umoney && hmoney) - Your("wallet contains %ld %s, and there %s %ld more stashed " - "away in your pack.", umoney, currency(umoney), - (hmoney == 1) ? "is" : "are", - hmoney); + char buf[BUFSZ]; + + if (!umoney) { + Strcpy(buf, "Your wallet is empty"); + } else { + Sprintf(buf, "Your wallet contains %ld %s", + umoney, currency(umoney)); + } + if (hmoney) { + Sprintf(eos(buf), + ", %s you have %ld %s stashed away in your pack", + umoney ? "and" : "but", hmoney, + umoney ? "more" : currency(hmoney)); + } + pline("%s.", buf); } else { long total = umoney + hmoney; if (total) From 9bf9aca4a960f2320e2bcade7e72e8b9786dfc27 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Wed, 5 Oct 2022 23:01:07 -0400 Subject: [PATCH 2/2] Move stashed gold in #attributes to its own line The line got a lot longer than most other #attributes lines when the hero had gold both in open inventory and in stashed containers, so break it up into two lines (using the same approach as the pantheon info in the first section). Maybe this isn't necessary but it does make it stand out less. --- src/insight.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/insight.c b/src/insight.c index 52ce6269b..9ed83db57 100644 --- a/src/insight.c +++ b/src/insight.c @@ -729,14 +729,15 @@ basics_enlightenment(int mode UNUSED, int final) Sprintf(buf, " Your wallet contain%s %ld %s", !final ? "s" : "ed", umoney, currency(umoney)); } - if (hmoney) { - Sprintf(eos(buf), - ", %s you %s %ld %s stashed away in your pack", - umoney ? "and" : "but", !final ? "have" : "had", - hmoney, umoney ? "more" : currency(hmoney)); - } - Strcat(buf, "."); + Strcat(buf, hmoney ? "," : "."); enlght_out(buf); + + if (hmoney) { + Sprintf(buf, "%ld %s stashed away in your pack", + hmoney, umoney ? "more" : currency(hmoney)); + enl_msg(umoney ? "and you " : "but you ", "have ", "had ", buf, + ""); + } } if (flags.pickup) {