summaryrefslogtreecommitdiffstats
path: root/src/ClientHandle.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2017-07-28 18:54:40 +0200
committerGitHub <noreply@github.com>2017-07-28 18:54:40 +0200
commiteb4432bb6260eaadb41495149739244308e9e125 (patch)
tree8f1787586d23194ef5f4d7af8a4454f0ea9e179a /src/ClientHandle.cpp
parentHandle incomplete packets in cProtocolRecognizer (diff)
downloadcuberite-eb4432bb6260eaadb41495149739244308e9e125.tar
cuberite-eb4432bb6260eaadb41495149739244308e9e125.tar.gz
cuberite-eb4432bb6260eaadb41495149739244308e9e125.tar.bz2
cuberite-eb4432bb6260eaadb41495149739244308e9e125.tar.lz
cuberite-eb4432bb6260eaadb41495149739244308e9e125.tar.xz
cuberite-eb4432bb6260eaadb41495149739244308e9e125.tar.zst
cuberite-eb4432bb6260eaadb41495149739244308e9e125.zip
Diffstat (limited to 'src/ClientHandle.cpp')
-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);