From a922c4a0aad01e6280c3ab392577108c53f98754 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Sun, 26 Mar 2023 11:34:46 +0200 Subject: [PATCH] get away with only one invulnerability tracker for status bar and HUD Just remembered that `ST_ticker()` is *always* called before `HU_Ticker()`. --- src/hu_stuff.c | 14 +++++--------- src/st_stuff.c | 10 ++++++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 6418c56b..56f2745a 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -361,7 +361,7 @@ void HU_ResetMessageColors(void) } } -static boolean hu_invul; +extern boolean st_invul; static char* ColorByHealth(int health, int maxhealth, boolean invul) { @@ -836,7 +836,7 @@ static void HU_widget_build_health (void) sprintf(hud_healthstr + i, "%3d", st_health); // set the display color from the amount of health posessed - w_health.cr = ColorByHealth(plr->health, 100, hu_invul); + w_health.cr = ColorByHealth(plr->health, 100, st_invul); // transfer the init string to the widget HUlib_addStringToTextLine(&w_health, hud_healthstr); @@ -884,7 +884,7 @@ static void HU_widget_build_armor (void) if (hud_armor_type) { w_armor.cr = - hu_invul ? colrngs[CR_GRAY] : + st_invul ? colrngs[CR_GRAY] : (plr->armortype == 0) ? colrngs[CR_RED] : (plr->armortype == 1) ? colrngs[CR_GREEN] : colrngs[CR_BLUE]; @@ -895,7 +895,7 @@ static void HU_widget_build_armor (void) // set the display color from the amount of armor posessed w_armor.cr = - hu_invul ? colrngs[CR_GRAY] : + st_invul ? colrngs[CR_GRAY] : (armor < armor_red) ? colrngs[CR_RED] : (armor < armor_yellow) ? colrngs[CR_GOLD] : (armor <= armor_green) ? colrngs[CR_GREEN] : @@ -1271,7 +1271,7 @@ static void HU_UpdateCrosshair(void) crosshair.y = (screenblocks <= 10) ? (ORIGHEIGHT-ST_HEIGHT)/2 : ORIGHEIGHT/2; if (hud_crosshair_health) - crosshair.cr = ColorByHealth(plr->health, 100, hu_invul); + crosshair.cr = ColorByHealth(plr->health, 100, st_invul); else crosshair.cr = colrngs[hud_crosshair_color]; @@ -1475,10 +1475,6 @@ void HU_Ticker(void) HU_disableAllWidgets(); draw_crispy_hud = false; - hu_invul = (plr->powers[pw_invulnerability] > 4*32 || - plr->powers[pw_invulnerability] & 8) || - plr->cheats & CF_GODMODE; - if ((automapactive && hud_widget_font == 1) || hud_widget_font == 2) { hu_font2 = hu_font; diff --git a/src/st_stuff.c b/src/st_stuff.c index 13c320cd..79e4bbbf 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -816,6 +816,8 @@ static int SmoothCount(int shownval, int realval) } } +boolean st_invul; + void ST_Ticker(void) { st_health = SmoothCount(st_health, plyr->health); @@ -825,6 +827,10 @@ void ST_Ticker(void) st_randomnumber = M_Random(); ST_updateWidgets(); st_oldhealth = plyr->health; + + st_invul = (plyr->powers[pw_invulnerability] > 4*32 || + plyr->powers[pw_invulnerability] & 8) || + plyr->cheats & CF_GODMODE; } static int st_palette = 0; @@ -909,10 +915,6 @@ void ST_drawWidgets(void) // the real values, only ever relevant when using smooth counts const int health = plyr->health, armor = plyr->armorpoints; - boolean st_invul = (plyr->powers[pw_invulnerability] > 4*32 || - plyr->powers[pw_invulnerability] & 8) || - plyr->cheats & CF_GODMODE; - // clear area if (!st_crispyhud && st_statusbaron) {