1
0

Moved the check into a new function and just calls that function and a blank FindAndDoWithPlayer added.

This commit is contained in:
Vincent 2014-12-08 00:12:48 -08:00
parent 83c728fce4
commit d8d3b9aec5
4 changed files with 52 additions and 23 deletions

View File

@ -1788,17 +1788,7 @@ void cClientHandle::HandleKeepAlive(int a_KeepAliveID)
bool cClientHandle::HandleHandshake(const AString & a_Username) bool cClientHandle::CheckMultiLogin(void)
{
if (!cRoot::Get()->GetPluginManager()->CallHookHandshake(*this, a_Username))
{
if (cRoot::Get()->GetServer()->GetNumPlayers() >= cRoot::Get()->GetServer()->GetMaxPlayers())
{
Kick("The server is currently full :(-- Try again later");
return false;
}
}
if (!(cRoot::Get()->GetServer()->IsAllowMultiLogin()))
{ {
std::list<AString> usernamesServer = cRoot::Get()->GetServer()->GetUsernames(); std::list<AString> usernamesServer = cRoot::Get()->GetServer()->GetUsernames();
@ -1810,6 +1800,7 @@ bool cClientHandle::HandleHandshake(const AString & a_Username)
return false; return false;
} }
} }
class cCallback : class cCallback :
public cPlayerListCallback public cPlayerListCallback
{ {
@ -1818,11 +1809,36 @@ bool cClientHandle::HandleHandshake(const AString & a_Username)
return true; return true;
} }
} Callback; } Callback;
if (cRoot::Get()->GetDefaultWorld()->DoWithPlayer(a_Username, Callback)) if (cRoot::Get()->GetDefaultWorld()->DoWithPlayer(a_Username, Callback))
{ {
Kick("A player of the username is already logged in"); 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))
{
if (cRoot::Get()->GetServer()->GetNumPlayers() >= cRoot::Get()->GetServer()->GetMaxPlayers())
{
Kick("The server is currently full :(-- Try again later");
return false;
} }
} }
if (!(cRoot::Get()->GetServer()->IsAllowMultiLogin()))
{
return CheckMultiLogin();
}
return true; return true;
} }

View File

@ -280,6 +280,8 @@ public:
void HandleEntityLeaveBed (int a_EntityID); void HandleEntityLeaveBed (int a_EntityID);
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. */
bool CheckMultiLogin(void);
/** 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,6 +649,15 @@ bool cRoot::DoWithPlayerByUUID(const AString & a_PlayerUUID, cPlayerListCallback
bool cRoot::FindAndDoWithPlayer(const AString & a_PlayerName, cPlayerListCallback & a_Callback)
{
}
AString cRoot::GetProtocolVersionTextFromInt(int a_ProtocolVersion) AString cRoot::GetProtocolVersionTextFromInt(int a_ProtocolVersion)
{ {
return cProtocolRecognizer::GetVersionTextFromInt(a_ProtocolVersion); return cProtocolRecognizer::GetVersionTextFromInt(a_ProtocolVersion);

View File

@ -129,6 +129,8 @@ 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);
// tolua_begin // tolua_begin
/// Sends a chat message to all connected clients (in all worlds) /// Sends a chat message to all connected clients (in all worlds)