yet more wizard mode handling (trunk only)
Reorganize the recent wizard mode control: move set_playmode() from
xxxmain.c to the core, and have it call new authorize_wizard_mode() to do
the port-specific part. If the set_playmode() call during startup doesn't
result in running in wizard mode (either because not allowed or user
didn't request it), it will be called again during restore if the save
file is from a wizard mode game.
For ports which check character name for authorization, players will
have to use `nethack -u whatever -D' (or options for name and playmode) to
restore a wizard mode save file if WIZARD has been changed from "wizard".
plname[] from a wizard mode saved game will always have that value, so if
it's not the right one players will need to get authorized by the startup
code before loading the save file.
This commit is contained in:
@@ -39,7 +39,6 @@ extern void NDECL(check_linux_console);
|
||||
extern void NDECL(init_linux_cons);
|
||||
#endif
|
||||
|
||||
static void NDECL(set_playmode);
|
||||
static void NDECL(wd_message);
|
||||
static boolean wiz_error_flag = FALSE;
|
||||
|
||||
@@ -507,10 +506,9 @@ port_help()
|
||||
#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;
|
||||
@@ -532,21 +530,9 @@ set_playmode()
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user