Core: Add proper cleanup at exit for smart script waypoints and instance encounters

This commit is contained in:
Shauren
2012-03-24 18:42:35 +01:00
parent a306c00d43
commit e64d1d43dd
3 changed files with 27 additions and 2 deletions

View File

@@ -35,6 +35,14 @@ void SmartWaypointMgr::LoadFromDB()
{
uint32 oldMSTime = getMSTime();
for (UNORDERED_MAP<uint32, WPPath*>::iterator itr = waypoint_map.begin(); itr != waypoint_map.end(); ++itr)
{
for (WPPath::iterator pathItr = itr->second->begin(); pathItr != itr->second->end(); ++pathItr)
delete pathItr->second;
delete itr->second;
}
waypoint_map.clear();
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_SMARTAI_WP);
@@ -84,6 +92,19 @@ void SmartWaypointMgr::LoadFromDB()
sLog->outString();
}
SmartWaypointMgr::~SmartWaypointMgr()
{
for (UNORDERED_MAP<uint32, WPPath*>::iterator itr = waypoint_map.begin(); itr != waypoint_map.end(); ++itr)
{
for (WPPath::iterator pathItr = itr->second->begin(); pathItr != itr->second->end(); ++pathItr)
delete pathItr->second;
delete itr->second;
}
waypoint_map.clear();
}
void SmartAIMgr::LoadSmartAIFromDB()
{
uint32 oldMSTime = getMSTime();

View File

@@ -1230,9 +1230,9 @@ typedef UNORDERED_MAP<uint32, ObjectList*> ObjectListMap;
class SmartWaypointMgr
{
friend class ACE_Singleton<SmartWaypointMgr, ACE_Null_Mutex>;
SmartWaypointMgr(){};
SmartWaypointMgr() {}
public:
~SmartWaypointMgr(){};
~SmartWaypointMgr();
void LoadFromDB();

View File

@@ -252,6 +252,10 @@ ObjectMgr::~ObjectMgr()
itr->second.Clear();
_cacheTrainerSpellStore.clear();
for (DungeonEncounterContainer::iterator itr =_dungeonEncounterStore.begin(); itr != _dungeonEncounterStore.end(); ++itr)
for (DungeonEncounterList::iterator encounterItr = itr->second.begin(); encounterItr != itr->second.end(); ++encounterItr)
delete *encounterItr;
}
void ObjectMgr::AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data)