From 080d2c6cd439acb2059adc4e24a279de98aa0db6 Mon Sep 17 00:00:00 2001 From: ariel- Date: Thu, 1 Feb 2018 13:10:51 -0300 Subject: Core/Spells: rework part 4: iterate over effects first Ref #18395 Implement far spell queue processing Closes #7395 --- src/server/game/Maps/Map.cpp | 14 ++++++++++++++ src/server/game/Maps/Map.h | 6 ++++++ 2 files changed, 20 insertions(+) (limited to 'src/server/game/Maps') diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 347882d34c6..609426e1b11 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -3395,8 +3395,22 @@ bool Map::IsSpawnGroupActive(uint32 groupId) const return (_toggledSpawnGroupIds.find(groupId) != _toggledSpawnGroupIds.end()) != !(data->flags & SPAWNGROUP_FLAG_MANUAL_SPAWN); } +void Map::AddFarSpellCallback(FarSpellCallback&& callback) +{ + _farSpellCallbacks.Enqueue(new FarSpellCallback(std::move(callback))); +} + void Map::DelayedUpdate(uint32 t_diff) { + { + FarSpellCallback* callback; + while (_farSpellCallbacks.Dequeue(callback)) + { + (*callback)(this); + delete callback; + } + } + for (_transportsUpdateIter = _transports.begin(); _transportsUpdateIter != _transports.end();) { Transport* transport = *_transportsUpdateIter; diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 94feabcc7af..adccf8c00c5 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -26,6 +26,7 @@ #include "GridDefines.h" #include "GridRefManager.h" #include "MapRefManager.h" +#include "MPSCQueue.h" #include "ObjectGuid.h" #include "Optional.h" #include "SharedDefines.h" @@ -853,6 +854,9 @@ class TC_GAME_API Map : public GridRefManager // This will not affect any already-present creatures in the group void SetSpawnGroupInactive(uint32 groupId) { SetSpawnGroupActive(groupId, false); } + typedef std::function FarSpellCallback; + void AddFarSpellCallback(FarSpellCallback&& callback); + private: // Type specific code for add/remove to/from grid template @@ -916,6 +920,8 @@ class TC_GAME_API Map : public GridRefManager std::unordered_set _corpseBones; std::unordered_set _updateObjects; + + MPSCQueue _farSpellCallbacks; }; enum InstanceResetMethod -- cgit v1.2.3