Core/Scripts: Removed script calls from constructors and destructors

This commit is contained in:
Shauren
2024-03-14 20:32:03 +01:00
parent 6224036efd
commit 783f9c0ea3
2 changed files with 18 additions and 16 deletions

View File

@@ -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();