diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index 0adaa15d..061e5699 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -171,7 +171,7 @@ inline int GetSpriteRes( int width, int height ) i = 2560; } - return i; + return Q_min( i, gHUD.m_iMaxRes ); } void ScaleColors( int &r, int &g, int &b, int a ); diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index b4d199be..d18f1bf2 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -482,13 +482,28 @@ void CHud::VidInit( void ) m_hsprLogo = 0; m_hsprCursor = 0; + // a1ba: don't break the loading order here and + // don't cause memory leak but check + // maximum HUD sprite resolution we have + m_iMaxRes = 640; + client_sprite_t *pSpriteList = m_pSpriteList ? m_pSpriteList : + SPR_GetList( "sprites/hud.txt", &m_iSpriteCountAllRes ); + if( pSpriteList ) + { + for( int i = 0; i < m_iSpriteCountAllRes; i++ ) + { + if( m_iMaxRes < pSpriteList[i].iRes ) + m_iMaxRes = pSpriteList[i].iRes; + } + } + m_iRes = GetSpriteRes( ScreenWidth, ScreenHeight ); // Only load this once if( !m_pSpriteList ) { // we need to load the hud.txt, and all sprites within - m_pSpriteList = SPR_GetList( "sprites/hud.txt", &m_iSpriteCountAllRes ); + m_pSpriteList = pSpriteList; if( m_pSpriteList ) { diff --git a/cl_dll/hud.h b/cl_dll/hud.h index 6bd3d9a3..aca0601b 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -555,6 +555,7 @@ public: int m_iFOV; int m_Teamplay; int m_iRes; + int m_iMaxRes; cvar_t *m_pCvarStealMouse; cvar_t *m_pCvarDraw; cvar_t *m_pAllowHD;