mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
finished client enter/leave events, removed client changes
This commit is contained in:
parent
9164c1d879
commit
8971497029
|
@ -318,6 +318,11 @@ Messages = [
|
|||
NetIntRange("m_MatchCurrent", 0, 'max_int'),
|
||||
]),
|
||||
|
||||
NetMessage("Sv_ClientDrop", [
|
||||
NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'),
|
||||
NetStringStrict("m_pReason"),
|
||||
]),
|
||||
|
||||
### Client messages
|
||||
NetMessage("Cl_Say", [
|
||||
NetBool("m_Team"),
|
||||
|
@ -341,15 +346,6 @@ Messages = [
|
|||
NetArray(NetIntAny("m_aSkinPartColors"), 6),
|
||||
]),
|
||||
|
||||
NetMessage("Cl_ChangeInfo", [
|
||||
NetStringStrict("m_pName"),
|
||||
NetStringStrict("m_pClan"),
|
||||
NetIntAny("m_Country"),
|
||||
NetArray(NetStringStrict("m_apSkinPartNames"), 6),
|
||||
NetArray(NetBool("m_aUseCustomColors"), 6),
|
||||
NetArray(NetIntAny("m_aSkinPartColors"), 6),
|
||||
]),
|
||||
|
||||
NetMessage("Cl_Kill", []),
|
||||
|
||||
NetMessage("Cl_ReadyChange", []),
|
||||
|
|
|
@ -547,7 +547,7 @@ int CServer::SendMsgEx(CMsgPacker *pMsg, int Flags, int ClientID, bool System)
|
|||
// broadcast
|
||||
int i;
|
||||
for(i = 0; i < MAX_CLIENTS; i++)
|
||||
if(m_aClients[i].m_State == CClient::STATE_INGAME)
|
||||
if(m_aClients[i].m_State == CClient::STATE_INGAME && !m_aClients[i].m_Quitting)
|
||||
{
|
||||
Packet.m_ClientID = i;
|
||||
m_NetServer.Send(&Packet);
|
||||
|
@ -702,6 +702,7 @@ int CServer::NewClientCallback(int ClientID, void *pUser)
|
|||
pThis->m_aClients[ClientID].m_Authed = AUTHED_NO;
|
||||
pThis->m_aClients[ClientID].m_AuthTries = 0;
|
||||
pThis->m_aClients[ClientID].m_pRconCmdToSend = 0;
|
||||
pThis->m_aClients[ClientID].m_Quitting = false;
|
||||
pThis->m_aClients[ClientID].Reset();
|
||||
return 0;
|
||||
}
|
||||
|
@ -713,12 +714,15 @@ int CServer::DelClientCallback(int ClientID, const char *pReason, void *pUser)
|
|||
char aAddrStr[NETADDR_MAXSTRSIZE];
|
||||
net_addr_str(pThis->m_NetServer.ClientAddr(ClientID), aAddrStr, sizeof(aAddrStr), true);
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "client dropped. cid=%d addr=%s reason='%s'", ClientID, aAddrStr, pReason);
|
||||
pThis->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf);
|
||||
str_format(aBuf, sizeof(aBuf), "client dropped. cid=%d addr=%s reason='%s'", ClientID, aAddrStr, pReason);
|
||||
pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf);
|
||||
|
||||
// notify the mod about the drop
|
||||
if(pThis->m_aClients[ClientID].m_State >= CClient::STATE_READY)
|
||||
{
|
||||
pThis->m_aClients[ClientID].m_Quitting = true;
|
||||
pThis->GameServer()->OnClientDrop(ClientID, pReason);
|
||||
}
|
||||
|
||||
pThis->m_aClients[ClientID].m_State = CClient::STATE_EMPTY;
|
||||
pThis->m_aClients[ClientID].m_aName[0] = 0;
|
||||
|
@ -727,6 +731,7 @@ int CServer::DelClientCallback(int ClientID, const char *pReason, void *pUser)
|
|||
pThis->m_aClients[ClientID].m_Authed = AUTHED_NO;
|
||||
pThis->m_aClients[ClientID].m_AuthTries = 0;
|
||||
pThis->m_aClients[ClientID].m_pRconCmdToSend = 0;
|
||||
pThis->m_aClients[ClientID].m_Quitting = false;
|
||||
pThis->m_aClients[ClientID].m_Snapshots.PurgeAll();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ public:
|
|||
int m_AuthTries;
|
||||
|
||||
int m_MapChunk;
|
||||
bool m_Quitting;
|
||||
const IConsole::CCommandInfo *m_pRconCmdToSend;
|
||||
|
||||
void Reset();
|
||||
|
|
|
@ -56,7 +56,6 @@ CMenus::CMenus()
|
|||
|
||||
m_NeedRestartGraphics = false;
|
||||
m_NeedRestartSound = false;
|
||||
m_NeedSendinfo = false;
|
||||
m_TeePartSelection = NO_SELECTION;
|
||||
m_TeePartsColorSelection = NO_SELECTION;
|
||||
m_aSaveSkinName[0] = 0;
|
||||
|
@ -1752,12 +1751,6 @@ void CMenus::SetActive(bool Active)
|
|||
m_MenuActive = Active;
|
||||
if(!m_MenuActive)
|
||||
{
|
||||
if(m_NeedSendinfo)
|
||||
{
|
||||
m_pClient->SendInfo(false);
|
||||
m_NeedSendinfo = false;
|
||||
}
|
||||
|
||||
if(Client()->State() == IClient::STATE_ONLINE)
|
||||
{
|
||||
m_pClient->OnRelease();
|
||||
|
|
|
@ -202,7 +202,6 @@ class CMenus : public CComponent
|
|||
// for settings
|
||||
bool m_NeedRestartGraphics;
|
||||
bool m_NeedRestartSound;
|
||||
bool m_NeedSendinfo;
|
||||
int m_TeePartSelection;
|
||||
int m_TeePartsColorSelection;
|
||||
char m_aSaveSkinName[24];
|
||||
|
|
|
@ -296,7 +296,6 @@ void CMenus::RenderHSLPicker(CUIRect Picker)
|
|||
}
|
||||
if(UseAlpha)
|
||||
g_Config.m_PlayerColorTattoo = (Alp << 24) + NewVal;
|
||||
m_NeedSendinfo = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,7 +364,6 @@ void CMenus::RenderSkinSelection(CUIRect MainView)
|
|||
*gs_apUCCVariables[p] = s->m_aUseCustomColors[p];
|
||||
*gs_apColorVariables[p] = s->m_aPartColors[p];
|
||||
}
|
||||
m_NeedSendinfo = true;
|
||||
}
|
||||
m_TeePartSelection = NO_SELECTION;
|
||||
}
|
||||
|
@ -453,7 +451,6 @@ void CMenus::RenderSkinPartSelection(CUIRect MainView)
|
|||
{
|
||||
const CSkins::CSkinPart *s = s_paList[p][NewSelected];
|
||||
mem_copy(gs_apSkinVariables[p], s->m_aName, 24);
|
||||
m_NeedSendinfo = true;
|
||||
}
|
||||
m_TeePartSelection = NO_SELECTION;
|
||||
}
|
||||
|
@ -784,8 +781,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
|
|||
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Name"));
|
||||
UI()->DoLabelScaled(&Label, aBuf, 14.0, -1);
|
||||
static float s_OffsetName = 0.0f;
|
||||
if(DoEditBox(g_Config.m_PlayerName, &Button, g_Config.m_PlayerName, sizeof(g_Config.m_PlayerName), 14.0f, &s_OffsetName))
|
||||
m_NeedSendinfo = true;
|
||||
DoEditBox(g_Config.m_PlayerName, &Button, g_Config.m_PlayerName, sizeof(g_Config.m_PlayerName), 14.0f, &s_OffsetName);
|
||||
|
||||
// player clan
|
||||
MainView.HSplitTop(5.0f, 0, &MainView);
|
||||
|
@ -795,8 +791,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
|
|||
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Clan"));
|
||||
UI()->DoLabelScaled(&Label, aBuf, 14.0, -1);
|
||||
static float s_OffsetClan = 0.0f;
|
||||
if(DoEditBox(g_Config.m_PlayerClan, &Button, g_Config.m_PlayerClan, sizeof(g_Config.m_PlayerClan), 14.0f, &s_OffsetClan))
|
||||
m_NeedSendinfo = true;
|
||||
DoEditBox(g_Config.m_PlayerClan, &Button, g_Config.m_PlayerClan, sizeof(g_Config.m_PlayerClan), 14.0f, &s_OffsetClan);
|
||||
|
||||
// country flag selector
|
||||
MainView.HSplitTop(20.0f, 0, &MainView);
|
||||
|
@ -833,7 +828,6 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView)
|
|||
if(OldSelected != NewSelected)
|
||||
{
|
||||
g_Config.m_PlayerCountry = m_pClient->m_pCountryFlags->GetByIndex(NewSelected)->m_CountryCode;
|
||||
m_NeedSendinfo = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1076,7 +1070,6 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
if(m_TeePartsColorSelection & gs_aSelectionParts[p])
|
||||
*gs_apUCCVariables[p] = CheckedUCC;
|
||||
}
|
||||
m_NeedSendinfo = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -201,26 +201,6 @@ void CGameClient::OnConsoleInit()
|
|||
for(int i = 0; i < m_All.m_Num; i++)
|
||||
m_All.m_paComponents[i]->OnConsoleInit();
|
||||
|
||||
|
||||
//
|
||||
Console()->Chain("player_name", ConchainSpecialInfoupdate, this);
|
||||
Console()->Chain("player_clan", ConchainSpecialInfoupdate, this);
|
||||
Console()->Chain("player_country", ConchainSpecialInfoupdate, this);
|
||||
|
||||
static const char *const s_apParts[6] = {"body", "tattoo", "decoration", "hands", "feet", "eyes"};
|
||||
for(int p = 0; p < NUM_SKINPARTS; p++)
|
||||
{
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "player_color_%s", s_apParts[p]);
|
||||
Console()->Chain(aBuf, ConchainSpecialInfoupdate, this);
|
||||
str_format(aBuf, sizeof(aBuf), "player_use_custom_color_%s", s_apParts[p]);
|
||||
Console()->Chain(aBuf, ConchainSpecialInfoupdate, this);
|
||||
str_format(aBuf, sizeof(aBuf), "player_skin_%s", s_apParts[p]);
|
||||
Console()->Chain(aBuf, ConchainSpecialInfoupdate, this);
|
||||
}
|
||||
|
||||
Console()->Chain("player_skin", ConchainUpdateSkinParts, this);
|
||||
|
||||
//
|
||||
m_SuppressEvents = false;
|
||||
}
|
||||
|
@ -335,10 +315,9 @@ void CGameClient::OnConnected()
|
|||
Client()->GetServerInfo(&CurrentServerInfo);
|
||||
|
||||
m_ServerMode = SERVERMODE_PURE;
|
||||
m_LastSendInfo = 0;
|
||||
|
||||
// send the inital info
|
||||
SendInfo(true);
|
||||
SendStartInfo();
|
||||
}
|
||||
|
||||
void CGameClient::OnReset()
|
||||
|
@ -454,29 +433,6 @@ void CGameClient::OnRender()
|
|||
// clear new tick flags
|
||||
m_NewTick = false;
|
||||
m_NewPredictedTick = false;
|
||||
|
||||
// check if client info has to be resent
|
||||
//if(m_LastSendInfo && Client()->State() == IClient::STATE_ONLINE && m_Snap.m_LocalClientID >= 0 && !m_pMenus->IsActive() && m_LastSendInfo+time_freq()*6 < time_get())
|
||||
//{
|
||||
// // 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)
|
||||
// {
|
||||
// SendInfo(false);
|
||||
// }
|
||||
// for(int p = 0; p < NUM_SKINPARTS; p++)
|
||||
// {
|
||||
// if(str_comp(gs_apSkinVariables[p], m_aClients[m_Snap.m_LocalClientID].m_aaSkinPartNames[p]))
|
||||
// SendInfo(false);
|
||||
// else if(*gs_apUCCVariables[p] != m_aClients[m_Snap.m_LocalClientID].m_aUseCustomColors[p] ||
|
||||
// *gs_apColorVariables[p] != m_aClients[m_Snap.m_LocalClientID].m_aSkinPartColors[p])
|
||||
// {
|
||||
// SendInfo(false);
|
||||
// }
|
||||
// }
|
||||
// m_LastSendInfo = 0;
|
||||
//}
|
||||
}
|
||||
|
||||
void CGameClient::OnRelease()
|
||||
|
@ -545,10 +501,36 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
|
|||
if(MsgId == NETMSGTYPE_SV_CLIENTINFO)
|
||||
{
|
||||
CNetMsg_Sv_ClientInfo *pMsg = (CNetMsg_Sv_ClientInfo *)pRawMsg;
|
||||
CClientData *pClient = &m_aClients[pMsg->m_ClientID];
|
||||
Client()->RecordGameMessage(false);
|
||||
|
||||
if(pMsg->m_Local)
|
||||
{
|
||||
if(m_LocalClientID != -1)
|
||||
{
|
||||
//if(g_Config.m_Debug)
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client", "invalid local clientinfo");
|
||||
return;
|
||||
}
|
||||
m_LocalClientID = pMsg->m_ClientID;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_aClients[pMsg->m_ClientID].m_Active)
|
||||
{
|
||||
//if(g_Config.m_Debug)
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client", "invalid clientinfo");
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_LocalClientID != -1)
|
||||
{
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), Localize("'%s' entered and joined the %s"), pMsg->m_pName, GetTeamName(pMsg->m_Team, m_GameInfo.m_GameFlags&GAMEFLAG_TEAMS));
|
||||
m_pChat->AddLine(-1, 0, aBuf);
|
||||
}
|
||||
}
|
||||
|
||||
m_aClients[pMsg->m_ClientID].m_Active = true;
|
||||
m_aClients[pMsg->m_ClientID].m_Team = pMsg->m_Team;
|
||||
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));
|
||||
|
@ -560,8 +542,28 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
|
|||
m_aClients[pMsg->m_ClientID].m_aSkinPartColors[i] = pMsg->m_aSkinPartColors[i];
|
||||
}
|
||||
|
||||
pClient->UpdateRenderInfo(true);
|
||||
Client()->RecordGameMessage(false);
|
||||
|
||||
m_aClients[pMsg->m_ClientID].UpdateRenderInfo(true);
|
||||
}
|
||||
else if(MsgId == NETMSGTYPE_SV_CLIENTDROP)
|
||||
{
|
||||
CNetMsg_Sv_ClientDrop *pMsg = (CNetMsg_Sv_ClientDrop *)pRawMsg;
|
||||
|
||||
if(m_LocalClientID == pMsg->m_ClientID || !m_aClients[pMsg->m_ClientID].m_Active)
|
||||
{
|
||||
//if(g_Config.m_Debug)
|
||||
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "client", "invalid clientinfo");
|
||||
return;
|
||||
}
|
||||
|
||||
char aBuf[128];
|
||||
if(pMsg->m_pReason[0])
|
||||
str_format(aBuf, sizeof(aBuf), Localize("'%s' has left the game (%s)"), m_aClients[pMsg->m_ClientID].m_aName, pMsg->m_pReason);
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), Localize("'%s' has left the game"), m_aClients[pMsg->m_ClientID].m_aName);
|
||||
m_pChat->AddLine(-1, 0, aBuf);
|
||||
|
||||
m_aClients[pMsg->m_ClientID].Reset();
|
||||
}
|
||||
else if(MsgId == NETMSGTYPE_SV_GAMEINFO)
|
||||
{
|
||||
|
@ -796,7 +798,6 @@ void CGameClient::OnNewSnapshot()
|
|||
const CNetObj_PlayerInfo *pInfo = (const CNetObj_PlayerInfo *)pData;
|
||||
int ClientID = Item.m_ID;
|
||||
|
||||
m_aClients[ClientID].m_Active = true;
|
||||
m_Snap.m_paPlayerInfos[ClientID] = pInfo;
|
||||
m_Snap.m_aInfoByScore[ClientID].m_pPlayerInfo = pInfo;
|
||||
m_Snap.m_aInfoByScore[ClientID].m_ClientID = ClientID;
|
||||
|
@ -895,13 +896,6 @@ void CGameClient::OnNewSnapshot()
|
|||
m_Snap.m_SpecInfo.m_SpectatorID = SPEC_FREEVIEW;
|
||||
}
|
||||
|
||||
// clear out unneeded client data
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
if(!m_Snap.m_paPlayerInfos[i] && m_aClients[i].m_Active)
|
||||
m_aClients[i].Reset();
|
||||
}
|
||||
|
||||
// update friend state
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
|
@ -1207,40 +1201,19 @@ void CGameClient::SendSwitchTeam(int Team)
|
|||
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
|
||||
}
|
||||
|
||||
void CGameClient::SendInfo(bool Start)
|
||||
void CGameClient::SendStartInfo()
|
||||
{
|
||||
if(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;
|
||||
for(int p = 0; p < NUM_SKINPARTS; p++)
|
||||
{
|
||||
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;
|
||||
for(int p = 0; p < NUM_SKINPARTS; p++)
|
||||
{
|
||||
Msg.m_apSkinPartNames[p] = gs_apSkinVariables[p];
|
||||
Msg.m_aUseCustomColors[p] = *gs_apUCCVariables[p];
|
||||
Msg.m_aSkinPartColors[p] = *gs_apColorVariables[p];
|
||||
}
|
||||
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
for(int p = 0; p < NUM_SKINPARTS; p++)
|
||||
{
|
||||
Msg.m_apSkinPartNames[p] = gs_apSkinVariables[p];
|
||||
Msg.m_aUseCustomColors[p] = *gs_apUCCVariables[p];
|
||||
Msg.m_aSkinPartColors[p] = *gs_apColorVariables[p];
|
||||
}
|
||||
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
|
||||
|
||||
// activate timer to resend the info if it gets filtered
|
||||
if(!m_LastSendInfo || m_LastSendInfo+time_freq()*5 < time_get())
|
||||
m_LastSendInfo = time_get();
|
||||
Msg.m_apSkinPartNames[p] = gs_apSkinVariables[p];
|
||||
Msg.m_aUseCustomColors[p] = *gs_apUCCVariables[p];
|
||||
Msg.m_aSkinPartColors[p] = *gs_apColorVariables[p];
|
||||
}
|
||||
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
|
||||
}
|
||||
|
||||
void CGameClient::SendKill()
|
||||
|
@ -1270,31 +1243,6 @@ void CGameClient::ConReadyChange(IConsole::IResult *pResult, void *pUserData)
|
|||
((CGameClient*)pUserData)->SendReadyChange();
|
||||
}
|
||||
|
||||
void CGameClient::ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
||||
{
|
||||
pfnCallback(pResult, pCallbackUserData);
|
||||
if(pResult->NumArguments())
|
||||
((CGameClient*)pUserData)->SendInfo(false);
|
||||
}
|
||||
|
||||
void CGameClient::ConchainUpdateSkinParts(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
|
||||
{
|
||||
pfnCallback(pResult, pCallbackUserData);
|
||||
CGameClient *pSelf = (CGameClient*)pUserData;
|
||||
if(pResult->NumArguments() && pSelf->m_pSkins->Num() > 0)
|
||||
{
|
||||
int SkinID = pSelf->m_pSkins->Find(g_Config.m_PlayerSkin);
|
||||
const CSkins::CSkin *s = pSelf->m_pSkins->Get(SkinID);
|
||||
for(int p = 0; p < NUM_SKINPARTS; p++)
|
||||
{
|
||||
mem_copy(gs_apSkinVariables[p], s->m_apParts[p]->m_aName, 24);
|
||||
*gs_apUCCVariables[p] = s->m_aUseCustomColors[p];
|
||||
*gs_apColorVariables[p] = s->m_aPartColors[p];
|
||||
}
|
||||
pSelf->SendInfo(false);
|
||||
}
|
||||
}
|
||||
|
||||
IGameClient *CreateGameClient()
|
||||
{
|
||||
return &g_GameClient;
|
||||
|
|
|
@ -56,15 +56,10 @@ class CGameClient : public IGameClient
|
|||
int m_PredictedTick;
|
||||
int m_LastNewPredictedTick;
|
||||
|
||||
int64 m_LastSendInfo;
|
||||
|
||||
static void ConTeam(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConKill(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConReadyChange(IConsole::IResult *pResult, void *pUserData);
|
||||
|
||||
static void ConchainSpecialInfoupdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||
static void ConchainUpdateSkinParts(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||
|
||||
public:
|
||||
IKernel *Kernel() { return IInterface::Kernel(); }
|
||||
IEngine *Engine() const { return m_pEngine; }
|
||||
|
@ -238,7 +233,7 @@ public:
|
|||
// actions
|
||||
// TODO: move these
|
||||
void SendSwitchTeam(int Team);
|
||||
void SendInfo(bool Start);
|
||||
void SendStartInfo();
|
||||
void SendKill();
|
||||
void SendReadyChange();
|
||||
|
||||
|
|
|
@ -570,10 +570,10 @@ void CGameContext::OnClientEnter(int ClientID)
|
|||
|
||||
m_VoteUpdate = true;
|
||||
|
||||
// update client infos
|
||||
// update client infos (others before local)
|
||||
CNetMsg_Sv_ClientInfo NewClientInfoMsg;
|
||||
NewClientInfoMsg.m_ClientID = ClientID;
|
||||
NewClientInfoMsg.m_Local = 1;
|
||||
NewClientInfoMsg.m_Local = 0;
|
||||
NewClientInfoMsg.m_Team = m_apPlayers[ClientID]->GetTeam();
|
||||
NewClientInfoMsg.m_pName = Server()->ClientName(ClientID);
|
||||
NewClientInfoMsg.m_pClan = Server()->ClientClan(ClientID);
|
||||
|
@ -584,16 +584,17 @@ void CGameContext::OnClientEnter(int ClientID)
|
|||
NewClientInfoMsg.m_aUseCustomColors[p] = m_apPlayers[ClientID]->m_TeeInfos.m_aUseCustomColors[p];
|
||||
NewClientInfoMsg.m_aSkinPartColors[p] = m_apPlayers[ClientID]->m_TeeInfos.m_aSkinPartColors[p];
|
||||
}
|
||||
Server()->SendPackMsg(&NewClientInfoMsg, MSGFLAG_VITAL|MSGFLAG_NORECORD, ClientID);
|
||||
NewClientInfoMsg.m_Local = 0;
|
||||
|
||||
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
if(i == ClientID || !IsClientReady(i))
|
||||
if(i == ClientID || !Server()->ClientIngame(i))
|
||||
continue;
|
||||
|
||||
// new info for others
|
||||
Server()->SendPackMsg(&NewClientInfoMsg, MSGFLAG_VITAL|MSGFLAG_NORECORD, i);
|
||||
|
||||
// existing infos for new player
|
||||
CNetMsg_Sv_ClientInfo ClientInfoMsg;
|
||||
ClientInfoMsg.m_ClientID = i;
|
||||
ClientInfoMsg.m_Local = 0;
|
||||
|
@ -609,6 +610,10 @@ void CGameContext::OnClientEnter(int ClientID)
|
|||
}
|
||||
Server()->SendPackMsg(&ClientInfoMsg, MSGFLAG_VITAL|MSGFLAG_NORECORD, ClientID);
|
||||
}
|
||||
|
||||
// local info
|
||||
NewClientInfoMsg.m_Local = 1;
|
||||
Server()->SendPackMsg(&NewClientInfoMsg, MSGFLAG_VITAL|MSGFLAG_NORECORD, ClientID);
|
||||
}
|
||||
|
||||
void CGameContext::OnClientConnected(int ClientID, bool Dummy)
|
||||
|
@ -637,10 +642,16 @@ void CGameContext::OnClientTeamChange(int ClientID)
|
|||
void CGameContext::OnClientDrop(int ClientID, const char *pReason)
|
||||
{
|
||||
AbortVoteOnDisconnect(ClientID);
|
||||
m_pController->OnPlayerDisconnect(m_apPlayers[ClientID], pReason);
|
||||
m_pController->OnPlayerDisconnect(m_apPlayers[ClientID]);
|
||||
delete m_apPlayers[ClientID];
|
||||
m_apPlayers[ClientID] = 0;
|
||||
|
||||
// update clients on drop
|
||||
CNetMsg_Sv_ClientDrop Msg;
|
||||
Msg.m_ClientID = ClientID;
|
||||
Msg.m_pReason = pReason;
|
||||
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1);
|
||||
|
||||
m_VoteUpdate = true;
|
||||
}
|
||||
|
||||
|
@ -1005,36 +1016,6 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
CNetMsg_Sv_ReadyToEnter m;
|
||||
Server()->SendPackMsg(&m, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID);
|
||||
}
|
||||
else if (MsgID == NETMSGTYPE_CL_CHANGEINFO)
|
||||
{
|
||||
if(g_Config.m_SvSpamprotection && pPlayer->m_LastChangeInfo && pPlayer->m_LastChangeInfo+Server()->TickSpeed()*5 > Server()->Tick())
|
||||
return;
|
||||
|
||||
CNetMsg_Cl_ChangeInfo *pMsg = (CNetMsg_Cl_ChangeInfo *)pRawMsg;
|
||||
pPlayer->m_LastChangeInfo = Server()->Tick();
|
||||
|
||||
// set infos
|
||||
char aOldName[MAX_NAME_LENGTH];
|
||||
str_copy(aOldName, Server()->ClientName(ClientID), sizeof(aOldName));
|
||||
Server()->SetClientName(ClientID, pMsg->m_pName);
|
||||
if(str_comp(aOldName, Server()->ClientName(ClientID)) != 0)
|
||||
{
|
||||
char aChatText[256];
|
||||
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);
|
||||
|
||||
for(int p = 0; p < 6; p++)
|
||||
{
|
||||
str_copy(pPlayer->m_TeeInfos.m_aaSkinPartNames[p], pMsg->m_apSkinPartNames[p], 24);
|
||||
pPlayer->m_TeeInfos.m_aUseCustomColors[p] = pMsg->m_aUseCustomColors[p];
|
||||
pPlayer->m_TeeInfos.m_aSkinPartColors[p] = pMsg->m_aSkinPartColors[p];
|
||||
}
|
||||
|
||||
m_pController->OnPlayerInfoChange(pPlayer);
|
||||
}
|
||||
else if (MsgID == NETMSGTYPE_CL_EMOTICON && !m_World.m_Paused)
|
||||
{
|
||||
CNetMsg_Cl_Emoticon *pMsg = (CNetMsg_Cl_Emoticon *)pRawMsg;
|
||||
|
|
|
@ -317,9 +317,6 @@ void IGameController::OnPlayerConnect(CPlayer *pPlayer)
|
|||
pPlayer->Respawn();
|
||||
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), "'%s' entered and joined the %s", Server()->ClientName(ClientID), GetTeamName(pPlayer->GetTeam()));
|
||||
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "team_join player='%d:%s' team=%d", ClientID, Server()->ClientName(ClientID), pPlayer->GetTeam());
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
|
||||
|
||||
|
@ -327,20 +324,14 @@ void IGameController::OnPlayerConnect(CPlayer *pPlayer)
|
|||
UpdateGameInfo(ClientID);
|
||||
}
|
||||
|
||||
void IGameController::OnPlayerDisconnect(CPlayer *pPlayer, const char *pReason)
|
||||
void IGameController::OnPlayerDisconnect(CPlayer *pPlayer)
|
||||
{
|
||||
pPlayer->OnDisconnect();
|
||||
|
||||
int ClientID = pPlayer->GetCID();
|
||||
if(Server()->ClientIngame(ClientID))
|
||||
{
|
||||
char aBuf[512];
|
||||
if(pReason && *pReason)
|
||||
str_format(aBuf, sizeof(aBuf), "'%s' has left the game (%s)", Server()->ClientName(ClientID), pReason);
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "'%s' has left the game", Server()->ClientName(ClientID));
|
||||
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
|
||||
|
||||
char aBuf[128];
|
||||
str_format(aBuf, sizeof(aBuf), "leave player='%d:%s'", ClientID, Server()->ClientName(ClientID));
|
||||
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "game", aBuf);
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ public:
|
|||
virtual bool OnEntity(int Index, vec2 Pos);
|
||||
|
||||
void OnPlayerConnect(class CPlayer *pPlayer);
|
||||
void OnPlayerDisconnect(class CPlayer *pPlayer, const char *pReason);
|
||||
void OnPlayerDisconnect(class CPlayer *pPlayer);
|
||||
void OnPlayerInfoChange(class CPlayer *pPlayer);
|
||||
void OnPlayerReadyChange(class CPlayer *pPlayer);
|
||||
|
||||
|
|
Loading…
Reference in a new issue