Cache globals in hud_show_cloak_invuln

This commit is contained in:
Kp 2015-06-13 22:42:20 +00:00
parent 379a2a32b7
commit b2887abd51

View file

@ -1625,35 +1625,30 @@ static void hud_show_weapons(void)
static void hud_show_cloak_invuln(void)
{
const auto &plr = Players[Player_num];
const auto player_flags = plr.flags;
if (!(player_flags & (PLAYER_FLAGS_CLOAKED | PLAYER_FLAGS_INVULNERABLE)))
return;
gr_set_fontcolor(BM_XRGB(0,31,0),-1 );
const auto &&line_spacing = LINE_SPACING;
const auto base_y = grd_curcanv->cv_bitmap.bm_h - ((Game_mode & GM_MULTI) ? line_spacing * 8 : line_spacing * 4);
const auto gametime64 = GameTime64;
if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) {
int y = grd_curcanv->cv_bitmap.bm_h;
if (Game_mode & GM_MULTI)
y -= LINE_SPACING*8;
else
y -= LINE_SPACING*4;
const fix64 effect_end = Players[Player_num].cloak_time+CLOAK_TIME_MAX-GameTime64;
if (effect_end > F1_0*3 || GameTime64 & 0x8000)
if (player_flags & PLAYER_FLAGS_CLOAKED)
{
const fix64 effect_end = plr.cloak_time + CLOAK_TIME_MAX - gametime64;
if (effect_end > F1_0*3 || gametime64 & 0x8000)
{
gr_printf(FSPACX(1), y, "%s: %lu", TXT_CLOAKED, static_cast<unsigned long>(effect_end / F1_0));
gr_printf(FSPACX(1), base_y, "%s: %lu", TXT_CLOAKED, static_cast<unsigned long>(effect_end / F1_0));
}
}
if (Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE) {
int y = grd_curcanv->cv_bitmap.bm_h;
if (Game_mode & GM_MULTI)
y -= LINE_SPACING*9;
else
y -= LINE_SPACING*5;
const fix64 effect_end = Players[Player_num].invulnerable_time+INVULNERABLE_TIME_MAX-GameTime64;
if (effect_end > F1_0*4 || GameTime64 & 0x8000)
if (player_flags & PLAYER_FLAGS_INVULNERABLE)
{
const fix64 effect_end = plr.invulnerable_time + INVULNERABLE_TIME_MAX - gametime64;
if (effect_end > F1_0*4 || gametime64 & 0x8000)
{
gr_printf(FSPACX(1), y, "%s: %lu", TXT_INVULNERABLE, static_cast<unsigned long>(effect_end / F1_0));
gr_printf(FSPACX(1), base_y - line_spacing, "%s: %lu", TXT_INVULNERABLE, static_cast<unsigned long>(effect_end / F1_0));
}
}