1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-29 17:15:32 +00:00

[Server] Add Cell::sendToLoaded() for sending events to loaded players

This commit is contained in:
David Cernat 2017-02-19 19:42:16 +02:00
parent eb0744aa77
commit 791089d342
2 changed files with 21 additions and 0 deletions

View file

@ -37,6 +37,23 @@ Cell::TPlayers Cell::getPlayers()
return players;
}
void Cell::sendToLoaded(mwmp::WorldPacket *worldPacket, mwmp::BaseEvent *baseEvent)
{
std::list <Player*> plList;
for (auto pl :getPlayers())
plList.push_back(pl);
plList.sort();
plList.unique();
for (auto pl : plList)
{
if (pl->guid == baseEvent->guid) continue;
worldPacket->Send(baseEvent, pl->guid);
}
}
std::string Cell::getDescription() const
{
return cell.getDescription();

View file

@ -8,6 +8,8 @@
#include <deque>
#include <string>
#include <components/esm/records.hpp>
#include <components/openmw-mp/Base/BaseEvent.hpp>
#include <components/openmw-mp/Packets/World/WorldPacket.hpp>
class Player;
class Cell;
@ -60,9 +62,11 @@ public:
void removePlayer(Player *player);
TPlayers getPlayers();
void sendToLoaded(mwmp::WorldPacket *worldPacket, mwmp::BaseEvent *baseEvent);
std::string getDescription() const;
private:
TPlayers players;
ESM::Cell cell;