aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Maps/Map.cpp18
-rw-r--r--src/server/game/Maps/MapManager.cpp16
2 files changed, 18 insertions, 16 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 19c9fff765c..b603d704f97 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -16,14 +16,13 @@
*/
#include "Map.h"
-#include "BattlefieldMgr.h"
#include "Battleground.h"
#include "CellImpl.h"
#include "CharacterPackets.h"
#include "Containers.h"
#include "Conversation.h"
-#include "DatabaseEnv.h"
#include "DB2Stores.h"
+#include "DatabaseEnv.h"
#include "DynamicTree.h"
#include "GameObjectModel.h"
#include "GameTime.h"
@@ -43,7 +42,6 @@
#include "ObjectAccessor.h"
#include "ObjectGridLoader.h"
#include "ObjectMgr.h"
-#include "OutdoorPvPMgr.h"
#include "Pet.h"
#include "PhasingHandler.h"
#include "PoolMgr.h"
@@ -51,9 +49,9 @@
#include "SpellAuras.h"
#include "TerrainMgr.h"
#include "Transport.h"
-#include "Vehicle.h"
#include "VMapFactory.h"
#include "VMapManager2.h"
+#include "Vehicle.h"
#include "Vignette.h"
#include "VignettePackets.h"
#include "Weather.h"
@@ -90,10 +88,6 @@ struct RespawnInfoWithHandle : RespawnInfo
Map::~Map()
{
- // UnloadAll must be called before deleting the map
-
- sScriptMgr->OnDestroyMap(this);
-
// Delete all waiting spawns, else there will be a memory leak
// This doesn't delete from database.
UnloadAllRespawnInfos();
@@ -110,9 +104,6 @@ Map::~Map()
if (!m_scriptSchedule.empty())
sMapMgr->DecreaseScheduledScriptCount(m_scriptSchedule.size());
- sOutdoorPvPMgr->DestroyOutdoorPvPForMap(this);
- sBattlefieldMgr->DestroyBattlefieldsForMap(this);
-
m_terrain->UnloadMMapInstance(GetId(), GetInstanceId());
}
@@ -173,11 +164,6 @@ i_scriptLock(false), _respawnTimes(std::make_unique<RespawnListContainer>()), _r
m_terrain->LoadMMapInstance(GetId(), GetInstanceId());
_worldStateValues = sWorldStateMgr->GetInitialWorldStatesForMap(this);
-
- sOutdoorPvPMgr->CreateOutdoorPvPForMap(this);
- sBattlefieldMgr->CreateBattlefieldsForMap(this);
-
- sScriptMgr->OnCreateMap(this);
}
void Map::InitVisibilityDistance()
diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp
index 6b1845a247b..59a9a269142 100644
--- a/src/server/game/Maps/MapManager.cpp
+++ b/src/server/game/Maps/MapManager.cpp
@@ -16,6 +16,7 @@
*/
#include "MapManager.h"
+#include "BattlefieldMgr.h"
#include "Battleground.h"
#include "Containers.h"
#include "DatabaseEnv.h"
@@ -25,6 +26,7 @@
#include "InstanceLockMgr.h"
#include "Log.h"
#include "Map.h"
+#include "OutdoorPvPMgr.h"
#include "Player.h"
#include "ScenarioMgr.h"
#include "ScriptMgr.h"
@@ -253,6 +255,10 @@ Map* MapManager::CreateMap(uint32 mapId, Player* player)
{
ptr.reset(map);
map->SetWeakPtr(ptr);
+
+ sScriptMgr->OnCreateMap(map);
+ sOutdoorPvPMgr->CreateOutdoorPvPForMap(map);
+ sBattlefieldMgr->CreateBattlefieldsForMap(map);
}
}
@@ -349,6 +355,10 @@ bool MapManager::DestroyMap(Map* map)
if (map->HavePlayers())
return false;
+ sOutdoorPvPMgr->DestroyOutdoorPvPForMap(map);
+ sBattlefieldMgr->DestroyBattlefieldsForMap(map);
+ sScriptMgr->OnDestroyMap(map);
+
map->UnloadAll();
// Free up the instance id and allow it to be reused for normal dungeons, bgs and arenas
@@ -368,8 +378,14 @@ void MapManager::UnloadAll()
{
// first unload maps
for (auto iter = i_maps.begin(); iter != i_maps.end(); ++iter)
+ {
iter->second->UnloadAll();
+ sOutdoorPvPMgr->DestroyOutdoorPvPForMap(iter->second.get());
+ sBattlefieldMgr->DestroyBattlefieldsForMap(iter->second.get());
+ sScriptMgr->OnDestroyMap(iter->second.get());
+ }
+
// then delete them
i_maps.clear();