diff options
author | Mattes D <github@xoft.cz> | 2014-12-10 11:17:11 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-12-10 11:17:11 +0100 |
commit | 32bce44f1f6167bfce5deaa084e7dd90f71e39e2 (patch) | |
tree | 33315fbd4cda5b3be615f763deca3a8f660ead8f /src/ClientHandle.cpp | |
parent | Fixed compiling. (diff) | |
parent | Changed method call to DoesAllowMultiLogin() instead of IsAllowMultiLogin() (diff) | |
download | cuberite-32bce44f1f6167bfce5deaa084e7dd90f71e39e2.tar cuberite-32bce44f1f6167bfce5deaa084e7dd90f71e39e2.tar.gz cuberite-32bce44f1f6167bfce5deaa084e7dd90f71e39e2.tar.bz2 cuberite-32bce44f1f6167bfce5deaa084e7dd90f71e39e2.tar.lz cuberite-32bce44f1f6167bfce5deaa084e7dd90f71e39e2.tar.xz cuberite-32bce44f1f6167bfce5deaa084e7dd90f71e39e2.tar.zst cuberite-32bce44f1f6167bfce5deaa084e7dd90f71e39e2.zip |
Diffstat (limited to 'src/ClientHandle.cpp')
-rw-r--r-- | src/ClientHandle.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index c4a620565..cc83bcab3 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1778,6 +1778,43 @@ void cClientHandle::HandleKeepAlive(int a_KeepAliveID) +bool cClientHandle::CheckMultiLogin(const AString & a_Username) +{ + // If the multilogin is allowed, skip this check entirely: + if ((cRoot::Get()->GetServer()->DoesAllowMultiLogin())) + { + return true; + } + + // Check if the player is waiting to be transferred to the World. + if (cRoot::Get()->GetServer()->IsPlayerInQueue(a_Username)) + { + Kick("A player of the username is already logged in"); + return false; + } + + class cCallback : + public cPlayerListCallback + { + virtual bool Item(cPlayer * a_Player) override + { + return true; + } + } Callback; + + // Check if the player is in any World. + if (cRoot::Get()->DoWithPlayer(a_Username, Callback)) + { + Kick("A player of the username is already logged in"); + return false; + } + return true; +} + + + + + bool cClientHandle::HandleHandshake(const AString & a_Username) { if (!cRoot::Get()->GetPluginManager()->CallHookHandshake(*this, a_Username)) @@ -1788,7 +1825,8 @@ bool cClientHandle::HandleHandshake(const AString & a_Username) return false; } } - return true; + + return CheckMultiLogin(a_Username); } |