[Server] Simplify getPlayer methods, add isPlayerExists method

remotes/1728160796594174844/tmp_0.7.0-alpha
Koncord 7 years ago
parent 193034f09c
commit 1a9bf253f6

@ -54,9 +54,10 @@ void Players::newPlayer(RakNet::RakNetGUID guid)
Player *Players::getPlayer(RakNet::RakNetGUID guid)
{
if (players.count(guid) == 0)
auto it = players.find(guid);
if (it == players.end())
return nullptr;
return players[guid];
return it->second;
}
TPlayers *Players::getPlayers()
@ -123,9 +124,10 @@ int Player::getLoadState()
Player *Players::getPlayer(unsigned short id)
{
if (slots.find(id) == slots.end())
auto it = slots.find(id);
if (it == slots.end())
return nullptr;
return slots[id];
return it->second;
}
CellController::TContainer *Player::getCells()
@ -174,3 +176,8 @@ void Player::forEachLoaded(std::function<void(Player *pl, Player *other)> func)
func(this, pl);
}
}
bool Players::isPlayerExists(RakNet::RakNetGUID guid)
{
return players.find(guid) != players.end();
}

@ -34,6 +34,7 @@ public:
static Player *getPlayer(unsigned short id);
static TPlayers *getPlayers();
static unsigned short getLastPlayerId();
static bool isPlayerExists(RakNet::RakNetGUID guid);
private:
static TPlayers players;

Loading…
Cancel
Save