[Client] Add method to PlayerList for getting players by their actorId

pull/593/head
David Cernat 3 years ago
parent fe4a761ffe
commit 9817d3a563

@ -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<RakNet::RakNetGUID> PlayerList::getPlayersInCell(const ESM::Cell& cell)
{
std::vector<RakNet::RakNetGUID> playersInCell;

@ -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<RakNet::RakNetGUID> getPlayersInCell(const ESM::Cell& cell);
static bool isDedicatedPlayer(const MWWorld::Ptr &ptr);

Loading…
Cancel
Save