Created
September 4, 2011 18:04
-
-
Save rsa/1193239 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp | |
| index c84b2a3..f4a135b 100644 | |
| --- a/src/game/DynamicObject.cpp | |
| +++ b/src/game/DynamicObject.cpp | |
| @@ -170,7 +170,7 @@ void DynamicObject::Delay(int32 delaytime) | |
| bool foundAura = false; | |
| for (int32 i = m_effIndex + 1; i < MAX_EFFECT_INDEX; ++i) | |
| { | |
| - if ((holder->GetSpellProto()->Effect[i] == SPELL_EFFECT_PERSISTENT_AREA_AURA || holder->GetSpellProto()->Effect[i] == SPELL_EFFECT_ADD_FARSIGHT) && holder->m_auras[i]) | |
| + if ((holder->GetSpellProto()->Effect[i] == SPELL_EFFECT_PERSISTENT_AREA_AURA || holder->GetSpellProto()->Effect[i] == SPELL_EFFECT_ADD_FARSIGHT) && holder->GetAuraByEffectIndex(SpellEffectIndex(i))) | |
| { | |
| foundAura = true; | |
| break; | |
| diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h | |
| index f8e8e8f..cd79f20 100644 | |
| --- a/src/game/GridNotifiersImpl.h | |
| +++ b/src/game/GridNotifiersImpl.h | |
| @@ -166,8 +166,7 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target) | |
| { | |
| if (!holder->GetAuraByEffectIndex(eff_index)) | |
| { | |
| - PersistentAreaAura* Aur = new PersistentAreaAura(spellInfo, eff_index, NULL, holder, target, i_dynobject.GetCaster()); | |
| - holder->AddAura(Aur, eff_index); | |
| + PersistentAreaAura* Aur = holder->CreatePersistentAreaAura(spellInfo, eff_index, NULL, target, i_dynobject.GetCaster()); | |
| target->AddAuraToModList(Aur); | |
| holder->SetInUse(true); | |
| Aur->ApplyModifier(true,true); | |
| @@ -182,8 +181,7 @@ inline void MaNGOS::DynamicObjectUpdater::VisitHelper(Unit* target) | |
| else | |
| { | |
| holder = CreateSpellAuraHolder(spellInfo, target, i_dynobject.GetCaster()); | |
| - PersistentAreaAura* Aur = new PersistentAreaAura(spellInfo, eff_index, NULL, holder, target, i_dynobject.GetCaster()); | |
| - holder->AddAura(Aur, eff_index); | |
| + holder->CreatePersistentAreaAura(spellInfo, eff_index, NULL, target, i_dynobject.GetCaster()); | |
| target->AddSpellAuraHolder(holder); | |
| } | |
| diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp | |
| index 3e83a72..27e708e 100644 | |
| --- a/src/game/Level3.cpp | |
| +++ b/src/game/Level3.cpp | |
| @@ -4018,8 +4018,7 @@ bool ChatHandler::HandleAuraCommand(char* args) | |
| eff == SPELL_EFFECT_APPLY_AURA || | |
| eff == SPELL_EFFECT_PERSISTENT_AREA_AURA) | |
| { | |
| - Aura *aur = CreateAura(spellInfo, SpellEffectIndex(i), NULL, holder, target); | |
| - holder->AddAura(aur, SpellEffectIndex(i)); | |
| + holder->CreateAura(spellInfo, SpellEffectIndex(i), NULL, target, NULL, NULL); | |
| } | |
| } | |
| target->AddSpellAuraHolder(holder); | |
| diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp | |
| index 13c2542..141c271 100644 | |
| --- a/src/game/Pet.cpp | |
| +++ b/src/game/Pet.cpp | |
| @@ -1394,12 +1394,11 @@ void Pet::_LoadAuras(uint32 timediff) | |
| if ((effIndexMask & (1 << i)) == 0) | |
| continue; | |
| - Aura* aura = CreateAura(spellproto, SpellEffectIndex(i), NULL, holder, this); | |
| + Aura* aura = holder->CreateAura(spellproto, SpellEffectIndex(i), NULL, (Unit*)this, NULL, NULL); | |
| if (!damage[i]) | |
| damage[i] = aura->GetModifier()->m_amount; | |
| aura->SetLoadedState(damage[i], periodicTime[i]); | |
| - holder->AddAura(aura, SpellEffectIndex(i)); | |
| } | |
| if (!holder->IsEmptyHolder()) | |
| @@ -3073,8 +3072,7 @@ bool Pet::ReapplyScalingAura(SpellAuraHolder* holder, SpellEntry const *spellpro | |
| RemoveAura(oldaura, AURA_REMOVE_BY_STACK); | |
| } | |
| - Aura* aura = CreateAura(spellproto, index, &basePoints, holder, this, this, NULL); | |
| - holder->AddAura(aura, index); | |
| + Aura* aura = holder->CreateAura(spellproto, index, &basePoints, this, this, NULL); | |
| holder->SetAuraDuration(aura->GetAuraMaxDuration()); | |
| AddAuraToModList(aura); | |
| aura->ApplyModifier(true,true); | |
| diff --git a/src/game/Player.cpp b/src/game/Player.cpp | |
| index 086d2ca..3e1bd0c 100644 | |
| --- a/src/game/Player.cpp | |
| +++ b/src/game/Player.cpp | |
| @@ -16791,12 +16791,12 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff) | |
| if ((effIndexMask & (1 << i)) == 0) | |
| continue; | |
| - Aura* aura = CreateAura(spellproto, SpellEffectIndex(i), NULL, holder, this); | |
| + Aura* aura = holder->CreateAura(spellproto, SpellEffectIndex(i), NULL, this, NULL, NULL); | |
| + | |
| if (!damage[i]) | |
| damage[i] = aura->GetModifier()->m_amount; | |
| aura->SetLoadedState(damage[i], periodicTime[i]); | |
| - holder->AddAura(aura, SpellEffectIndex(i)); | |
| } | |
| if (!holder->IsEmptyHolder()) | |
| diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp | |
| index b161c40..3533ce8 100644 | |
| --- a/src/game/SpellAuras.cpp | |
| +++ b/src/game/SpellAuras.cpp | |
| @@ -372,7 +372,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]= | |
| static AuraType const frozenAuraTypes[] = { SPELL_AURA_MOD_ROOT, SPELL_AURA_MOD_STUN, SPELL_AURA_NONE }; | |
| -Aura::Aura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster, Item* castItem) : | |
| +Aura::Aura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder* holder, Unit *target, Unit *caster, Item* castItem) : | |
| m_periodicTimer(0), m_periodicTick(0), m_removeMode(AURA_REMOVE_BY_DEFAULT), | |
| m_effIndex(eff), m_positive(false), m_isPeriodic(false), m_isAreaAura(false), | |
| m_isPersistent(false), m_in_use(0), m_spellAuraHolder(holder) | |
| @@ -447,7 +447,7 @@ Aura::~Aura() | |
| { | |
| } | |
| -AreaAura::AreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, | |
| +AreaAura::AreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder* holder, Unit *target, | |
| Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, holder, target, caster, castItem) | |
| { | |
| m_isAreaAura = true; | |
| @@ -501,7 +501,7 @@ AreaAura::~AreaAura() | |
| { | |
| } | |
| -PersistentAreaAura::PersistentAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, | |
| +PersistentAreaAura::PersistentAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder* holder, Unit *target, | |
| Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, holder, target, caster, castItem) | |
| { | |
| m_isPersistent = true; | |
| @@ -511,7 +511,7 @@ PersistentAreaAura::~PersistentAreaAura() | |
| { | |
| } | |
| -SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, | |
| +SingleEnemyTargetAura::SingleEnemyTargetAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder* holder, Unit *target, | |
| Unit *caster, Item* castItem) : Aura(spellproto, eff, currentBasePoints, holder, target, caster, castItem) | |
| { | |
| if (caster) | |
| @@ -534,19 +534,49 @@ Unit* SingleEnemyTargetAura::GetTriggerTarget() const | |
| return ObjectAccessor::GetUnit(*(m_spellAuraHolder->GetTarget()), m_castersTargetGuid); | |
| } | |
| -Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster, Item* castItem) | |
| +Aura* SpellAuraHolder::CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, Unit *target, Unit *caster, Item* castItem) | |
| { | |
| - if (IsAreaAuraEffect(spellproto->Effect[eff])) | |
| - return new AreaAura(spellproto, eff, currentBasePoints, holder, target, caster, castItem); | |
| - | |
| + RemoveAura(eff); | |
| uint32 triggeredSpellId = spellproto->EffectTriggerSpell[eff]; | |
| - | |
| - if (SpellEntry const* triggeredSpellInfo = sSpellStore.LookupEntry(triggeredSpellId)) | |
| + if (IsAreaAuraEffect(spellproto->Effect[eff])) | |
| + { | |
| + AddAura((Aura)AreaAura(spellproto, eff, currentBasePoints, this, target, caster, castItem), eff); | |
| + return GetAuraByEffectIndex(eff); | |
| + } | |
| + else if (SpellEntry const* triggeredSpellInfo = sSpellStore.LookupEntry(triggeredSpellId)) | |
| + { | |
| for (int i = 0; i < MAX_EFFECT_INDEX; ++i) | |
| + { | |
| if (triggeredSpellInfo->EffectImplicitTargetA[i] == TARGET_SINGLE_ENEMY) | |
| - return new SingleEnemyTargetAura(spellproto, eff, currentBasePoints, holder, target, caster, castItem); | |
| + { | |
| + AddAura((Aura)SingleEnemyTargetAura(spellproto, eff, currentBasePoints, this, target, caster, castItem),eff); | |
| + return GetAuraByEffectIndex(eff); | |
| + } | |
| + } | |
| + } | |
| + // else - normal aura | |
| - return new Aura(spellproto, eff, currentBasePoints, holder, target, caster, castItem); | |
| + AddAura(Aura(spellproto, eff, currentBasePoints, this, target, caster, castItem),eff); | |
| + | |
| + return GetAuraByEffectIndex(eff); | |
| +} | |
| + | |
| +PersistentAreaAura* SpellAuraHolder::CreatePersistentAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, Unit* target, Unit* caster, Item* castItem) | |
| +{ | |
| + RemoveAura(eff); | |
| + | |
| + AddAura((Aura)PersistentAreaAura(spellproto, eff, currentBasePoints, this, target, caster, castItem),eff); | |
| + | |
| + return ((PersistentAreaAura*)GetAuraByEffectIndex(eff)); | |
| +} | |
| + | |
| +AreaAura* SpellAuraHolder::CreateAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, Unit* target, Unit* caster, Item* castItem) | |
| +{ | |
| + RemoveAura(eff); | |
| + | |
| + AddAura((Aura)AreaAura(spellproto, eff, currentBasePoints, this, target, caster, castItem),eff); | |
| + | |
| + return ((AreaAura*)GetAuraByEffectIndex(eff)); | |
| } | |
| SpellAuraHolder* CreateSpellAuraHolder(SpellEntry const* spellproto, Unit *target, WorldObject *caster, Item *castItem) | |
| @@ -779,8 +809,7 @@ void AreaAura::Update(uint32 diff) | |
| holder->SetAuraDuration(GetAuraDuration()); | |
| - AreaAura *aur = new AreaAura(actualSpellInfo, m_effIndex, &actualBasePoints, holder, (*tIter), caster, NULL); | |
| - holder->AddAura(aur, m_effIndex); | |
| + AreaAura* aur = holder->CreateAreaAura(actualSpellInfo, m_effIndex, &actualBasePoints, (*tIter), caster, NULL); | |
| if (addedToExisting) | |
| { | |
| @@ -9765,7 +9794,7 @@ void Aura::HandleAuraStopNaturalManaRegen(bool apply, bool Real) | |
| bool Aura::IsLastAuraOnHolder() | |
| { | |
| for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) | |
| - if (i != GetEffIndex() && GetHolder()->m_auras[i]) | |
| + if (i != GetEffIndex() && GetHolder()->GetAuraByEffectIndex(SpellEffectIndex(i))) | |
| return false; | |
| return true; | |
| } | |
| @@ -9784,6 +9813,7 @@ m_permanent(false), m_isRemovedOnShapeLost(true), m_deleted(false), m_in_use(0) | |
| { | |
| MANGOS_ASSERT(target); | |
| MANGOS_ASSERT(spellproto && spellproto == sSpellStore.LookupEntry( spellproto->Id ) && "`info` must be pointer to sSpellStore element"); | |
| + m_aurasStorage.clear(); | |
| if (!caster) | |
| m_casterGuid = target->GetObjectGuid(); | |
| @@ -9842,18 +9872,29 @@ m_permanent(false), m_isRemovedOnShapeLost(true), m_deleted(false), m_in_use(0) | |
| RemoveAura(SpellEffectIndex(i)); | |
| } | |
| -void SpellAuraHolder::AddAura(Aura *aura, SpellEffectIndex index) | |
| +void SpellAuraHolder::AddAura(Aura aura, SpellEffectIndex index) | |
| { | |
| - m_auras[index] = aura; | |
| + RemoveAura(index); | |
| + m_aurasStorage.insert(std::make_pair(index,aura)); | |
| m_auraFlags |= (1 << index); | |
| } | |
| void SpellAuraHolder::RemoveAura(SpellEffectIndex index) | |
| { | |
| - m_auras[index] = (Aura*)NULL; | |
| + if (m_aurasStorage.find(index) != m_aurasStorage.end()) | |
| + m_aurasStorage.erase(index); | |
| m_auraFlags &= ~(1 << index); | |
| } | |
| +Aura* SpellAuraHolder::GetAuraByEffectIndex(SpellEffectIndex index) | |
| +{ | |
| + AuraStorage::iterator itr = m_aurasStorage.find(index); | |
| + if (itr != m_aurasStorage.end()) | |
| + return &itr->second; | |
| + else | |
| + return (Aura*)NULL; | |
| +} | |
| + | |
| void SpellAuraHolder::ApplyAuraModifiers(bool apply, bool real) | |
| { | |
| for (int32 i = 0; i < MAX_EFFECT_INDEX && !IsDeleted(); ++i) | |
| @@ -9904,7 +9945,7 @@ void SpellAuraHolder::_AddSpellAuraHolder() | |
| uint8 flags = 0; | |
| for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) | |
| { | |
| - if (m_auras[i]) | |
| + if (GetAuraByEffectIndex(SpellEffectIndex(i))) | |
| flags |= (1 << i); | |
| } | |
| flags |= ((GetCasterGuid() == GetTarget()->GetObjectGuid()) ? AFLAG_NOT_CASTER : AFLAG_NONE) | ((GetSpellMaxDuration(m_spellProto) > 0 && !(m_spellProto->AttributesEx5 & SPELL_ATTR_EX5_NO_DURATION)) ? AFLAG_DURATION : AFLAG_NONE) | (IsPositive() ? AFLAG_POSITIVE : AFLAG_NEGATIVE); | |
| @@ -10177,7 +10218,7 @@ void SpellAuraHolder::SetStackAmount(uint32 stackAmount) | |
| for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) | |
| { | |
| - if (Aura *aur = m_auras[i]) | |
| + if (Aura* aur = GetAuraByEffectIndex(SpellEffectIndex(i))) | |
| { | |
| int32 bp = aur->GetBasePoints(); | |
| int32 amount = m_stackAmount * caster->CalculateSpellDamage(target, m_spellProto, SpellEffectIndex(i), &bp); | |
| @@ -10227,7 +10268,7 @@ Unit* SpellAuraHolder::GetCaster() const | |
| return ObjectAccessor::GetUnit(*m_target, m_casterGuid);// player will search at any maps | |
| } | |
| -bool SpellAuraHolder::IsWeaponBuffCoexistableWith(SpellAuraHolder const* ref) const | |
| +bool SpellAuraHolder::IsWeaponBuffCoexistableWith(SpellAuraHolder const* ref) | |
| { | |
| // only item casted spells | |
| if (!GetCastItemGuid()) | |
| @@ -11298,10 +11339,6 @@ void SpellAuraHolder::HandleSpellSpecificBoostsForward(bool apply) | |
| SpellAuraHolder::~SpellAuraHolder() | |
| { | |
| - // note: auras in delete list won't be affected since they clear themselves from holder when adding to deletedAuraslist | |
| - for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) | |
| - if (Aura *aur = m_auras[i]) | |
| - delete aur; | |
| } | |
| void SpellAuraHolder::Update(uint32 diff) | |
| @@ -11340,7 +11377,7 @@ void SpellAuraHolder::Update(uint32 diff) | |
| } | |
| for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) | |
| - if (Aura *aura = m_auras[i]) | |
| + if (Aura *aura = GetAuraByEffectIndex(SpellEffectIndex(i))) | |
| aura->UpdateAura(diff); | |
| // Channeled aura required check distance from caster | |
| @@ -11394,59 +11431,59 @@ void SpellAuraHolder::SetAuraMaxDuration(int32 duration) | |
| SetAuraFlags(GetAuraFlags() & ~AFLAG_DURATION); | |
| } | |
| -bool SpellAuraHolder::HasMechanic(uint32 mechanic) const | |
| +bool SpellAuraHolder::HasMechanic(uint32 mechanic) | |
| { | |
| if (mechanic == m_spellProto->Mechanic) | |
| return true; | |
| for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) | |
| - if (m_auras[i] && m_spellProto->EffectMechanic[i] == mechanic) | |
| + if (GetAuraByEffectIndex(SpellEffectIndex(i)) && m_spellProto->EffectMechanic[i] == mechanic) | |
| return true; | |
| return false; | |
| } | |
| -bool SpellAuraHolder::HasMechanicMask(uint32 mechanicMask) const | |
| +bool SpellAuraHolder::HasMechanicMask(uint32 mechanicMask) | |
| { | |
| if (mechanicMask & (1 << (m_spellProto->Mechanic - 1))) | |
| return true; | |
| for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) | |
| - if (m_auras[i] && m_spellProto->EffectMechanic[i] && ((1 << (m_spellProto->EffectMechanic[i] -1)) & mechanicMask)) | |
| + if (GetAuraByEffectIndex(SpellEffectIndex(i)) && m_spellProto->EffectMechanic[i] && ((1 << (m_spellProto->EffectMechanic[i] -1)) & mechanicMask)) | |
| return true; | |
| return false; | |
| } | |
| -bool SpellAuraHolder::IsPersistent() const | |
| +bool SpellAuraHolder::IsPersistent() | |
| { | |
| for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) | |
| - if (Aura *aur = m_auras[i]) | |
| + if (Aura *aur = GetAuraByEffectIndex(SpellEffectIndex(i))) | |
| if (aur->IsPersistent()) | |
| return true; | |
| return false; | |
| } | |
| -bool SpellAuraHolder::IsAreaAura() const | |
| +bool SpellAuraHolder::IsAreaAura() | |
| { | |
| for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) | |
| - if (Aura *aur = m_auras[i]) | |
| + if (Aura *aur = GetAuraByEffectIndex(SpellEffectIndex(i))) | |
| if (aur->IsAreaAura()) | |
| return true; | |
| return false; | |
| } | |
| -bool SpellAuraHolder::IsPositive() const | |
| +bool SpellAuraHolder::IsPositive() | |
| { | |
| for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) | |
| - if (Aura *aur = m_auras[i]) | |
| + if (Aura *aur = GetAuraByEffectIndex(SpellEffectIndex(i))) | |
| if (!aur->IsPositive()) | |
| return false; | |
| return true; | |
| } | |
| -bool SpellAuraHolder::IsEmptyHolder() const | |
| +bool SpellAuraHolder::IsEmptyHolder() | |
| { | |
| for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) | |
| - if (m_auras[i]) | |
| + if (GetAuraByEffectIndex(SpellEffectIndex(i))) | |
| return false; | |
| return true; | |
| } | |
| diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h | |
| index ab52b72..0d3b080 100644 | |
| --- a/src/game/SpellAuras.h | |
| +++ b/src/game/SpellAuras.h | |
| @@ -37,6 +37,10 @@ struct ProcTriggerSpell; | |
| // forward decl | |
| class Aura; | |
| +class AreaAura; | |
| +class PersistentAreaAura; | |
| + | |
| +typedef std::map<SpellEffectIndex,Aura> AuraStorage; | |
| // internal helper | |
| struct ReapplyAffectedPassiveAurasHelper; | |
| @@ -45,9 +49,11 @@ class MANGOS_DLL_SPEC SpellAuraHolder | |
| { | |
| public: | |
| SpellAuraHolder (SpellEntry const* spellproto, Unit *target, WorldObject *caster, Item *castItem); | |
| - Aura* m_auras[MAX_EFFECT_INDEX]; | |
| - void AddAura(Aura *aura, SpellEffectIndex index); | |
| + Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32* currentBasePoints, Unit *target, Unit *caster, Item* castItem); | |
| + PersistentAreaAura* CreatePersistentAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL); | |
| + AreaAura* CreateAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, Unit *target, Unit *caster = NULL, Item* castItem = NULL); | |
| + | |
| void RemoveAura(SpellEffectIndex index); | |
| void ApplyAuraModifiers(bool apply, bool real = false); | |
| void _AddSpellAuraHolder(); | |
| @@ -65,7 +71,7 @@ class MANGOS_DLL_SPEC SpellAuraHolder | |
| void SetStackAmount(uint32 stackAmount); | |
| bool ModStackAmount(int32 num); // return true if last charge dropped | |
| - Aura* GetAuraByEffectIndex(SpellEffectIndex index) const { return m_auras[index]; } | |
| + Aura* GetAuraByEffectIndex(SpellEffectIndex index); | |
| uint32 GetId() const { return m_spellProto->Id; } | |
| SpellEntry const* GetSpellProto() const { return m_spellProto; } | |
| @@ -81,15 +87,15 @@ class MANGOS_DLL_SPEC SpellAuraHolder | |
| void SetPermanent(bool permanent) { m_permanent = permanent; } | |
| bool IsPassive() const { return m_isPassive; } | |
| bool IsDeathPersistent() const { return m_isDeathPersist; } | |
| - bool IsPersistent() const; | |
| - bool IsPositive() const; | |
| - bool IsAreaAura() const; // if one from auras of holder applied as area aura | |
| - bool IsWeaponBuffCoexistableWith(SpellAuraHolder const* ref) const; | |
| + bool IsPersistent(); | |
| + bool IsPositive(); | |
| + bool IsAreaAura(); // if one from auras of holder applied as area aura | |
| + bool IsWeaponBuffCoexistableWith(SpellAuraHolder const* ref); | |
| bool IsNeedVisibleSlot(Unit const* caster) const; | |
| bool IsRemovedOnShapeLost() const { return m_isRemovedOnShapeLost; } | |
| bool IsInUse() const { return m_in_use;} | |
| bool IsDeleted() const { return m_deleted;} | |
| - bool IsEmptyHolder() const; | |
| + bool IsEmptyHolder(); | |
| void SetDeleted() { m_deleted = true; } | |
| @@ -157,11 +163,13 @@ class MANGOS_DLL_SPEC SpellAuraHolder | |
| SetAuraDuration(duration); | |
| } | |
| - bool HasMechanic(uint32 mechanic) const; | |
| - bool HasMechanicMask(uint32 mechanicMask) const; | |
| + bool HasMechanic(uint32 mechanic); | |
| + bool HasMechanicMask(uint32 mechanicMask); | |
| ~SpellAuraHolder(); | |
| + | |
| private: | |
| + void AddAura(Aura aura, SpellEffectIndex index); | |
| Unit* m_target; | |
| ObjectGuid m_casterGuid; | |
| ObjectGuid m_castItemGuid; // it is NOT safe to keep a pointer to the item because it may get deleted | |
| @@ -181,6 +189,8 @@ class MANGOS_DLL_SPEC SpellAuraHolder | |
| AuraRemoveMode m_removeMode:8; // Store info for know remove aura reason | |
| DiminishingGroup m_AuraDRGroup:8; // Diminishing | |
| + AuraStorage m_aurasStorage; // Auras storage | |
| + | |
| bool m_permanent:1; | |
| bool m_isPassive:1; | |
| bool m_isDeathPersist:1; | |
| @@ -207,8 +217,8 @@ typedef void(Aura::*pAuraHandler)(bool Apply, bool Real); | |
| class MANGOS_DLL_SPEC Aura | |
| { | |
| + friend class SpellAuraHolder; | |
| friend struct ReapplyAffectedPassiveAurasHelper; | |
| - MANGOS_DLL_SPEC friend Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster, Item* castItem); | |
| public: | |
| //aura handlers | |
| @@ -458,15 +468,14 @@ class MANGOS_DLL_SPEC Aura | |
| bool isAffectedOnSpell(SpellEntry const *spell) const; | |
| bool CanProcFrom(SpellEntry const *spell, uint32 procFlag, uint32 EventProcEx, uint32 procEx, bool active, bool useClassMask) const; | |
| - //SpellAuraHolder const* GetHolder() const { return m_spellHolder; } | |
| - SpellAuraHolder* GetHolder() { return m_spellAuraHolder; } | |
| + SpellAuraHolder* GetHolder() { return m_spellAuraHolder; } | |
| SpellAuraHolder* const GetHolder() const { return m_spellAuraHolder; } | |
| bool IsLastAuraOnHolder(); | |
| bool HasMechanic(uint32 mechanic) const; | |
| protected: | |
| - Aura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL); | |
| + Aura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder* holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL); | |
| // must be called only from Aura::UpdateAura | |
| virtual void Update(uint32 diff); | |
| @@ -500,7 +509,7 @@ class MANGOS_DLL_SPEC Aura | |
| bool IsEffectStacking(); | |
| - SpellAuraHolder* const m_spellAuraHolder; | |
| + SpellAuraHolder* m_spellAuraHolder; | |
| private: | |
| void ReapplyAffectedPassiveAuras(Unit* target, bool owner_mode); | |
| }; | |
| @@ -508,7 +517,7 @@ class MANGOS_DLL_SPEC Aura | |
| class MANGOS_DLL_SPEC AreaAura : public Aura | |
| { | |
| public: | |
| - AreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL); | |
| + AreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder* holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL); | |
| ~AreaAura(); | |
| protected: | |
| void Update(uint32 diff); | |
| @@ -520,7 +529,7 @@ class MANGOS_DLL_SPEC AreaAura : public Aura | |
| class MANGOS_DLL_SPEC PersistentAreaAura : public Aura | |
| { | |
| public: | |
| - PersistentAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL); | |
| + PersistentAreaAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder* holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL); | |
| ~PersistentAreaAura(); | |
| protected: | |
| void Update(uint32 diff); | |
| @@ -528,17 +537,16 @@ class MANGOS_DLL_SPEC PersistentAreaAura : public Aura | |
| class MANGOS_DLL_SPEC SingleEnemyTargetAura : public Aura | |
| { | |
| - MANGOS_DLL_SPEC friend Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster, Item* castItem); | |
| + friend class SpellAuraHolder; | |
| public: | |
| ~SingleEnemyTargetAura(); | |
| Unit* GetTriggerTarget() const; | |
| protected: | |
| - SingleEnemyTargetAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL); | |
| + SingleEnemyTargetAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder* holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL); | |
| ObjectGuid m_castersTargetGuid; | |
| }; | |
| -MANGOS_DLL_SPEC Aura* CreateAura(SpellEntry const* spellproto, SpellEffectIndex eff, int32 *currentBasePoints, SpellAuraHolder *holder, Unit *target, Unit *caster = NULL, Item* castItem = NULL); | |
| MANGOS_DLL_SPEC SpellAuraHolder* CreateSpellAuraHolder(SpellEntry const* spellproto, Unit *target, WorldObject *caster, Item *castItem = NULL); | |
| #endif | |
| diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp | |
| index 2468eb9..994dcbd 100644 | |
| --- a/src/game/SpellEffects.cpp | |
| +++ b/src/game/SpellEffects.cpp | |
| @@ -4485,7 +4485,7 @@ void Spell::EffectApplyAura(SpellEffectIndex eff_idx) | |
| DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Spell: Aura is: %u", m_spellInfo->EffectApplyAuraName[eff_idx]); | |
| - Aura* aur = CreateAura(m_spellInfo, eff_idx, &m_currentBasePoints[eff_idx], m_spellAuraHolder, unitTarget, caster, m_CastItem); | |
| + Aura* aur = m_spellAuraHolder->CreateAura(m_spellInfo, eff_idx, &m_currentBasePoints[eff_idx], unitTarget, caster, m_CastItem); | |
| // Now Reduce spell duration using data received at spell hit | |
| int32 duration = aur->GetAuraMaxDuration(); | |
| @@ -4510,8 +4510,6 @@ void Spell::EffectApplyAura(SpellEffectIndex eff_idx) | |
| m_spellAuraHolder->SetAuraMaxDuration(duration); | |
| m_spellAuraHolder->SetAuraDuration(duration); | |
| } | |
| - | |
| - m_spellAuraHolder->AddAura(aur, eff_idx); | |
| } | |
| void Spell::EffectUnlearnSpecialization(SpellEffectIndex eff_idx) | |
| @@ -5341,8 +5339,7 @@ void Spell::EffectApplyAreaAura(SpellEffectIndex eff_idx) | |
| if (!unitTarget->isAlive()) | |
| return; | |
| - AreaAura* Aur = new AreaAura(m_spellInfo, eff_idx, &m_currentBasePoints[eff_idx], m_spellAuraHolder, unitTarget, m_caster, m_CastItem); | |
| - m_spellAuraHolder->AddAura(Aur, eff_idx); | |
| + m_spellAuraHolder->CreateAreaAura(m_spellInfo, eff_idx, &m_currentBasePoints[eff_idx], unitTarget, m_caster, m_CastItem); | |
| } | |
| void Spell::EffectSummonType(SpellEffectIndex eff_idx) | |
| diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp | |
| index 76ccc5b..fa73cb5 100644 | |
| --- a/src/game/Unit.cpp | |
| +++ b/src/game/Unit.cpp | |
| @@ -4726,7 +4726,7 @@ void Unit::RemoveAura(uint32 spellId, SpellEffectIndex effindex, Aura* except) | |
| SpellAuraHolderBounds spair = GetSpellAuraHolderBounds(spellId); | |
| for(SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second; ) | |
| { | |
| - Aura *aur = iter->second->m_auras[effindex]; | |
| + Aura *aur = iter->second->GetAuraByEffectIndex(effindex); | |
| if (aur && aur != except) | |
| { | |
| RemoveSingleAuraFromSpellAuraHolder(iter->second, effindex); | |
| @@ -4776,7 +4776,7 @@ void Unit::RemoveSingleAuraFromSpellAuraHolder(uint32 spellId, SpellEffectIndex | |
| SpellAuraHolderBounds spair = GetSpellAuraHolderBounds(spellId); | |
| for(SpellAuraHolderMap::iterator iter = spair.first; iter != spair.second; ) | |
| { | |
| - Aura *aur = iter->second->m_auras[effindex]; | |
| + Aura* aur = iter->second->GetAuraByEffectIndex(effindex); | |
| if (aur && aur->GetCasterGuid() == casterGuid) | |
| { | |
| RemoveSingleAuraFromSpellAuraHolder(iter->second, effindex, mode); | |
| @@ -4905,14 +4905,11 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, ObjectGuid casterGuid, U | |
| int32 basePoints = aur->GetBasePoints(); | |
| // construct the new aura for the attacker - will never return NULL, it's just a wrapper for | |
| // some different constructors | |
| - Aura * new_aur = CreateAura(spellProto, aur->GetEffIndex(), &basePoints, new_holder, stealer, this); | |
| + Aura* new_aur = new_holder->CreateAura(spellProto, aur->GetEffIndex(), &basePoints, stealer, this, NULL); | |
| // set periodic to do at least one tick (for case when original aura has been at last tick preparing) | |
| int32 periodic = aur->GetModifier()->periodictime; | |
| new_aur->GetModifier()->periodictime = periodic < new_max_dur ? periodic : new_max_dur; | |
| - | |
| - // add the new aura to stealer | |
| - new_holder->AddAura(new_aur, new_aur->GetEffIndex()); | |
| } | |
| if (holder->GetSpellProto()->AttributesEx7 & SPELL_ATTR_EX7_DISPEL_CHARGES) | |
| @@ -5158,7 +5155,7 @@ void Unit::RemoveSpellAuraHolder(SpellAuraHolder *holder, AuraRemoveMode mode) | |
| for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) | |
| { | |
| - if (Aura *aura = holder->m_auras[i]) | |
| + if (Aura *aura = holder->GetAuraByEffectIndex(SpellEffectIndex(i))) | |
| RemoveAura(aura, mode); | |
| } | |
| @@ -7113,10 +7110,10 @@ uint32 Unit::SpellDamageBonusDone(Unit *pVictim, SpellEntry const *spellProto, u | |
| else if (spellProto->SpellFamilyFlags.test<CF_PRIEST_SHADOW_WORD_DEATH_TARGET>()) | |
| { | |
| // Glyph of Shadow word: Death | |
| - if (SpellAuraHolder const* glyph = GetSpellAuraHolder(55682)) | |
| + if (SpellAuraHolder* const glyph = GetSpellAuraHolder(55682)) | |
| { | |
| - Aura const* hpPct = glyph->GetAuraByEffectIndex(EFFECT_INDEX_0); | |
| - Aura const* dmPct = glyph->GetAuraByEffectIndex(EFFECT_INDEX_1); | |
| + Aura* hpPct = glyph->GetAuraByEffectIndex(EFFECT_INDEX_0); | |
| + Aura* dmPct = glyph->GetAuraByEffectIndex(EFFECT_INDEX_1); | |
| if (hpPct && dmPct && pVictim->GetHealth() * 100 <= pVictim->GetMaxHealth() * hpPct->GetModifier()->m_amount) | |
| DoneTotalMod *= (dmPct->GetModifier()->m_amount + 100.0f) / 100.0f; | |
| } | |
| @@ -12098,10 +12095,22 @@ void Unit::CleanupDeletedAuras() | |
| delete *iter; | |
| m_deletedHolders.clear(); | |
| - // really delete auras "deleted" while processing its ApplyModify code | |
| +/* // really delete auras "deleted" while processing its ApplyModify code | |
| for(AuraList::const_iterator itr = m_deletedAuras.begin(); itr != m_deletedAuras.end(); ++itr) | |
| - delete *itr; | |
| + { | |
| + Aura* aura = *itr; | |
| + if (!aura) | |
| + continue; | |
| + | |
| + SpellAuraHolder* holder = aura->GetHolder(); | |
| + | |
| + if (!holder) // now this impossible. need ASSERT in this. | |
| + continue; | |
| + | |
| + holder->RemoveAura(aura->GetEffIndex()); | |
| + } | |
| m_deletedAuras.clear(); | |
| +*/ | |
| } | |
| bool Unit::CheckAndIncreaseCastCounter() | |
| @@ -12154,8 +12163,7 @@ void Unit::_AddAura(uint32 spellID, uint32 duration) | |
| spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA || | |
| spellInfo->Effect[i] == SPELL_EFFECT_PERSISTENT_AREA_AURA ) | |
| { | |
| - Aura *aura = CreateAura(spellInfo, SpellEffectIndex(i), NULL, holder, this); | |
| - holder->AddAura(aura, SpellEffectIndex(i)); | |
| + Aura *aura = holder->CreateAura(spellInfo, SpellEffectIndex(i), NULL, this, NULL, NULL); | |
| holder->SetAuraDuration(duration); | |
| DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "Manually adding aura of spell %u, index %u, duration %u ms", spellID, i, duration); | |
| } | |
| diff --git a/src/game/UnitAuraProcHandler.cpp b/src/game/UnitAuraProcHandler.cpp | |
| index e2a9e02..99ee2b7 100644 | |
| --- a/src/game/UnitAuraProcHandler.cpp | |
| +++ b/src/game/UnitAuraProcHandler.cpp | |
| @@ -4671,8 +4671,7 @@ SpellAuraProcResult Unit::HandleMendingAuraProc( Unit* /*pVictim*/, uint32 /*dam | |
| continue; | |
| int32 basePoints = aur->GetBasePoints(); | |
| - Aura * new_aur = CreateAura(spellProto, aur->GetEffIndex(), &basePoints, new_holder, target, caster); | |
| - new_holder->AddAura(new_aur, new_aur->GetEffIndex()); | |
| + new_holder->CreateAura(spellProto, aur->GetEffIndex(), &basePoints, target, caster, NULL); | |
| } | |
| new_holder->SetAuraCharges(jumps, false); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment