From b47a282850d4989a5535c10acb2989205b4fc9e8 Mon Sep 17 00:00:00 2001 From: QAston Date: Mon, 9 Mar 2009 20:22:52 +0100 Subject: *Allow lifebloom stack from 2 different casters. --HG-- branch : trunk --- src/game/Unit.cpp | 83 +++++++++++++++++++++++++------------------------------ 1 file changed, 37 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 6c75903072f..7ccdb5dce75 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -4154,59 +4154,50 @@ bool Unit::AddAura(Aura *Aur) SpellEntry const* aurSpellInfo = Aur->GetSpellProto(); spellEffectPair spair = spellEffectPair(Aur->GetId(), Aur->GetEffIndex()); - AuraMap::iterator i = m_Auras.find( spair ); - // take out same spell - if (i != m_Auras.end()) + // passive and persistent auras can stack with themselves any number of times + if (!Aur->IsPassive() && !Aur->IsPersistent()) { - // passive and persistent auras can stack with themselves any number of times - if (!Aur->IsPassive() && !Aur->IsPersistent()) + // if StackAmount==0 not allow auras from same caster + for(AuraMap::iterator i2 = m_Auras.lower_bound(spair); i2 != m_Auras.upper_bound(spair); ++i2) { - // replace aura if next will > spell StackAmount - if(aurSpellInfo->StackAmount) + if(i2->second->GetCasterGUID()==Aur->GetCasterGUID()) { - Aur->SetStackAmount(i->second->GetStackAmount()); - if(Aur->GetStackAmount() < aurSpellInfo->StackAmount) - Aur->SetStackAmount(Aur->GetStackAmount()+1); - RemoveAura(i,AURA_REMOVE_BY_STACK); - } - // if StackAmount==0 not allow auras from same caster - else - { - for(AuraMap::iterator i2 = m_Auras.lower_bound(spair); i2 != m_Auras.upper_bound(spair); ++i2) + // replace aura if next will > spell StackAmount + if(aurSpellInfo->StackAmount) { - if(i2->second->GetCasterGUID()==Aur->GetCasterGUID()) - { - // can be only single (this check done at _each_ aura add - RemoveAura(i2,AURA_REMOVE_BY_STACK); - break; - } - - bool stop = false; - switch(aurSpellInfo->EffectApplyAuraName[Aur->GetEffIndex()]) - { - // DoT/HoT/etc - case SPELL_AURA_PERIODIC_DAMAGE: // allow stack - case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: - case SPELL_AURA_PERIODIC_LEECH: - case SPELL_AURA_PERIODIC_HEAL: - case SPELL_AURA_OBS_MOD_HEALTH: - case SPELL_AURA_PERIODIC_MANA_LEECH: - case SPELL_AURA_PERIODIC_ENERGIZE: - case SPELL_AURA_OBS_MOD_MANA: - case SPELL_AURA_POWER_BURN_MANA: - break; - default: // not allow - // can be only single (this check done at _each_ aura add - RemoveAura(i2,AURA_REMOVE_BY_STACK); - stop = true; - break; - } - - if(stop) - break; + Aur->SetStackAmount(i2->second->GetStackAmount()); + if(Aur->GetStackAmount() < aurSpellInfo->StackAmount) + Aur->SetStackAmount(Aur->GetStackAmount()+1); } + // can be only single (this check done at _each_ aura add + RemoveAura(i2,AURA_REMOVE_BY_STACK); + break; + } + + bool stop = false; + switch(aurSpellInfo->EffectApplyAuraName[Aur->GetEffIndex()]) + { + // DoT/HoT/etc + case SPELL_AURA_PERIODIC_DAMAGE: // allow stack + case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: + case SPELL_AURA_PERIODIC_LEECH: + case SPELL_AURA_PERIODIC_HEAL: + case SPELL_AURA_OBS_MOD_HEALTH: + case SPELL_AURA_PERIODIC_MANA_LEECH: + case SPELL_AURA_PERIODIC_ENERGIZE: + case SPELL_AURA_OBS_MOD_MANA: + case SPELL_AURA_POWER_BURN_MANA: + break; + default: // not allow + // can be only single (this check done at _each_ aura add + RemoveAura(i2,AURA_REMOVE_BY_STACK); + stop = true; + break; } + + if(stop) + break; } } -- cgit v1.2.3 From 2cf3028e38e83d77a7aa7f71795d5b6bcc42f6e9 Mon Sep 17 00:00:00 2001 From: megamage Date: Mon, 9 Mar 2009 16:27:11 -0600 Subject: *Fix a crash caused by bindsight spells. --HG-- branch : trunk --- src/game/Map.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 847ec49c119..9c2521ca3bd 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -754,9 +754,11 @@ void Map::Update(const uint32 &t_diff) if(obj->isType(TYPEMASK_UNIT)) { if(!((Unit*)obj)->GetSharedVisionList().empty()) - for(SharedVisionList::const_iterator it = ((Unit*)obj)->GetSharedVisionList().begin(); it != ((Unit*)obj)->GetSharedVisionList().end(); ++it) + for(SharedVisionList::const_iterator itr = ((Unit*)obj)->GetSharedVisionList().begin(); itr != ((Unit*)obj)->GetSharedVisionList().end();) { - Trinity::PlayerRelocationNotifier notifier(**it); + Player *player = *itr; + ++itr; + Trinity::PlayerRelocationNotifier notifier(*player); VisitAll(obj->GetPositionX(), obj->GetPositionY(), World::GetMaxVisibleDistance(), notifier); notifier.Notify(); } -- cgit v1.2.3 From 1fe1d6c094aac00ab5f52dfb36759293d7561b33 Mon Sep 17 00:00:00 2001 From: QAston Date: Tue, 10 Mar 2009 00:34:03 +0100 Subject: Update stacking code. --HG-- branch : trunk --- src/game/SpellAuras.cpp | 5 ----- src/game/SpellMgr.cpp | 3 +++ src/game/Unit.cpp | 59 +++++++++++++++++++++++++------------------------ 3 files changed, 33 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 034370f9564..99adb488eb1 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -908,11 +908,6 @@ void Aura::_AddAura() void Aura::_RemoveAura() { - // Remove all triggered by aura spells vs unlimited duration - // except same aura replace case - if(m_removeMode!=AURA_REMOVE_BY_STACK) - CleanupTriggeredSpells(); - Unit* caster = GetCaster(); if(caster && IsPersistent()) diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index c01b3c69ca3..9320d26d88d 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -1400,6 +1400,9 @@ bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2, bool case SPELL_AURA_PERIODIC_ENERGIZE: case SPELL_AURA_PERIODIC_MANA_LEECH: case SPELL_AURA_PERIODIC_LEECH: + case SPELL_AURA_POWER_BURN_MANA: + case SPELL_AURA_OBS_MOD_MANA: + case SPELL_AURA_OBS_MOD_HEALTH: return false; default: break; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 7ccdb5dce75..d8a41165479 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -4158,7 +4158,6 @@ bool Unit::AddAura(Aura *Aur) // passive and persistent auras can stack with themselves any number of times if (!Aur->IsPassive() && !Aur->IsPersistent()) { - // if StackAmount==0 not allow auras from same caster for(AuraMap::iterator i2 = m_Auras.lower_bound(spair); i2 != m_Auras.upper_bound(spair); ++i2) { if(i2->second->GetCasterGUID()==Aur->GetCasterGUID()) @@ -4174,30 +4173,6 @@ bool Unit::AddAura(Aura *Aur) RemoveAura(i2,AURA_REMOVE_BY_STACK); break; } - - bool stop = false; - switch(aurSpellInfo->EffectApplyAuraName[Aur->GetEffIndex()]) - { - // DoT/HoT/etc - case SPELL_AURA_PERIODIC_DAMAGE: // allow stack - case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: - case SPELL_AURA_PERIODIC_LEECH: - case SPELL_AURA_PERIODIC_HEAL: - case SPELL_AURA_OBS_MOD_HEALTH: - case SPELL_AURA_PERIODIC_MANA_LEECH: - case SPELL_AURA_PERIODIC_ENERGIZE: - case SPELL_AURA_OBS_MOD_MANA: - case SPELL_AURA_POWER_BURN_MANA: - break; - default: // not allow - // can be only single (this check done at _each_ aura add - RemoveAura(i2,AURA_REMOVE_BY_STACK); - stop = true; - break; - } - - if(stop) - break; } } @@ -4350,8 +4325,6 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) uint32 i_effIndex = (*i).second->GetEffIndex(); - if(i_spellId == spellId) continue; - bool is_triggered_by_spell = false; // prevent triggered aura of removing aura that triggered it for(int j = 0; j < 3; ++j) @@ -4408,7 +4381,22 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur) sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for Unit::RemoveNoStackAurasDueToAura", i->second->GetId(), i->second->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex()); continue; } - RemoveAurasDueToSpell(i_spellId); + + // Remove all auras by aura caster + for (uint8 a=0;a<3;++a) + { + spellEffectPair spair = spellEffectPair((*i).second->GetId(), a); + for(AuraMap::iterator iter = m_Auras.lower_bound(spair); iter != m_Auras.upper_bound(spair);) + { + if(iter->second->GetCasterGUID()==(*i).second->GetCasterGUID()) + { + RemoveAura(iter, AURA_REMOVE_BY_STACK); + iter = m_Auras.lower_bound(spair); + } + else + ++iter; + } + } if( m_Auras.empty() ) break; @@ -4746,8 +4734,21 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) Aur->_RemoveAura(); - if(mode != AURA_REMOVE_BY_STACK) + bool stack = false; + spellEffectPair spair = spellEffectPair(Aur->GetId(), Aur->GetEffIndex()); + for(AuraMap::const_iterator itr = GetAuras().lower_bound(spair); itr != GetAuras().upper_bound(spair); ++itr) { + if (itr->second->GetCasterGUID()==GetGUID()) + { + stack = true; + } + } + if (!stack) + { + // Remove all triggered by aura spells vs unlimited duration + CleanupTriggeredSpells(); + + // Remove Linked Auras uint32 id = Aur->GetId(); if(spellmgr.GetSpellCustomAttr(id) & SPELL_ATTR_CU_LINK_REMOVE) { -- cgit v1.2.3 From 19af8f62adcf9b76a419ed49fee169733bbfcedf Mon Sep 17 00:00:00 2001 From: QAston Date: Tue, 10 Mar 2009 00:47:59 +0100 Subject: *Fix a typo. --HG-- branch : trunk --- src/game/SpellAuras.h | 2 +- src/game/Unit.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h index 249eb4b6762..be95c5245b7 100644 --- a/src/game/SpellAuras.h +++ b/src/game/SpellAuras.h @@ -271,6 +271,7 @@ class TRINITY_DLL_SPEC Aura bool IsDeathPersistent() const { return m_isDeathPersist; } bool IsRemovedOnShapeLost() const { return m_isRemovedOnShapeLost; } bool IsInUse() const { return m_in_use;} + void CleanupTriggeredSpells(); virtual void Update(uint32 diff); void ApplyModifier(bool apply, bool Real = false); @@ -339,7 +340,6 @@ class TRINITY_DLL_SPEC Aura int32 m_stackAmount; private: - void CleanupTriggeredSpells(); void SetAura(uint32 slot, bool remove) { m_target->SetUInt32Value(UNIT_FIELD_AURA + slot, remove ? 0 : GetId()); } void SetAuraFlag(uint32 slot, bool add); void SetAuraLevel(uint32 slot, uint32 level); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index d8a41165479..bb337ec9d7f 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -4746,7 +4746,7 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) if (!stack) { // Remove all triggered by aura spells vs unlimited duration - CleanupTriggeredSpells(); + Aur->CleanupTriggeredSpells(); // Remove Linked Auras uint32 id = Aur->GetId(); -- cgit v1.2.3