From 9f16eaa0a52a228742086a0285028a83dc3cc527 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 5 Aug 2023 12:50:47 -0700 Subject: [PATCH] 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. --- doc/fixes3-7-0.txt | 2 ++ src/botl.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 690726cd6..2c3728764 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1225,6 +1225,8 @@ allow #sit while flying over a squeaky board trap to trigger it weight of statues of wraiths and of monsters which never leave a corpse was 0 when a werecreature in human form attacked hero, it could transform to critter despite hero having the Protection_from_shape_changers_attibute +status highlighting for hit points didn't work as intended for up or down HP + changes; 'up' rule was used for both, 'down' rule was ignored Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/botl.c b/src/botl.c index c112dc808..95bf6d3ef 100644 --- a/src/botl.c +++ b/src/botl.c @@ -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));