summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
authorTycho Bickerstaff <work.tycho@gmail.com>2013-12-19 01:00:14 +0100
committerTycho Bickerstaff <work.tycho@gmail.com>2013-12-19 01:00:14 +0100
commitcdca5a3eac0a15a97d510ee5cb70e0ef0bf53971 (patch)
tree20ceec18155a50a385815878ed64b803255341b8 /src/ClientHandle.cpp
parentfixed bindings generation (diff)
parentUpdate Contributing.md (diff)
downloadcuberite-cdca5a3eac0a15a97d510ee5cb70e0ef0bf53971.tar
cuberite-cdca5a3eac0a15a97d510ee5cb70e0ef0bf53971.tar.gz
cuberite-cdca5a3eac0a15a97d510ee5cb70e0ef0bf53971.tar.bz2
cuberite-cdca5a3eac0a15a97d510ee5cb70e0ef0bf53971.tar.lz
cuberite-cdca5a3eac0a15a97d510ee5cb70e0ef0bf53971.tar.xz
cuberite-cdca5a3eac0a15a97d510ee5cb70e0ef0bf53971.tar.zst
cuberite-cdca5a3eac0a15a97d510ee5cb70e0ef0bf53971.zip
Diffstat (limited to 'src/ClientHandle.cpp')
-rw-r--r--src/ClientHandle.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 9565fc41f..9550e3afe 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -998,7 +998,7 @@ void cClientHandle::HandleChat(const AString & a_Message)
// Not a command, broadcast as a simple message:
AString Msg;
- Printf(Msg, "<%s%s%s> %s",
+ Printf(Msg, "%s<%s>%s %s",
m_Player->GetColor().c_str(),
m_Player->GetName().c_str(),
cChatColor::White.c_str(),
@@ -1216,12 +1216,13 @@ void cClientHandle::HandleRespawn(void)
void cClientHandle::HandleDisconnect(const AString & a_Reason)
{
- LOGD("Received d/c packet from \"%s\" with reason \"%s\"", m_Username.c_str(), a_Reason.c_str());
+ LOGD("Received d/c packet from %s with reason \"%s\"", m_Username.c_str(), a_Reason.c_str());
if (!cRoot::Get()->GetPluginManager()->CallHookDisconnect(m_Player, a_Reason))
{
AString DisconnectMessage;
- Printf(DisconnectMessage, "%s disconnected: %s", m_Username.c_str(), a_Reason.c_str());
- m_Player->GetWorld()->BroadcastChat(DisconnectMessage, this);
+ Printf(DisconnectMessage, "%s[LEAVE] %s%s has left the game", cChatColor::Yellow.c_str(), cChatColor::White.c_str(), m_Username.c_str());
+ cRoot::Get()->BroadcastChat(DisconnectMessage);
+ LOGINFO("Player %s has left the game.", m_Username.c_str());
}
m_HasSentDC = true;
Destroy();
@@ -2287,7 +2288,19 @@ void cClientHandle::SocketClosed(void)
{
// The socket has been closed for any reason
- LOGD("Client \"%s\" @ %s disconnected", m_Username.c_str(), m_IPString.c_str());
+ LOGD("Player %s @ %s disconnected", m_Username.c_str(), m_IPString.c_str());
+
+ if (m_Username != "") // Ignore client pings
+ {
+ if (!cRoot::Get()->GetPluginManager()->CallHookDisconnect(m_Player, "Player disconnected"))
+ {
+ AString DisconnectMessage;
+ Printf(DisconnectMessage, "%s[LEAVE] %s%s has left the game", cChatColor::Yellow.c_str(), cChatColor::White.c_str(), m_Username.c_str());
+ cRoot::Get()->BroadcastChat(DisconnectMessage);
+ LOGINFO("Player %s has left the game.", m_Username.c_str());
+ }
+ }
+
Destroy();
}