From 30d9c9f4d9e46fec403f3fa810898017a18e93b6 Mon Sep 17 00:00:00 2001 From: oy Date: Tue, 15 Mar 2011 11:23:49 +0100 Subject: made network support clan name and country code for players --- src/game/client/gameclient.cpp | 12 +++++++++++- src/game/client/gameclient.h | 4 +++- src/game/server/gamecontext.cpp | 4 ++++ src/game/server/player.cpp | 4 +++- 4 files changed, 21 insertions(+), 3 deletions(-) (limited to 'src/game') diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 0e2e8056..b6e89a7b 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -324,6 +324,8 @@ void CGameClient::OnReset() for(int i = 0; i < MAX_CLIENTS; i++) { m_aClients[i].m_aName[0] = 0; + m_aClients[i].m_aClan[0] = 0; + m_aClients[i].m_Country = -1; m_aClients[i].m_SkinID = 0; m_aClients[i].m_Team = 0; m_aClients[i].m_Angle = 0; @@ -442,6 +444,8 @@ void CGameClient::OnRender() { // resend if client info differs if(str_comp(g_Config.m_PlayerName, m_aClients[m_Snap.m_LocalClientID].m_aName) || + str_comp(g_Config.m_PlayerClan, m_aClients[m_Snap.m_LocalClientID].m_aClan) || + g_Config.m_PlayerCountry != m_aClients[m_Snap.m_LocalClientID].m_Country || str_comp(g_Config.m_PlayerSkin, m_aClients[m_Snap.m_LocalClientID].m_aSkinName) || (m_Snap.m_pGameInfoObj && !(m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_TEAMS) && // no teamgame? (g_Config.m_PlayerUseCustomColor != m_aClients[m_Snap.m_LocalClientID].m_UseCustomColor || @@ -685,7 +689,9 @@ void CGameClient::OnNewSnapshot() { const CNetObj_ClientInfo *pInfo = (const CNetObj_ClientInfo *)pData; int ClientID = Item.m_ID; - IntsToStr(&pInfo->m_Name0, 6, m_aClients[ClientID].m_aName); + IntsToStr(&pInfo->m_Name0, 4, m_aClients[ClientID].m_aName); + IntsToStr(&pInfo->m_Clan0, 3, m_aClients[ClientID].m_aClan); + m_aClients[ClientID].m_Country = pInfo->m_Country; IntsToStr(&pInfo->m_Skin0, 6, m_aClients[ClientID].m_aSkinName); m_aClients[ClientID].m_UseCustomColor = pInfo->m_UseCustomColor; @@ -1005,6 +1011,8 @@ void CGameClient::SendInfo(bool Start) { CNetMsg_Cl_StartInfo Msg; Msg.m_pName = g_Config.m_PlayerName; + Msg.m_pClan = g_Config.m_PlayerClan; + Msg.m_Country = g_Config.m_PlayerCountry; Msg.m_pSkin = g_Config.m_PlayerSkin; Msg.m_UseCustomColor = g_Config.m_PlayerUseCustomColor; Msg.m_ColorBody = g_Config.m_PlayerColorBody; @@ -1015,6 +1023,8 @@ void CGameClient::SendInfo(bool Start) { CNetMsg_Cl_ChangeInfo Msg; Msg.m_pName = g_Config.m_PlayerName; + Msg.m_pClan = g_Config.m_PlayerClan; + Msg.m_Country = g_Config.m_PlayerCountry; Msg.m_pSkin = g_Config.m_PlayerSkin; Msg.m_UseCustomColor = g_Config.m_PlayerUseCustomColor; Msg.m_ColorBody = g_Config.m_PlayerColorBody; diff --git a/src/game/client/gameclient.h b/src/game/client/gameclient.h index 831cae24..a3092514 100644 --- a/src/game/client/gameclient.h +++ b/src/game/client/gameclient.h @@ -159,7 +159,9 @@ public: int m_ColorBody; int m_ColorFeet; - char m_aName[64]; + char m_aName[MAX_NAME_LENGTH]; + char m_aClan[MAX_CLAN_LENGTH]; + int m_Country; char m_aSkinName[64]; int m_SkinID; int m_SkinColor; diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 8c3dc3e3..348b6735 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -796,6 +796,8 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) // set start infos Server()->SetClientName(ClientID, pMsg->m_pName); + Server()->SetClientClan(ClientID, pMsg->m_pClan); + Server()->SetClientCountry(ClientID, pMsg->m_Country); str_copy(pPlayer->m_TeeInfos.m_SkinName, pMsg->m_pSkin, sizeof(pPlayer->m_TeeInfos.m_SkinName)); pPlayer->m_TeeInfos.m_UseCustomColor = pMsg->m_UseCustomColor; pPlayer->m_TeeInfos.m_ColorBody = pMsg->m_ColorBody; @@ -840,6 +842,8 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) str_format(aChatText, sizeof(aChatText), "'%s' changed name to '%s'", aOldName, Server()->ClientName(ClientID)); SendChat(-1, CGameContext::CHAT_ALL, aChatText); } + Server()->SetClientClan(ClientID, pMsg->m_pClan); + Server()->SetClientCountry(ClientID, pMsg->m_Country); str_copy(pPlayer->m_TeeInfos.m_SkinName, pMsg->m_pSkin, sizeof(pPlayer->m_TeeInfos.m_SkinName)); pPlayer->m_TeeInfos.m_UseCustomColor = pMsg->m_UseCustomColor; pPlayer->m_TeeInfos.m_ColorBody = pMsg->m_ColorBody; diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 82b45011..6c118a19 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -107,7 +107,9 @@ void CPlayer::Snap(int SnappingClient) if(!pClientInfo) return; - StrToInts(&pClientInfo->m_Name0, 6, Server()->ClientName(m_ClientID)); + StrToInts(&pClientInfo->m_Name0, 4, Server()->ClientName(m_ClientID)); + StrToInts(&pClientInfo->m_Clan0, 3, Server()->ClientClan(m_ClientID)); + pClientInfo->m_Country = Server()->ClientCountry(m_ClientID); StrToInts(&pClientInfo->m_Skin0, 6, m_TeeInfos.m_SkinName); pClientInfo->m_UseCustomColor = m_TeeInfos.m_UseCustomColor; pClientInfo->m_ColorBody = m_TeeInfos.m_ColorBody; -- cgit 1.4.1