From: Pasi Kallinen Date: Thu, 24 Dec 2015 10:29:27 +0000 (+0200) Subject: Allow defining symbols with OPTIONS X-Git-Tag: NetHack-3.6.1_RC01~1123 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=69e7f4e29b2e9baef231a660893cfb28a038e068;p=nethack 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 --- diff --git a/include/extern.h b/include/extern.h index 2591f9ec5..4839a9c20 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1645,7 +1645,7 @@ E int FDECL(add_autopickup_exception, (const char *)); E void NDECL(free_autopickup_exceptions); E int FDECL(load_symset, (const char *, int)); E void NDECL(free_symsets); -E void FDECL(parsesymbols, (char *)); +E boolean FDECL(parsesymbols, (char *)); E struct symparse *FDECL(match_sym, (char *)); E void NDECL(set_playmode); E int FDECL(sym_val, (char *)); diff --git a/src/files.c b/src/files.c index 209042459..9e4f1d21e 100644 --- a/src/files.c +++ b/src/files.c @@ -2386,7 +2386,10 @@ int src; *op = '\0'; } /* parse here */ - parsesymbols(bufp); + if (!parsesymbols(bufp)) { + raw_printf("Error in SYMBOLS definition '%s'.\n", bufp); + wait_synch(); + } if (morelines) { do { *symbuf = '\0'; diff --git a/src/options.c b/src/options.c index 2f74c3564..c2bf0432a 100644 --- a/src/options.c +++ b/src/options.c @@ -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 */ badoption(opts); } @@ -4974,7 +4980,7 @@ free_symsets() } /* Parse the value of a SYMBOLS line from a config file */ -void +boolean parsesymbols(opts) register char *opts; { @@ -4984,7 +4990,7 @@ register char *opts; if ((op = index(opts, ',')) != 0) { *op++ = 0; - parsesymbols(op); + if (!parsesymbols(op)) return FALSE; } /* S_sample:string */ @@ -4993,7 +4999,7 @@ register char *opts; if (!strval) strval = index(opts, '='); if (!strval) - return; + return FALSE; *strval++ = '\0'; /* strip leading and trailing white space from symname and strval */ @@ -5002,12 +5008,13 @@ register char *opts; symp = match_sym(symname); if (!symp) - return; + return FALSE; if (symp->range && symp->range != SYM_CONTROL) { val = sym_val(strval); update_l_symset(symp, val); } + return TRUE; } struct symparse *