fix #K3890 - "wall_angle: unknown hwall mode 4"

When lastseentyp[x][y] is different from levl[x][y].typ and #terrain
tries to show <x,y>, 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.
This commit is contained in:
PatR
2023-04-30 00:38:40 -07:00
parent 70949a787e
commit 14e35ce419
2 changed files with 20 additions and 9 deletions

View File

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

View File

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