diff --git a/apps/openmw-mp/Player.cpp b/apps/openmw-mp/Player.cpp index 6e66f8151..fb94a6159 100644 --- a/apps/openmw-mp/Player.cpp +++ b/apps/openmw-mp/Player.cpp @@ -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 func) func(this, pl); } } + +bool Players::isPlayerExists(RakNet::RakNetGUID guid) +{ + return players.find(guid) != players.end(); +} diff --git a/apps/openmw-mp/Player.hpp b/apps/openmw-mp/Player.hpp index a956a4a52..487719343 100644 --- a/apps/openmw-mp/Player.hpp +++ b/apps/openmw-mp/Player.hpp @@ -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;