diff --git a/apps/openmw/mwmp/PlayerList.cpp b/apps/openmw/mwmp/PlayerList.cpp index 6f57a6812..195b692cd 100644 --- a/apps/openmw/mwmp/PlayerList.cpp +++ b/apps/openmw/mwmp/PlayerList.cpp @@ -80,6 +80,23 @@ DedicatedPlayer *PlayerList::getPlayer(const MWWorld::Ptr &ptr) return nullptr; } +DedicatedPlayer* PlayerList::getPlayer(int actorId) +{ + for (auto& playerEntry : playerList) + { + if (playerEntry.second == nullptr || playerEntry.second->getPtr().mRef == nullptr) + continue; + + MWWorld::Ptr playerPtr = playerEntry.second->getPtr(); + int playerActorId = playerPtr.getClass().getCreatureStats(playerPtr).getActorId(); + + if (actorId == playerActorId) + return playerEntry.second; + } + + return nullptr; +} + std::vector PlayerList::getPlayersInCell(const ESM::Cell& cell) { std::vector playersInCell; diff --git a/apps/openmw/mwmp/PlayerList.hpp b/apps/openmw/mwmp/PlayerList.hpp index 5a3e09850..097c4259c 100644 --- a/apps/openmw/mwmp/PlayerList.hpp +++ b/apps/openmw/mwmp/PlayerList.hpp @@ -34,6 +34,7 @@ namespace mwmp static DedicatedPlayer *getPlayer(RakNet::RakNetGUID guid); static DedicatedPlayer *getPlayer(const MWWorld::Ptr &ptr); + static DedicatedPlayer* getPlayer(int actorId); static std::vector getPlayersInCell(const ESM::Cell& cell); static bool isDedicatedPlayer(const MWWorld::Ptr &ptr);