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 389f03e90e
two months ago.  Mea culpa.

Closes #1200
This commit is contained in:
PatR
2024-01-15 02:56:26 -08:00
parent 9745121137
commit 40e919dbf9
2 changed files with 26 additions and 21 deletions

View File

@@ -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

View File

@@ -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 */