From 4eb69a1fcea585b7cf87d308a663cd3c265d4eed Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 24 Mar 2019 14:34:56 +0100 Subject: [PATCH] removed some magic values --- datasrc/network.py | 8 ++++++++ scripts/cmd5.py | 2 +- src/game/client/gameclient.cpp | 6 +++--- src/game/client/gameclient.h | 8 ++++---- src/game/client/render.cpp | 1 - src/game/client/render.h | 9 +-------- src/game/server/gamecontext.cpp | 10 +++++----- src/game/server/player.cpp | 2 +- src/game/server/player.h | 6 +++--- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/datasrc/network.py b/datasrc/network.py index 58752851f..2320b3dc2 100644 --- a/datasrc/network.py +++ b/datasrc/network.py @@ -45,6 +45,14 @@ enum SPEC_FLAGRED, SPEC_FLAGBLUE, NUM_SPECMODES, + + SKINPART_BODY = 0, + SKINPART_MARKING, + SKINPART_DECORATION, + SKINPART_HANDS, + SKINPART_FEET, + SKINPART_EYES, + NUM_SKINPARTS, }; ''' diff --git a/scripts/cmd5.py b/scripts/cmd5.py index 6f879470d..c01451378 100644 --- a/scripts/cmd5.py +++ b/scripts/cmd5.py @@ -30,6 +30,6 @@ for filename in sys.argv[1:]: hash = hashlib.md5(f).hexdigest().lower()[16:] #TODO 0.8: improve nethash creation -if hash == "7dc99529e56a8ded": +if hash == "7fed48e71cffe081": hash = "802f1be60a05665f" print('#define GAME_NETVERSION_HASH "%s"' % hash) diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 200fe5446..719e3e5eb 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -744,7 +744,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker) str_copy(m_aClients[pMsg->m_ClientID].m_aName, pMsg->m_pName, sizeof(m_aClients[pMsg->m_ClientID].m_aName)); str_copy(m_aClients[pMsg->m_ClientID].m_aClan, pMsg->m_pClan, sizeof(m_aClients[pMsg->m_ClientID].m_aClan)); m_aClients[pMsg->m_ClientID].m_Country = pMsg->m_Country; - for(int i = 0; i < 6; i++) + for(int i = 0; i < NUM_SKINPARTS; i++) { str_copy(m_aClients[pMsg->m_ClientID].m_aaSkinPartNames[i], pMsg->m_apSkinPartNames[i], 24); m_aClients[pMsg->m_ClientID].m_aUseCustomColors[i] = pMsg->m_aUseCustomColors[i]; @@ -803,7 +803,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker) return; } - for(int i = 0; i < 6; i++) + for(int i = 0; i < NUM_SKINPARTS; i++) { str_copy(m_aClients[pMsg->m_ClientID].m_aaSkinPartNames[i], pMsg->m_apSkinPartNames[i], 24); m_aClients[pMsg->m_ClientID].m_aUseCustomColors[i] = pMsg->m_aUseCustomColors[i]; @@ -1293,7 +1293,7 @@ void CGameClient::OnDemoRecSnap() StrToInts(pClientInfo->m_aClan, 3, m_aClients[i].m_aClan); pClientInfo->m_Country = m_aClients[i].m_Country; - for(int p = 0; p < 6; p++) + for(int p = 0; p < NUM_SKINPARTS; p++) { StrToInts(pClientInfo->m_aaSkinPartNames[p], 6, m_aClients[i].m_aaSkinPartNames[p]); pClientInfo->m_aUseCustomColors[p] = m_aClients[i].m_aUseCustomColors[p]; diff --git a/src/game/client/gameclient.h b/src/game/client/gameclient.h index 1062b232a..4d041b146 100644 --- a/src/game/client/gameclient.h +++ b/src/game/client/gameclient.h @@ -171,10 +171,10 @@ public: char m_aName[MAX_NAME_LENGTH]; char m_aClan[MAX_CLAN_LENGTH]; int m_Country; - char m_aaSkinPartNames[6][24]; - int m_aUseCustomColors[6]; - int m_aSkinPartColors[6]; - int m_SkinPartIDs[6]; + char m_aaSkinPartNames[NUM_SKINPARTS][24]; + int m_aUseCustomColors[NUM_SKINPARTS]; + int m_aSkinPartColors[NUM_SKINPARTS]; + int m_SkinPartIDs[NUM_SKINPARTS]; int m_Team; int m_Emoticon; int m_EmoticonStart; diff --git a/src/game/client/render.cpp b/src/game/client/render.cpp index 3286ece1c..2b790c9be 100644 --- a/src/game/client/render.cpp +++ b/src/game/client/render.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include "animstate.h" #include "render.h" diff --git a/src/game/client/render.h b/src/game/client/render.h index 646d869cd..9e64caf82 100644 --- a/src/game/client/render.h +++ b/src/game/client/render.h @@ -5,6 +5,7 @@ #include #include +#include #include #include "ui.h" @@ -12,14 +13,6 @@ // sprite renderings enum { - SKINPART_BODY = 0, - SKINPART_MARKING, - SKINPART_DECORATION, - SKINPART_HANDS, - SKINPART_FEET, - SKINPART_EYES, - NUM_SKINPARTS, - SPRITE_FLAG_FLIP_Y = 1, SPRITE_FLAG_FLIP_X = 2, diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index aee38815f..675c752ef 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -283,7 +283,7 @@ void CGameContext::SendSkinChange(int ClientID) { CNetMsg_Sv_SkinChange Msg; Msg.m_ClientID = ClientID; - for(int p = 0; p < 6; p++) + for(int p = 0; p < NUM_SKINPARTS; p++) { Msg.m_apSkinPartNames[p] = m_apPlayers[ClientID]->m_TeeInfos.m_aaSkinPartNames[p]; Msg.m_aUseCustomColors[p] = m_apPlayers[ClientID]->m_TeeInfos.m_aUseCustomColors[p]; @@ -619,7 +619,7 @@ void CGameContext::OnClientEnter(int ClientID) if(g_Config.m_SvSilentSpectatorMode && m_apPlayers[ClientID]->GetTeam() == TEAM_SPECTATORS) NewClientInfoMsg.m_Silent = true; - for(int p = 0; p < 6; p++) + for(int p = 0; p < NUM_SKINPARTS; p++) { NewClientInfoMsg.m_apSkinPartNames[p] = m_apPlayers[ClientID]->m_TeeInfos.m_aaSkinPartNames[p]; NewClientInfoMsg.m_aUseCustomColors[p] = m_apPlayers[ClientID]->m_TeeInfos.m_aUseCustomColors[p]; @@ -645,7 +645,7 @@ void CGameContext::OnClientEnter(int ClientID) ClientInfoMsg.m_pClan = Server()->ClientClan(i); ClientInfoMsg.m_Country = Server()->ClientCountry(i); ClientInfoMsg.m_Silent = false; - for(int p = 0; p < 6; p++) + for(int p = 0; p < NUM_SKINPARTS; p++) { ClientInfoMsg.m_apSkinPartNames[p] = m_apPlayers[i]->m_TeeInfos.m_aaSkinPartNames[p]; ClientInfoMsg.m_aUseCustomColors[p] = m_apPlayers[i]->m_TeeInfos.m_aUseCustomColors[p]; @@ -1000,7 +1000,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) pPlayer->m_LastChangeInfo = Server()->Tick(); CNetMsg_Cl_SkinChange *pMsg = (CNetMsg_Cl_SkinChange *)pRawMsg; - for(int p = 0; p < 6; p++) + for(int p = 0; p < NUM_SKINPARTS; p++) { str_copy(pPlayer->m_TeeInfos.m_aaSkinPartNames[p], pMsg->m_apSkinPartNames[p], 24); pPlayer->m_TeeInfos.m_aUseCustomColors[p] = pMsg->m_aUseCustomColors[p]; @@ -1032,7 +1032,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) Server()->SetClientClan(ClientID, pMsg->m_pClan); Server()->SetClientCountry(ClientID, pMsg->m_Country); - for(int p = 0; p < 6; p++) + for(int p = 0; p < NUM_SKINPARTS; p++) { str_copy(pPlayer->m_TeeInfos.m_aaSkinPartNames[p], pMsg->m_apSkinPartNames[p], 24); pPlayer->m_TeeInfos.m_aUseCustomColors[p] = pMsg->m_aUseCustomColors[p]; diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index ebf31c159..b41d7fad9 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -189,7 +189,7 @@ void CPlayer::Snap(int SnappingClient) StrToInts(pClientInfo->m_aClan, 3, Server()->ClientClan(m_ClientID)); pClientInfo->m_Country = Server()->ClientCountry(m_ClientID); - for(int p = 0; p < 6; p++) + for(int p = 0; p < NUM_SKINPARTS; p++) { StrToInts(pClientInfo->m_aaSkinPartNames[p], 6, m_TeeInfos.m_aaSkinPartNames[p]); pClientInfo->m_aUseCustomColors[p] = m_TeeInfos.m_aUseCustomColors[p]; diff --git a/src/game/server/player.h b/src/game/server/player.h index 568c7befa..0f8cbc308 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -81,9 +81,9 @@ public: // TODO: clean this up struct { - char m_aaSkinPartNames[6][24]; - int m_aUseCustomColors[6]; - int m_aSkinPartColors[6]; + char m_aaSkinPartNames[NUM_SKINPARTS][24]; + int m_aUseCustomColors[NUM_SKINPARTS]; + int m_aSkinPartColors[NUM_SKINPARTS]; } m_TeeInfos; int m_RespawnTick;