From 14e35ce419b7c7cebfd56f0e217490abc5555b83 Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 30 Apr 2023 00:38:40 -0700 Subject: [PATCH] fix #K3890 - "wall_angle: unknown hwall mode 4" When lastseentyp[x][y] is different from levl[x][y].typ and #terrain tries to show , the value of levl[x][y].flags might not have an approrpriate value for the remembered terrain type. The reported problem was an impossible() about wall mode. rm.wall_info == 4 corresponds to rm.doormask == D_OPEN and both of them are overloaded on rm.flags. A spot remembered as a wall but actually a secret door might cause this if it has become discovered ('wall' changed to closed door) and then opened (with door intact) while out of view. [I'm not sure how that could happen though.] I was unable to reproduce it so haven't verified that the fix works. --- doc/fixes3-7-0.txt | 3 +++ src/detect.c | 26 +++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index f6b7b1eb0..85dc71ec3 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1159,6 +1159,9 @@ change helm of brilliance from iron to crystal so that it no longer needs to fake player monsters in endgame had a 1 in 1000 chance to be given a stack of 0 gold pieces, eventually triggering an impossible warning (cited one was "Calculating weight of 0 gold pieces?") +avoid "wall_angle: unknown hwall mode 4" when using #terrain command to + display a spot remembered as a wall but actually a secret door that + has been transformed into an open door while not in sight Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/detect.c b/src/detect.c index 53ffca0dc..868029a41 100644 --- a/src/detect.c +++ b/src/detect.c @@ -2061,18 +2061,26 @@ reveal_terrain_getglyph(coordxy x, coordxy y, int full, unsigned swallowed, && M_AP_TYPE(mtmp) == M_AP_FURNITURE) { glyph = cmap_to_glyph(mtmp->mappearance); } else { - /* we have a topology type but we want a screen - symbol in order to derive a glyph; some screen - symbols need the flags field of levl[][] in - addition to the type (to disambiguate STAIRS to - S_upstair or S_dnstair, for example; current - flags might not be intended for remembered type, - but we've got no other choice) */ - schar save_typ = levl[x][y].typ; + struct rm save_spot; + /* + * We have a topology type but we want a screen symbol + * in order to derive a glyph. Some screen symbols need + * the flags field of levl[][] in addition to the type + * (to disambiguate STAIRS to S_upstair or S_dnstair, + * for example). Current flags might not be intended + * for remembered type, but we've got no other choice. + * An exception is wall_info which can be recalculated and + * needs to be. Otherwise back_to_glyph() -> wall_angle() + * might issue an impossible() for it if it is currently + * doormask==D_OPEN for an open door remembered as a wall. + */ + save_spot = levl[x][y]; levl[x][y].typ = gl.lastseentyp[x][y]; + if (IS_WALL(levl[x][y].typ)) + xy_set_wall_state(x, y); /* levl[x][y].wall_info */ glyph = back_to_glyph(x, y); - levl[x][y].typ = save_typ; + levl[x][y] = save_spot; } } }