Core/Auras: Move code which uses polymorphism out of Aura constructor.

This commit is contained in:
QAston
2011-02-06 13:17:29 +01:00
parent 1d36febab2
commit b5e78bf208
4 changed files with 11 additions and 4 deletions

View File

@@ -13,7 +13,7 @@ typedef void(AuraEffect::*pAuraEffectHandler)(AuraApplication const * aurApp, ui
class AuraEffect
{
friend Aura::Aura(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID);
friend void Aura::_InitEffects(uint8 effMask, Unit * caster, int32 *baseAmount);
friend Aura::~Aura();
private:
~AuraEffect();

View File

@@ -337,8 +337,6 @@ m_owner(owner), m_timeCla(0), m_updateTargetMapInterval(0),
m_casterLevel(caster ? caster->getLevel() : m_spellProto->spellLevel), m_procCharges(0), m_stackAmount(1),
m_isRemoved(false), m_isSingleTarget(false)
{
LoadScripts();
if (m_spellProto->manaPerSecond || m_spellProto->manaPerSecondPerLevel)
m_timeCla = 1 * IN_MILLISECONDS;
@@ -363,7 +361,11 @@ m_isRemoved(false), m_isSingleTarget(false)
m_procCharges = m_spellProto->procCharges;
if (modOwner)
modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges);
}
void Aura::_InitEffects(uint8 effMask, Unit * caster, int32 *baseAmount)
{
// shouldn't be in constructor - functions in AuraEffect::AuraEffect use polymorphism
for (uint8 i=0 ; i<MAX_SPELL_EFFECTS; ++i)
{
if (effMask & (uint8(1) << i))
@@ -1846,6 +1848,8 @@ UnitAura::UnitAura(SpellEntry const* spellproto, uint8 effMask, WorldObject * ow
: Aura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID)
{
m_AuraDRGroup = DIMINISHING_NONE;
LoadScripts();
_InitEffects(effMask, caster, baseAmount);
GetUnitOwner()->_AddAura(this, caster);
};
@@ -1955,9 +1959,11 @@ void UnitAura::FillTargetMap(std::map<Unit *, uint8> & targets, Unit * caster)
DynObjAura::DynObjAura(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID)
: Aura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID)
{
LoadScripts();
ASSERT(GetDynobjOwner());
ASSERT(GetDynobjOwner()->IsInWorld());
ASSERT(GetDynobjOwner()->GetMap() == caster->GetMap());
_InitEffects(effMask, caster, baseAmount);
GetDynobjOwner()->SetAura(this);
}

View File

@@ -85,6 +85,7 @@ class Aura
static Aura * TryCreate(SpellEntry const* spellproto, WorldObject * owner, Unit * caster, int32 *baseAmount = NULL, Item * castItem = NULL, uint64 casterGUID = 0);
static Aura * Create(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount = NULL, Item * castItem = NULL, uint64 casterGUID = 0);
explicit Aura(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID);
void _InitEffects(uint8 effMask, Unit * caster, int32 *baseAmount);
~Aura();
SpellEntry const* GetSpellProto() const { return m_spellProto; }

View File

@@ -448,7 +448,7 @@ class AuraScript : public _SpellScript
// executed when periodic aura effect ticks on target
// example: OnEffectPeriodic += AuraEffectPeriodicFn(class::function, EffectIndexSpecifier, EffectAuraNameSpecifier);
// where function is: void function (AuraEffect const * aurEff, AuraEffectHandleModes mode);
// where function is: void function (AuraEffect const * aurEff);
HookList<EffectPeriodicHandler> OnEffectPeriodic;
#define AuraEffectPeriodicFn(F, I, N) EffectPeriodicHandlerFunction(&F, I, N)