[7257] Fixed unexpected errors in log and non-freed memory at battleground system shutdown. Author: VladimirMangos

--HG--
branch : trunk
This commit is contained in:
megamage
2009-02-10 09:55:16 -06:00
parent f62e062b0d
commit 70798207f8
5 changed files with 27 additions and 7 deletions
+6
View File
@@ -1359,6 +1359,9 @@ void BattleGround::SpawnBGCreature(uint32 type, uint32 respawntime)
*/
bool BattleGround::DelCreature(uint32 type)
{
if(!m_BgCreatures[type])
return true;
Creature *cr = HashMapHolder<Creature>::Find(m_BgCreatures[type]);
if(!cr)
{
@@ -1374,6 +1377,9 @@ bool BattleGround::DelCreature(uint32 type)
bool BattleGround::DelObject(uint32 type)
{
if(!m_BgObjects[type])
return true;
GameObject *obj = HashMapHolder<GameObject>::Find(m_BgObjects[type]);
if(!obj)
{
+15 -6
View File
@@ -1044,16 +1044,25 @@ BattleGroundMgr::BattleGroundMgr() : m_AutoDistributionTimeChecker(0), m_ArenaTe
BattleGroundMgr::~BattleGroundMgr()
{
BattleGroundSet::iterator itr, next;
for(itr = m_BattleGrounds.begin(); itr != m_BattleGrounds.end(); itr = next)
DeleteAlllBattleGrounds();
}
void BattleGroundMgr::DeleteAlllBattleGrounds()
{
for(BattleGroundSet::iterator itr = m_BattleGrounds.begin(); itr != m_BattleGrounds.end();)
{
next = itr;
++next;
BattleGround * bg = itr->second;
m_BattleGrounds.erase(itr);
m_BattleGrounds.erase(itr++);
delete bg;
}
m_BattleGrounds.clear();
// destroy template battlegrounds that listed only in queues (other already terminated)
for(uint32 bgTypeId = 0; bgTypeId < MAX_BATTLEGROUND_TYPE_ID; ++bgTypeId)
{
// ~BattleGround call unregistring BG from queue
while(!BGFreeSlotQueue[bgTypeId].empty())
delete BGFreeSlotQueue[bgTypeId].front();
}
}
// used to update running battlegrounds, and delete finished ones
+1
View File
@@ -208,6 +208,7 @@ class BattleGroundMgr
void RemoveBattleGround(uint32 instanceID) { m_BattleGrounds.erase(instanceID); }
void CreateInitialBattleGrounds();
void DeleteAlllBattleGrounds();
void SendToBattleGround(Player *pl, uint32 InstanceID);