From 1e237e4b8f576aba2dda56db7992dd19b535a6e8 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Fri, 20 Oct 2023 14:37:58 -0400 Subject: [PATCH] Fix: shunt to explore mode after wizmode auth fail If an unauthorized player requests the game launch in wizard mode, it will try to put her in explore mode instead. If this happened during restoration of a previous (normal) saved game, the setting of discover in wd_message() would bypass iflags.deferred_X, allowing the player to select to keep the non-explore-mode save file. [Actually, when I tested it I always got an error when answering yes to the "keep the save file?" prompt, but that's a problem too...] Because deferred_X was still 1 after this, the pline "You are already in explore mode" would also be printed following the prompt (when moveloop_preamble() attempted to set explore mode). Fix this so that loading a normal game with -D, then failing the authorization, boots into explore mode via iflags.deferred_X and the "really enter explore mode?" prompt, as it would have if -X were specified on the command line to begin with. --- src/options.c | 4 +++- sys/libnh/libnhmain.c | 8 +++----- sys/unix/unixmain.c | 8 +++----- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/options.c b/src/options.c index e8ffe174b..d23a1a01d 100644 --- a/src/options.c +++ b/src/options.c @@ -10258,8 +10258,10 @@ set_playmode(void) else wizard = FALSE; /* not allowed or not available */ /* try explore mode if we didn't make it into wizard mode */ + /* if requesting wizard mode when restoring a normal game, this will + set iflags.deferred_X and prompt to activate explore mode after the + save file has already been deleted */ discover = !wizard; - iflags.deferred_X = FALSE; } if (discover && !authorize_explore_mode()) { discover = iflags.deferred_X = FALSE; diff --git a/sys/libnh/libnhmain.c b/sys/libnh/libnhmain.c index 5770c5c4e..d7d757cd3 100644 --- a/sys/libnh/libnhmain.c +++ b/sys/libnh/libnhmain.c @@ -633,14 +633,12 @@ wd_message(void) } else { You("cannot access debug (wizard) mode."); } - wizard = 0; /* (paranoia) */ - if (!explore_error_flag) { + wizard = FALSE; /* (paranoia) */ + if (!explore_error_flag) pline("Entering explore/discovery mode instead."); - discover = 1; - } } else if (explore_error_flag) { You("cannot access explore mode."); /* same as enter_explore_mode */ - discover = 0; /* (more paranoia) */ + discover = iflags.deferred_X = FALSE; /* (more paranoia) */ } else if (discover) You("are in non-scoring explore/discovery mode."); } diff --git a/sys/unix/unixmain.c b/sys/unix/unixmain.c index 2da764cae..ec039ddf7 100644 --- a/sys/unix/unixmain.c +++ b/sys/unix/unixmain.c @@ -992,14 +992,12 @@ wd_message(void) } else { You("cannot access debug (wizard) mode."); } - wizard = 0; /* (paranoia) */ - if (!explore_error_flag) { + wizard = FALSE; /* (paranoia) */ + if (!explore_error_flag) pline("Entering explore/discovery mode instead."); - discover = 1; - } } else if (explore_error_flag) { You("cannot access explore mode."); /* same as enter_explore_mode */ - discover = 0; /* (more paranoia) */ + discover = iflags.deferred_X = FALSE; /* (more paranoia) */ } else if (discover) You("are in non-scoring explore/discovery mode."); }