Fix mention_map and hiders causing a light source error

Prevent glyph change messages while loading a level file.
Otherwise a monster hiding under an item triggered a vision recalc
before light sources were linked to their sources, leading into
strange errors looking like pointer corruption.

getlev -> hide_monst -> hideunder -> newsym -> show_glyph ->
 pline_xy -> vision_recalc -> do_light_sources -> get_obj_location

Add in_getlev program state variable, analogous to in_mklev
This commit is contained in:
Pasi Kallinen
2024-04-18 09:01:11 +03:00
parent 064523e162
commit 7db8f7c6a5
4 changed files with 6 additions and 1 deletions
+1
View File
@@ -766,6 +766,7 @@ struct sinfo {
int exiting; /* an exit handler is executing */ int exiting; /* an exit handler is executing */
int saving; /* creating a save file */ int saving; /* creating a save file */
int restoring; /* reloading a save file */ int restoring; /* reloading a save file */
int in_getlev; /* in getlev() */
int in_moveloop; /* normal gameplay in progress */ int in_moveloop; /* normal gameplay in progress */
int in_impossible; /* reporting a warning */ int in_impossible; /* reporting a warning */
int in_docrt; /* in docrt(): redrawing the whole screen */ int in_docrt; /* in docrt(): redrawing the whole screen */
+1
View File
@@ -1950,6 +1950,7 @@ show_glyph(coordxy x, coordxy y, int glyph)
if (a11y.glyph_updates && !a11y.mon_notices_blocked if (a11y.glyph_updates && !a11y.mon_notices_blocked
&& !gp.program_state.in_docrt && !gp.program_state.in_docrt
&& !gp.program_state.in_getlev
&& (oldglyph != glyph || gg.gbuf[y][x].gnew)) { && (oldglyph != glyph || gg.gbuf[y][x].gnew)) {
int c = glyph_to_cmap(glyph); int c = glyph_to_cmap(glyph);
if ((glyph_is_nothing(oldglyph) || glyph_is_unexplored(oldglyph) if ((glyph_is_nothing(oldglyph) || glyph_is_unexplored(oldglyph)
+3
View File
@@ -1005,6 +1005,8 @@ getlev(NHFILE *nhfp, int pid, xint8 lev)
short tlev; short tlev;
#endif #endif
gp.program_state.in_getlev = TRUE;
if (ghostly) if (ghostly)
clear_id_mapping(); clear_id_mapping();
@@ -1233,6 +1235,7 @@ getlev(NHFILE *nhfp, int pid, xint8 lev)
if (ghostly) if (ghostly)
clear_id_mapping(); clear_id_mapping();
gp.program_state.in_getlev = FALSE;
} }
void void
+1 -1
View File
@@ -521,7 +521,7 @@ vision_recalc(int control)
int oldseenv; /* previous seenv value */ int oldseenv; /* previous seenv value */
gv.vision_full_recalc = 0; /* reset flag */ gv.vision_full_recalc = 0; /* reset flag */
if (gi.in_mklev || !iflags.vision_inited) if (gi.in_mklev || gp.program_state.in_getlev || !iflags.vision_inited)
return; return;
/* /*