status highlight fix for experience level

When I expanded the Guidebook's sample configuration file I added
several status_hilite options.  I decided that I'd better test what
was written and discovered that if Xp had an up or changed rule as
well as one or more percentage rules, it was showing bogus changes
whenever the integer value of the percentage changed.  The fix
turned out to be simple but it took a while to figure out.

I ultimately left the status_hilite settings out of the sample
options, because they tended to be too wide for Guidebook.txt's
formatting rather than because they weren't working as expected.
This commit is contained in:
PatR
2019-11-07 17:54:57 -08:00
parent 2058ad10f9
commit 6afb780d98
2 changed files with 12 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 botl.c $NHDT-Date: 1562114350 2019/07/03 00:39:10 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.146 $ */
/* NetHack 3.6 botl.c $NHDT-Date: 1573178085 2019/11/08 01:54:45 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.148 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2006. */
/* NetHack may be freely redistributed. See license for details. */
@@ -142,9 +142,9 @@ do_statusline2()
if (Upolyd)
Sprintf(expr, "HD:%d", mons[u.umonnum].mlevel);
else if (flags.showexp)
Sprintf(expr, "Xp:%u/%-1ld", u.ulevel, u.uexp);
Sprintf(expr, "Xp:%d/%-1ld", u.ulevel, u.uexp);
else
Sprintf(expr, "Exp:%u", u.ulevel);
Sprintf(expr, "Exp:%d", u.ulevel);
xln = strlen(expr);
/* time/move counter */
@@ -850,6 +850,12 @@ boolean *valsetlist;
if (anytype != ANY_MASK32) {
#ifdef STATUS_HILITES
if (chg || *curr->val) {
/* if Xp percentage changed, we set 'chg' to 1 above;
reset that if the Xp value hasn't actually changed
or possibly went down rather than up (level loss) */
if (chg == 1 && fld == BL_XP)
chg = compare_blstats(prev, curr);
curr->hilite_rule = get_hilite(idx, fld,
(genericptr_t) &curr->a,
chg, pc, &color);