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

This commit is contained in:
VladimirMangos 2009-02-10 05:58:38 +03:00
parent 0e37851a11
commit 6bacf2239f
5 changed files with 27 additions and 7 deletions

View file

@ -1322,6 +1322,9 @@ void BattleGround::SpawnBGCreature(uint32 type, uint32 respawntime)
*/ */
bool BattleGround::DelCreature(uint32 type) bool BattleGround::DelCreature(uint32 type)
{ {
if(!m_BgCreatures[type])
return true;
Creature *cr = HashMapHolder<Creature>::Find(m_BgCreatures[type]); Creature *cr = HashMapHolder<Creature>::Find(m_BgCreatures[type]);
if(!cr) if(!cr)
{ {
@ -1336,6 +1339,9 @@ bool BattleGround::DelCreature(uint32 type)
bool BattleGround::DelObject(uint32 type) bool BattleGround::DelObject(uint32 type)
{ {
if(!m_BgObjects[type])
return true;
GameObject *obj = HashMapHolder<GameObject>::Find(m_BgObjects[type]); GameObject *obj = HashMapHolder<GameObject>::Find(m_BgObjects[type]);
if(!obj) if(!obj)
{ {

View file

@ -1090,16 +1090,25 @@ BattleGroundMgr::BattleGroundMgr() : m_AutoDistributionTimeChecker(0), m_ArenaTe
BattleGroundMgr::~BattleGroundMgr() BattleGroundMgr::~BattleGroundMgr()
{ {
BattleGroundSet::iterator itr, next; DeleteAlllBattleGrounds();
for(itr = m_BattleGrounds.begin(); itr != m_BattleGrounds.end(); itr = next) }
void BattleGroundMgr::DeleteAlllBattleGrounds()
{
for(BattleGroundSet::iterator itr = m_BattleGrounds.begin(); itr != m_BattleGrounds.end();)
{ {
next = itr;
++next;
BattleGround * bg = itr->second; BattleGround * bg = itr->second;
m_BattleGrounds.erase(itr); m_BattleGrounds.erase(itr++);
delete bg; 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 // used to update running battlegrounds, and delete finished ones

View file

@ -207,6 +207,7 @@ class BattleGroundMgr
void RemoveBattleGround(uint32 instanceID) { m_BattleGrounds.erase(instanceID); } void RemoveBattleGround(uint32 instanceID) { m_BattleGrounds.erase(instanceID); }
void CreateInitialBattleGrounds(); void CreateInitialBattleGrounds();
void DeleteAlllBattleGrounds();
void SendToBattleGround(Player *pl, uint32 InstanceID); void SendToBattleGround(Player *pl, uint32 InstanceID);

View file

@ -27,6 +27,7 @@
#include "Timer.h" #include "Timer.h"
#include "ObjectAccessor.h" #include "ObjectAccessor.h"
#include "MapManager.h" #include "MapManager.h"
#include "BattleGroundMgr.h"
#include "Database/DatabaseEnv.h" #include "Database/DatabaseEnv.h"
@ -75,6 +76,9 @@ void WorldRunnable::run()
sWorld.KickAll(); // save and kick all players sWorld.KickAll(); // save and kick all players
sWorld.UpdateSessions( 1 ); // real players unload required UpdateSessions call sWorld.UpdateSessions( 1 ); // real players unload required UpdateSessions call
// unload battleground templates before different singletons destroyed
sBattleGroundMgr.DeleteAlllBattleGrounds();
sWorldSocketMgr->StopNetwork(); sWorldSocketMgr->StopNetwork();
MapManager::Instance().UnloadAll(); // unload all grids (including locked in memory) MapManager::Instance().UnloadAll(); // unload all grids (including locked in memory)

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "7256" #define REVISION_NR "7257"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__