Fix scope drawing after changelevel.

This commit is contained in:
Andrey Akhmichin 2021-04-04 06:11:57 +05:00
parent f8444ba06c
commit 5766ab7779
3 changed files with 22 additions and 4 deletions

View File

@ -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 )

View File

@ -563,9 +563,11 @@ private:
//
//-----------------------------------------------------
//
class CHudScope
class CHudScope : public CHudBase
{
public:
int Init( void );
int VidInit( void );
int DrawScope( void );
int DrawText( void );

View File

@ -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 );