Core/Auras: Add Aura::TryRefreshStackOrCreate function and remove stack checks from Aura::Create
This commit is contained in:
@@ -213,70 +213,73 @@ void AuraApplication::ClientUpdate(bool remove)
|
||||
m_target->SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
Aura * Aura::TryCreate(SpellEntry const* spellproto, uint8 tryEffMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID)
|
||||
uint8 Aura::BuildEffectMaskForOwner(SpellEntry const* spellProto, uint8 avalibleEffectMask, WorldObject* owner)
|
||||
{
|
||||
ASSERT(spellProto);
|
||||
ASSERT(owner);
|
||||
uint8 effMask = 0;
|
||||
switch(owner->GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
case TYPEID_PLAYER:
|
||||
for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (IsUnitOwnedAuraEffect(spellProto->Effect[i]))
|
||||
effMask |= 1 << i;
|
||||
}
|
||||
break;
|
||||
case TYPEID_DYNAMICOBJECT:
|
||||
for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (spellProto->Effect[i] == SPELL_EFFECT_PERSISTENT_AREA_AURA)
|
||||
effMask |= 1 << i;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return effMask & avalibleEffectMask;
|
||||
}
|
||||
|
||||
Aura* Aura::TryRefreshStackOrCreate(SpellEntry const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, uint64 casterGUID /*= 0*/, bool* refresh /*= NULL*/)
|
||||
{
|
||||
ASSERT(spellproto);
|
||||
ASSERT(owner);
|
||||
ASSERT(caster || casterGUID);
|
||||
ASSERT(tryEffMask <= MAX_EFFECT_MASK);
|
||||
uint8 effMask = 0;
|
||||
switch(owner->GetTypeId())
|
||||
if (refresh)
|
||||
*refresh = false;
|
||||
uint8 effMask = Aura::BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
|
||||
if (!effMask)
|
||||
return NULL;
|
||||
if (Aura* foundAura = owner->ToUnit()->_TryStackingOrRefreshingExistingAura(spellproto, effMask, caster, baseAmount, castItem, casterGUID))
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
case TYPEID_PLAYER:
|
||||
for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (IsUnitOwnedAuraEffect(spellproto->Effect[i]))
|
||||
effMask |= 1 << i;
|
||||
}
|
||||
break;
|
||||
case TYPEID_DYNAMICOBJECT:
|
||||
for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (spellproto->Effect[i] == SPELL_EFFECT_PERSISTENT_AREA_AURA)
|
||||
effMask |= 1 << i;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
// we've here aura, which script triggered removal after modding stack amount
|
||||
// check the state here, so we won't create new Aura object
|
||||
if (foundAura->IsRemoved())
|
||||
return NULL;
|
||||
|
||||
if (refresh)
|
||||
*refresh = true;
|
||||
return foundAura;
|
||||
}
|
||||
if (uint8 realMask = effMask & tryEffMask)
|
||||
return Create(spellproto, realMask, owner, caster, baseAmount, castItem, casterGUID);
|
||||
return NULL;
|
||||
else
|
||||
return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
|
||||
}
|
||||
|
||||
Aura * Aura::TryCreate(SpellEntry const* spellproto, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID)
|
||||
Aura* Aura::TryCreate(SpellEntry const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, uint64 casterGUID /*= 0*/)
|
||||
{
|
||||
ASSERT(spellproto);
|
||||
ASSERT(owner);
|
||||
ASSERT(caster || casterGUID);
|
||||
uint8 effMask = 0;
|
||||
switch(owner->GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
case TYPEID_PLAYER:
|
||||
for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (IsUnitOwnedAuraEffect(spellproto->Effect[i]))
|
||||
effMask |= 1 << i;
|
||||
}
|
||||
break;
|
||||
case TYPEID_DYNAMICOBJECT:
|
||||
for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (spellproto->Effect[i] == SPELL_EFFECT_PERSISTENT_AREA_AURA)
|
||||
effMask |= 1 << i;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (effMask)
|
||||
return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
|
||||
return NULL;
|
||||
ASSERT(tryEffMask <= MAX_EFFECT_MASK);
|
||||
uint8 effMask = Aura::BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
|
||||
if (!effMask)
|
||||
return NULL;
|
||||
return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
|
||||
}
|
||||
|
||||
Aura* Aura::Create(SpellEntry const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, uint64 casterGUID /*= 0*/)
|
||||
Aura* Aura::Create(SpellEntry const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, uint64 casterGUID)
|
||||
{
|
||||
ASSERT(effMask);
|
||||
ASSERT(spellproto);
|
||||
@@ -306,10 +309,7 @@ Aura* Aura::Create(SpellEntry const* spellproto, uint8 effMask, WorldObject* own
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
case TYPEID_PLAYER:
|
||||
if (Aura* foundAura = owner->ToUnit()->_TryStackingOrRefreshingExistingAura(spellproto, effMask, caster, baseAmount, castItem, casterGUID))
|
||||
aura = foundAura;
|
||||
else
|
||||
aura = new UnitAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
|
||||
aura = new UnitAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
|
||||
break;
|
||||
case TYPEID_DYNAMICOBJECT:
|
||||
aura = new DynObjAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
|
||||
|
||||
@@ -83,9 +83,10 @@ class Aura
|
||||
public:
|
||||
typedef std::map<uint64, AuraApplication *> ApplicationMap;
|
||||
|
||||
static Aura * TryCreate(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount = NULL, Item * castItem = NULL, uint64 casterGUID = 0);
|
||||
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);
|
||||
static uint8 BuildEffectMaskForOwner(SpellEntry const* spellProto, uint8 avalibleEffectMask, WorldObject* owner);
|
||||
static Aura* TryRefreshStackOrCreate(SpellEntry const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount = NULL, Item* castItem = NULL, uint64 casterGUID = 0, bool* refresh = NULL);
|
||||
static Aura* TryCreate(SpellEntry const* spellproto, uint8 effMask, 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, Item* castItem, uint64 casterGUID);
|
||||
explicit Aura(SpellEntry const* spellproto, WorldObject * owner, Unit * caster, Item * castItem, uint64 casterGUID);
|
||||
void _InitEffects(uint8 effMask, Unit * caster, int32 *baseAmount);
|
||||
virtual ~Aura();
|
||||
|
||||
@@ -1427,7 +1427,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool
|
||||
|
||||
if (m_originalCaster)
|
||||
{
|
||||
m_spellAura = Aura::TryCreate(aurSpellInfo, effectMask, unit,
|
||||
m_spellAura = Aura::TryRefreshStackOrCreate(aurSpellInfo, effectMask, unit,
|
||||
m_originalCaster, (aurSpellInfo == m_spellInfo)? &m_spellValue->EffectBasePoints[0] : &basePoints[0], m_CastItem);
|
||||
if (m_spellAura)
|
||||
{
|
||||
|
||||
@@ -2543,7 +2543,7 @@ void Spell::EffectPersistentAA(SpellEffIndex effIndex)
|
||||
|
||||
dynObj->GetMap()->Add(dynObj);
|
||||
|
||||
if (Aura* aura = Aura::TryCreate(m_spellInfo, dynObj, caster, &m_spellValue->EffectBasePoints[0]))
|
||||
if (Aura* aura = Aura::TryCreate(m_spellInfo, MAX_EFFECT_MASK, dynObj, caster, &m_spellValue->EffectBasePoints[0]))
|
||||
{
|
||||
m_spellAura = aura;
|
||||
m_spellAura->_RegisterForTargets();
|
||||
|
||||
Reference in New Issue
Block a user