From f8444ba06c5caedbc3a9eddf383931719630caa3 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sun, 4 Apr 2021 05:28:48 +0500 Subject: [PATCH 1/3] 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 ); From 5766ab7779253918100cca41c1acdbdc9d970e15 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sun, 4 Apr 2021 06:11:57 +0500 Subject: [PATCH 2/3] Fix scope drawing after changelevel. --- cl_dll/hud.cpp | 2 ++ cl_dll/hud.h | 4 +++- cl_dll/poke646/scope.cpp | 20 +++++++++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index a016c161..4009dbd6 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -260,6 +260,7 @@ void CHud::Init( void ) m_Scoreboard.Init(); m_Menu.Init(); + m_Scope.Init(); MsgFunc_ResetHUD( 0, 0, NULL ); } @@ -439,6 +440,7 @@ void CHud::VidInit( void ) m_StatusIcons.VidInit(); m_Scoreboard.VidInit(); m_MOTD.VidInit(); + m_Scope.VidInit(); } int CHud::MsgFunc_Logo( const char *pszName, int iSize, void *pbuf ) diff --git a/cl_dll/hud.h b/cl_dll/hud.h index 12063e52..c32676a3 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -563,9 +563,11 @@ private: // //----------------------------------------------------- // -class CHudScope +class CHudScope : public CHudBase { public: + int Init( void ); + int VidInit( void ); int DrawScope( void ); int DrawText( void ); diff --git a/cl_dll/poke646/scope.cpp b/cl_dll/poke646/scope.cpp index e777a3e2..d054fa34 100644 --- a/cl_dll/poke646/scope.cpp +++ b/cl_dll/poke646/scope.cpp @@ -34,6 +34,20 @@ extern vec3_t v_cl_angles; // last client/mouse angle extern vec3_t v_sim_org; // last sim origin extern cvar_t *adjust_fov; +int CHudScope::Init( void ) +{ + gHUD.AddHudElem( this ); + + return 1; +} + +int CHudScope::VidInit( void ) +{ + m_hSprite = 0; + + return 1; +} + int CHudScope::DrawScope() { vec3_t angles, forward, right, up; @@ -62,12 +76,12 @@ int CHudScope::DrawScope() flDist = Length( delta ); if( flDist >= 118.0f ) - sprintf( m_szDist, "%.2f m", flDist * 0.0254f ); + sprintf( m_szDist, "%.2f m", (double)(flDist / 39.37f) ); else strcpy( m_szDist, "-.-- m" ); - x = tan( gHUD.m_iFOV * 0.008726646259971648 ) * 11.0; - y = x * 0.00390625; + x = tan( gHUD.m_iFOV / 114.6f ) * 11.0f; + y = x * / 255.0f; gEngfuncs.pTriAPI->RenderMode( kRenderTransTexture ); //additive gEngfuncs.pTriAPI->CullFace( TRI_NONE ); From 25c6c2a470695fbf36bf28c5126c1d7781819ea5 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sun, 4 Apr 2021 06:46:18 +0500 Subject: [PATCH 3/3] Fix ammo meter. --- cl_dll/ammo.cpp | 12 ++++++------ dlls/player.cpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index 031fbfd5..26acc12c 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -645,14 +645,14 @@ int CHudAmmo::MsgFunc_WeaponList( const char *pszName, int iSize, void *pbuf ) strcpy( Weapon.szName, READ_STRING() ); Weapon.iAmmoType = (int)READ_CHAR(); - Weapon.iMax1 = READ_BYTE(); - if( Weapon.iMax1 == 255 ) - Weapon.iMax1 = -1; + Weapon.iMax1 = READ_SHORT(); + // if( Weapon.iMax1 == 255 ) + // Weapon.iMax1 = -1; Weapon.iAmmo2Type = READ_CHAR(); - Weapon.iMax2 = READ_BYTE(); - if( Weapon.iMax2 == 255 ) - Weapon.iMax2 = -1; + Weapon.iMax2 = READ_SHORT(); + // if( Weapon.iMax2 == 255 ) + // Weapon.iMax2 = -1; Weapon.iSlot = READ_CHAR(); Weapon.iSlotPos = READ_CHAR(); diff --git a/dlls/player.cpp b/dlls/player.cpp index 3b70f2c2..fe46c32b 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3954,9 +3954,9 @@ void CBasePlayer::UpdateClientData( void ) MESSAGE_BEGIN( MSG_ONE, gmsgWeaponList, NULL, pev ); WRITE_STRING( pszName ); // string weapon name WRITE_BYTE( GetAmmoIndex( II.pszAmmo1 ) ); // byte Ammo Type - WRITE_BYTE( II.iMaxAmmo1 ); // byte Max Ammo 1 + WRITE_SHORT( II.iMaxAmmo1 ); // byte Max Ammo 1 WRITE_BYTE( GetAmmoIndex( II.pszAmmo2 ) ); // byte Ammo2 Type - WRITE_BYTE( II.iMaxAmmo2 ); // byte Max Ammo 2 + WRITE_SHORT( II.iMaxAmmo2 ); // byte Max Ammo 2 WRITE_BYTE( II.iSlot ); // byte bucket WRITE_BYTE( II.iPosition ); // byte bucket pos WRITE_BYTE( II.iId ); // byte id (bit index into pev->weapons)