From 7cffdf40b6d781d19523dbe86cadc7f88c7b1c8a Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Thu, 15 Aug 2024 15:25:28 +0800 Subject: [PATCH] Make gameclient m_Sixup an array for dummy --- src/engine/client.h | 2 +- src/game/client/components/chat.cpp | 6 ++--- src/game/client/gameclient.cpp | 18 ++++++++----- src/game/client/gameclient.h | 7 ++--- src/game/client/sixup_translate_game.cpp | 28 ++++++++++---------- src/game/client/sixup_translate_snapshot.cpp | 8 +++--- 6 files changed, 37 insertions(+), 32 deletions(-) diff --git a/src/engine/client.h b/src/engine/client.h index a9599f89b..202aa96bc 100644 --- a/src/engine/client.h +++ b/src/engine/client.h @@ -390,7 +390,7 @@ public: virtual int ClientVersion7() const = 0; - virtual void ApplySkin7InfoFromSnapObj(const protocol7::CNetObj_De_ClientInfo *pObj, int ClientId) = 0; + virtual void ApplySkin7InfoFromSnapObj(const protocol7::CNetObj_De_ClientInfo *pObj, int ClientId, int Conn) = 0; virtual int OnDemoRecSnap7(class CSnapshot *pFrom, class CSnapshot *pTo, int Conn) = 0; virtual int TranslateSnap(class CSnapshot *pSnapDstSix, class CSnapshot *pSnapSrcSeven, int Conn, bool Dummy) = 0; }; diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 57bef7314..d84c3827b 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -823,14 +823,14 @@ void CChat::AddLine(int ClientId, int Team, const char *pLine) { for(int Part = 0; Part < protocol7::NUM_SKINPARTS; Part++) { - const char *pPartName = LineAuthor.m_Sixup.m_aaSkinPartNames[Part]; + const char *pPartName = LineAuthor.m_Sixup[g_Config.m_ClDummy].m_aaSkinPartNames[Part]; int Id = m_pClient->m_Skins7.FindSkinPart(Part, pPartName, false); const CSkins7::CSkinPart *pSkinPart = m_pClient->m_Skins7.GetSkinPart(Part, Id); - if(LineAuthor.m_Sixup.m_aUseCustomColors[Part]) + if(LineAuthor.m_Sixup[g_Config.m_ClDummy].m_aUseCustomColors[Part]) { pCurrentLine->m_Sixup.m_aTextures[Part] = pSkinPart->m_ColorTexture; pCurrentLine->m_Sixup.m_aColors[Part] = m_pClient->m_Skins7.GetColor( - LineAuthor.m_Sixup.m_aSkinPartColors[Part], + LineAuthor.m_Sixup[g_Config.m_ClDummy].m_aSkinPartColors[Part], Part == protocol7::SKINPART_MARKING); } else diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 1897f34e9..d5d926884 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -2373,11 +2374,14 @@ void CGameClient::CClientData::Reset() m_Country = -1; m_aSkinName[0] = '\0'; m_SkinColor = 0; - for(int i = 0; i < protocol7::NUM_SKINPARTS; ++i) + for(auto &Info : m_Sixup) { - m_Sixup.m_aaSkinPartNames[i][0] = '\0'; - m_Sixup.m_aUseCustomColors[i] = 0; - m_Sixup.m_aSkinPartColors[i] = 0; + for(int i = 0; i < protocol7::NUM_SKINPARTS; ++i) + { + Info.m_aaSkinPartNames[i][0] = '\0'; + Info.m_aUseCustomColors[i] = 0; + Info.m_aSkinPartColors[i] = 0; + } } m_Team = 0; m_Emoticon = 0; @@ -2503,11 +2507,11 @@ bool CGameClient::GotWantedSkin7(bool Dummy) for(int SkinPart = 0; SkinPart < protocol7::NUM_SKINPARTS; SkinPart++) { - if(str_comp(m_aClients[m_aLocalIds[(int)Dummy]].m_Sixup.m_aaSkinPartNames[SkinPart], apSkinPartsPtr[SkinPart])) + if(str_comp(m_aClients[m_aLocalIds[(int)Dummy]].m_Sixup[g_Config.m_ClDummy].m_aaSkinPartNames[SkinPart], apSkinPartsPtr[SkinPart])) return false; - if(m_aClients[m_aLocalIds[(int)Dummy]].m_Sixup.m_aUseCustomColors[SkinPart] != aUCCVars[SkinPart]) + if(m_aClients[m_aLocalIds[(int)Dummy]].m_Sixup[g_Config.m_ClDummy].m_aUseCustomColors[SkinPart] != aUCCVars[SkinPart]) return false; - if(m_aClients[m_aLocalIds[(int)Dummy]].m_Sixup.m_aSkinPartColors[SkinPart] != aColorVars[SkinPart]) + if(m_aClients[m_aLocalIds[(int)Dummy]].m_Sixup[g_Config.m_ClDummy].m_aSkinPartColors[SkinPart] != aColorVars[SkinPart]) return false; } diff --git a/src/game/client/gameclient.h b/src/game/client/gameclient.h index fc9f537f6..dff3ac903 100644 --- a/src/game/client/gameclient.h +++ b/src/game/client/gameclient.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -449,7 +450,7 @@ public: }; // 0.7 Skin - CSixup m_Sixup; + CSixup m_Sixup[NUM_DUMMIES]; }; CClientData m_aClients[MAX_CLIENTS]; @@ -509,8 +510,8 @@ public: void OnConsoleInit() override; void OnStateChange(int NewState, int OldState) override; template - void ApplySkin7InfoFromGameMsg(const T *pMsg, int ClientId); - void ApplySkin7InfoFromSnapObj(const protocol7::CNetObj_De_ClientInfo *pObj, int ClientId) override; + void ApplySkin7InfoFromGameMsg(const T *pMsg, int ClientId, int Conn); + void ApplySkin7InfoFromSnapObj(const protocol7::CNetObj_De_ClientInfo *pObj, int ClientId, int Conn) override; int OnDemoRecSnap7(class CSnapshot *pFrom, class CSnapshot *pTo, int Conn) override; void *TranslateGameMsg(int *pMsgId, CUnpacker *pUnpacker, int Conn); int TranslateSnap(CSnapshot *pSnapDstSix, CSnapshot *pSnapSrcSeven, int Conn, bool Dummy) override; diff --git a/src/game/client/sixup_translate_game.cpp b/src/game/client/sixup_translate_game.cpp index c11100ca3..6d67f29a3 100644 --- a/src/game/client/sixup_translate_game.cpp +++ b/src/game/client/sixup_translate_game.cpp @@ -79,18 +79,18 @@ void CGameClient::DoTeamChangeMessage7(const char *pName, int ClientId, int Team } template -void CGameClient::ApplySkin7InfoFromGameMsg(const T *pMsg, int ClientId) +void CGameClient::ApplySkin7InfoFromGameMsg(const T *pMsg, int ClientId, int Conn) { CClientData *pClient = &m_aClients[ClientId]; char *apSkinPartsPtr[protocol7::NUM_SKINPARTS]; for(int Part = 0; Part < protocol7::NUM_SKINPARTS; Part++) { - str_utf8_copy_num(pClient->m_Sixup.m_aaSkinPartNames[Part], pMsg->m_apSkinPartNames[Part], sizeof(pClient->m_Sixup.m_aaSkinPartNames[Part]), protocol7::MAX_SKIN_LENGTH); - apSkinPartsPtr[Part] = pClient->m_Sixup.m_aaSkinPartNames[Part]; - pClient->m_Sixup.m_aUseCustomColors[Part] = pMsg->m_aUseCustomColors[Part]; - pClient->m_Sixup.m_aSkinPartColors[Part] = pMsg->m_aSkinPartColors[Part]; + str_utf8_copy_num(pClient->m_Sixup[Conn].m_aaSkinPartNames[Part], pMsg->m_apSkinPartNames[Part], sizeof(pClient->m_Sixup[Conn].m_aaSkinPartNames[Part]), protocol7::MAX_SKIN_LENGTH); + apSkinPartsPtr[Part] = pClient->m_Sixup[Conn].m_aaSkinPartNames[Part]; + pClient->m_Sixup[Conn].m_aUseCustomColors[Part] = pMsg->m_aUseCustomColors[Part]; + pClient->m_Sixup[Conn].m_aSkinPartColors[Part] = pMsg->m_aSkinPartColors[Part]; } - m_Skins7.ValidateSkinParts(apSkinPartsPtr, pClient->m_Sixup.m_aUseCustomColors, pClient->m_Sixup.m_aSkinPartColors, m_pClient->m_TranslationContext.m_GameFlags); + m_Skins7.ValidateSkinParts(apSkinPartsPtr, pClient->m_Sixup[Conn].m_aUseCustomColors, pClient->m_Sixup[Conn].m_aSkinPartColors, m_pClient->m_TranslationContext.m_GameFlags); if(time_season() == SEASON_XMAS) { @@ -102,9 +102,9 @@ void CGameClient::ApplySkin7InfoFromGameMsg(const T *pMsg, int ClientId) for(int Part = 0; Part < protocol7::NUM_SKINPARTS; Part++) { - int Id = m_Skins7.FindSkinPart(Part, pClient->m_Sixup.m_aaSkinPartNames[Part], false); + int Id = m_Skins7.FindSkinPart(Part, pClient->m_Sixup[Conn].m_aaSkinPartNames[Part], false); const CSkins7::CSkinPart *pSkinPart = m_Skins7.GetSkinPart(Part, Id); - if(pClient->m_Sixup.m_aUseCustomColors[Part]) + if(pClient->m_Sixup[Conn].m_aUseCustomColors[Part]) { pClient->m_SkinInfo.m_Sixup.m_aTextures[Part] = pSkinPart->m_ColorTexture; pClient->m_SkinInfo.m_Sixup.m_aColors[Part] = m_Skins7.GetColor(pMsg->m_aSkinPartColors[Part], Part == protocol7::SKINPART_MARKING); @@ -116,15 +116,15 @@ void CGameClient::ApplySkin7InfoFromGameMsg(const T *pMsg, int ClientId) } if(pClient->m_SkinInfo.m_Sixup.m_HatTexture.IsValid()) { - if(Part == protocol7::SKINPART_BODY && str_comp(pClient->m_Sixup.m_aaSkinPartNames[Part], "standard")) + if(Part == protocol7::SKINPART_BODY && str_comp(pClient->m_Sixup[Conn].m_aaSkinPartNames[Part], "standard")) pClient->m_SkinInfo.m_Sixup.m_HatSpriteIndex = CSkins7::HAT_OFFSET_SIDE + (ClientId % CSkins7::HAT_NUM); - if(Part == protocol7::SKINPART_DECORATION && !str_comp(pClient->m_Sixup.m_aaSkinPartNames[Part], "twinbopp")) + if(Part == protocol7::SKINPART_DECORATION && !str_comp(pClient->m_Sixup[Conn].m_aaSkinPartNames[Part], "twinbopp")) pClient->m_SkinInfo.m_Sixup.m_HatSpriteIndex = CSkins7::HAT_OFFSET_SIDE + (ClientId % CSkins7::HAT_NUM); } } } -void CGameClient::ApplySkin7InfoFromSnapObj(const protocol7::CNetObj_De_ClientInfo *pObj, int ClientId) +void CGameClient::ApplySkin7InfoFromSnapObj(const protocol7::CNetObj_De_ClientInfo *pObj, int ClientId, int Conn) { char aSkinPartNames[protocol7::NUM_SKINPARTS][protocol7::MAX_SKIN_ARRAY_SIZE]; protocol7::CNetMsg_Sv_SkinChange Msg; @@ -136,7 +136,7 @@ void CGameClient::ApplySkin7InfoFromSnapObj(const protocol7::CNetObj_De_ClientIn Msg.m_aUseCustomColors[Part] = pObj->m_aUseCustomColors[Part]; Msg.m_aSkinPartColors[Part] = pObj->m_aSkinPartColors[Part]; } - ApplySkin7InfoFromGameMsg(&Msg, ClientId); + ApplySkin7InfoFromGameMsg(&Msg, ClientId, Conn); } void *CGameClient::TranslateGameMsg(int *pMsgId, CUnpacker *pUnpacker, int Conn) @@ -293,7 +293,7 @@ void *CGameClient::TranslateGameMsg(int *pMsgId, CUnpacker *pUnpacker, int Conn) CTranslationContext::CClientData &Client = m_pClient->m_TranslationContext.m_aClients[pMsg7->m_ClientId]; Client.m_Active = true; - ApplySkin7InfoFromGameMsg(pMsg7, pMsg7->m_ClientId); + ApplySkin7InfoFromGameMsg(pMsg7, pMsg7->m_ClientId, Conn); // skin will be moved to the 0.6 snap by the translation context // and we drop the game message return nullptr; @@ -495,7 +495,7 @@ void *CGameClient::TranslateGameMsg(int *pMsgId, CUnpacker *pUnpacker, int Conn) str_copy(Client.m_aName, pMsg7->m_pName); str_copy(Client.m_aClan, pMsg7->m_pClan); Client.m_Country = pMsg7->m_Country; - ApplySkin7InfoFromGameMsg(pMsg7, pMsg7->m_ClientId); + ApplySkin7InfoFromGameMsg(pMsg7, pMsg7->m_ClientId, Conn); if(m_pClient->m_TranslationContext.m_aLocalClientId[Conn] == -1) return nullptr; if(pMsg7->m_Silent || pMsg7->m_Local) diff --git a/src/game/client/sixup_translate_snapshot.cpp b/src/game/client/sixup_translate_snapshot.cpp index 1cbb03f18..900e4b7a0 100644 --- a/src/game/client/sixup_translate_snapshot.cpp +++ b/src/game/client/sixup_translate_snapshot.cpp @@ -466,7 +466,7 @@ int CGameClient::TranslateSnap(CSnapshot *pSnapDstSix, CSnapshot *pSnapSrcSeven, IntsToStr(pInfo->m_aClan, 3, Client.m_aClan, std::size(Client.m_aClan)); Client.m_Country = pInfo->m_Country; - ApplySkin7InfoFromSnapObj(pInfo, ClientId); + ApplySkin7InfoFromSnapObj(pInfo, ClientId, Conn); } else if(pItem7->Type() == protocol7::NETOBJTYPE_DE_GAMEINFO) { @@ -524,9 +524,9 @@ int CGameClient::OnDemoRecSnap7(CSnapshot *pFrom, CSnapshot *pTo, int Conn) for(int Part = 0; Part < protocol7::NUM_SKINPARTS; Part++) { - StrToInts(ClientInfoObj.m_aaSkinPartNames[Part], 6, m_aClients[i].m_Sixup.m_aaSkinPartNames[Part]); - ClientInfoObj.m_aUseCustomColors[Part] = m_aClients[i].m_Sixup.m_aUseCustomColors[Part]; - ClientInfoObj.m_aSkinPartColors[Part] = m_aClients[i].m_Sixup.m_aSkinPartColors[Part]; + StrToInts(ClientInfoObj.m_aaSkinPartNames[Part], 6, m_aClients[i].m_Sixup[Conn].m_aaSkinPartNames[Part]); + ClientInfoObj.m_aUseCustomColors[Part] = m_aClients[i].m_Sixup[Conn].m_aUseCustomColors[Part]; + ClientInfoObj.m_aSkinPartColors[Part] = m_aClients[i].m_Sixup[Conn].m_aSkinPartColors[Part]; } mem_copy(pItem, &ClientInfoObj, sizeof(protocol7::CNetObj_De_ClientInfo));