1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

- proper destructors for handlers and lib objects

This commit is contained in:
Ivan Savenko
2013-04-21 16:38:31 +00:00
parent 2ea1051395
commit 4db13ba845
13 changed files with 79 additions and 10 deletions

View File

@ -131,6 +131,15 @@ CSpell::CSpell()
isOffensive = false;
}
CSpell::~CSpell()
{
for (size_t i=0; i<effects.size(); i++)
{
for (size_t j=0; j<effects[i].size(); j++)
delete effects[i][j];
}
}
std::vector<BattleHex> CSpell::rangeInHexes(BattleHex centralHex, ui8 schoolLvl, ui8 side, bool *outDroppedHexes) const
{
std::vector<BattleHex> ret;
@ -479,7 +488,7 @@ CSpellHandler::CSpellHandler()
auto v = v_node.convertTo<std::vector<int> >();
auto a = a_node.convertTo<std::vector<int> >();
for (int i=0; i<4 ; i++)
for (int i=0; i<s->effects.size() ; i++)
{
Bonus * b = JsonUtils::parseBonus(bonus_node);
b->sid = s->id; //for all
@ -493,10 +502,8 @@ CSpellHandler::CSpellHandler()
s->effects[i].push_back(b);
}
}
auto find_in_map = [](std::string name, std::vector<Bonus::BonusType> &vec)
{
auto it = bonusNameMap.find(name);
@ -533,6 +540,14 @@ CSpellHandler::CSpellHandler()
}
}
CSpellHandler::~CSpellHandler()
{
BOOST_FOREACH(auto & spell, spells)
{
spell.dellNull();
}
}
std::vector<bool> CSpellHandler::getDefaultAllowed() const
{
std::vector<bool> allowedSpells;