diff options
author | Vincent <vincent.leung60@gmail.com> | 2014-12-08 09:12:48 +0100 |
---|---|---|
committer | Vincent <vincent.leung60@gmail.com> | 2014-12-08 09:12:48 +0100 |
commit | d8d3b9aec5bbb0f6d632d86f1fb7b1e8f58e9063 (patch) | |
tree | 7d51c143dd473da9bccff93dbfa89bb8314bbd2d /src/ClientHandle.cpp | |
parent | Merge branch 'issue_1253' of https://github.com/p-mcgowan/MCServer into issue_1253 (diff) | |
download | cuberite-d8d3b9aec5bbb0f6d632d86f1fb7b1e8f58e9063.tar cuberite-d8d3b9aec5bbb0f6d632d86f1fb7b1e8f58e9063.tar.gz cuberite-d8d3b9aec5bbb0f6d632d86f1fb7b1e8f58e9063.tar.bz2 cuberite-d8d3b9aec5bbb0f6d632d86f1fb7b1e8f58e9063.tar.lz cuberite-d8d3b9aec5bbb0f6d632d86f1fb7b1e8f58e9063.tar.xz cuberite-d8d3b9aec5bbb0f6d632d86f1fb7b1e8f58e9063.tar.zst cuberite-d8d3b9aec5bbb0f6d632d86f1fb7b1e8f58e9063.zip |
Diffstat (limited to 'src/ClientHandle.cpp')
-rw-r--r-- | src/ClientHandle.cpp | 60 |
1 files changed, 38 insertions, 22 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 3fca48394..025588485 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -1788,6 +1788,41 @@ void cClientHandle::HandleKeepAlive(int a_KeepAliveID) +bool cClientHandle::CheckMultiLogin(void) +{ + std::list<AString> usernamesServer = cRoot::Get()->GetServer()->GetUsernames(); + + for (auto item : usernamesServer) + { + if ((item).compare(a_Username) == 0) + { + 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; + + if (cRoot::Get()->GetDefaultWorld()->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)) @@ -1798,31 +1833,12 @@ bool cClientHandle::HandleHandshake(const AString & a_Username) return false; } } + if (!(cRoot::Get()->GetServer()->IsAllowMultiLogin())) { - std::list<AString> usernamesServer = cRoot::Get()->GetServer()->GetUsernames(); - - for (auto item : usernamesServer) - { - if ((item).compare(a_Username) == 0) - { - 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; - if (cRoot::Get()->GetDefaultWorld()->DoWithPlayer(a_Username, Callback)) - { - Kick("A player of the username is already logged in"); - } + return CheckMultiLogin(); } + return true; } |