summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ClientHandle.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 1b63153d2..3270cc37f 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -179,6 +179,9 @@ void cClientHandle::Destroy(void)
if (player != nullptr)
{
+ // Atomically decrement player count (in world or server thread)
+ cRoot::Get()->GetServer()->PlayerDestroyed();
+
auto world = player->GetWorld();
if (world != nullptr)
{
@@ -322,6 +325,9 @@ void cClientHandle::Kick(const AString & a_Reason)
void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, const Json::Value & a_Properties)
{
+ // Atomically increment player count (in server thread)
+ cRoot::Get()->GetServer()->PlayerCreated();
+
cWorld * World;
{
cCSLock lock(m_CSState);
@@ -662,11 +668,14 @@ void cClientHandle::HandleNPCTrade(int a_SlotNum)
void cClientHandle::HandlePing(void)
{
+ /* TODO: unused function, handles Legacy Server List Ping
+ http://wiki.vg/Protocol#Legacy_Server_List_Ping suggests that servers SHOULD handle this packet */
+
// Somebody tries to retrieve information about the server
AString Reply;
const cServer & Server = *cRoot::Get()->GetServer();
- Printf(Reply, "%s%s%i%s%i",
+ Printf(Reply, "%s%s" SIZE_T_FMT "%s" SIZE_T_FMT,
Server.GetDescription().c_str(),
cChatColor::Delimiter,
Server.GetNumPlayers(),
@@ -1860,17 +1869,14 @@ bool cClientHandle::HandleHandshake(const AString & a_Username)
{
if (a_Username.length() > 16)
{
- Kick("Your username is too long(>16 characters)");
+ Kick("Your username is too long (>16 characters)");
return false;
}
- if (!cRoot::Get()->GetPluginManager()->CallHookHandshake(*this, a_Username))
+ if (cRoot::Get()->GetPluginManager()->CallHookHandshake(*this, a_Username))
{
- if (cRoot::Get()->GetServer()->GetNumPlayers() >= cRoot::Get()->GetServer()->GetMaxPlayers())
- {
- Kick("The server is currently full :(-- Try again later");
- return false;
- }
+ Kick("Entry denied by plugin");
+ return false;
}
return CheckMultiLogin(a_Username);