From 55650666ed3fcb8a828cf9f5d1b6408a400740ef Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 14 Oct 2023 00:01:33 -0700 Subject: [PATCH] \#overview vs temples and altars Reported by entrez: it was possible for #overview to show a line of just "." if a temple was known and its altar was unknown and no other features such as thrones or fountains were known on the level. It now lists "M temples and N altars" when both are present and the case that yielded "." becomes "a temple". That's an improvement but there might be edge cases it gets wrong. A listing of "a temple and an altar" is ambiguous because there isn't any way to tell whether the altar it mentions is inside the temple. That seems acceptable to me. I think it should include more alignment information about temples and altars, instead of just adding "to " when all known altars are of hero's alignment, but this doesn't attempt to address that. --- doc/fixes3-7-0.txt | 3 +++ src/dungeon.c | 38 +++++++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 375395253..9833ccde8 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1258,6 +1258,9 @@ barbed devils have an attack that sticks you to them balrogs prefer bullwhip if hero is wielding a weapon ice devils have an additional attack, a slowing touch buff scroll of confuse monster and blessed potion of monster detection +if a temple was entered while blind, #overview could show a line of just "." + when describing altars if no other interesting features on that level + were known Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/dungeon.c b/src/dungeon.c index 52ca6fbab..4497ce710 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -3590,16 +3590,30 @@ tunesuffix( #endif #define COMMA (i++ > 0 ? ", " : PREFIX) /* "iterate" once; safe to use as ``if (cond) ADDTOBUF(); else whatever;'' */ -#define ADDNTOBUF(nam, var) \ +#define ADDTOBUF(nam, var) \ + do { \ + if (var) \ + Sprintf(eos(buf), "%s%s", COMMA, (nam)); \ + } while (0) +#define ADDNTOBUF(nam, var) \ do { \ if (var) \ Sprintf(eos(buf), "%s%s %s%s", COMMA, seen_string((var), (nam)), \ (nam), plur(var)); \ } while (0) -#define ADDTOBUF(nam, var) \ - do { \ - if (var) \ - Sprintf(eos(buf), "%s%s", COMMA, (nam)); \ +/* ADD2NTOBUF: for "M temples and N altars"; seen_string() is safe to use + multiple times within one expression; so is plur() */ +#define ADD2NTOBUF(nam, var, nam2, var2) \ + do { \ + if (var && var2) { \ + Sprintf(eos(buf), "%s%s %s%s and %s %s%s", COMMA, \ + seen_string((var), (nam)), (nam), plur(var), \ + seen_string((var2), (nam2)), (nam2), plur(var2)); \ + } else if (var) { \ + ADDNTOBUF(nam, var); \ + } else if (var2) { \ + ADDNTOBUF(nam2, var2); \ + } \ } while (0) static void @@ -3692,14 +3706,16 @@ print_mapseen( Sprintf(eos(buf), "%s%s", COMMA, an(shop_string(mptr->feat.shoptype))); } - if (mptr->feat.naltar > 0) { + if (mptr->feat.naltar > 0 || mptr->feat.ntemple > 0) { unsigned atmp; - /* Temples + non-temple altars get munged into just "altars" */ - if (mptr->feat.ntemple != mptr->feat.naltar) - ADDNTOBUF("altar", mptr->feat.naltar); - else - ADDNTOBUF("temple", mptr->feat.ntemple); + /* being aware of a temple doesn't guarantee being aware of its + altar (via entrance message when entering while blinded, or + possibly it being out of view in an irregularly shaped room); + FIXME: if all temples present have been desecrated, we ought + to say so */ + ADD2NTOBUF("temple", mptr->feat.ntemple, + "altar", mptr->feat.naltar); /* only print out altar's god if they are all to your god */ atmp = mptr->feat.msalign; /* 0, 1, 2, 3 */