summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent <vincent.leung60@gmail.com>2014-12-08 09:45:29 +0100
committerVincent <vincent.leung60@gmail.com>2014-12-08 09:45:29 +0100
commit6de07d4a39096f19c075695824aa87a1907e4edc (patch)
treedc054c1be5c63b9b2303c208e8c8ad83eb37fcee
parentremoved last space in handlehandshake (diff)
downloadcuberite-6de07d4a39096f19c075695824aa87a1907e4edc.tar
cuberite-6de07d4a39096f19c075695824aa87a1907e4edc.tar.gz
cuberite-6de07d4a39096f19c075695824aa87a1907e4edc.tar.bz2
cuberite-6de07d4a39096f19c075695824aa87a1907e4edc.tar.lz
cuberite-6de07d4a39096f19c075695824aa87a1907e4edc.tar.xz
cuberite-6de07d4a39096f19c075695824aa87a1907e4edc.tar.zst
cuberite-6de07d4a39096f19c075695824aa87a1907e4edc.zip
-rw-r--r--src/ClientHandle.cpp11
-rw-r--r--src/ClientHandle.h2
-rw-r--r--src/Root.cpp2
-rw-r--r--src/Root.h2
-rw-r--r--src/Server.cpp11
-rw-r--r--src/Server.h4
6 files changed, 14 insertions, 18 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 4031fa1df..6f7bd1faf 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1788,19 +1788,14 @@ void cClientHandle::HandleKeepAlive(int a_KeepAliveID)
-bool cClientHandle::CheckMultiLogin(void)
+bool cClientHandle::CheckMultiLogin(const AString & a_Username)
{
if (!(cRoot::Get()->GetServer()->IsAllowMultiLogin()))
{
- std::list<AString> usernamesServer = cRoot::Get()->GetServer()->GetUsernames();
-
- for (auto item : usernamesServer)
+ if (cRoot::Get()->GetServer()->IsPlayerInQueue(a_Username))
{
- if ((item).compare(a_Username) == 0)
- {
Kick("A player of the username is already logged in");
return false;
- }
}
class cCallback :
@@ -1837,7 +1832,7 @@ bool cClientHandle::HandleHandshake(const AString & a_Username)
}
}
- return CheckMultiLogin();
+ return CheckMultiLogin(a_Username);
}
diff --git a/src/ClientHandle.h b/src/ClientHandle.h
index 880a404da..add004bd5 100644
--- a/src/ClientHandle.h
+++ b/src/ClientHandle.h
@@ -281,7 +281,7 @@ public:
void HandleEntitySprinting (int a_EntityID, bool a_IsSprinting);
/** Kicks the current player if the same username is already logged in. */
- bool CheckMultiLogin(void);
+ bool CheckMultiLogin(const AString & a_Username);
/** Called when the protocol handshake has been received (for protocol versions that support it;
otherwise the first instant when a username is received).
Returns true if the player is to be let in, false if they were disconnected
diff --git a/src/Root.cpp b/src/Root.cpp
index e51b7a048..dddb943a2 100644
--- a/src/Root.cpp
+++ b/src/Root.cpp
@@ -649,7 +649,7 @@ bool cRoot::DoWithPlayerByUUID(const AString & a_PlayerUUID, cPlayerListCallback
-bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback)
+bool cRoot::DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback)
{
}
diff --git a/src/Root.h b/src/Root.h
index b926b36bc..b3cde8748 100644
--- a/src/Root.h
+++ b/src/Root.h
@@ -129,7 +129,7 @@ public:
/** Finds the player over his uuid and calls the callback */
bool DoWithPlayerByUUID(const AString & a_PlayerUUID, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS <<
- bool FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback);
+ bool DoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback);
// tolua_begin
diff --git a/src/Server.cpp b/src/Server.cpp
index 15c9521b9..a1dd27c57 100644
--- a/src/Server.cpp
+++ b/src/Server.cpp
@@ -304,16 +304,17 @@ int cServer::GetNumPlayers(void) const
-std::list<AString> cServer::GetUsernames()
+bool cServer::IsPlayerInQueue(AString a_Username)
{
- std::list<AString> usernames;
cCSLock Lock(m_CSClients);
for (auto client : m_Clients)
{
- AString username = (client)->GetUsername();
- usernames.insert(usernames.begin(),username);
+ if ((client->GetUsername()).compare(a_Username) == 0)
+ {
+ return true;
+ }
}
- return usernames;
+ return false;
}
diff --git a/src/Server.h b/src/Server.h
index c9741bb7b..e329b5c65 100644
--- a/src/Server.h
+++ b/src/Server.h
@@ -67,8 +67,8 @@ public: // tolua_export
int GetNumPlayers(void) const;
void SetMaxPlayers(int a_MaxPlayers) { m_MaxPlayers = a_MaxPlayers; }
- // Get the users waiting to be put into the World.
- std::list<AString> GetUsernames(void);
+ // Check if the player is queued to be transferred to a World.
+ bool IsPlayerInQueue(AString a_Username);
// Can login more than once with same username.
bool IsAllowMultiLogin(void) { return m_bAllowMultiLogin; }