Unlink Battleground and BattlegroundMap when one of them is deleted. Fix crash #3239.

This commit is contained in:
megamage
2011-09-27 17:26:13 -04:00
parent 5f043e6291
commit eb946691c7
2 changed files with 11 additions and 0 deletions

View File

@@ -220,7 +220,12 @@ Battleground::~Battleground()
sBattlegroundMgr->RemoveBattleground(GetInstanceID(), GetTypeID());
// unload map
if (m_Map)
{
m_Map->SetUnload();
//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();

View File

@@ -2593,6 +2593,12 @@ BattlegroundMap::BattlegroundMap(uint32 id, time_t expiry, uint32 InstanceId, Ma
BattlegroundMap::~BattlegroundMap()
{
if(m_bg)
{
//unlink to prevent crash, always unlink all pointer reference before destruction
m_bg->SetBgMap(NULL);
m_bg = NULL;
}
}
void BattlegroundMap::InitVisibilityDistance()