E long FDECL(macseek, (int,long,short));
E int FDECL(macunlink, (const char *));
+/* ### macmain.c ### */
+
+E boolean NDECL(authorize_wizard_mode);
+
/* ### macsnd.c ### */
E void FDECL(mac_speaker, (struct obj *,char *));
E void FDECL(parsesymbols, (char *));
E struct symparse *FDECL(match_sym, (char *));
#endif
+E void NDECL(set_playmode);
/* ### pager.c ### */
# ifdef CHDIR
E void FDECL(chdirx, (char *,BOOLEAN_P));
# endif /* CHDIR */
+E boolean NDECL(authorize_wizard_mode);
#endif /* MICRO || WIN32 */
/* ### pcsys.c ### */
E void NDECL(port_help);
# endif
E void FDECL(sethanguphandler, (void (*)(int)));
+E boolean NDECL(authorize_wizard_mode);
#endif /* UNIX */
-
/* ### unixtty.c ### */
#if defined(UNIX) || defined(__BEOS__)
E void FDECL(chdirx, (const char *,BOOLEAN_P));
# endif /* CHDIR */
E void FDECL(sethanguphandler, (void (*)(int)));
+E boolean NDECL(authorize_wizard_mode);
/* ### vmsmisc.c ### */
return 1;
}
+/* set up for wizard mode if player or save file has requested to it;
+ called from port-specific startup code to handle `nethack -D' or
+ OPTIONS=playmode:debug, or from dorecover()'s restgamestate() if
+ restoring a game which was saved in wizard mode */
+void
+set_playmode()
+{
+ if (wizard) {
+#ifdef WIZARD
+ if (authorize_wizard_mode())
+ Strcpy(plname, "wizard");
+ else
+#endif
+ wizard = FALSE; /* not allowed or not available */
+ /* force explore mode if we didn't make it into wizard mode */
+ discover = !wizard;
+ }
+ /* don't need to do anything special for explore mode or normal play */
+}
+
#endif /* OPTION_LISTS_ONLY */
/*options.c*/
/* 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
+ if (newgameflags.debug) {
+ /* authorized by startup code; wizard mode exists and is allowed */
+ wizard = TRUE, discover = FALSE;
+ } else if (wizard) {
+ /* specified by save file; check authorization now */
+ set_playmode();
}
#ifdef SYSFLAGS
newgamesysflags = sysflags;
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);
}
/* validate wizard mode if player has requested access to it */
-static void
-set_playmode()
+boolean
+authorize_wizard_mode()
{
- if (wizard) {
#ifdef WIZARD
/* other ports validate user name or character name here */
+ return TRUE;
#else
- wizard = FALSE;
-#endif
-
- if (!wizard) {
- discover = TRUE;
-#ifdef WIZARD
- } else {
- discover = FALSE; /* paranoia */
- Strcpy(plname, "wizard");
+ return FALSE;
#endif
- }
- }
- /* don't need to do anything special for explore mode or normal play */
}
#ifndef __begui__
#include <fcntl.h>
#endif
-static void NDECL(set_playmode);
-
static void finder_file_request(void);
int main(void);
}
/* validate wizard mode if player has requested access to it */
-static void
-set_playmode()
+boolean
+authorize_wizard_mode()
{
- if (wizard) {
#ifdef WIZARD
/* other ports validate user name or character name here */
+ return TRUE;
#else
- wizard = FALSE;
-#endif
-
- if (!wizard) {
- discover = TRUE;
-#ifdef WIZARD
- } else {
- discover = FALSE; /* paranoia */
- Strcpy(plname, "wizard");
+ return FALSE;
#endif
- }
- }
- /* don't need to do anything special for explore mode or normal play */
}
/*macmain.c*/
extern void NDECL(mswin_destroy_reg);
#endif
-STATIC_DCL void NDECL(set_playmode);
-
#ifdef EXEPATH
STATIC_DCL char *FDECL(exepath,(char *));
#endif
#endif
/* validate wizard mode if player has requested access to it */
-STATIC_OVL void
-set_playmode()
+boolean
+authorize_wizard_mode()
{
- if (wizard) {
#ifdef WIZARD
- if (strcmp(plname, WIZARD_NAME)) wizard = FALSE;
-#else
- wizard = FALSE;
+ if (!strcmp(plname, WIZARD_NAME)) return TRUE;
#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 */
+ return FALSE;
}
#ifdef EXEPATH
extern void NDECL(init_linux_cons);
#endif
-static void NDECL(set_playmode);
static void NDECL(wd_message);
static boolean wiz_error_flag = FALSE;
#endif
/* validate wizard mode if player has requested access to it */
-static void
-set_playmode()
+boolean
+authorize_wizard_mode()
{
- if (wizard) {
#ifdef WIZARD
char *user;
int uid;
pw = getpwuid(uid);
}
}
- if (!pw || strcmp(pw->pw_name, WIZARD_NAME)) wizard = FALSE;
-#else /* !WIZARD */
- wizard = FALSE;
-#endif /* ?WIZARD */
-
- if (!wizard) {
- discover = wiz_error_flag = TRUE;
-#ifdef WIZARD
- } else {
- discover = FALSE; /* paranoia */
- Strcpy(plname, "wizard");
-#endif
- }
- }
- /* don't need to do anything special for explore mode or normal play */
+ if (pw && !strcmp(pw->pw_name, WIZARD_NAME)) return TRUE;
+#endif /* WIZARD */
+ return FALSE;
}
static void
#include <ssdef.h> /* system service status codes */
#endif
-static void NDECL(set_playmode);
static void NDECL(wd_message);
static boolean wiz_error_flag = FALSE;
to match it, avoiding need to test which one to use in string ops */
/* validate wizard mode if player has requested access to it */
-static void
-set_playmode()
+boolean
+authorize_wizard_mode()
{
- if (wizard) {
-#ifdef WIZARD
- if (strcmpi(nh_getenv("USER"), WIZARD_NAME)) wizard = FALSE;
-#else
- wizard = FALSE;
-#endif
-
- if (!wizard) {
- discover = wiz_error_flag = TRUE;
#ifdef WIZARD
- } else {
- discover = FALSE; /* paranoia */
- Strcpy(plname, "wizard");
+ if (!strcmpi(nh_getenv("USER"), WIZARD_NAME)) return TRUE;
#endif
- }
- }
- /* don't need to do anything special for explore mode or normal play */
+ return FALSE;
}
static void