From f8444ba06c5caedbc3a9eddf383931719630caa3 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sun, 4 Apr 2021 05:28:48 +0500 Subject: [PATCH] Fix HUD scale time. --- cl_dll/hud.cpp | 1 + cl_dll/hud_redraw.cpp | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index 212ec667..a016c161 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -240,6 +240,7 @@ void CHud::Init( void ) // In case we get messages before the first update -- time will be valid m_flTime = 1.0; + m_flScaleColorTime = 3.0f; m_Ammo.Init(); m_Health.Init(); diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index b4889a59..ef71034b 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -93,7 +93,17 @@ int CHud::Redraw( float flTime, int intermission ) // Clock was reset, reset delta if( m_flTimeDelta < 0 ) + { m_flTimeDelta = 0; + m_flScaleColorTime = 0.0f; + } + + if( m_flScaleColorTime != 0.0f ) + { + float flTimeDiff = m_flScaleColorTime - m_flTime; + if( flTimeDiff <= 0.0f ) + m_flScaleColorTime = 0.0f; + } if( !m_iIntermission && intermission ) { @@ -199,7 +209,7 @@ void ScaleColors( int &r, int &g, int &b, int a ) } f = 1.0f - flTimeDiff; } - float x = f * (float)a / 255; + float x = f * ((float)a / 255.0f); r = (int)( r * x ); g = (int)( g * x ); b = (int)( b * x );