windows calls genl_prag() during startup
genl_prag() will process the prag@ command line options, if present Close #1634
This commit is contained in:
@@ -949,6 +949,7 @@ extern void early_options(int *argc_p, char ***argv_p, char **hackdir_p);
|
||||
#ifdef WIN32
|
||||
int windows_early_options(const char *);
|
||||
#endif
|
||||
extern void genl_prag(int, char **); /* profession, race, align, gender */
|
||||
|
||||
/* ### eat.c ### */
|
||||
|
||||
|
||||
@@ -359,6 +359,89 @@ early_options(int *argc_p, char ***argv_p, char **hackdir_p)
|
||||
config_error_done();
|
||||
return;
|
||||
}
|
||||
|
||||
/* profession (role), race, alignment, gender command line options */
|
||||
void
|
||||
genl_prag(int argc, char *argv[])
|
||||
{
|
||||
char *arg;
|
||||
int i;
|
||||
|
||||
config_error_init(FALSE, "command line", FALSE);
|
||||
|
||||
while (argc > 1 && argv[1][0] == '-') {
|
||||
argv++;
|
||||
argc--;
|
||||
arg = argv[0];
|
||||
/* allow second dash if arg is longer than one character */
|
||||
if (arg[0] == '-' && arg[1] == '-'
|
||||
&& arg[2] != '\0'
|
||||
/* "--a=b" violates the "--" ok when at least 2 chars long rule */
|
||||
&& (arg[3] != '\0' && arg[3] != '=' && arg[3] != ':'))
|
||||
++arg;
|
||||
if (strchr("prag@", arg[1])) {
|
||||
switch (arg[1]) {
|
||||
case 'a':
|
||||
if (arg[2]) {
|
||||
if ((i = str2align(&arg[2])) >= 0)
|
||||
flags.initalign = i;
|
||||
} else if (argc > 1) {
|
||||
argc--;
|
||||
argv++;
|
||||
if ((i = str2align(argv[0])) >= 0)
|
||||
flags.initalign = i;
|
||||
}
|
||||
break;
|
||||
case 'g':
|
||||
if (arg[2]) {
|
||||
if ((i = str2gend(&arg[2])) >= 0)
|
||||
flags.initgend = i;
|
||||
} else if (argc > 1) {
|
||||
argc--;
|
||||
argv++;
|
||||
if ((i = str2gend(argv[0])) >= 0)
|
||||
flags.initgend = i;
|
||||
}
|
||||
break;
|
||||
case 'p': /* profession (role) */
|
||||
if (arg[2]) {
|
||||
if ((i = str2role(&arg[2])) >= 0)
|
||||
flags.initrole = i;
|
||||
} else if (argc > 1) {
|
||||
argc--;
|
||||
argv++;
|
||||
if ((i = str2role(argv[0])) >= 0)
|
||||
flags.initrole = i;
|
||||
}
|
||||
break;
|
||||
case 'r': /* race */
|
||||
if (arg[2]) {
|
||||
if ((i = str2race(&arg[2])) >= 0)
|
||||
flags.initrace = i;
|
||||
} else if (argc > 1) {
|
||||
argc--;
|
||||
argv++;
|
||||
if ((i = str2race(argv[0])) >= 0)
|
||||
flags.initrace = i;
|
||||
}
|
||||
break;
|
||||
case '@':
|
||||
flags.randomall = 1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* default for "-x" is to play as the role that starts with "x" */
|
||||
if ((i = str2role(&argv[1][0])) >= 0) {
|
||||
flags.initrole = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* empty or "N errors on command line" */
|
||||
config_error_done();
|
||||
return;
|
||||
}
|
||||
|
||||
/* for command-line options that perform some immediate action and then
|
||||
terminate the program without starting play, like 'nethack --version'
|
||||
or 'nethack -s Zelda'; do some cleanup before that termination */
|
||||
|
||||
@@ -289,6 +289,9 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
|
||||
nethack_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
genl_prag(argc, argv); /* command line options for profession, race,
|
||||
* alignment, gender */
|
||||
|
||||
/* Finished processing options, lock all directory paths */
|
||||
for (int i = 0; i < PREFIX_COUNT; i++)
|
||||
fqn_prefix_locked[i] = TRUE;
|
||||
|
||||
Reference in New Issue
Block a user