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:
@@ -517,8 +517,10 @@ restgamestate(fd, stuckid, steedid)
|
|||||||
register int fd;
|
register int fd;
|
||||||
unsigned int *stuckid, *steedid; /* STEED */
|
unsigned int *stuckid, *steedid; /* STEED */
|
||||||
{
|
{
|
||||||
/* discover is actually flags.explore */
|
struct flag newgameflags;
|
||||||
boolean remember_discover = discover;
|
#ifdef SYSFLAGS
|
||||||
|
struct sysflag newgamesysflags;
|
||||||
|
#endif
|
||||||
struct obj *otmp, *tmp_bc;
|
struct obj *otmp, *tmp_bc;
|
||||||
int uid;
|
int uid;
|
||||||
|
|
||||||
@@ -536,9 +538,24 @@ unsigned int *stuckid, *steedid; /* STEED */
|
|||||||
if (context.warntype.speciesidx)
|
if (context.warntype.speciesidx)
|
||||||
context.warntype.species = &mons[context.warntype.speciesidx];
|
context.warntype.species = &mons[context.warntype.speciesidx];
|
||||||
|
|
||||||
|
/* we want to be able to revert to command line/environment/config
|
||||||
|
file option values instead of keeping old save file option values
|
||||||
|
if partial restore fails and we resort to starting a new game */
|
||||||
|
newgameflags = flags;
|
||||||
mread(fd, (genericptr_t) &flags, sizeof(struct flag));
|
mread(fd, (genericptr_t) &flags, sizeof(struct flag));
|
||||||
if (remember_discover) discover = remember_discover;
|
/* wizard and discover are actually flags.debug and flags.explore;
|
||||||
|
player might be overriding the save file values for them */
|
||||||
|
if (newgameflags.explore) discover = TRUE;
|
||||||
|
if (newgameflags.debug) wizard = TRUE;
|
||||||
|
if (wizard) {
|
||||||
|
#ifdef WIZARD
|
||||||
|
discover = FALSE;
|
||||||
|
#else
|
||||||
|
discover = TRUE, wizard = FALSE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
#ifdef SYSFLAGS
|
#ifdef SYSFLAGS
|
||||||
|
newgamesysflags = sysflags;
|
||||||
mread(fd, (genericptr_t) &sysflags, sizeof(struct sysflag));
|
mread(fd, (genericptr_t) &sysflags, sizeof(struct sysflag));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -560,6 +577,11 @@ unsigned int *stuckid, *steedid; /* STEED */
|
|||||||
wiz1_level.dlevel = 0;
|
wiz1_level.dlevel = 0;
|
||||||
u.uz.dnum = 0;
|
u.uz.dnum = 0;
|
||||||
u.uz.dlevel = 1;
|
u.uz.dlevel = 1;
|
||||||
|
/* revert to pre-restore option settings */
|
||||||
|
flags = newgameflags;
|
||||||
|
#ifdef SYSFLAGS
|
||||||
|
sysflags = newgamesysflags;
|
||||||
|
#endif
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
/* in case hangup save occurred in midst of level change */
|
/* in case hangup save occurred in midst of level change */
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* SCCS Id: @(#)bemain.c 3.5 2006/04/01 */
|
/* SCCS Id: @(#)bemain.c 3.5 2007/02/15 */
|
||||||
/* Copyright (c) Dean Luick, 1996. */
|
/* Copyright (c) Dean Luick, 1996. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -11,6 +11,8 @@ static void process_options(int argc, char **argv);
|
|||||||
static void chdirx(const char *dir);
|
static void chdirx(const char *dir);
|
||||||
static void getlock(void);
|
static void getlock(void);
|
||||||
|
|
||||||
|
static void NDECL(set_playmode);
|
||||||
|
|
||||||
#ifdef __begui__
|
#ifdef __begui__
|
||||||
#define MAIN nhmain
|
#define MAIN nhmain
|
||||||
int nhmain(int argc, char **argv);
|
int nhmain(int argc, char **argv);
|
||||||
@@ -41,12 +43,7 @@ int MAIN(int argc, char **argv)
|
|||||||
u.uhp = 1; /* prevent RIP on early quits */
|
u.uhp = 1; /* prevent RIP on early quits */
|
||||||
process_options(argc, argv); /* command line options */
|
process_options(argc, argv); /* command line options */
|
||||||
|
|
||||||
|
set_playmode(); /* sets plname to "wizard" for wizard mode */
|
||||||
#ifdef WIZARD
|
|
||||||
if (wizard)
|
|
||||||
Strcpy(plname, "wizard");
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
if(!*plname || !strncmp(plname, "player", 4)
|
if(!*plname || !strncmp(plname, "player", 4)
|
||||||
|| !strncmp(plname, "games", 4))
|
|| !strncmp(plname, "games", 4))
|
||||||
askname();
|
askname();
|
||||||
@@ -57,7 +54,6 @@ int MAIN(int argc, char **argv)
|
|||||||
Sprintf(lock,"%d%s", getuid(), plname);
|
Sprintf(lock,"%d%s", getuid(), plname);
|
||||||
getlock();
|
getlock();
|
||||||
|
|
||||||
|
|
||||||
dlb_init(); /* must be before newgame() */
|
dlb_init(); /* must be before newgame() */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -80,12 +76,6 @@ int MAIN(int argc, char **argv)
|
|||||||
display_gamewindows();
|
display_gamewindows();
|
||||||
|
|
||||||
if ((fd = restore_saved_game()) >= 0) {
|
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
|
#ifdef NEWS
|
||||||
if(iflags.news) {
|
if(iflags.news) {
|
||||||
display_file(NEWS, FALSE);
|
display_file(NEWS, FALSE);
|
||||||
@@ -96,12 +86,8 @@ int MAIN(int argc, char **argv)
|
|||||||
mark_synch(); /* flush output */
|
mark_synch(); /* flush output */
|
||||||
if (dorecover(fd)) {
|
if (dorecover(fd)) {
|
||||||
resuming = TRUE; /* not starting new game */
|
resuming = TRUE; /* not starting new game */
|
||||||
#ifdef WIZARD
|
|
||||||
if (!wizard && remember_wiz_mode) wizard = TRUE;
|
|
||||||
#endif
|
|
||||||
if (discover)
|
if (discover)
|
||||||
You("are in non-scoring discovery mode.");
|
You("are in non-scoring discovery mode.");
|
||||||
|
|
||||||
if (discover || wizard) {
|
if (discover || wizard) {
|
||||||
if(yn("Do you want to keep the save file?") == 'n')
|
if(yn("Do you want to keep the save file?") == 'n')
|
||||||
(void) delete_savefile();
|
(void) delete_savefile();
|
||||||
@@ -165,12 +151,12 @@ static void process_options(int argc, char **argv)
|
|||||||
switch (argv[0][1]) {
|
switch (argv[0][1]) {
|
||||||
case 'D':
|
case 'D':
|
||||||
#ifdef WIZARD
|
#ifdef WIZARD
|
||||||
wizard = TRUE;
|
wizard = TRUE, discover = FALSE;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
/* otherwise fall thru to discover */
|
/* otherwise fall thru to discover */
|
||||||
case 'X':
|
case 'X':
|
||||||
discover = TRUE;
|
discover = TRUE, wizard = FALSE;
|
||||||
break;
|
break;
|
||||||
#ifdef NEWS
|
#ifdef NEWS
|
||||||
case 'n':
|
case 'n':
|
||||||
@@ -251,6 +237,29 @@ void getlock(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef __begui__
|
#ifndef __begui__
|
||||||
/*
|
/*
|
||||||
* If we are not using the Be GUI, then just exit -- we don't need to
|
* If we are not using the Be GUI, then just exit -- we don't need to
|
||||||
@@ -262,3 +271,5 @@ void nethack_exit(int status)
|
|||||||
exit(status);
|
exit(status);
|
||||||
}
|
}
|
||||||
#endif /* !__begui__ */
|
#endif /* !__begui__ */
|
||||||
|
|
||||||
|
/*bemain.c*/
|
||||||
|
|||||||
@@ -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. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -24,6 +24,8 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void NDECL(set_playmode);
|
||||||
|
|
||||||
static void finder_file_request(void);
|
static void finder_file_request(void);
|
||||||
int main(void);
|
int main(void);
|
||||||
|
|
||||||
@@ -78,12 +80,9 @@ main (void)
|
|||||||
|
|
||||||
display_gamewindows();
|
display_gamewindows();
|
||||||
|
|
||||||
#ifdef WIZARD
|
set_playmode(); /* sets plname to "wizard" for wizard mode */
|
||||||
if (wizard)
|
if (!*plname || !strncmp(plname, "player", 4) ||
|
||||||
Strcpy(plname, "wizard");
|
!strncmp(plname, "games", 4))
|
||||||
else
|
|
||||||
#endif
|
|
||||||
if(!*plname || !strncmp(plname, "player", 4) || !strncmp(plname, "games", 4))
|
|
||||||
askname();
|
askname();
|
||||||
plnamesuffix(); /* strip suffix from name; calls askname() */
|
plnamesuffix(); /* strip suffix from name; calls askname() */
|
||||||
/* again if suffix was whole name */
|
/* again if suffix was whole name */
|
||||||
@@ -93,12 +92,6 @@ main (void)
|
|||||||
getlock ();
|
getlock ();
|
||||||
|
|
||||||
if ((fd = restore_saved_game()) >= 0) {
|
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
|
#ifdef NEWS
|
||||||
if(iflags.news) {
|
if(iflags.news) {
|
||||||
display_file(NEWS, FALSE);
|
display_file(NEWS, FALSE);
|
||||||
@@ -110,9 +103,6 @@ main (void)
|
|||||||
game_active = 1;
|
game_active = 1;
|
||||||
if (dorecover(fd)) {
|
if (dorecover(fd)) {
|
||||||
resuming = TRUE; /* not starting new game */
|
resuming = TRUE; /* not starting new game */
|
||||||
#ifdef WIZARD
|
|
||||||
if(!wizard && remember_wiz_mode) wizard = TRUE;
|
|
||||||
#endif
|
|
||||||
if (discover || wizard) {
|
if (discover || wizard) {
|
||||||
if(yn("Do you want to keep the save file?") == 'n')
|
if(yn("Do you want to keep the save file?") == 'n')
|
||||||
(void) delete_savefile();
|
(void) delete_savefile();
|
||||||
@@ -280,4 +270,27 @@ finder_file_request(void)
|
|||||||
#endif /* 0 */
|
#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*/
|
/*macmain.c*/
|
||||||
|
|||||||
@@ -429,12 +429,6 @@ char *argv[];
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((fd = restore_saved_game()) >= 0) {
|
if ((fd = restore_saved_game()) >= 0) {
|
||||||
#ifdef WIZARD
|
|
||||||
/* Since wizard is actually flags.debug, restoring might
|
|
||||||
* overwrite it.
|
|
||||||
*/
|
|
||||||
boolean remember_wiz_mode = wizard;
|
|
||||||
#endif
|
|
||||||
#ifndef NO_SIGNAL
|
#ifndef NO_SIGNAL
|
||||||
(void) signal(SIGINT, (SIG_RET_TYPE) done1);
|
(void) signal(SIGINT, (SIG_RET_TYPE) done1);
|
||||||
#endif
|
#endif
|
||||||
@@ -449,12 +443,8 @@ char *argv[];
|
|||||||
|
|
||||||
if (dorecover(fd)) {
|
if (dorecover(fd)) {
|
||||||
resuming = TRUE; /* not starting new game */
|
resuming = TRUE; /* not starting new game */
|
||||||
#ifdef WIZARD
|
|
||||||
if (!wizard && remember_wiz_mode) wizard = TRUE;
|
|
||||||
#endif
|
|
||||||
if (discover)
|
if (discover)
|
||||||
You("are in non-scoring discovery mode.");
|
You("are in non-scoring discovery mode.");
|
||||||
|
|
||||||
if (discover || wizard) {
|
if (discover || wizard) {
|
||||||
if(yn("Do you want to keep the save file?") == 'n')
|
if(yn("Do you want to keep the save file?") == 'n')
|
||||||
(void) delete_savefile();
|
(void) delete_savefile();
|
||||||
|
|||||||
@@ -234,12 +234,6 @@ char *argv[];
|
|||||||
display_gamewindows();
|
display_gamewindows();
|
||||||
|
|
||||||
if ((fd = restore_saved_game()) >= 0) {
|
if ((fd = restore_saved_game()) >= 0) {
|
||||||
#ifdef WIZARD
|
|
||||||
/* Since wizard is actually flags.debug, restoring might
|
|
||||||
* overwrite it.
|
|
||||||
*/
|
|
||||||
boolean remember_wiz_mode = wizard;
|
|
||||||
#endif
|
|
||||||
const char *fq_save = fqname(SAVEF, SAVEPREFIX, 1);
|
const char *fq_save = fqname(SAVEF, SAVEPREFIX, 1);
|
||||||
|
|
||||||
(void) chmod(fq_save,0); /* disallow parallel restores */
|
(void) chmod(fq_save,0); /* disallow parallel restores */
|
||||||
@@ -254,9 +248,6 @@ char *argv[];
|
|||||||
mark_synch(); /* flush output */
|
mark_synch(); /* flush output */
|
||||||
if (dorecover(fd)) {
|
if (dorecover(fd)) {
|
||||||
resuming = TRUE; /* not starting new game */
|
resuming = TRUE; /* not starting new game */
|
||||||
#ifdef WIZARD
|
|
||||||
if (!wizard && remember_wiz_mode) wizard = TRUE;
|
|
||||||
#endif
|
|
||||||
wd_message();
|
wd_message();
|
||||||
if (discover || wizard) {
|
if (discover || wizard) {
|
||||||
if(yn("Do you want to keep the save file?") == 'n')
|
if(yn("Do you want to keep the save file?") == 'n')
|
||||||
|
|||||||
@@ -174,12 +174,6 @@ char *argv[];
|
|||||||
display_gamewindows();
|
display_gamewindows();
|
||||||
|
|
||||||
if ((fd = restore_saved_game()) >= 0) {
|
if ((fd = restore_saved_game()) >= 0) {
|
||||||
#ifdef WIZARD
|
|
||||||
/* Since wizard is actually flags.debug, restoring might
|
|
||||||
* overwrite it.
|
|
||||||
*/
|
|
||||||
boolean remember_wiz_mode = wizard;
|
|
||||||
#endif
|
|
||||||
const char *fq_save = fqname(SAVEF, SAVEPREFIX, 1);
|
const char *fq_save = fqname(SAVEF, SAVEPREFIX, 1);
|
||||||
|
|
||||||
(void) chmod(fq_save,0); /* disallow parallel restores */
|
(void) chmod(fq_save,0); /* disallow parallel restores */
|
||||||
@@ -194,9 +188,6 @@ char *argv[];
|
|||||||
mark_synch(); /* flush output */
|
mark_synch(); /* flush output */
|
||||||
if (dorecover(fd)) {
|
if (dorecover(fd)) {
|
||||||
resuming = TRUE; /* not starting new game */
|
resuming = TRUE; /* not starting new game */
|
||||||
#ifdef WIZARD
|
|
||||||
if (!wizard && remember_wiz_mode) wizard = TRUE;
|
|
||||||
#endif
|
|
||||||
wd_message();
|
wd_message();
|
||||||
if (discover || wizard) {
|
if (discover || wizard) {
|
||||||
if (yn("Do you want to keep the save file?") == 'n')
|
if (yn("Do you want to keep the save file?") == 'n')
|
||||||
|
|||||||
Reference in New Issue
Block a user