Fix crash when closing otclient in debug mode

This commit is contained in:
Eduardo Bart 2012-10-03 12:49:57 -03:00
parent b50eecc779
commit 31efe0a82d
3 changed files with 12 additions and 4 deletions

View File

@ -41,6 +41,13 @@ static bool isInZone(const Position& pos/* placePos*/,
); );
} }
void CreatureManager::terminate()
{
clearSpawns();
clear();
m_nullCreature = nullptr;
}
void Spawn::load(TiXmlElement* node) void Spawn::load(TiXmlElement* node)
{ {
Position centerPos = node->readPos("center"); Position centerPos = node->readPos("center");
@ -276,14 +283,14 @@ void CreatureManager::loadCreatureBuffer(const std::string& buffer)
if(attrib->ValueStr() != "look") if(attrib->ValueStr() != "look")
continue; continue;
m_loadCreatureBuffer(attrib, newType); internalLoadCreatureBuffer(attrib, newType);
break; break;
} }
doc.Clear(); doc.Clear();
} }
void CreatureManager::m_loadCreatureBuffer(TiXmlElement* attrib, const CreatureTypePtr& m) void CreatureManager::internalLoadCreatureBuffer(TiXmlElement* attrib, const CreatureTypePtr& m)
{ {
if(std::find(m_creatures.begin(), m_creatures.end(), m) != m_creatures.end()) if(std::find(m_creatures.begin(), m_creatures.end(), m) != m_creatures.end())
return; return;

View File

@ -99,6 +99,7 @@ public:
CreatureManager(); CreatureManager();
void clear() { m_creatures.clear(); } void clear() { m_creatures.clear(); }
void clearSpawns(); void clearSpawns();
void terminate();
void loadMonsters(const std::string& file); void loadMonsters(const std::string& file);
void loadSingleCreature(const std::string& file); void loadSingleCreature(const std::string& file);
@ -119,7 +120,7 @@ public:
const std::vector<CreatureTypePtr>& getCreatures() { return m_creatures; } const std::vector<CreatureTypePtr>& getCreatures() { return m_creatures; }
protected: protected:
void m_loadCreatureBuffer(TiXmlElement* elem, const CreatureTypePtr& m); void internalLoadCreatureBuffer(TiXmlElement* elem, const CreatureTypePtr& m);
private: private:
std::vector<CreatureTypePtr> m_creatures; std::vector<CreatureTypePtr> m_creatures;

View File

@ -79,7 +79,7 @@ void OTClient::init(const std::vector<std::string>& args)
void OTClient::terminate() void OTClient::terminate()
{ {
g_creatures.clear(); g_creatures.terminate();
g_game.terminate(); g_game.terminate();
g_map.terminate(); g_map.terminate();
g_things.terminate(); g_things.terminate();