Delete DynamicObject if AddToMap fails.

This commit is contained in:
megamage committed 2011-11-28 14:19:29 -05:00
1 parent 81fea2d7b5
commit 1f70fd2851
3 files changed
+10 -9

No files matched your search

+2 -7
View File
@@ -2589,14 +2589,12 @@ void Spell::EffectPersistentAA(SpellEffIndex effIndex)
if (!caster->IsInWorld())
return;
DynamicObject* dynObj = new DynamicObject();
if (!dynObj->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, m_spellInfo->Id, *m_targets.GetDst(), radius, false, DYNAMIC_OBJECT_AREA_SPELL))
if (!dynObj->CreateDynamicObject(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, m_spellInfo->Id, *m_targets.GetDst(), radius, false, DYNAMIC_OBJECT_AREA_SPELL))
{
delete dynObj;
return;
}
dynObj->GetMap()->AddToMap(dynObj);
if (Aura* aura = Aura::TryCreate(m_spellInfo, MAX_EFFECT_MASK, dynObj, caster, &m_spellValue->EffectBasePoints[0]))
{
m_spellAura = aura;
@@ -3440,16 +3438,13 @@ void Spell::EffectAddFarsight(SpellEffIndex effIndex)
return;
DynamicObject* dynObj = new DynamicObject();
if (!dynObj->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, *m_targets.GetDst(), radius, true, DYNAMIC_OBJECT_FARSIGHT_FOCUS))
if (!dynObj->CreateDynamicObject(sObjectMgr->GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, *m_targets.GetDst(), radius, true, DYNAMIC_OBJECT_FARSIGHT_FOCUS))
{
delete dynObj;
return;
}
dynObj->SetDuration(duration);
dynObj->setActive(true); //must before add to map to be put in world container
dynObj->GetMap()->AddToMap(dynObj); //grid will also be loaded
dynObj->SetCasterViewpoint();
}