From 8a7f3b2b6bde8d73dc8da942778e45e60d06c5ea Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 19 Dec 2024 18:18:11 -0800 Subject: [PATCH] more issue #1303 Various bits I had in progress before Michael's commit. Mainly forget engravings when bones are saved instead of leaving them flagged as seen for the next hero who gets the level. --- include/engrave.h | 3 +-- include/extern.h | 1 + src/bones.c | 1 + src/detect.c | 2 +- src/display.c | 13 +++++++------ src/engrave.c | 34 ++++++++++++++++++++++++++-------- 6 files changed, 37 insertions(+), 17 deletions(-) diff --git a/include/engrave.h b/include/engrave.h index 00fd586e1..47fd84783 100644 --- a/include/engrave.h +++ b/include/engrave.h @@ -47,8 +47,7 @@ struct engr { #define spot_shows_engravings(x,y) \ (levl[(x)][(y)].typ == CORR \ - || levl[(x)][(y)].typ == SCORR \ || levl[(x)][(y)].typ == ICE \ - || levl[(x)][(y)].typ == ROOM ) + || levl[(x)][(y)].typ == ROOM) #endif /* ENGRAVE_H */ diff --git a/include/extern.h b/include/extern.h index 932e95514..2b8bba295 100644 --- a/include/extern.h +++ b/include/extern.h @@ -959,6 +959,7 @@ extern void del_engr_at(coordxy, coordxy); extern int freehand(void); extern int doengrave(void); extern void sanitize_engravings(void); +extern void forget_engravings(void); extern void engraving_sanity_check(void); extern void save_engravings(NHFILE *) NONNULLARG1; extern void rest_engravings(NHFILE *) NONNULLARG1; diff --git a/src/bones.c b/src/bones.c index 98fb9fd97..3ecd93125 100644 --- a/src/bones.c +++ b/src/bones.c @@ -445,6 +445,7 @@ savebones(int how, time_t when, struct obj *corpse) iter_mons(remove_mon_from_bones); /* send various unique monsters away, */ dmonsfree(); /* then discard dead or gone monsters */ + forget_engravings(); /* next hero won't have read any engravings yet */ /* mark all named fruits as nonexistent; if/when we come to instances of any of them we'll mark those as existing (using goodfruit()) */ for (f = gf.ffruit; f; f = f->nextf) diff --git a/src/detect.c b/src/detect.c index 172f4704c..ccede5c5d 100644 --- a/src/detect.c +++ b/src/detect.c @@ -1404,7 +1404,7 @@ show_map_spot(coordxy x, coordxy y, boolean cnf) if (!IS_FURNITURE(lev->typ)) { if ((t = t_at(x, y)) != 0 && t->tseen) { map_trap(t, 1); - } else if ((ep = engr_at(x, y)) != 0) { + } else if ((ep = engr_at(x, y)) != 0 && !cnf) { map_engraving(ep, 1); } else if (glyph_is_trap(oldglyph) || glyph_is_object(oldglyph)) { show_glyph(x, y, oldglyph); diff --git a/src/display.c b/src/display.c index f47e63062..71c77bb87 100644 --- a/src/display.c +++ b/src/display.c @@ -420,8 +420,9 @@ unmap_object(coordxy x, coordxy y) struct rm *lev = &levl[x][y]; if (spot_shows_engravings(x, y) - && (ep = engr_at(x, y)) != 0 && !covers_traps(x, y)) { - ep->erevealed = 0; + && (ep = engr_at(x, y)) != 0 && !covers_traps(x, y)) { + if (cansee(x, y)) + ep->erevealed = 1; map_engraving(ep, 0); } else { map_background(x, y, 0); @@ -458,7 +459,7 @@ unmap_object(coordxy x, coordxy y) map_trap(trap, show); \ } else if (spot_shows_engravings(x, y) \ && (ml_ep = engr_at(x, y)) != 0 \ - && ml_ep->erevealed != 0 \ + && ml_ep->erevealed \ && !covers_traps(x, y)) { \ map_engraving(ml_ep, show); \ } else { \ @@ -857,7 +858,7 @@ feel_location(coordxy x, coordxy y) show_glyph(x, y, lev->glyph = cmap_to_glyph(S_darkroom)); } } else { - if ((ep = engr_at(x, y)) && !ep->erevealed && engr_can_be_felt(ep)) + if ((ep = engr_at(x, y)) != 0 && engr_can_be_felt(ep)) ep->erevealed = 1; _map_location(x, y, 1); @@ -959,6 +960,8 @@ newsym(coordxy x, coordxy y) mon = m_at(x, y); worm_tail = is_worm_tail(mon); + if ((ep = engr_at(x, y)) != 0) + ep->erevealed = 1; /* even when covered by objects or a monster */ /* * Normal region shown only on accessible positions, but * poison clouds and steam clouds also shown above lava, @@ -1020,8 +1023,6 @@ newsym(coordxy x, coordxy y) } else if (glyph_is_invisible(lev->glyph)) { map_invisible(x, y); } else { - if ((ep = engr_at(x, y)) && !ep->erevealed) - ep->erevealed = 1; _map_location(x, y, 1); /* map the location */ } } diff --git a/src/engrave.c b/src/engrave.c index 07f30bea5..a11d8bc4c 100644 --- a/src/engrave.c +++ b/src/engrave.c @@ -317,7 +317,7 @@ read_engr_at(coordxy x, coordxy y) const char *eloc = surface(x, y); int sensed = 0; - /* Sensing an engraving does not require sight, + /* Sensing an engraving does not require sight for some engraving types, * nor does it necessarily imply comprehension (literacy). */ if (ep && ep->engr_txt[actual_text][0]) { @@ -1467,6 +1467,22 @@ sanitize_engravings(void) } } +/* mark all engravings as not-discovered/not-read when saving bones */ +void +forget_engravings(void) +{ + struct engr *ep; + + for (ep = head_engr; ep; ep = ep->nxt_engr) { + ep->erevealed = ep->eread = 0; + + /* Note: engr_txt[actual_text], engr_txt[rememberd_text], and + * engr_txt[pristine_text] retain their original text rather + * than get updated to reflect each engraving's current text. + * Does it matter? */ + } +} + void engraving_sanity_check(void) { @@ -1665,16 +1681,18 @@ see_engraving(struct engr *ep) newsym(ep->engr_x, ep->engr_y); } -/* like see_engravings() but overrides vision, but - only for some types of engravings that can be felt */ +/* like see_engravings() but overrides vision, but only for some types + of engravings that can be felt [this isn't actually used anywhere?] */ void feel_engraving(struct engr *ep) { - ep->eread = 1; - ep->erevealed = 1; - map_engraving(ep, 1); - /* in case it's beneath something, redisplay the something */ - newsym(ep->engr_x, ep->engr_y); + if (engr_can_be_felt(ep)) { + ep->eread = 1; + ep->erevealed = 1; + map_engraving(ep, 1); + /* in case it's beneath something, redisplay the something */ + newsym(ep->engr_x, ep->engr_y); + } } static const char blind_writing[][21] = {