diff --git a/src/game/client/components/mapimages.cpp b/src/game/client/components/mapimages.cpp index aea75a40a6b..51c143a0a80 100644 --- a/src/game/client/components/mapimages.cpp +++ b/src/game/client/components/mapimages.cpp @@ -25,15 +25,9 @@ const char *const gs_apModEntitiesNames[] = { "f-ddrace", }; -CMapImages::CMapImages() : - CMapImages(100) -{ -} - -CMapImages::CMapImages(int TextureSize) +CMapImages::CMapImages() { m_Count = 0; - m_TextureScale = TextureSize; mem_zero(m_aEntitiesIsLoaded, sizeof(m_aEntitiesIsLoaded)); m_SpeedupArrowIsLoaded = false; @@ -44,6 +38,7 @@ CMapImages::CMapImages(int TextureSize) void CMapImages::OnInit() { + m_TextureScale = g_Config.m_ClTextEntitiesSize; InitOverlayTextures(); if(str_comp(g_Config.m_ClAssetsEntities, "default") == 0) @@ -52,6 +47,8 @@ void CMapImages::OnInit() { str_format(m_aEntitiesPath, sizeof(m_aEntitiesPath), "assets/entities/%s", g_Config.m_ClAssetsEntities); } + + Console()->Chain("cl_text_entities_size", ConchainClTextEntitiesSize, this); } void CMapImages::OnMapLoadImpl(class CLayers *pLayers, IMap *pMap) @@ -381,6 +378,16 @@ void CMapImages::ChangeEntitiesPath(const char *pPath) } } +void CMapImages::ConchainClTextEntitiesSize(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData) +{ + pfnCallback(pResult, pCallbackUserData); + if(pResult->NumArguments()) + { + CMapImages *pThis = static_cast(pUserData); + pThis->SetTextureScale(g_Config.m_ClTextEntitiesSize); + } +} + void CMapImages::SetTextureScale(int Scale) { if(m_TextureScale == Scale) diff --git a/src/game/client/components/mapimages.h b/src/game/client/components/mapimages.h index 45709182be7..a1641260cf3 100644 --- a/src/game/client/components/mapimages.h +++ b/src/game/client/components/mapimages.h @@ -3,6 +3,7 @@ #ifndef GAME_CLIENT_COMPONENTS_MAPIMAGES_H #define GAME_CLIENT_COMPONENTS_MAPIMAGES_H +#include #include #include @@ -43,7 +44,6 @@ class CMapImages : public CComponent public: CMapImages(); - CMapImages(int TextureSize); virtual int Sizeof() const override { return sizeof(*this); } IGraphics::CTextureHandle Get(int Index) const { return m_aTextures[Index]; } @@ -77,6 +77,7 @@ class CMapImages : public CComponent IGraphics::CTextureHandle m_OverlayCenterTexture; int m_TextureScale; + static void ConchainClTextEntitiesSize(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); void InitOverlayTextures(); IGraphics::CTextureHandle UploadEntityLayerText(int TextureSize, int MaxWidth, int YOffset); void UpdateEntityLayerText(CImageInfo &TextImage, int TextureSize, int MaxWidth, int YOffset, int NumbersPower, int MaxNumber = -1); diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 90ee6aee1ad..9504328456f 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -247,7 +247,6 @@ void CGameClient::OnConsoleInit() Console()->Chain("cl_vanilla_skins_only", ConchainRefreshSkins, this); Console()->Chain("cl_dummy", ConchainSpecialDummy, this); - Console()->Chain("cl_text_entities_size", ConchainClTextEntitiesSize, this); Console()->Chain("cl_menu_map", ConchainMenuMap, this); } @@ -407,8 +406,6 @@ void CGameClient::OnInit() GenerateTimeoutCode(g_Config.m_ClTimeoutCode); GenerateTimeoutCode(g_Config.m_ClDummyTimeoutCode); - m_MapImages.SetTextureScale(g_Config.m_ClTextEntitiesSize); - // Aggressively try to grab window again since some Windows users report // window not being focused after starting client. Graphics()->SetWindowGrab(true); @@ -2780,17 +2777,6 @@ void CGameClient::ConchainSpecialDummy(IConsole::IResult *pResult, void *pUserDa } } -void CGameClient::ConchainClTextEntitiesSize(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData) -{ - pfnCallback(pResult, pCallbackUserData); - - if(pResult->NumArguments()) - { - CGameClient *pGameClient = (CGameClient *)pUserData; - pGameClient->m_MapImages.SetTextureScale(g_Config.m_ClTextEntitiesSize); - } -} - IGameClient *CreateGameClient() { return new CGameClient(); diff --git a/src/game/client/gameclient.h b/src/game/client/gameclient.h index fbddeee3a54..8bda5b80e71 100644 --- a/src/game/client/gameclient.h +++ b/src/game/client/gameclient.h @@ -227,7 +227,6 @@ class CGameClient : public IGameClient static void ConchainSpecialDummyInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainRefreshSkins(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConchainSpecialDummy(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); - static void ConchainClTextEntitiesSize(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); static void ConTuneZone(IConsole::IResult *pResult, void *pUserData);