more wizard/explore mode control (trunk only)

Wizard mode or explore mode can be forced on (via -D or -X on the
command line, or now via OPTIONS=playmode:debug|explore) when restoring
a saved game; explore mode handling was confined to restgamestate(), but
wizard mode handling was replicated in every main().  Treat `wizard' the
same as `discover'.  Also, prevent a new game started when restore fails
from using the old game's option settings if partial restore attempt got
far enough to load the flags struct.  And update bemain.c and macmain.c
to catch up with the others modified by the playmode patch.
This commit is contained in:
nethack.rankin
2007-02-16 02:35:30 +00:00
parent 5c0a06d6b0
commit 1659dd5634
6 changed files with 85 additions and 67 deletions

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)macmain.c 3.5 2006/04/01 */
/* SCCS Id: @(#)macmain.c 3.5 2007/02/15 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -24,6 +24,8 @@
#include <fcntl.h>
#endif
static void NDECL(set_playmode);
static void finder_file_request(void);
int main(void);
@@ -78,12 +80,9 @@ main (void)
display_gamewindows();
#ifdef WIZARD
if (wizard)
Strcpy(plname, "wizard");
else
#endif
if(!*plname || !strncmp(plname, "player", 4) || !strncmp(plname, "games", 4))
set_playmode(); /* sets plname to "wizard" for wizard mode */
if (!*plname || !strncmp(plname, "player", 4) ||
!strncmp(plname, "games", 4))
askname();
plnamesuffix(); /* strip suffix from name; calls askname() */
/* again if suffix was whole name */
@@ -93,12 +92,6 @@ main (void)
getlock ();
if ((fd = restore_saved_game()) >= 0) {
#ifdef WIZARD
/* Since wizard is actually flags.debug, restoring might
* overwrite it.
*/
boolean remember_wiz_mode = wizard;
#endif
#ifdef NEWS
if(iflags.news) {
display_file(NEWS, FALSE);
@@ -110,9 +103,6 @@ main (void)
game_active = 1;
if (dorecover(fd)) {
resuming = TRUE; /* not starting new game */
#ifdef WIZARD
if(!wizard && remember_wiz_mode) wizard = TRUE;
#endif
if (discover || wizard) {
if(yn("Do you want to keep the save file?") == 'n')
(void) delete_savefile();
@@ -280,4 +270,27 @@ finder_file_request(void)
#endif /* 0 */
}
/* validate wizard mode if player has requested access to it */
static void
set_playmode()
{
if (wizard) {
#ifdef WIZARD
/* other ports validate user name or character name here */
#else
wizard = FALSE;
#endif
if (!wizard) {
discover = TRUE;
#ifdef WIZARD
} else {
discover = FALSE; /* paranoia */
Strcpy(plname, "wizard");
#endif
}
}
/* don't need to do anything special for explore mode or normal play */
}
/*macmain.c*/