OPTIONS=playmode:normal|explore|debug (trunk only)

Relief for the command-line impaired.  Allow player to request
explore or wizard mode via run-time config file or NETHACKOPTIONS.
Validation is left to xxxmain() and has been updated for Unix, VMS, and
ports which share pcmain.  Mac and Be appear to allow any user to access
wizard mode, and may not need any modification, although they'll continue
to have the old buglet of running with both wizard and discover flags set
if player uses `nethack -X -D'.  This may or may not work as-is for the
Qt interface depending upon whether it goes through one of the xxxmain()'s
mentioned above [someone needs to make sure that it doesn't allow Qt on
Unix to bypass the (username == WIZARD_NAME) test when user requests
wizard mode].

     playmode:discov[ery] is a synonym for explor[e] and playmode:wizard
is one for debug.  Using -X or -D on the command line overrides any
config file or environment playmode value.  (We might want to add -N or
something to force normal mode when config/env specifies something else.)

     This suffers from the same bug as `nethack -X' and `nethack -D':  a
player can save a game in normal mode, then restore in explore or debug
mode and choose to retain the save file, obtain information about the
current game (identifying inventory or using enlightenment or mapping out
previously visited levels and so on), quit, then restore the original save
file normally in order to take advantage of the undeserved information.
This commit is contained in:
nethack.rankin
2007-02-15 05:21:24 +00:00
parent 658c931aad
commit 293d984946

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)options.c 3.5 2006/09/23 */
/* SCCS Id: @(#)options.c 3.5 2007/02/14 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -320,6 +320,13 @@ static struct Comp_Opt
20, SET_IN_GAME },
{ "pickup_types", "types of objects to pick up automatically",
MAXOCLASSES, SET_IN_GAME },
{ "playmode",
#ifdef WIZARD
"normal play, non-scoring explore mode, or debug mode",
#else
"normal play or non-scoring explore mode",
#endif
8, DISP_IN_GAME },
{ "player_selection", "choose character via dialog or prompts",
12, DISP_IN_GAME },
{ "race", "your starting race (e.g., Human, Elf)",
@@ -1837,6 +1844,33 @@ goodfruit:
}
return;
}
/* play mode: normal, explore/discovery, or debug/wizard */
fullname = "playmode";
if (match_optname(opts, fullname, 4, TRUE)) {
if (duplicate) complain_about_duplicate(opts, 1);
if (negated) bad_negation(fullname, FALSE);
if (duplicate || negated) return;
op = string_for_opt(opts, TRUE);
if (!strncmpi(op, "normal", 6) || !strcmpi(op, "play")) {
wizard = discover = FALSE;
} else if (!strncmpi(op, "explore", 6) ||
!strncmpi(op, "discovery", 6)) {
wizard = FALSE, discover = TRUE;
} else if (!strncmpi(op, "debug", 5) ||
!strncmpi(op, "wizard", 6)) {
#ifdef WIZARD
wizard = TRUE, discover = FALSE;
#else
raw_printf("\"%s\":%s -- debug mode not available.",
fullname, op);
#endif
} else {
raw_printf("Invalid value for \"%s\":%s.", fullname, op);
}
return;
}
/* WINCAP
* player_selection: dialog | prompts */
fullname = "player_selection";
@@ -1844,9 +1878,9 @@ goodfruit:
if (duplicate) complain_about_duplicate(opts,1);
op = string_for_opt(opts, negated);
if (op && !negated) {
if (!strncmpi (op, "dialog", sizeof("dialog")-1))
if (!strncmpi(op, "dialog", sizeof("dialog")-1))
iflags.wc_player_selection = VIA_DIALOG;
else if (!strncmpi (op, "prompt", sizeof("prompt")-1))
else if (!strncmpi(op, "prompt", sizeof("prompt")-1))
iflags.wc_player_selection = VIA_PROMPTS;
else
badoption(opts);
@@ -2676,7 +2710,9 @@ doset()
if (!iflags.menu_tab_sep)
Sprintf(fmtstr_doset_add_menu, "%%s%%-%ds [%%s]", biggest_name);
/* deliberately put `name', `role', `race', `gender' first */
/* deliberately put `playmode', `name', `role', `race', `gender' first
(also alignment if anything ever comes before it in compopt[]) */
doset_add_menu(tmpwin, "playmode", 0);
doset_add_menu(tmpwin, "name", 0);
doset_add_menu(tmpwin, "role", 0);
doset_add_menu(tmpwin, "race", 0);
@@ -2685,7 +2721,8 @@ doset()
for (pass = startpass; pass <= endpass; pass++)
for (i = 0; compopt[i].name; i++)
if (compopt[i].optflags == pass) {
if (!strcmp(compopt[i].name, "name") ||
if (!strcmp(compopt[i].name, "playmode") ||
!strcmp(compopt[i].name, "name") ||
!strcmp(compopt[i].name, "role") ||
!strcmp(compopt[i].name, "race") ||
!strcmp(compopt[i].name, "gender"))
@@ -3535,7 +3572,11 @@ char *buf;
else if (!strcmp(optname, "pickup_types")) {
oc_to_str(flags.pickup_types, ocl);
Sprintf(buf, "%s", ocl[0] ? ocl : "all" );
}
}
else if (!strcmp(optname, "playmode")) {
Strcpy(buf,
wizard ? "debug" : discover ? "explore" : "normal");
}
else if (!strcmp(optname, "race"))
Sprintf(buf, "%s", rolestring(flags.initrace, races, noun));
#ifdef REINCARNATION