mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Spells: fixed mem leak
This commit is contained in:
@@ -942,23 +942,20 @@ SpellEffectInfo::StaticData SpellEffectInfo::_data[TOTAL_SPELL_EFFECTS] =
|
||||
{EFFECT_IMPLICIT_TARGET_NONE, TARGET_OBJECT_TYPE_NONE}, // 244 SPELL_EFFECT_244
|
||||
};
|
||||
|
||||
SpellInfo::SpellInfo(SpellEntry const* spellEntry, SpellEffectEntryMap effects)
|
||||
SpellInfo::SpellInfo(SpellEntry const* spellEntry, SpellEffectEntryMap const& effectsMap)
|
||||
{
|
||||
Id = spellEntry->ID;
|
||||
|
||||
// SpellDifficultyEntry
|
||||
for (SpellEffectEntryMap::const_iterator itr = effects.begin(); itr != effects.end(); ++itr)
|
||||
for (SpellEffectEntryMap::value_type const& itr : effectsMap)
|
||||
{
|
||||
SpellEffectEntryVector effects = itr->second;
|
||||
_effects[itr->first].resize(effects.size());
|
||||
SpellEffectEntryVector const& effects = itr.second;
|
||||
_effects[itr.first].resize(effects.size());
|
||||
|
||||
for (uint32 i = effects.size(); i > 0; --i)
|
||||
for (size_t i = 0; i < effects.size(); ++i)
|
||||
{
|
||||
SpellEffectEntry const* effect = effects[i - 1];
|
||||
if (!effect)
|
||||
continue;
|
||||
|
||||
_effects[itr->first][effect->EffectIndex] = new SpellEffectInfo(spellEntry, this, effect->EffectIndex, effect);
|
||||
if (SpellEffectEntry const* effect = effects[i])
|
||||
_effects[itr.first][effect->EffectIndex] = new SpellEffectInfo(spellEntry, this, effect->EffectIndex, effect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1128,6 +1125,15 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry, SpellEffectEntryMap effects)
|
||||
SpellInfo::~SpellInfo()
|
||||
{
|
||||
_UnloadImplicitTargetConditionLists();
|
||||
_UnloadSpellEffects();
|
||||
}
|
||||
|
||||
void SpellInfo::_UnloadSpellEffects()
|
||||
{
|
||||
for (SpellEffectInfoMap::value_type& i : _effects)
|
||||
for (size_t j = 0; j < i.second.size(); ++j)
|
||||
delete i.second[j];
|
||||
_effects.clear();
|
||||
}
|
||||
|
||||
uint32 SpellInfo::GetCategory() const
|
||||
|
||||
@@ -450,7 +450,7 @@ public:
|
||||
SpellTotemsEntry const* GetSpellTotems() const;
|
||||
SpellMiscEntry const* GetSpellMisc() const;
|
||||
|
||||
SpellInfo(SpellEntry const* spellEntry, SpellEffectEntryMap effects);
|
||||
SpellInfo(SpellEntry const* spellEntry, SpellEffectEntryMap const& effectsMap);
|
||||
~SpellInfo();
|
||||
|
||||
uint32 GetCategory() const;
|
||||
@@ -572,6 +572,7 @@ public:
|
||||
|
||||
// unloading helpers
|
||||
void _UnloadImplicitTargetConditionLists();
|
||||
void _UnloadSpellEffects();
|
||||
|
||||
SpellEffectInfoVector GetEffectsForDifficulty(uint32 difficulty) const;
|
||||
SpellEffectInfo const* GetEffect(uint32 difficulty, uint32 index) const;
|
||||
|
||||
Reference in New Issue
Block a user