status hilites fix

The options menu for status hilites wouldn't work as intended if the
entries in the initblstats[] array were changed to not be in BL_xyz
order.  (No effect on current behavior since they are in that order.)
This commit is contained in:
PatR
2023-09-15 12:35:42 -07:00
parent 8845ead907
commit 450efa0dc4

View File

@@ -4121,7 +4121,7 @@ boolean
status_hilite_menu(void) status_hilite_menu(void)
{ {
winid tmpwin; winid tmpwin;
int i, res; int i, fld, res;
menu_item *picks = (menu_item *) 0; menu_item *picks = (menu_item *) 0;
anything any; anything any;
boolean redo; boolean redo;
@@ -4149,19 +4149,21 @@ status_hilite_menu(void)
} }
for (i = 0; i < MAXBLSTATS; i++) { for (i = 0; i < MAXBLSTATS; i++) {
int count = status_hilite_linestr_countfield(i); int count;
char buf[BUFSZ]; char buf[BUFSZ];
fld = initblstats[i].fld;
count = status_hilite_linestr_countfield(fld);
#ifndef SCORE_ON_BOTL #ifndef SCORE_ON_BOTL
/* config file might contain rules for highlighting 'score' /* config file might contain rules for highlighting 'score'
even when SCORE_ON_BOTL is disabled; if so, 'O' command even when SCORE_ON_BOTL is disabled; if so, 'O' command
menus will show them and allow deletions but not additions, menus will show them and allow deletions but not additions,
otherwise, it won't show 'score' at all */ otherwise, it won't show 'score' at all */
if (initblstats[i].fld == BL_SCORE && !count) if (fld == BL_SCORE && !count)
continue; continue;
#endif #endif
any = cg.zeroany; any = cg.zeroany;
any.a_int = i + 1; any.a_int = fld + 1;
Sprintf(buf, "%-18s", initblstats[i].fldname); Sprintf(buf, "%-18s", initblstats[i].fldname);
if (count) if (count)
Sprintf(eos(buf), " (%d defined)", count); Sprintf(eos(buf), " (%d defined)", count);
@@ -4171,11 +4173,11 @@ status_hilite_menu(void)
end_menu(tmpwin, "Status hilites:"); end_menu(tmpwin, "Status hilites:");
if ((res = select_menu(tmpwin, PICK_ONE, &picks)) > 0) { if ((res = select_menu(tmpwin, PICK_ONE, &picks)) > 0) {
i = picks->item.a_int - 1; fld = picks->item.a_int - 1;
if (i < 0) { if (fld < 0) {
status_hilites_viewall(); status_hilites_viewall();
} else { } else {
if (status_hilite_menu_fld(i)) if (status_hilite_menu_fld(fld))
reset_status_hilites(); reset_status_hilites();
} }
free((genericptr_t) picks), picks = (menu_item *) 0; free((genericptr_t) picks), picks = (menu_item *) 0;