Last of the config error handling

This commit is contained in:
Pasi Kallinen
2017-09-09 18:10:15 +03:00
parent b9c52ff31c
commit a4becd6970

View File

@@ -1820,13 +1820,17 @@ illegal_menu_cmd_key(c)
char c; char c;
{ {
if (c == 0 || c == '\r' || c == '\n' || c == '\033' if (c == 0 || c == '\r' || c == '\n' || c == '\033'
|| c == ' ' || digit(c) || (letter(c) && c != '@')) || c == ' ' || digit(c) || (letter(c) && c != '@')) {
config_error_add("Reserved menu command key '%s'", visctrl(c));
return TRUE; return TRUE;
else { /* reject default object class symbols */ } else { /* reject default object class symbols */
int j; int j;
for (j = 1; j < MAXOCLASSES; j++) for (j = 1; j < MAXOCLASSES; j++)
if (c == def_oc_syms[j].sym) if (c == def_oc_syms[j].sym) {
config_error_add("Menu command key '%s' is an object class",
visctrl(c));
return TRUE; return TRUE;
}
} }
return FALSE; return FALSE;
} }
@@ -2117,7 +2121,7 @@ boolean tinitial, tfrom_file;
symset[ROGUESET].name = dupstr(op); symset[ROGUESET].name = dupstr(op);
if (!read_sym_file(ROGUESET)) { if (!read_sym_file(ROGUESET)) {
clear_symsetentry(ROGUESET, TRUE); clear_symsetentry(ROGUESET, TRUE);
config_error_add("Unable to load symbol set \"%s\" from \"%s\".", config_error_add("Unable to load symbol set \"%s\" from \"%s\"",
op, SYMBOLS); op, SYMBOLS);
return FALSE; return FALSE;
} else { } else {
@@ -2141,7 +2145,7 @@ boolean tinitial, tfrom_file;
symset[PRIMARY].name = dupstr(op); symset[PRIMARY].name = dupstr(op);
if (!read_sym_file(PRIMARY)) { if (!read_sym_file(PRIMARY)) {
clear_symsetentry(PRIMARY, TRUE); clear_symsetentry(PRIMARY, TRUE);
config_error_add("Unable to load symbol set \"%s\" from \"%s\".", config_error_add("Unable to load symbol set \"%s\" from \"%s\"",
op, SYMBOLS); op, SYMBOLS);
return FALSE; return FALSE;
} else { } else {
@@ -2721,7 +2725,8 @@ boolean tinitial, tfrom_file;
else else
break; /* no next token */ break; /* no next token */
} /* for(;;) */ } /* for(;;) */
} } else
return FALSE;
return retval; return retval;
} }
@@ -2768,7 +2773,8 @@ boolean tinitial, tfrom_file;
config_error_add("Unknown %s parameter '%s'", fullname, op); config_error_add("Unknown %s parameter '%s'", fullname, op);
return FALSE; return FALSE;
} }
} } else
return FALSE;
return retval; return retval;
} }
@@ -2848,9 +2854,10 @@ boolean tinitial, tfrom_file;
op = string_for_opt(opts, negated); op = string_for_opt(opts, negated);
if ((negated && !op) || (!negated && op)) if ((negated && !op) || (!negated && op))
flags.pile_limit = negated ? 0 : atoi(op); flags.pile_limit = negated ? 0 : atoi(op);
else if (negated) else if (negated) {
bad_negation(fullname, TRUE); bad_negation(fullname, TRUE);
else /* !op */ return FALSE;
} else /* !op */
flags.pile_limit = PILE_LIMIT_DFLT; flags.pile_limit = PILE_LIMIT_DFLT;
/* sanity check */ /* sanity check */
if (flags.pile_limit < 0) if (flags.pile_limit < 0)
@@ -2878,7 +2885,7 @@ boolean tinitial, tfrom_file;
} else if (!strncmpi(op, "debug", 5) || !strncmpi(op, "wizard", 6)) { } else if (!strncmpi(op, "debug", 5) || !strncmpi(op, "wizard", 6)) {
wizard = TRUE, discover = FALSE; wizard = TRUE, discover = FALSE;
} else { } else {
config_error_add("Invalid value for \"%s\":%s.", fullname, op); config_error_add("Invalid value for \"%s\":%s", fullname, op);
return FALSE; return FALSE;
} }
return retval; return retval;
@@ -2897,16 +2904,19 @@ boolean tinitial, tfrom_file;
else if (!strncmpi(op, "prompt", sizeof("prompt") - 1)) else if (!strncmpi(op, "prompt", sizeof("prompt") - 1))
iflags.wc_player_selection = VIA_PROMPTS; iflags.wc_player_selection = VIA_PROMPTS;
else { else {
config_error_add("Unknown %s parameter '%s'", "pickup_types", op); config_error_add("Unknown %s parameter '%s'", fullname, op);
return FALSE; return FALSE;
} }
} else if (negated) } else if (negated) {
bad_negation(fullname, TRUE); bad_negation(fullname, TRUE);
return FALSE;
}
return retval; return retval;
} }
/* things to disclose at end of game */ /* things to disclose at end of game */
if (match_optname(opts, "disclose", 7, TRUE)) { fullname = "disclose";
if (match_optname(opts, fullname, 7, TRUE)) {
/* /*
* The order that the end_disclose options are stored: * The order that the end_disclose options are stored:
* inventory, attribs, vanquished, genocided, * inventory, attribs, vanquished, genocided,
@@ -2928,14 +2938,13 @@ boolean tinitial, tfrom_file;
* and the presence of a i,a,g,v, or c without a prefix * and the presence of a i,a,g,v, or c without a prefix
* sets the corresponding value to DISCLOSE_YES_WITHOUT_PROMPT. * sets the corresponding value to DISCLOSE_YES_WITHOUT_PROMPT.
*/ */
boolean badopt = FALSE;
int idx, prefix_val; int idx, prefix_val;
if (duplicate) if (duplicate)
complain_about_duplicate(opts, 1); complain_about_duplicate(opts, 1);
op = string_for_opt(opts, TRUE); op = string_for_opt(opts, TRUE);
if (op && negated) { if (op && negated) {
bad_negation("disclose", TRUE); bad_negation(fullname, TRUE);
return FALSE; return FALSE;
} }
/* "disclose" without a value means "all with prompting" /* "disclose" without a value means "all with prompting"
@@ -2988,23 +2997,22 @@ boolean tinitial, tfrom_file;
prefix_val = c; prefix_val = c;
} else if (c == ' ') { } else if (c == ' ') {
; /* do nothing */ ; /* do nothing */
} else } else {
badopt = TRUE; config_error_add("Unknown %s parameter '%c'", fullname, *op);
return FALSE;
}
op++; op++;
} }
if (badopt) {
config_error_add("Unknown %s parameter '%s'", "disclose", op);
return FALSE;
}
return retval; return retval;
} }
/* scores:5t[op] 5a[round] o[wn] */ /* scores:5t[op] 5a[round] o[wn] */
if (match_optname(opts, "scores", 4, TRUE)) { fullname = "scores";
if (match_optname(opts, fullname, 4, TRUE)) {
if (duplicate) if (duplicate)
complain_about_duplicate(opts, 1); complain_about_duplicate(opts, 1);
if (negated) { if (negated) {
bad_negation("scores", FALSE); bad_negation(fullname, FALSE);
return FALSE; return FALSE;
} }
if (!(op = string_for_opt(opts, FALSE))) if (!(op = string_for_opt(opts, FALSE)))
@@ -3038,7 +3046,7 @@ boolean tinitial, tfrom_file;
flags.end_own = !negated; flags.end_own = !negated;
break; break;
default: default:
config_error_add("Unknown %s parameter '%s'", "scores", op); config_error_add("Unknown %s parameter '%s'", fullname, op);
return FALSE; return FALSE;
} }
while (letter(*++op) || *op == ' ') while (letter(*++op) || *op == ' ')
@@ -3065,7 +3073,8 @@ boolean tinitial, tfrom_file;
config_error_add("Unknown %s parameter '%s'", fullname, op); config_error_add("Unknown %s parameter '%s'", fullname, op);
return FALSE; return FALSE;
} }
} } else
return FALSE;
return retval; return retval;
} }
@@ -3233,6 +3242,8 @@ boolean tinitial, tfrom_file;
} else { } else {
#if defined(WIN32) #if defined(WIN32)
op = string_for_opt(opts, 0); op = string_for_opt(opts, 0);
if (!op)
return FALSE;
map_subkeyvalue(op); map_subkeyvalue(op);
#endif #endif
} }
@@ -3263,7 +3274,8 @@ boolean tinitial, tfrom_file;
if (iflags.wc_tile_file) if (iflags.wc_tile_file)
free(iflags.wc_tile_file); free(iflags.wc_tile_file);
iflags.wc_tile_file = dupstr(op); iflags.wc_tile_file = dupstr(op);
} } else
return FALSE;
return retval; return retval;
} }
/* WINCAP /* WINCAP
@@ -3307,7 +3319,8 @@ boolean tinitial, tfrom_file;
char buf[WINTYPELEN]; char buf[WINTYPELEN];
nmcpy(buf, op, WINTYPELEN); nmcpy(buf, op, WINTYPELEN);
choose_windows(buf); choose_windows(buf);
} } else
return FALSE;
return retval; return retval;
} }
#ifdef WINCHAIN #ifdef WINCHAIN
@@ -3320,7 +3333,8 @@ boolean tinitial, tfrom_file;
char buf[WINTYPELEN]; char buf[WINTYPELEN];
nmcpy(buf, op, WINTYPELEN); nmcpy(buf, op, WINTYPELEN);
addto_windowchain(buf); addto_windowchain(buf);
} } else
return FALSE;
return retval; return retval;
} }
#endif #endif
@@ -3342,7 +3356,8 @@ boolean tinitial, tfrom_file;
} }
/* menustyle:traditional or combination or full or partial */ /* menustyle:traditional or combination or full or partial */
if (match_optname(opts, "menustyle", 4, TRUE)) { fullname = "menustyle";
if (match_optname(opts, fullname, 4, TRUE)) {
int tmp; int tmp;
boolean val_required = (strlen(opts) > 5 && !negated); boolean val_required = (strlen(opts) > 5 && !negated);
@@ -3374,7 +3389,7 @@ boolean tinitial, tfrom_file;
flags.menu_style = MENU_PARTIAL; flags.menu_style = MENU_PARTIAL;
break; break;
default: default:
config_error_add("Unknown %s parameter '%s'", "menustyle", op); config_error_add("Unknown %s parameter '%s'", fullname, op);
return FALSE; return FALSE;
} }
return retval; return retval;
@@ -3407,6 +3422,7 @@ boolean tinitial, tfrom_file;
if (match_optname(opts, fullname, (int) strlen(fullname), TRUE)) { if (match_optname(opts, fullname, (int) strlen(fullname), TRUE)) {
if (negated) { if (negated) {
bad_negation(fullname, FALSE); bad_negation(fullname, FALSE);
return FALSE;
} else if ((op = string_for_opt(opts, FALSE)) != 0) { } else if ((op = string_for_opt(opts, FALSE)) != 0) {
char c, op_buf[BUFSZ]; char c, op_buf[BUFSZ];
@@ -3414,7 +3430,6 @@ boolean tinitial, tfrom_file;
c = *op_buf; c = *op_buf;
if (illegal_menu_cmd_key(c)) { if (illegal_menu_cmd_key(c)) {
/* TODO FIXME */
return FALSE; return FALSE;
} else } else
add_menu_cmd_alias(c, default_menu_cmd_info[i].cmd); add_menu_cmd_alias(c, default_menu_cmd_info[i].cmd);
@@ -3461,8 +3476,8 @@ boolean tinitial, tfrom_file;
switch_symbols(TRUE); switch_symbols(TRUE);
} }
if (badflag) { if (badflag) {
pline("Failure to load symbol set %s.", fullname); config_error_add("Failure to load symbol set %s.", fullname);
wait_synch(); return FALSE;
} }
} }
return retval; return retval;
@@ -3490,8 +3505,8 @@ boolean tinitial, tfrom_file;
} }
} }
if (badflag) { if (badflag) {
pline("Failure to load symbol set %s.", sym_name); config_error_add("Failure to load symbol set %s.", sym_name);
wait_synch(); return FALSE;
} else { } else {
switch_symbols(TRUE); switch_symbols(TRUE);
if (!initial && Is_rogue_level(&u.uz)) if (!initial && Is_rogue_level(&u.uz))
@@ -3519,8 +3534,8 @@ boolean tinitial, tfrom_file;
} }
} }
if (badflag) { if (badflag) {
pline("Failure to load symbol set %s.", fullname); config_error_add("Failure to load symbol set %s.", fullname);
wait_synch(); return FALSE;
} else { } else {
switch_symbols(TRUE); switch_symbols(TRUE);
if (!initial && Is_rogue_level(&u.uz)) if (!initial && Is_rogue_level(&u.uz))