mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-05 18:19:41 +00:00
[Client] Add method to PlayerList for getting players by their actorId
This commit is contained in:
parent
fe4a761ffe
commit
9817d3a563
2 changed files with 18 additions and 0 deletions
|
@ -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…
Reference in a new issue