Apply sysconf EXPLORERS restriction on startup
The sysconf EXPLORERS list restricting access to explore mode was being evaluated and used when a player used the #exploremode command in-game, or when specifying -X or OPTIONS=playmode:explore on the command line when resuming a normal game, but not when starting an entirely new game. When SYSCF is avilable, check for authorization early, similar to debug mode authorization, to restrict access to explore mode to EXPLORERS under (hopefully) all circumstances.
This commit is contained in:
@@ -53,7 +53,7 @@ extern void init_linux_cons(void);
|
||||
#endif
|
||||
|
||||
static void wd_message(void);
|
||||
static boolean wiz_error_flag = FALSE;
|
||||
static boolean wiz_error_flag = FALSE, explore_error_flag = FALSE;
|
||||
static struct passwd *get_unix_pw(void);
|
||||
|
||||
int
|
||||
@@ -964,6 +964,22 @@ authorize_wizard_mode(void)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* similar to above, validate explore mode access */
|
||||
boolean
|
||||
authorize_explore_mode(void)
|
||||
{
|
||||
#ifdef SYSCF
|
||||
if (sysopt.explorers && sysopt.explorers[0]) {
|
||||
if (check_user_string(sysopt.explorers))
|
||||
return TRUE;
|
||||
}
|
||||
explore_error_flag = TRUE; /* not being allowed into explore mode */
|
||||
return FALSE;
|
||||
#else
|
||||
return TRUE; /* if sysconf disabled, no restrictions on explore mode */
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
wd_message(void)
|
||||
{
|
||||
@@ -973,9 +989,17 @@ wd_message(void)
|
||||
pline("Only user%s %s may access debug (wizard) mode.",
|
||||
strchr(sysopt.wizards, ' ') ? "s" : "", tmp);
|
||||
free(tmp);
|
||||
} else
|
||||
} else {
|
||||
You("cannot access debug (wizard) mode.");
|
||||
}
|
||||
wizard = 0; /* (paranoia) */
|
||||
if (!explore_error_flag) {
|
||||
pline("Entering explore/discovery mode instead.");
|
||||
wizard = 0, discover = 1; /* (paranoia) */
|
||||
discover = 1;
|
||||
}
|
||||
} else if (explore_error_flag) {
|
||||
You("cannot access explore mode."); /* same as enter_explore_mode */
|
||||
discover = 0; /* (more paranoia) */
|
||||
} else if (discover)
|
||||
You("are in non-scoring explore/discovery mode.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user