From 01cb9d312f911710ddae46ebf99f192c620100ab Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 5 Oct 2021 01:57:27 -0700 Subject: [PATCH] unused variable: g.restoring Get rid of the last reference to 'g.restoring' (which managed to unintentionally survive the change to 'g.program_state.restoring'). Also have suppress_map_output() check 'g.program_state.saving' and switch the couple of checks against that flag to use the function. --- include/decl.h | 1 - src/botl.c | 7 +++---- src/decl.c | 1 - src/display.c | 6 +++--- src/invent.c | 6 +++--- src/restore.c | 2 ++ 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/include/decl.h b/include/decl.h index 951e12811..87b5a4874 100644 --- a/include/decl.h +++ b/include/decl.h @@ -1131,7 +1131,6 @@ struct instance_globals { /* restore.c */ int n_ids_mapped; struct bucket *id_map; - boolean restoring; struct fruit *oldfruit; long omoves; diff --git a/src/botl.c b/src/botl.c index fa30cd5be..2a0d2efa0 100644 --- a/src/botl.c +++ b/src/botl.c @@ -249,8 +249,8 @@ bot(void) { /* dosave() flags completion by setting u.uhp to -1; supprss_map_output() covers program_state.restoring and is used for status as well as map */ - if (u.uhp != -1 && g.youmonst.data && iflags.status_updates - && !g.program_state.saving && !suppress_map_output()) { + if (u.uhp != -1 && g.youmonst.data + && iflags.status_updates && !suppress_map_output()) { if (VIA_WINDOWPORT()) { bot_via_windowport(); } else { @@ -273,8 +273,7 @@ timebot(void) to skip update; suppress_map_output() handles program_state.restoring and program_state.done_hup (tty hangup => no further output at all) and we use it for maybe skipping status as well as for the map */ - if (flags.time && iflags.status_updates - && !g.program_state.saving && !suppress_map_output()) { + if (flags.time && iflags.status_updates && !suppress_map_output()) { if (VIA_WINDOWPORT()) { stat_update_time(); } else { diff --git a/src/decl.c b/src/decl.c index f9bc6fcfe..1cd1042d3 100644 --- a/src/decl.c +++ b/src/decl.c @@ -580,7 +580,6 @@ const struct instance_globals g_init = { /* restore.c */ 0, /* n_ids_mapped */ 0, /* id_map */ - FALSE, /* restoring */ UNDEFINED_PTR, /* oldfruit */ UNDEFINED_VALUE, /* omoves */ diff --git a/src/display.c b/src/display.c index 053c4fb0b..c3ac520d5 100644 --- a/src/display.c +++ b/src/display.c @@ -539,7 +539,7 @@ warning_of(struct monst *mon) boolean suppress_map_output(void) { - if (g.in_mklev || g.program_state.restoring) + if (g.in_mklev || g.program_state.saving || g.program_state.restoring) return TRUE; #ifdef HANGUPHANDLING if (g.program_state.done_hup) @@ -1480,7 +1480,7 @@ redraw_map(void) * !u.ux: display isn't ready yet; (restoring || !on_level()): was part * of cliparound() but interface shouldn't access this much internals */ - if (!u.ux || g.restoring || !on_level(&u.uz0, &u.uz)) + if (!u.ux || suppress_map_output() || !on_level(&u.uz0, &u.uz)) return; /* @@ -1829,7 +1829,7 @@ flush_screen(int cursor_on_u) glyph_info bkglyphinfo = nul_glyphinfo; /* 3.7: don't update map, status, or perm_invent during save/restore */ - if (g.program_state.saving || g.program_state.restoring) + if (suppress_map_output()) return; if (cursor_on_u == -1) diff --git a/src/invent.c b/src/invent.c index 93e552870..9e24f22ad 100644 --- a/src/invent.c +++ b/src/invent.c @@ -2346,12 +2346,12 @@ learn_unseen_invent(void) /* persistent inventory window is maintained by interface code; 'update_inventory' used to be a macro for - (*windowprocs.win_update_inventory) but the restore hackery - was getting out of hand; this is now a central call point */ + (*windowprocs.win_update_inventory) but the restore hackery to suppress + screen updates was getting out of hand; this is now a central call point */ void update_inventory(void) { - if (g.program_state.saving || g.program_state.restoring) + if (suppress_map_output()) /* despite name, used for perm_invent too */ return; /* diff --git a/src/restore.c b/src/restore.c index 18bab2d08..e4d50d942 100644 --- a/src/restore.c +++ b/src/restore.c @@ -756,7 +756,9 @@ dorecover(NHFILE* nhfp) int rtmp; struct obj *otmp; + /* suppress map display if some part of the code tries to update that */ g.program_state.restoring = 1; + get_plname_from_file(nhfp, g.plname); getlev(nhfp, 0, (xchar) 0); if (!restgamestate(nhfp, &stuckid, &steedid)) {