1
0

Fixed compile errors

This commit is contained in:
Vincent 2014-12-08 00:45:29 -08:00
parent 656964dc38
commit 6de07d4a39
6 changed files with 14 additions and 18 deletions

View File

@ -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())) if (!(cRoot::Get()->GetServer()->IsAllowMultiLogin()))
{ {
std::list<AString> usernamesServer = cRoot::Get()->GetServer()->GetUsernames(); if (cRoot::Get()->GetServer()->IsPlayerInQueue(a_Username))
for (auto item : usernamesServer)
{ {
if ((item).compare(a_Username) == 0)
{
Kick("A player of the username is already logged in"); Kick("A player of the username is already logged in");
return false; return false;
}
} }
class cCallback : class cCallback :
@ -1837,7 +1832,7 @@ bool cClientHandle::HandleHandshake(const AString & a_Username)
} }
} }
return CheckMultiLogin(); return CheckMultiLogin(a_Username);
} }

View File

@ -281,7 +281,7 @@ public:
void HandleEntitySprinting (int a_EntityID, bool a_IsSprinting); void HandleEntitySprinting (int a_EntityID, bool a_IsSprinting);
/** Kicks the current player if the same username is already logged in. */ /** 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; /** Called when the protocol handshake has been received (for protocol versions that support it;
otherwise the first instant when a username is received). otherwise the first instant when a username is received).
Returns true if the player is to be let in, false if they were disconnected Returns true if the player is to be let in, false if they were disconnected

View File

@ -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)
{ {
} }

View File

@ -129,7 +129,7 @@ public:
/** Finds the player over his uuid and calls the callback */ /** Finds the player over his uuid and calls the callback */
bool DoWithPlayerByUUID(const AString & a_PlayerUUID, cPlayerListCallback & a_Callback); // >> EXPORTED IN MANUALBINDINGS << 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 // tolua_begin

View File

@ -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); cCSLock Lock(m_CSClients);
for (auto client : m_Clients) for (auto client : m_Clients)
{ {
AString username = (client)->GetUsername(); if ((client->GetUsername()).compare(a_Username) == 0)
usernames.insert(usernames.begin(),username); {
return true;
}
} }
return usernames; return false;
} }

View File

@ -67,8 +67,8 @@ public: // tolua_export
int GetNumPlayers(void) const; int GetNumPlayers(void) const;
void SetMaxPlayers(int a_MaxPlayers) { m_MaxPlayers = a_MaxPlayers; } void SetMaxPlayers(int a_MaxPlayers) { m_MaxPlayers = a_MaxPlayers; }
// Get the users waiting to be put into the World. // Check if the player is queued to be transferred to a World.
std::list<AString> GetUsernames(void); bool IsPlayerInQueue(AString a_Username);
// Can login more than once with same username. // Can login more than once with same username.
bool IsAllowMultiLogin(void) { return m_bAllowMultiLogin; } bool IsAllowMultiLogin(void) { return m_bAllowMultiLogin; }