From 791089d34293e2a05ff3e9a3136c7ca3c4a8b83b Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 19 Feb 2017 19:42:16 +0200 Subject: [PATCH] [Server] Add Cell::sendToLoaded() for sending events to loaded players --- apps/openmw-mp/Cell.cpp | 17 +++++++++++++++++ apps/openmw-mp/Cell.hpp | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/apps/openmw-mp/Cell.cpp b/apps/openmw-mp/Cell.cpp index c907d90d2..c4a1c570d 100644 --- a/apps/openmw-mp/Cell.cpp +++ b/apps/openmw-mp/Cell.cpp @@ -37,6 +37,23 @@ Cell::TPlayers Cell::getPlayers() return players; } +void Cell::sendToLoaded(mwmp::WorldPacket *worldPacket, mwmp::BaseEvent *baseEvent) +{ + std::list 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(); diff --git a/apps/openmw-mp/Cell.hpp b/apps/openmw-mp/Cell.hpp index 162becebe..938aa0a55 100644 --- a/apps/openmw-mp/Cell.hpp +++ b/apps/openmw-mp/Cell.hpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include 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;