From bbbf5f6bcc4fb47bef615f53b33dda9563e10e5e Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 21 Apr 2022 02:39:54 -0700 Subject: [PATCH] duplicate status highlight rules Noticed earlier when testing the status_hilite_menu_fld() changes: if you enter a duplicate rule (with different highlighting), it didn't replace the previous one and the old rule continued to be used. This still doesn't do replacement, but by adding the new rule at the end of the list of rules for the specified field instead of inserting it at the beginning, the new rule gets used. --- src/botl.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/botl.c b/src/botl.c index 5dfb8fc51..5a79f6e3f 100644 --- a/src/botl.c +++ b/src/botl.c @@ -2351,7 +2351,7 @@ query_arrayvalue( static void status_hilite_add_threshold(int fld, struct hilite_s *hilite) { - struct hilite_s *new_hilite; + struct hilite_s *new_hilite, *old_hilite; if (!hilite) return; @@ -2362,8 +2362,16 @@ status_hilite_add_threshold(int fld, struct hilite_s *hilite) new_hilite->set = TRUE; new_hilite->fld = fld; - new_hilite->next = g.blstats[0][fld].thresholds; - g.blstats[0][fld].thresholds = new_hilite; + new_hilite->next = (struct hilite_s *) 0; + /* insert new entry at the end of the list */ + if (!g.blstats[0][fld].thresholds) { + g.blstats[0][fld].thresholds = new_hilite; + } else { + for (old_hilite = g.blstats[0][fld].thresholds; old_hilite->next; + old_hilite = old_hilite->next) + continue; + old_hilite->next = new_hilite; + } /* sort_hilites(fld) */ /* current and prev must both point at the same hilites */ @@ -3680,12 +3688,11 @@ status_hilite_menu_add(int origfld) hilite.rel = TXT_VALUE; Strcpy(hilite.textmatch, aligntxt[rv]); } else if (fld == BL_HUNGER) { - static const char *const hutxt[] = { "Satiated", (char *) 0, "Hungry", - "Weak", "Fainting", "Fainted", - "Starved" }; - int rv = query_arrayvalue(qry_buf, - hutxt, - SATIATED, STARVED + 1); + static const char *const hutxt[] = { + "Satiated", (char *) 0, "Hungry", "Weak", + "Fainting", "Fainted", "Starved" + }; + int rv = query_arrayvalue(qry_buf, hutxt, SATIATED, STARVED + 1); if (rv < SATIATED) goto choose_behavior; -- 2.50.1