Core/Battlegrounds: Unload all grids before destroying battleground object

Closes #28755
This commit is contained in:
Shauren
2023-01-15 14:25:18 +01:00
parent badb55bfd9
commit 3fc3cd455b
2 changed files with 4 additions and 2 deletions

View File

@@ -134,7 +134,9 @@ Battleground::~Battleground()
// 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(nullptr);
m_Map = nullptr;

View File

@@ -244,7 +244,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
bool UnloadGrid(NGridType& ngrid, bool pForce);
void GridMarkNoUnload(uint32 x, uint32 y);
void GridUnmarkNoUnload(uint32 x, uint32 y);
virtual void UnloadAll();
void UnloadAll();
void ResetGridExpiry(NGridType &grid, float factor = 1) const
{