servergame GetNumJoinsPerPlayer optimized
This commit is contained in:
@@ -1181,8 +1181,9 @@ int
|
|||||||
ServerGame::GetNumJoinsPerPlayer(const std::string &playerName)
|
ServerGame::GetNumJoinsPerPlayer(const std::string &playerName)
|
||||||
{
|
{
|
||||||
int num = 0;
|
int num = 0;
|
||||||
if(m_numJoinsPerPlayer.find(playerName) != m_numJoinsPerPlayer.end()) {
|
NumJoinsPerPlayerMap::const_iterator pos = m_numJoinsPerPlayer.find(playerName);
|
||||||
num = m_numJoinsPerPlayer[playerName];
|
if (pos != m_numJoinsPerPlayer.end()) {
|
||||||
|
num = pos->second;
|
||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,11 +260,10 @@ SessionManager::IsGuestAllowedToConnect(const std::string &clientAddress) const
|
|||||||
int num = 0;
|
int num = 0;
|
||||||
while (i != end) {
|
while (i != end) {
|
||||||
boost::shared_ptr<PlayerData> tmpPlayer(i->second->GetPlayerData());
|
boost::shared_ptr<PlayerData> tmpPlayer(i->second->GetPlayerData());
|
||||||
if(tmpPlayer && tmpPlayer->GetRights() == PLAYER_RIGHTS_GUEST) {
|
if (tmpPlayer && tmpPlayer->GetRights() == PLAYER_RIGHTS_GUEST) {
|
||||||
num++;
|
num++;
|
||||||
if(i->second->GetClientAddr() == clientAddress) {
|
if (i->second->GetClientAddr() == clientAddress) {
|
||||||
// guest has same ip as another guest in lobby or
|
// guest has same ip as another guest in lobby or
|
||||||
// number of guests in lobby >= SERVER_MAX_GUEST_USERS_LOBBY => not allowed
|
|
||||||
retVal = false;
|
retVal = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user