From 0df430ad7807aaf634735101b8b3cce24a6449a5 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Sat, 1 Mar 2025 14:00:33 +0100 Subject: [PATCH] fix indicators flashing when invulnerability powerup fades out (#2217) * fix indicators flashing when invulnerability powerup fades out https://www.doomworld.com/forum/topic/112333-this-is-woof-1520-jan-31-2025/?page=106&tab=comments#comment-2902657 * use player_t instead of struct player_s --- src/hu_crosshair.c | 2 +- src/st_stuff.c | 3 +-- src/st_stuff.h | 7 +++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/hu_crosshair.c b/src/hu_crosshair.c index a99667f8..19829500 100644 --- a/src/hu_crosshair.c +++ b/src/hu_crosshair.c @@ -130,7 +130,7 @@ void HU_UpdateCrosshair(void) crosshair.y = (screenblocks <= 10) ? (SCREENHEIGHT - ST_HEIGHT) / 2 : SCREENHEIGHT / 2; - boolean invul = (plr->cheats & CF_GODMODE) || plr->powers[pw_invulnerability]; + boolean invul = ST_PlayerInvulnerable(plr); if (hud_crosshair_health) { diff --git a/src/st_stuff.c b/src/st_stuff.c index c087b592..bb08270e 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -880,8 +880,7 @@ static void UpdateBoomColors(sbarelem_t *elem, player_t *player) sbe_number_t *number = elem->subtype.number; - boolean invul = (player->powers[pw_invulnerability] - || player->cheats & CF_GODMODE); + boolean invul = ST_PlayerInvulnerable(player); crange_idx_e cr; diff --git a/src/st_stuff.h b/src/st_stuff.h index 5a935db9..6c858fb2 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -66,6 +66,13 @@ extern int health_red; // health amount less than which status is red extern int health_yellow; // health amount less than which status is yellow extern int health_green; // health amount above is blue, below is green +static inline boolean ST_PlayerInvulnerable(player_t *player) +{ + return (player->cheats & CF_GODMODE) || + (player->powers[pw_invulnerability] > 4 * 32) || + (player->powers[pw_invulnerability] & 8); +} + extern boolean palette_changes; extern struct hudfont_s *stcfnt;