diff --git a/apps/openmw-mp/Player.cpp b/apps/openmw-mp/Player.cpp index a3082c3d6..7105423bf 100644 --- a/apps/openmw-mp/Player.cpp +++ b/apps/openmw-mp/Player.cpp @@ -295,22 +295,25 @@ void Player::forEachLoaded(std::function func) } } -void Player::sendToLoaded(mwmp::PlayerPacket *myPacket) +void Player::sendToLoaded(mwmp::PlayerPacket &myPacket) { - std::list plList; - - for (auto &cell : cells) - for (auto &pl : *cell) - plList.push_back(pl); + static std::set plList; + static CellController::TContainer *addrCells = nullptr; - plList.sort(); - plList.unique(); + if (addrCells != &cells) + { + addrCells = &cells; + plList.clear(); + for (auto &cell : cells) + for (auto &pl : *cell) + plList.insert(pl); + } - for (auto pl : plList) + for (auto &pl : plList) { if (pl == this) continue; - myPacket->setPlayer(this); - myPacket->Send(pl->guid); + myPacket.setPlayer(this); + myPacket.Send(pl->guid); } } diff --git a/apps/openmw-mp/Player.hpp b/apps/openmw-mp/Player.hpp index ea03a7a10..9b7ac4c24 100644 --- a/apps/openmw-mp/Player.hpp +++ b/apps/openmw-mp/Player.hpp @@ -66,7 +66,7 @@ public: virtual ~Player(); CellController::TContainer *getCells(); - void sendToLoaded(mwmp::PlayerPacket *myPacket); + void sendToLoaded(mwmp::PlayerPacket &myPacket); void forEachLoaded(std::function func); diff --git a/apps/openmw-mp/processors/player/ProcessorPlayerAnimFlags.hpp b/apps/openmw-mp/processors/player/ProcessorPlayerAnimFlags.hpp index ecac9ed6f..524e36d18 100644 --- a/apps/openmw-mp/processors/player/ProcessorPlayerAnimFlags.hpp +++ b/apps/openmw-mp/processors/player/ProcessorPlayerAnimFlags.hpp @@ -21,7 +21,7 @@ namespace mwmp { DEBUG_PRINTF(strPacketID.c_str()); - player->sendToLoaded(&packet); + player->sendToLoaded(packet); } }; } diff --git a/apps/openmw-mp/processors/player/ProcessorPlayerAnimPlay.hpp b/apps/openmw-mp/processors/player/ProcessorPlayerAnimPlay.hpp index d9c064438..9ac60e739 100644 --- a/apps/openmw-mp/processors/player/ProcessorPlayerAnimPlay.hpp +++ b/apps/openmw-mp/processors/player/ProcessorPlayerAnimPlay.hpp @@ -17,7 +17,7 @@ namespace mwmp { DEBUG_PRINTF(strPacketID.c_str()); - player->sendToLoaded(&packet); + player->sendToLoaded(packet); } }; } diff --git a/apps/openmw-mp/processors/player/ProcessorPlayerAttack.hpp b/apps/openmw-mp/processors/player/ProcessorPlayerAttack.hpp index 296256654..44d65a533 100644 --- a/apps/openmw-mp/processors/player/ProcessorPlayerAttack.hpp +++ b/apps/openmw-mp/processors/player/ProcessorPlayerAttack.hpp @@ -25,7 +25,7 @@ namespace mwmp if (!player->creatureStats.mDead) { - player->sendToLoaded(&packet); + player->sendToLoaded(packet); } } }; diff --git a/apps/openmw-mp/processors/player/ProcessorPlayerAttribute.hpp b/apps/openmw-mp/processors/player/ProcessorPlayerAttribute.hpp index 62c52e39d..a7667dfda 100644 --- a/apps/openmw-mp/processors/player/ProcessorPlayerAttribute.hpp +++ b/apps/openmw-mp/processors/player/ProcessorPlayerAttribute.hpp @@ -23,7 +23,7 @@ namespace mwmp { //myPacket->Send(player, true); - player->sendToLoaded(&packet); + player->sendToLoaded(packet); Networking::get().getState().getEventCtrl().Call(player); } diff --git a/apps/openmw-mp/processors/player/ProcessorPlayerEquipment.hpp b/apps/openmw-mp/processors/player/ProcessorPlayerEquipment.hpp index f98d3111f..b62557db4 100644 --- a/apps/openmw-mp/processors/player/ProcessorPlayerEquipment.hpp +++ b/apps/openmw-mp/processors/player/ProcessorPlayerEquipment.hpp @@ -21,7 +21,7 @@ namespace mwmp { DEBUG_PRINTF(strPacketID.c_str()); - player->sendToLoaded(&packet); + player->sendToLoaded(packet); Networking::get().getState().getEventCtrl().Call(player); } diff --git a/apps/openmw-mp/processors/player/ProcessorPlayerPosition.hpp b/apps/openmw-mp/processors/player/ProcessorPlayerPosition.hpp index 3ba16930c..1e22212c5 100644 --- a/apps/openmw-mp/processors/player/ProcessorPlayerPosition.hpp +++ b/apps/openmw-mp/processors/player/ProcessorPlayerPosition.hpp @@ -22,7 +22,7 @@ namespace mwmp //DEBUG_PRINTF(strPacketID); if (!player->creatureStats.mDead) { - player->sendToLoaded(&packet); + player->sendToLoaded(packet); } } }; diff --git a/apps/openmw-mp/processors/player/ProcessorPlayerSkill.hpp b/apps/openmw-mp/processors/player/ProcessorPlayerSkill.hpp index a429bae93..c96fcdf3f 100644 --- a/apps/openmw-mp/processors/player/ProcessorPlayerSkill.hpp +++ b/apps/openmw-mp/processors/player/ProcessorPlayerSkill.hpp @@ -22,7 +22,7 @@ namespace mwmp if (!player->creatureStats.mDead) { //myPacket->Send(player, true); - player->sendToLoaded(&packet); + player->sendToLoaded(packet); Networking::get().getState().getEventCtrl().Call(player); } diff --git a/apps/openmw-mp/processors/player/ProcessorPlayerSpeech.hpp b/apps/openmw-mp/processors/player/ProcessorPlayerSpeech.hpp index 6768e700d..1f097932a 100644 --- a/apps/openmw-mp/processors/player/ProcessorPlayerSpeech.hpp +++ b/apps/openmw-mp/processors/player/ProcessorPlayerSpeech.hpp @@ -17,7 +17,7 @@ namespace mwmp { DEBUG_PRINTF(strPacketID.c_str()); - player->sendToLoaded(&packet); + player->sendToLoaded(packet); } }; } diff --git a/apps/openmw-mp/processors/player/ProcessorPlayerStatsDynamic.hpp b/apps/openmw-mp/processors/player/ProcessorPlayerStatsDynamic.hpp index 6df65e77d..b8a7a0fb8 100644 --- a/apps/openmw-mp/processors/player/ProcessorPlayerStatsDynamic.hpp +++ b/apps/openmw-mp/processors/player/ProcessorPlayerStatsDynamic.hpp @@ -21,7 +21,7 @@ namespace mwmp { DEBUG_PRINTF(strPacketID.c_str()); - player->sendToLoaded(&packet); + player->sendToLoaded(packet); } }; }