Allow defining symbols with OPTIONS

Some people are confused by the boulder -option, and
SYMBOLS=S_boulder, so allow defining symbols with
OPTION-lines in addition to the SYMBOLS.

So these are the same thing:

  SYMBOLS=S_boulder:0
  OPTIONS=S_boulder:0
This commit is contained in:
Pasi Kallinen
2015-12-24 12:29:27 +02:00
parent cc7d5c31b4
commit 69e7f4e29b
3 changed files with 16 additions and 6 deletions

View File

@@ -1645,7 +1645,7 @@ E int FDECL(add_autopickup_exception, (const char *));
E void NDECL(free_autopickup_exceptions); E void NDECL(free_autopickup_exceptions);
E int FDECL(load_symset, (const char *, int)); E int FDECL(load_symset, (const char *, int));
E void NDECL(free_symsets); E void NDECL(free_symsets);
E void FDECL(parsesymbols, (char *)); E boolean FDECL(parsesymbols, (char *));
E struct symparse *FDECL(match_sym, (char *)); E struct symparse *FDECL(match_sym, (char *));
E void NDECL(set_playmode); E void NDECL(set_playmode);
E int FDECL(sym_val, (char *)); E int FDECL(sym_val, (char *));

View File

@@ -2386,7 +2386,10 @@ int src;
*op = '\0'; *op = '\0';
} }
/* parse here */ /* parse here */
parsesymbols(bufp); if (!parsesymbols(bufp)) {
raw_printf("Error in SYMBOLS definition '%s'.\n", bufp);
wait_synch();
}
if (morelines) { if (morelines) {
do { do {
*symbuf = '\0'; *symbuf = '\0';

View File

@@ -3402,6 +3402,12 @@ boolean tinitial, tfrom_file;
} }
} }
/* Is it a symbol? */
if (strstr(opts, "S_") == opts && parsesymbols(opts)) {
switch_symbols(TRUE);
return;
}
/* out of valid options */ /* out of valid options */
badoption(opts); badoption(opts);
} }
@@ -4974,7 +4980,7 @@ free_symsets()
} }
/* Parse the value of a SYMBOLS line from a config file */ /* Parse the value of a SYMBOLS line from a config file */
void boolean
parsesymbols(opts) parsesymbols(opts)
register char *opts; register char *opts;
{ {
@@ -4984,7 +4990,7 @@ register char *opts;
if ((op = index(opts, ',')) != 0) { if ((op = index(opts, ',')) != 0) {
*op++ = 0; *op++ = 0;
parsesymbols(op); if (!parsesymbols(op)) return FALSE;
} }
/* S_sample:string */ /* S_sample:string */
@@ -4993,7 +4999,7 @@ register char *opts;
if (!strval) if (!strval)
strval = index(opts, '='); strval = index(opts, '=');
if (!strval) if (!strval)
return; return FALSE;
*strval++ = '\0'; *strval++ = '\0';
/* strip leading and trailing white space from symname and strval */ /* strip leading and trailing white space from symname and strval */
@@ -5002,12 +5008,13 @@ register char *opts;
symp = match_sym(symname); symp = match_sym(symname);
if (!symp) if (!symp)
return; return FALSE;
if (symp->range && symp->range != SYM_CONTROL) { if (symp->range && symp->range != SYM_CONTROL) {
val = sym_val(strval); val = sym_val(strval);
update_l_symset(symp, val); update_l_symset(symp, val);
} }
return TRUE;
} }
struct symparse * struct symparse *