]> granicus.if.org Git - nethack/commitdiff
more duplicate detect; also copy-and-paste for vt_tiledata entry left it enabled...
authornhmall <nhmall@nethack.org>
Sun, 1 Mar 2020 15:48:46 +0000 (10:48 -0500)
committernhmall <nhmall@nethack.org>
Sun, 1 Mar 2020 15:48:46 +0000 (10:48 -0500)
include/optlist.h
src/options.c

index d4cc3ec0434109891c139cd519c3eb351dbe431b..5bfeddc6fda46956e05498686f42f9a02588eb17 100644 (file)
@@ -70,8 +70,8 @@ pfx_##a,
 #endif
 
 /* B:nm, ln, opt_*, setwhere?, on?, negat?, val?, dup?, hndlr? Alias, boolptr */
-/* C:nm, ln, opt_*, setwhere?, on?, negat?, val?, dup?, hndlr? Alias, descr  */
-/* P:pfx, ln, opt_*, setwhere?, on?, negat?, val?, dup?, hndlr? Alias, descr */
+/* C:nm, ln, opt_*, setwhere?, negateok?, valok?, dupok?, hndlr? Alias, desc */
+/* P:pfx, ln, opt_*, setwhere?, negateok?, valok?, dupok?, hndlr? Alias, desc*/
 
     NHOPTB(acoustics, 0, opt_out, set_in_game, On, Yes, No, No, NoAlias,
                &flags.acoustics)
@@ -518,10 +518,10 @@ pfx_##a,
                 "video height")
 #endif
 #ifdef TTY_TILES_ESCCODES
-    NHOPTB(vt_tiledata, 0, opt_out, set_in_config, On, Yes, No, No, NoAlias,
+    NHOPTB(vt_tiledata, 0, opt_in, set_in_config, Off, Yes, No, No, NoAlias,
                 &iflags.vt_tiledata)
 #else
-    NHOPTB(vt_tiledata, 0, opt_out, set_in_config, On, Yes, No, No, NoAlias,
+    NHOPTB(vt_tiledata, 0, opt_in, set_in_config, Off, Yes, No, No, NoAlias,
                 (boolean *) 0)
 #endif
     NHOPTC(warnings, 10, opt_in, set_in_config, No, Yes, No, No, NoAlias,
index 5be359484c03fcc8625935ca0f3122b09a6a9dad..8406edf26813fd6cedbb9a9c4afc4b99d601f707 100644 (file)
@@ -107,7 +107,7 @@ extern char ttycolors[CLR_MAX]; /* in sys/msdos/video.c */
 #endif
 
 static char empty_optstr[] = { '\0' };
-boolean duplicate;
+boolean duplicate, using_alias;
 
 static const char def_inv_order[MAXOCLASSES] = {
     COIN_CLASS, AMULET_CLASS, WEAPON_CLASS, ARMOR_CLASS, FOOD_CLASS,
@@ -311,6 +311,7 @@ boolean tinitial, tfrom_file;
     boolean retval = TRUE;
 
     duplicate = FALSE;
+    using_alias = FALSE;
     g.opt_initial = tinitial;
     g.opt_from_file = tfrom_file;
     if ((op = index(opts, ',')) != 0) {
@@ -405,6 +406,7 @@ boolean tinitial, tfrom_file;
                                       allopt[i].valok);
             if (got_match) {
                 matchidx = i;
+                using_alias = TRUE;
                 break;
             }
         }
@@ -4518,10 +4520,6 @@ char *op;
         if (!g.opt_initial && (allopt[optidx].setwhere == set_in_config))
             return optn_err;
 
-        /* 0 means boolean opts */
-        if (duplicate_opt_detection(optidx))
-            complain_about_duplicate(optidx);
-
         op = string_for_opt(opts, TRUE);
         if (op != empty_optstr) {
             if (negated) {
@@ -5801,7 +5799,7 @@ duplicate_opt_detection(optidx)
 int optidx;
 {
     if (g.opt_initial && g.opt_from_file)
-        return allopt[optidx].dupdetected;
+        return allopt[optidx].dupdetected++;
     return FALSE;
 }
 
@@ -5809,15 +5807,20 @@ static void
 complain_about_duplicate(optidx)
 int optidx;
 {
+    char buf[BUFSZ];
+
 #ifdef MAC
     /* the Mac has trouble dealing with the output of messages while
      * processing the config file.  That should get fixed one day.
      * For now just return.
      */
 #else /* !MAC */
-    config_error_add("%s option specified multiple times: %s",
+    buf[0] = '\0';
+    if (using_alias)
+        Sprintf(buf, " (via alias: %s)", allopt[optidx].alias);
+    config_error_add("%s option specified multiple times: %s%s",
                      (allopt[optidx].opttyp == CompOpt) ? "compound" : "boolean",
-                     allopt[optidx].name);
+                     allopt[optidx].name, buf);
 #endif /* ?MAC */
     return;
 }
@@ -7076,7 +7079,7 @@ char **opp;
                 return FALSE;
             }
         } else {
-            if (duplicate_opt_detection(optidx))
+            if (duplicate && !allopt[optidx].dupeok)
                 complain_about_duplicate(optidx);
             *opp = op;
             return TRUE;