Delete DynamicObject if AddToMap fails.

This commit is contained in:
megamage
2011-11-28 14:19:29 -05:00
parent 81fea2d7b5
commit 1f70fd2851
3 changed files with 10 additions and 9 deletions
@@ -79,7 +79,7 @@ void DynamicObject::RemoveFromWorld()
}
}
bool DynamicObject::Create(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, bool active, DynamicObjectType type)
bool DynamicObject::CreateDynamicObject(uint32 guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, bool active, DynamicObjectType type)
{
SetMap(caster->GetMap());
Relocate(pos);
@@ -106,6 +106,12 @@ bool DynamicObject::Create(uint32 guidlow, Unit* caster, uint32 spellId, Positio
SetUInt32Value(DYNAMICOBJECT_CASTTIME, getMSTime());
m_isWorldObject = active;
if (active)
setActive(true); //must before add to map to be put in world container
if (!GetMap()->AddToMap(this))
return false;
return true;
}