the server shows the disconnect reason of clients now

This commit is contained in:
heinrich5991 2011-02-14 19:41:32 +01:00 committed by oy
parent 8cd7dec179
commit b6fa69cedb
6 changed files with 11 additions and 8 deletions

View file

@ -77,7 +77,7 @@ public:
virtual void OnClientConnected(int ClientID) = 0;
virtual void OnClientEnter(int ClientID) = 0;
virtual void OnClientDrop(int ClientID) = 0;
virtual void OnClientDrop(int ClientID, const char *pReason) = 0;
virtual void OnClientDirectInput(int ClientID, void *pInput) = 0;
virtual void OnClientPredictedInput(int ClientID, void *pInput) = 0;

View file

@ -597,7 +597,7 @@ int CServer::DelClientCallback(int ClientID, const char *pReason, void *pUser)
// notify the mod about the drop
if(pThis->m_aClients[ClientID].m_State >= CClient::STATE_READY)
pThis->GameServer()->OnClientDrop(ClientID);
pThis->GameServer()->OnClientDrop(ClientID, pReason);
pThis->m_aClients[ClientID].m_State = CClient::STATE_EMPTY;
pThis->m_aClients[ClientID].m_aName[0] = 0;

View file

@ -546,10 +546,10 @@ void CGameContext::OnClientConnected(int ClientID)
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, ClientID);
}
void CGameContext::OnClientDrop(int ClientID)
void CGameContext::OnClientDrop(int ClientID, const char *pReason)
{
AbortVoteKickOnDisconnect(ClientID);
m_apPlayers[ClientID]->OnDisconnect();
m_apPlayers[ClientID]->OnDisconnect(pReason);
delete m_apPlayers[ClientID];
m_apPlayers[ClientID] = 0;

View file

@ -156,7 +156,7 @@ public:
virtual void OnClientConnected(int ClientID);
virtual void OnClientEnter(int ClientID);
virtual void OnClientDrop(int ClientID);
virtual void OnClientDrop(int ClientID, const char *pReason);
virtual void OnClientDirectInput(int ClientID, void *pInput);
virtual void OnClientPredictedInput(int ClientID, void *pInput);

View file

@ -140,14 +140,17 @@ void CPlayer::Snap(int SnappingClient)
}
}
void CPlayer::OnDisconnect()
void CPlayer::OnDisconnect(const char *pReason)
{
KillCharacter();
if(Server()->ClientIngame(m_ClientID))
{
char aBuf[512];
str_format(aBuf, sizeof(aBuf), "'%s' has left the game", Server()->ClientName(m_ClientID));
if(pReason && *pReason)
str_format(aBuf, sizeof(aBuf), "'%s' has left the game (%s)", Server()->ClientName(m_ClientID), pReason);
else
str_format(aBuf, sizeof(aBuf), "'%s' has left the game", Server()->ClientName(m_ClientID));
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf);
str_format(aBuf, sizeof(aBuf), "leave player='%d:%s'", m_ClientID, Server()->ClientName(m_ClientID));

View file

@ -30,7 +30,7 @@ public:
void OnDirectInput(CNetObj_PlayerInput *NewInput);
void OnPredictedInput(CNetObj_PlayerInput *NewInput);
void OnDisconnect();
void OnDisconnect(const char *pReason);
void KillCharacter(int Weapon = WEAPON_GAME);
CCharacter *GetCharacter();