From c6f8d5a1aac8504cbc637f04f3b965a980cd64f6 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 9 Oct 2010 22:38:16 +0200 Subject: [PATCH] In HUD_ShowAcceleration code, return earlier if acceleration is 0 because there is nothing to show; consequently simplify a bit the logic --- qcsrc/client/hud.qc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index e315a0214..eae1b1252 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -4830,6 +4830,8 @@ void HUD_ShowAcceleration(void) f = bound(0, f * 10, 1); acc_avg = acc_avg * (1 - f) + acceleration * f; acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED); + if (acceleration == 0) + return; pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY; @@ -4839,17 +4841,15 @@ void HUD_ShowAcceleration(void) if (cvar("cl_showacceleration_color_custom")) rgb = stov(cvar_string("cl_showacceleration_color")); else { - rgb = '1 1 1'; - if (acceleration < 0) { + if (acceleration < 0) rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1); - } else if (acceleration > 0) { + else rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1); - } } if (acceleration > 0) HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL); - else if (acceleration < 0) + else HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL); } -- 2.39.2