about summary refs log tree commit diff
path: root/src/game/server
diff options
context:
space:
mode:
authorheinrich5991 <heinrich5991@gmail.com>2011-02-14 19:41:32 +0100
committeroy <Tom_Adams@web.de>2011-04-01 00:05:35 +0200
commitb6fa69cedb9d2b5117afe092b1c600f9f04c6a77 (patch)
tree6601a9ca06a62762cad5d695e7c22b6824602ba3 /src/game/server
parent8cd7dec1793a74dd922192a3f6a430208b8eb526 (diff)
downloadzcatch-b6fa69cedb9d2b5117afe092b1c600f9f04c6a77.tar.gz
zcatch-b6fa69cedb9d2b5117afe092b1c600f9f04c6a77.zip
the server shows the disconnect reason of clients now
Diffstat (limited to 'src/game/server')
-rw-r--r--src/game/server/gamecontext.cpp4
-rw-r--r--src/game/server/gamecontext.h2
-rw-r--r--src/game/server/player.cpp7
-rw-r--r--src/game/server/player.h2
4 files changed, 9 insertions, 6 deletions
diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp
index 56b733f3..704dd5a4 100644
--- a/src/game/server/gamecontext.cpp
+++ b/src/game/server/gamecontext.cpp
@@ -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;
 	
diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h
index 38100a06..4d2d0418 100644
--- a/src/game/server/gamecontext.h
+++ b/src/game/server/gamecontext.h
@@ -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);
 
diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp
index 6387cc9c..cf0e6683 100644
--- a/src/game/server/player.cpp
+++ b/src/game/server/player.cpp
@@ -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));
diff --git a/src/game/server/player.h b/src/game/server/player.h
index d91bc346..50f1c1a0 100644
--- a/src/game/server/player.h
+++ b/src/game/server/player.h
@@ -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();