register int fd;
unsigned int *stuckid, *steedid; /* STEED */
{
- /* discover is actually flags.explore */
- boolean remember_discover = discover;
+ struct flag newgameflags;
+#ifdef SYSFLAGS
+ struct sysflag newgamesysflags;
+#endif
struct obj *otmp, *tmp_bc;
int uid;
if (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));
- 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
+ newgamesysflags = sysflags;
mread(fd, (genericptr_t) &sysflags, sizeof(struct sysflag));
#endif
wiz1_level.dlevel = 0;
u.uz.dnum = 0;
u.uz.dlevel = 1;
+ /* revert to pre-restore option settings */
+ flags = newgameflags;
+#ifdef SYSFLAGS
+ sysflags = newgamesysflags;
+#endif
return(FALSE);
}
/* in case hangup save occurred in midst of level change */
-/* SCCS Id: @(#)bemain.c 3.5 2006/04/01 */
+/* SCCS Id: @(#)bemain.c 3.5 2007/02/15 */
/* Copyright (c) Dean Luick, 1996. */
/* NetHack may be freely redistributed. See license for details. */
static void chdirx(const char *dir);
static void getlock(void);
+static void NDECL(set_playmode);
+
#ifdef __begui__
#define MAIN nhmain
int nhmain(int argc, char **argv);
u.uhp = 1; /* prevent RIP on early quits */
process_options(argc, argv); /* command line options */
-
-#ifdef WIZARD
- if (wizard)
- Strcpy(plname, "wizard");
- else
-#endif
+ set_playmode(); /* sets plname to "wizard" for wizard mode */
if(!*plname || !strncmp(plname, "player", 4)
|| !strncmp(plname, "games", 4))
askname();
Sprintf(lock,"%d%s", getuid(), plname);
getlock();
-
dlb_init(); /* must be before newgame() */
/*
display_gamewindows();
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);
mark_synch(); /* flush output */
if (dorecover(fd)) {
resuming = TRUE; /* not starting new game */
-#ifdef WIZARD
- if (!wizard && remember_wiz_mode) wizard = TRUE;
-#endif
if (discover)
You("are in non-scoring discovery mode.");
-
if (discover || wizard) {
if(yn("Do you want to keep the save file?") == 'n')
(void) delete_savefile();
switch (argv[0][1]) {
case 'D':
#ifdef WIZARD
- wizard = TRUE;
+ wizard = TRUE, discover = FALSE;
break;
#endif
/* otherwise fall thru to discover */
case 'X':
- discover = TRUE;
+ discover = TRUE, wizard = FALSE;
break;
#ifdef NEWS
case 'n':
}
}
+/* 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__
/*
* If we are not using the Be GUI, then just exit -- we don't need to
exit(status);
}
#endif /* !__begui__ */
+
+/*bemain.c*/
-/* 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. */
#include <fcntl.h>
#endif
+static void NDECL(set_playmode);
+
static void finder_file_request(void);
int 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 */
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);
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();
#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*/
#endif
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
(void) signal(SIGINT, (SIG_RET_TYPE) done1);
#endif
if (dorecover(fd)) {
resuming = TRUE; /* not starting new game */
-#ifdef WIZARD
- if (!wizard && remember_wiz_mode) wizard = TRUE;
-#endif
if (discover)
You("are in non-scoring discovery mode.");
-
if (discover || wizard) {
if(yn("Do you want to keep the save file?") == 'n')
(void) delete_savefile();
display_gamewindows();
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);
(void) chmod(fq_save,0); /* disallow parallel restores */
mark_synch(); /* flush output */
if (dorecover(fd)) {
resuming = TRUE; /* not starting new game */
-#ifdef WIZARD
- if (!wizard && remember_wiz_mode) wizard = TRUE;
-#endif
wd_message();
if (discover || wizard) {
if(yn("Do you want to keep the save file?") == 'n')
display_gamewindows();
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);
(void) chmod(fq_save,0); /* disallow parallel restores */
mark_synch(); /* flush output */
if (dorecover(fd)) {
resuming = TRUE; /* not starting new game */
-#ifdef WIZARD
- if (!wizard && remember_wiz_mode) wizard = TRUE;
-#endif
wd_message();
if (discover || wizard) {
if (yn("Do you want to keep the save file?") == 'n')