diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 48e804568..4c672ebfb 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -876,10 +876,7 @@ void CChat::OnRefreshSkins() { if(Line.m_HasRenderTee) { - const CSkin *pSkin = m_pClient->m_Skins.Find(Line.m_aSkinName); - Line.m_TeeRenderInfo.m_OriginalRenderSkin = pSkin->m_OriginalSkin; - Line.m_TeeRenderInfo.m_ColorableRenderSkin = pSkin->m_ColorableSkin; - Line.m_TeeRenderInfo.m_SkinMetrics = pSkin->m_Metrics; + Line.m_TeeRenderInfo.Apply(m_pClient->m_Skins.Find(Line.m_aSkinName)); } else { diff --git a/src/game/client/components/ghost.cpp b/src/game/client/components/ghost.cpp index 61e73e9eb..e6e98fd90 100644 --- a/src/game/client/components/ghost.cpp +++ b/src/game/client/components/ghost.cpp @@ -366,10 +366,7 @@ void CGhost::OnRender() IsTeamplay = (m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_TEAMS) != 0; GhostNinjaRenderInfo = Ghost.m_RenderInfo; - GhostNinjaRenderInfo.m_OriginalRenderSkin = pSkin->m_OriginalSkin; - GhostNinjaRenderInfo.m_ColorableRenderSkin = pSkin->m_ColorableSkin; - GhostNinjaRenderInfo.m_BloodColor = pSkin->m_BloodColor; - GhostNinjaRenderInfo.m_SkinMetrics = pSkin->m_Metrics; + GhostNinjaRenderInfo.Apply(pSkin); GhostNinjaRenderInfo.m_CustomColoredSkin = IsTeamplay; if(!IsTeamplay) { @@ -392,11 +389,7 @@ void CGhost::InitRenderInfos(CGhostItem *pGhost) IntsToStr(&pGhost->m_Skin.m_Skin0, 6, aSkinName, std::size(aSkinName)); CTeeRenderInfo *pRenderInfo = &pGhost->m_RenderInfo; - const CSkin *pSkin = m_pClient->m_Skins.Find(aSkinName); - pRenderInfo->m_OriginalRenderSkin = pSkin->m_OriginalSkin; - pRenderInfo->m_ColorableRenderSkin = pSkin->m_ColorableSkin; - pRenderInfo->m_BloodColor = pSkin->m_BloodColor; - pRenderInfo->m_SkinMetrics = pSkin->m_Metrics; + pRenderInfo->Apply(m_pClient->m_Skins.Find(aSkinName)); pRenderInfo->m_CustomColoredSkin = pGhost->m_Skin.m_UseCustomColor; if(pGhost->m_Skin.m_UseCustomColor) { @@ -697,11 +690,7 @@ void CGhost::OnRefreshSkins() CTeeRenderInfo *pRenderInfo = &Ghost.m_RenderInfo; if(aSkinName[0] != '\0') { - const CSkin *pSkin = m_pClient->m_Skins.Find(aSkinName); - pRenderInfo->m_OriginalRenderSkin = pSkin->m_OriginalSkin; - pRenderInfo->m_ColorableRenderSkin = pSkin->m_ColorableSkin; - pRenderInfo->m_BloodColor = pSkin->m_BloodColor; - pRenderInfo->m_SkinMetrics = pSkin->m_Metrics; + pRenderInfo->Apply(m_pClient->m_Skins.Find(aSkinName)); } else { diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index f609855c5..2e8748706 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -1822,12 +1822,8 @@ bool CMenus::PrintHighlighted(const char *pName, F &&PrintFn) CTeeRenderInfo CMenus::GetTeeRenderInfo(vec2 Size, const char *pSkinName, bool CustomSkinColors, int CustomSkinColorBody, int CustomSkinColorFeet) const { - const CSkin *pSkin = m_pClient->m_Skins.Find(pSkinName); - CTeeRenderInfo TeeInfo; - TeeInfo.m_OriginalRenderSkin = pSkin->m_OriginalSkin; - TeeInfo.m_ColorableRenderSkin = pSkin->m_ColorableSkin; - TeeInfo.m_SkinMetrics = pSkin->m_Metrics; + TeeInfo.Apply(m_pClient->m_Skins.Find(pSkinName)); TeeInfo.m_CustomColoredSkin = CustomSkinColors; if(CustomSkinColors) { diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index d7143ab39..db89a67d2 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -633,11 +633,8 @@ void CMenus::RenderSettingsTee(CUIRect MainView) // Note: get the skin info after the settings buttons, because they can trigger a refresh // which invalidates the skin. - const CSkin *pSkin = m_pClient->m_Skins.Find(pSkinName); CTeeRenderInfo OwnSkinInfo; - OwnSkinInfo.m_OriginalRenderSkin = pSkin->m_OriginalSkin; - OwnSkinInfo.m_ColorableRenderSkin = pSkin->m_ColorableSkin; - OwnSkinInfo.m_SkinMetrics = pSkin->m_Metrics; + OwnSkinInfo.Apply(m_pClient->m_Skins.Find(pSkinName)); OwnSkinInfo.m_CustomColoredSkin = *pUseCustomColor; if(*pUseCustomColor) { diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index c62496613..f247731b1 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -844,10 +844,7 @@ void CPlayers::OnRender() { aRenderInfo[i].m_aSixup[g_Config.m_ClDummy].Reset(); - aRenderInfo[i].m_OriginalRenderSkin = pSkin->m_OriginalSkin; - aRenderInfo[i].m_ColorableRenderSkin = pSkin->m_ColorableSkin; - aRenderInfo[i].m_BloodColor = pSkin->m_BloodColor; - aRenderInfo[i].m_SkinMetrics = pSkin->m_Metrics; + aRenderInfo[i].Apply(pSkin); aRenderInfo[i].m_CustomColoredSkin = IsTeamplay; if(!IsTeamplay) { @@ -857,12 +854,8 @@ void CPlayers::OnRender() } } } - const CSkin *pSkin = m_pClient->m_Skins.Find("x_spec"); CTeeRenderInfo RenderInfoSpec; - RenderInfoSpec.m_OriginalRenderSkin = pSkin->m_OriginalSkin; - RenderInfoSpec.m_ColorableRenderSkin = pSkin->m_ColorableSkin; - RenderInfoSpec.m_BloodColor = pSkin->m_BloodColor; - RenderInfoSpec.m_SkinMetrics = pSkin->m_Metrics; + RenderInfoSpec.Apply(m_pClient->m_Skins.Find("x_spec")); RenderInfoSpec.m_CustomColoredSkin = false; RenderInfoSpec.m_Size = 64.0f; const int LocalClientId = m_pClient->m_Snap.m_LocalClientId; diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 63fc6f308..1a736508a 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -1554,11 +1554,7 @@ void CGameClient::OnNewSnapshot() pClient->m_SkinInfo.m_Size = 64; // find new skin - const CSkin *pSkin = m_Skins.Find(pClient->m_aSkinName); - pClient->m_SkinInfo.m_OriginalRenderSkin = pSkin->m_OriginalSkin; - pClient->m_SkinInfo.m_ColorableRenderSkin = pSkin->m_ColorableSkin; - pClient->m_SkinInfo.m_SkinMetrics = pSkin->m_Metrics; - pClient->m_SkinInfo.m_BloodColor = pSkin->m_BloodColor; + pClient->m_SkinInfo.Apply(m_Skins.Find(pClient->m_aSkinName)); pClient->m_SkinInfo.m_CustomColoredSkin = pClient->m_UseCustomColor; if(!pClient->m_UseCustomColor) @@ -3750,13 +3746,9 @@ void CGameClient::RefreshSkins() for(auto &Client : m_aClients) { - Client.m_SkinInfo.m_OriginalRenderSkin.Reset(); - Client.m_SkinInfo.m_ColorableRenderSkin.Reset(); if(Client.m_aSkinName[0] != '\0') { - const CSkin *pSkin = m_Skins.Find(Client.m_aSkinName); - Client.m_SkinInfo.m_OriginalRenderSkin = pSkin->m_OriginalSkin; - Client.m_SkinInfo.m_ColorableRenderSkin = pSkin->m_ColorableSkin; + Client.m_SkinInfo.Apply(m_Skins.Find(Client.m_aSkinName)); } else { diff --git a/src/game/client/render.h b/src/game/client/render.h index ac3b77c77..2501b0ce1 100644 --- a/src/game/client/render.h +++ b/src/game/client/render.h @@ -56,6 +56,14 @@ public: Sixup.Reset(); } + void Apply(const CSkin *pSkin) + { + m_OriginalRenderSkin = pSkin->m_OriginalSkin; + m_ColorableRenderSkin = pSkin->m_ColorableSkin; + m_BloodColor = pSkin->m_BloodColor; + m_SkinMetrics = pSkin->m_Metrics; + } + CSkin::SSkinTextures m_OriginalRenderSkin; CSkin::SSkinTextures m_ColorableRenderSkin;