diff options
Diffstat (limited to 'src/server/game/Maps/Map.cpp')
-rw-r--r-- | src/server/game/Maps/Map.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index e9fe8caffc3..7771fe6198e 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -56,6 +56,8 @@ #include "WeatherMgr.h" #include "World.h" #include "WorldSession.h" +#include "WorldStateMgr.h" +#include "WorldStatePackets.h" #include <sstream> #include "Hacks/boost_1_74_fibonacci_heap.h" @@ -371,6 +373,8 @@ i_scriptLock(false), _respawnCheckTimer(0) MMAP::MMapFactory::createOrGetMMapManager()->loadMapInstance(sWorld->GetDataPath(), GetId(), i_InstanceId); + _worldStateValues = sWorldStateMgr->GetInitialWorldStatesForMap(this); + sScriptMgr->OnCreateMap(this); } @@ -684,6 +688,30 @@ void Map::UpdatePersonalPhasesForPlayer(Player const* player) GetMultiPersonalPhaseTracker().OnOwnerPhaseChanged(player, getNGrid(cell.GridX(), cell.GridY()), this, cell); } +int32 Map::GetWorldStateValue(int32 worldStateId) const +{ + if (int32 const* value = Trinity::Containers::MapGetValuePtr(_worldStateValues, worldStateId)) + return *value; + + return 0; +} + +void Map::SetWorldStateValue(int32 worldStateId, int32 value) +{ + auto itr = _worldStateValues.try_emplace(worldStateId, 0).first; + int32 oldValue = itr->second; + itr->second = value; + + if (WorldStateTemplate const* worldStateTemplate = sWorldStateMgr->GetWorldStateTemplate(worldStateId)) + sScriptMgr->OnWorldStateValueChange(worldStateTemplate, oldValue, value, this); + + // Broadcast update to all players on the map + WorldPackets::WorldState::UpdateWorldState updateWorldState; + updateWorldState.VariableID = worldStateId; + updateWorldState.Value = value; + SendToPlayers(updateWorldState.Write()); +} + template<class T> void Map::InitializeObject(T* /*obj*/) { } |