]> granicus.if.org Git - nethack/commitdiff
Allow defining symbols with OPTIONS
authorPasi Kallinen <paxed@alt.org>
Thu, 24 Dec 2015 10:29:27 +0000 (12:29 +0200)
committerPasi Kallinen <paxed@alt.org>
Thu, 24 Dec 2015 10:33:17 +0000 (12:33 +0200)
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

include/extern.h
src/files.c
src/options.c

index 2591f9ec5bb2210927ea8ef28af983791041defc..4839a9c2036cfeba14baf6258757ed819d33ffb2 100644 (file)
@@ -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 *));
index 2090424597f8267e468540786e85803021b61e60..9e4f1d21e3d87cf780fc35ba4e8b515aeaf2d2a9 100644 (file)
@@ -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';
index 2f74c3564eab6e896b3c717690948e43b7a02cb7..c2bf0432a769792f402c682450568d2f38f517a9 100644 (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 */
     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 *