Core/DynamicObject: Delete DynObjAura on DynObj delete, not on aura remove from object (prevents crashes)

This commit is contained in:
QAston
2011-06-16 00:55:27 +02:00
parent 2bef7477bb
commit ebc9ead617
2 changed files with 7 additions and 5 deletions

View File

@@ -28,7 +28,7 @@
#include "ScriptMgr.h"
DynamicObject::DynamicObject() : WorldObject(),
_aura(NULL), _caster(NULL), _duration(0), _isViewpoint(false)
_aura(NULL), _removedAura(NULL), _caster(NULL), _duration(0), _isViewpoint(false)
{
m_objectType |= TYPEMASK_DYNAMICOBJECT;
m_objectTypeId = TYPEID_DYNAMICOBJECT;
@@ -44,6 +44,7 @@ DynamicObject::~DynamicObject()
ASSERT(!_aura);
ASSERT(!_caster);
ASSERT(!_isViewpoint);
delete _removedAura;
}
void DynamicObject::AddToWorld()
@@ -178,11 +179,11 @@ void DynamicObject::SetAura(Aura* aura)
void DynamicObject::RemoveAura()
{
ASSERT(_aura);
if (!_aura->IsRemoved())
_aura->_Remove(AURA_REMOVE_BY_DEFAULT);
delete _aura;
ASSERT(_aura && !_removedAura);
_removedAura = _aura;
_aura = NULL;
if (!_removedAura->IsRemoved())
_removedAura->_Remove(AURA_REMOVE_BY_DEFAULT);
}
void DynamicObject::SetCasterViewpoint()

View File

@@ -66,6 +66,7 @@ class DynamicObject : public WorldObject, public GridObject<DynamicObject>
protected:
Aura* _aura;
Aura* _removedAura;
Unit* _caster;
int32 _duration; // for non-aura dynobjects
bool _isViewpoint;