From 40e919dbf98b173943acf803fe712423af621553 Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 15 Jan 2024 02:56:26 -0800 Subject: [PATCH] github issue #1200 - erronenous engraving feedback Issue reported by chappg: if a monster or object covered an engraving, examining that monster or object with farlook would include the text of the engraving even though it wasn't the thing being examined. The report was for a bones level but that only mattered because it was a ghost on top of a grave (and the engraving on its headstone) that was being examined; bones data itself wasn't pertinent. It would happen with any engraving once the spot was mapped as an engraving or a grave provided that something else was currently displayed at the location. Bug was introduced by commit 389f03e90e1e58e78d5ab2f6df7def7274bd3111 two months ago. Mea culpa. Closes #1200 --- doc/fixes3-7-0.txt | 2 ++ src/pager.c | 45 ++++++++++++++++++++++++--------------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 4a3e2f956..497676c6a 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1828,6 +1828,8 @@ duration of temporary stoning resistance would be extended while eating a so if it timed out during the meal, player got the message about hero no longer being protected against stoning but was able to finish the meal safely +farlook at something that was on top of an engraving or grave would report + the engraving text or headstone epitaph along with the 'something' Fixes to 3.7.0-x Platform and/or Interface Problems Exposed Via git Repository diff --git a/src/pager.c b/src/pager.c index 3fa2ae9c9..cc7236c23 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1528,35 +1528,38 @@ do_screen_description( return found; } +/* when farlook is reporting on an engraving, include its text */ static boolean add_quoted_engraving(coordxy x, coordxy y, char *buf) { char temp_buf[BUFSZ]; struct engr *ep = engr_at(x, y); + boolean floorengr = !strcmp(buf, " (engraving"), + headstone = !strcmp(buf, " (grave"); - if (ep) { -#define GRAVESTONE "(grave" - /* is a grave's headstone if buf ends with "(grave"; - caller will add closing ")" after we return; - -1: sizeof for a literal string includes the terminating '\0' */ - boolean is_headstone = (IS_GRAVE(levl[x][y].typ) - && strlen(buf) >= (sizeof GRAVESTONE - 1) - && !strcmp(eos(buf) - (sizeof GRAVESTONE - 1), - GRAVESTONE)); + /* + * If there is no engraving here, there's nothing to do; just return. + * + * When buf[] is " (engraving" or " (grave" then we're looking at an + * engraving and we'll add its text. Caller supplies the closing paren. + * + * If buf[] contains anything else, we're looking at something (monster + * or object) that happens to be on top of an engraving, so we won't + * append the engraving text. + */ + if (!ep || (!floorengr && !headstone)) + return FALSE; - if (ep->eread) - Snprintf(temp_buf, sizeof temp_buf, " with %s: \"%s\"", - is_headstone ? "headstone reading" : "remembered text", - ep->engr_txt[remembered_text]); - else - Snprintf(temp_buf, sizeof temp_buf, " %s you haven't read", - is_headstone ? "whose headstone" : "that"); + if (ep->eread) + Snprintf(temp_buf, sizeof temp_buf, " with %s: \"%s\"", + headstone ? "headstone reading" : "remembered text", + ep->engr_txt[remembered_text]); + else + Snprintf(temp_buf, sizeof temp_buf, " %s you haven't read", + headstone ? "whose headstone" : "that"); - (void) strncat(buf, temp_buf, BUFSZ - strlen(buf) - 1); - return TRUE; -#undef ENGRVG - } - return FALSE; + (void) strncat(buf, temp_buf, BUFSZ - strlen(buf) - 1); + return TRUE; } /* also used by getpos hack in do_name.c */