fix 'up' and 'down' status highlighting for HP

If there was a status_hilite rule for hitpoints:up, it got used for
both up and down changes.  If there was one for hitpoints:down, it got
ignored even if there was no 'up' rule.  The flag for which direction
the value changed was always positive even when the value went down.

I'm reasonably sure that at some point HP up/down worked correctly.
This problem was present in 3.6.4; I didn't go back any farther.
This commit is contained in:
PatR
2023-08-05 12:50:47 -07:00
parent 9907d4c59e
commit 9f16eaa0a5
2 changed files with 6 additions and 4 deletions

View File

@@ -1222,7 +1222,7 @@ eval_notify_windowport_field(int fld, boolean *valsetlist, int idx)
? percentage(curr, &gb.blstats[idx][fldmax])
: 0; /* bullet proofing; can't get here */
if (pc != prev->percent_value)
chg = 1;
chg = (pc < prev->percent_value) ? -1 : 1;
curr->percent_value = pc;
} else {
pc = 0;
@@ -1473,7 +1473,7 @@ init_blstats(void)
*
*/
static int
compare_blstats(struct istat_s *bl1, struct istat_s*bl2)
compare_blstats(struct istat_s *bl1, struct istat_s *bl2)
{
int anytype, result = 0;
@@ -1484,8 +1484,8 @@ compare_blstats(struct istat_s *bl1, struct istat_s*bl2)
anytype = bl1->anytype;
if ((!bl1->a.a_void || !bl2->a.a_void)
&& (anytype == ANY_IPTR || anytype == ANY_UPTR || anytype == ANY_LPTR
|| anytype == ANY_ULPTR)) {
&& (anytype == ANY_IPTR || anytype == ANY_UPTR
|| anytype == ANY_LPTR || anytype == ANY_ULPTR)) {
panic("compare_blstat: invalid pointer %s, %s",
fmt_ptr((genericptr_t) bl1->a.a_void),
fmt_ptr((genericptr_t) bl2->a.a_void));