Core/Battlegrounds: Unload all grids before destroying battleground object

Port From (https://github.com/TrinityCore/TrinityCore/commit/3fc3cd455b51d2de4ba5a70b7eff15e23b3da481)
This commit is contained in:
hondacrx
2023-01-23 00:26:06 -05:00
parent 8921432333
commit 7ab417f08b
2 changed files with 9 additions and 2 deletions
+8 -1
View File
@@ -54,7 +54,14 @@ namespace Game.BattleGrounds
Global.BattlegroundMgr.RemoveBattleground(GetTypeID(), GetInstanceID());
// unload map
if (m_Map)
m_Map.SetUnload();
{
m_Map.UnloadAll(); // unload all objects (they may hold a reference to bg in their ZoneScript pointer)
m_Map.SetUnload(); // mark for deletion by MapManager
//unlink to prevent crash, always unlink all pointer reference before destruction
m_Map.SetBG(null);
m_Map = null;
}
// remove from bg free slot queue
RemoveFromBGFreeSlotQueue();
+1 -1
View File
@@ -1474,7 +1474,7 @@ namespace Game.Maps
}
}
public virtual void UnloadAll()
public void UnloadAll()
{
// clear all delayed moves, useless anyway do this moves before map unload.
creaturesToMove.Clear();