Moved the check into a new function and just calls that function and a blank FindAndDoWithPlayer added.
This commit is contained in:
parent
83c728fce4
commit
d8d3b9aec5
@ -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;
|
||||
}
|
||||
|
||||
|
@ -280,6 +280,8 @@ public:
|
||||
void HandleEntityLeaveBed (int a_EntityID);
|
||||
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;
|
||||
otherwise the first instant when a username is received).
|
||||
Returns true if the player is to be let in, false if they were disconnected
|
||||
|
@ -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)
|
||||
{
|
||||
return cProtocolRecognizer::GetVersionTextFromInt(a_ProtocolVersion);
|
||||
|
@ -128,7 +128,9 @@ 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);
|
||||
|
||||
// tolua_begin
|
||||
|
||||
/// Sends a chat message to all connected clients (in all worlds)
|
||||
|
Loading…
Reference in New Issue
Block a user