summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent <vincent.leung60@gmail.com>2014-11-29 20:22:03 +0100
committerVincent <vincent.leung60@gmail.com>2014-11-29 20:22:03 +0100
commita7bf2725c8bd5f8ec3e03584af87a7055cb15a60 (patch)
treebc377133bef0483cadea4a211ee2e541222dcd58
parentissue 1253 - prevent multiple logins with same username (diff)
downloadcuberite-a7bf2725c8bd5f8ec3e03584af87a7055cb15a60.tar
cuberite-a7bf2725c8bd5f8ec3e03584af87a7055cb15a60.tar.gz
cuberite-a7bf2725c8bd5f8ec3e03584af87a7055cb15a60.tar.bz2
cuberite-a7bf2725c8bd5f8ec3e03584af87a7055cb15a60.tar.lz
cuberite-a7bf2725c8bd5f8ec3e03584af87a7055cb15a60.tar.xz
cuberite-a7bf2725c8bd5f8ec3e03584af87a7055cb15a60.tar.zst
cuberite-a7bf2725c8bd5f8ec3e03584af87a7055cb15a60.zip
-rw-r--r--src/ClientHandle.cpp8
-rw-r--r--src/Server.cpp6
-rw-r--r--src/Server.h4
-rw-r--r--src/World.cpp10
-rw-r--r--src/World.h3
5 files changed, 18 insertions, 13 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index ae794d7cb..3c06f3401 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -1798,16 +1798,16 @@ bool cClientHandle::HandleHandshake(const AString & a_Username)
return false;
}
}
- if (!(cRoot::Get()->GetServer()->isAllowMultiLogin()))
+ if (!(cRoot::Get()->GetServer()->IsAllowMultiLogin()))
{
- std::list<std::string> usernamesServer = cRoot::Get()->GetServer()->GetUsernames();
- std::list<std::string> usernamesWorld = cRoot::Get()->GetDefaultWorld()-> GetUsernames();
+ std::list<AString> usernamesServer = cRoot::Get()->GetServer()->GetUsernames();
+ std::list<AString> usernamesWorld = cRoot::Get()->GetDefaultWorld()-> GetUsernames();
usernamesServer.sort();
usernamesWorld.sort();
usernamesServer.merge(usernamesWorld);
- for (std::list<std::string>::iterator itr = usernamesServer.begin(); itr != usernamesServer.end(); ++itr)
+ for (std::list<AString>::iterator itr = usernamesServer.begin(); itr != usernamesServer.end(); ++itr)
{
if ((*itr).compare(a_Username) == 0)
{
diff --git a/src/Server.cpp b/src/Server.cpp
index 157bad43e..ed02500ff 100644
--- a/src/Server.cpp
+++ b/src/Server.cpp
@@ -304,13 +304,13 @@ int cServer::GetNumPlayers(void) const
-std::list<std::string> cServer::GetUsernames()
+std::list<AString> cServer::GetUsernames()
{
- std::list<std::string> usernames;
+ std::list<AString> usernames;
cCSLock Lock(m_CSClients);
for (ClientList::iterator itr = m_Clients.begin(); itr != m_Clients.end(); ++itr)
{
- std::string username = (*itr)->GetUsername();
+ AString username = (*itr)->GetUsername();
usernames.insert(usernames.begin(),username);
}
return usernames;
diff --git a/src/Server.h b/src/Server.h
index 91e6e5c45..c9741bb7b 100644
--- a/src/Server.h
+++ b/src/Server.h
@@ -68,10 +68,10 @@ public: // tolua_export
void SetMaxPlayers(int a_MaxPlayers) { m_MaxPlayers = a_MaxPlayers; }
// Get the users waiting to be put into the World.
- std::list<std::string> GetUsernames(void);
+ std::list<AString> GetUsernames(void);
// Can login more than once with same username.
- bool isAllowMultiLogin(void) { return m_bAllowMultiLogin; }
+ bool IsAllowMultiLogin(void) { return m_bAllowMultiLogin; }
// Hardcore mode or not:
bool IsHardcore(void) const { return m_bIsHardcore; }
diff --git a/src/World.cpp b/src/World.cpp
index 9ae9e41d9..e6a2f161a 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -3667,14 +3667,18 @@ void cWorld::cChunkGeneratorCallbacks::CallHookChunkGenerated (cChunkDesc & a_Ch
-std::list<std::string> cWorld::GetUsernames()
+std::list<AString> cWorld::GetUsernames()
{
- std::list<std::string> usernames;
+ std::list<AString> usernames;
cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
- std::string username = (*itr)->GetName();
+ AString username = (*itr)->GetName();
usernames.insert(usernames.begin(),username);
}
return usernames;
}
+
+
+
+
diff --git a/src/World.h b/src/World.h
index 81470f869..a3ad4d1da 100644
--- a/src/World.h
+++ b/src/World.h
@@ -809,7 +809,8 @@ public:
void SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked = true); // tolua_export
/** Get the usernames from the World. */
- std::list<std::string> GetUsernames(void);
+ std::list<AString> GetUsernames(void);
+
private:
friend class cRoot;