mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-06 15:45:32 +00:00
[Server] Add Cell::sendToLoaded() for sending events to loaded players
This commit is contained in:
parent
eb0744aa77
commit
791089d342
2 changed files with 21 additions and 0 deletions
|
@ -37,6 +37,23 @@ Cell::TPlayers Cell::getPlayers()
|
||||||
return players;
|
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
|
std::string Cell::getDescription() const
|
||||||
{
|
{
|
||||||
return cell.getDescription();
|
return cell.getDescription();
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <components/esm/records.hpp>
|
#include <components/esm/records.hpp>
|
||||||
|
#include <components/openmw-mp/Base/BaseEvent.hpp>
|
||||||
|
#include <components/openmw-mp/Packets/World/WorldPacket.hpp>
|
||||||
|
|
||||||
class Player;
|
class Player;
|
||||||
class Cell;
|
class Cell;
|
||||||
|
@ -60,9 +62,11 @@ public:
|
||||||
void removePlayer(Player *player);
|
void removePlayer(Player *player);
|
||||||
|
|
||||||
TPlayers getPlayers();
|
TPlayers getPlayers();
|
||||||
|
void sendToLoaded(mwmp::WorldPacket *worldPacket, mwmp::BaseEvent *baseEvent);
|
||||||
|
|
||||||
std::string getDescription() const;
|
std::string getDescription() const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TPlayers players;
|
TPlayers players;
|
||||||
ESM::Cell cell;
|
ESM::Cell cell;
|
||||||
|
|
Loading…
Reference in a new issue