]> granicus.if.org Git - nethack/commitdiff
hilite_status: score vs !SCORE_ON_BOTL
authorPatR <rankin@nethack.org>
Mon, 25 Jun 2018 00:44:33 +0000 (17:44 -0700)
committerPatR <rankin@nethack.org>
Mon, 25 Jun 2018 00:44:33 +0000 (17:44 -0700)
When built without support for SCORE_ON_BOTL (the default), suppress
'score' field from 'O' menus for adding/removing hilite_status rules.

Also, add "encumbrance" as field name synonym for "carrying-capacity"
and "experience-points" for "experience".  Relevant for rules set in
config file or via NETHACKOPTIONS.

doc/fixes36.2
src/botl.c

index 7de9164954aea6589ffd369c296e7aa8f6969d14..23b699ac4cfc03528ace1a168dd6d6f2090afe73 100644 (file)
@@ -52,12 +52,15 @@ when using the 'O' command to create a status highlight that specifies
        separate rules for each attribute to be merged when highlighting
 highlighting status conditions would fail to use attributes if a rule with
        them was followed by another one without (color only or color&normal)
+when using 'O' to set hilite_status rules, hide the 'score' status field if
+       game has been built without SCORE_ON_BOTL; latent rules for 'score'
+       can still be set in config file but can't be added or removed via 'O'
 
 
 Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository
 ------------------------------------------------------------------
 fix access violation when --debug:xxxx has no other args after it
-Setting the inverse attribute for gold had the space before "$:" 
+setting the inverse attribute for gold had the space before "$:"
        getting highlighted along with the gold field
 sortloot segfaulted when filtering a subset of items (seen with 'A' command)
 
index 797e29d0bba03d8403165a0627886ff59621d77f..03c49395f3f6808f2939934b43f33438cce89640 100644 (file)
@@ -924,6 +924,7 @@ init_blstats()
 #ifdef STATUS_HILITES
             struct hilite_s *keep_hilite_chain = blstats[i][j].thresholds;
 #endif
+
             blstats[i][j] = initblstats[j];
             blstats[i][j].a = zeroany;
             if (blstats[i][j].valwidth) {
@@ -932,8 +933,7 @@ init_blstats()
             } else
                 blstats[i][j].val = (char *) 0;
 #ifdef STATUS_HILITES
-            if (keep_hilite_chain)
-                blstats[i][j].thresholds = keep_hilite_chain;
+            blstats[i][j].thresholds = keep_hilite_chain;
 #endif
         }
     }
@@ -1204,26 +1204,28 @@ static struct fieldid_t {
     const char *fieldname;
     enum statusfields fldid;
 } fieldids_alias[] = {
-    {"characteristics", BL_CHARACTERISTICS},
-    {"dx",       BL_DX},
-    {"co",       BL_CO},
-    {"con",      BL_CO},
-    {"points",   BL_SCORE},
-    {"cap",      BL_CAP},
-    {"pw",       BL_ENE},
-    {"pw-max",   BL_ENEMAX},
-    {"xl",       BL_XP},
-    {"xplvl",    BL_XP},
-    {"ac",       BL_AC},
-    {"hit-dice", BL_HD},
-    {"turns",    BL_TIME},
-    {"hp",       BL_HP},
-    {"hp-max",   BL_HPMAX},
-    {"dgn",      BL_LEVELDESC},
-    {"xp",       BL_EXP},
-    {"exp",      BL_EXP},
-    {"flags",    BL_CONDITION},
-    {0,          BL_FLUSH}
+    { "characteristics",   BL_CHARACTERISTICS },
+    { "encumbrance",       BL_CAP },
+    { "experience-points", BL_EXP },
+    { "dx",       BL_DX },
+    { "co",       BL_CO },
+    { "con",      BL_CO },
+    { "points",   BL_SCORE },
+    { "cap",      BL_CAP },
+    { "pw",       BL_ENE },
+    { "pw-max",   BL_ENEMAX },
+    { "xl",       BL_XP },
+    { "xplvl",    BL_XP },
+    { "ac",       BL_AC },
+    { "hit-dice", BL_HD },
+    { "turns",    BL_TIME },
+    { "hp",       BL_HP },
+    { "hp-max",   BL_HPMAX },
+    { "dgn",      BL_LEVELDESC },
+    { "xp",       BL_EXP },
+    { "exp",      BL_EXP },
+    { "flags",    BL_CONDITION },
+    {0,           BL_FLUSH }
 };
 
 /* format arguments */
@@ -1258,6 +1260,7 @@ const char *name;
         if (!nmatches) {
             /* check partial matches to canonical names */
             int len = (int) strlen(name);
+
             for (i = 0; i < SIZE(initblstats); i++)
                 if (!strncmpi(name, initblstats[i].fldname, len)) {
                     fld = initblstats[i].fld;
@@ -1286,7 +1289,8 @@ long augmented_time;
         return FALSE;
 
     while (tl) {
-        /* only this style times out */
+        /* only this style times out (includes general 'changed'
+           as well as specific 'up' and 'down') */
         if (tl->behavior == BL_TH_UPDOWN)
             return TRUE;
         tl = tl->next;
@@ -1491,6 +1495,7 @@ int *colorptr;
             case BL_TH_TEXTMATCH:
                 txtstr = blstats[idx][fldidx].val;
                 if (fldidx == BL_TITLE)
+                    /* "<name> the <rank-title>", skip past "<name> the " */
                     txtstr += (strlen(plname) + sizeof " the " - sizeof "");
                 if (hl->rel == TXT_VALUE && hl->textmatch[0]) {
                     if (fuzzymatch(hl->textmatch, txtstr, "\" -_", TRUE)) {
@@ -1523,15 +1528,14 @@ split_clridx(idx, coloridx, attrib)
 int idx;
 int *coloridx, *attrib;
 {
-    if (coloridx && attrib) {
+    if (coloridx)
         *coloridx = idx & 0x00FF;
+    if (attrib)
         *attrib = (idx >> 8) & 0x00FF;
-    }
 }
 
-
 /*
- * This is the parser for the hilite options
+ * This is the parser for the hilite options.
  *
  * parse_status_hl1() separates each hilite entry into
  * a set of field threshold/action component strings,
@@ -2422,17 +2426,24 @@ STATIC_OVL int
 status_hilite_linestr_countfield(fld)
 int fld;
 {
-    struct _status_hilite_line_str *tmp = status_hilite_str;
+    struct _status_hilite_line_str *tmp;
+    boolean countall = (fld == BL_FLUSH);
     int count = 0;
 
-    while (tmp) {
-        if (tmp->fld == fld || fld == BL_FLUSH)
+    for (tmp = status_hilite_str; tmp; tmp = tmp->next) {
+#ifndef SCORE_ON_BOTL
+        /* when SCORE_ON_BOTL is disabled, only count 'score' rules
+           if explicitly asked to do so; exclude them from 'all' count */
+        if (countall && tmp->fld == BL_SCORE)
+            continue;
+#endif
+        if (countall || tmp->fld == fld)
             count++;
-        tmp = tmp->next;
     }
     return count;
 }
 
+/* used by options handling, doset(options.c) */
 int
 count_status_hilites(VOID_ARGS)
 {
@@ -2635,8 +2646,12 @@ status_hilite_menu_choose_field()
     start_menu(tmpwin);
 
     for (i = 0; i < MAXBLSTATS; i++) {
+#ifndef SCORE_ON_BOTL
+        if (initblstats[i].fld == BL_SCORE)
+            continue;
+#endif
         any = zeroany;
-        any.a_int = (i+1);
+        any.a_int = (i + 1);
         add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE,
                  initblstats[i].fldname, MENU_UNSELECTED);
     }
@@ -3427,6 +3442,14 @@ shlmenu_redo:
         int count = status_hilite_linestr_countfield(i);
         char buf[BUFSZ];
 
+#ifndef SCORE_ON_BOTL
+        /* config file might contain rules for highlighting 'score'
+           even when SCORE_ON_BOTL is disabled; if so, 'O' command
+           menus won't manipulate them, but will display them for
+           the "View all hilites in config format" operation */
+        if (initblstats[i].fld == BL_SCORE)
+            continue;
+#endif
         any = zeroany;
         any.a_int = i + 1;
         Sprintf(buf, "%-18s", initblstats[i].fldname);
@@ -3436,7 +3459,6 @@ shlmenu_redo:
                  buf, MENU_UNSELECTED);
     }
 
-
     end_menu(tmpwin, "Status hilites:");
     if ((res = select_menu(tmpwin, PICK_ONE, &picks)) > 0) {
         i = picks->item.a_int - 1;