Skip to content

Commit

Permalink
[12776] Fix AreaAura bug when low level grouped with high level Playe…
Browse files Browse the repository at this point in the history
…r. Thank to @tarwyn for his precious help and proposed patch.

http://cmangos.net/thread-6773.html
  • Loading branch information
Cyberium committed Nov 11, 2014
1 parent 7dd00af commit 43caf20
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/game/SpellAuras.cpp
Expand Up @@ -447,7 +447,8 @@ Aura::~Aura()
}

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)
Unit* caster, Item* castItem, uint32 originalRankSpellId)
: Aura(spellproto, eff, currentBasePoints, holder, target, caster, castItem), m_originalRankSpellId(originalRankSpellId)
{
m_isAreaAura = true;

Expand Down Expand Up @@ -748,7 +749,7 @@ void AreaAura::Update(uint32 diff)

holder->SetAuraDuration(GetAuraDuration());

AreaAura* aur = new AreaAura(actualSpellInfo, m_effIndex, &actualBasePoints, holder, (*tIter), caster, NULL);
AreaAura* aur = new AreaAura(actualSpellInfo, m_effIndex, &actualBasePoints, holder, (*tIter), caster, NULL, GetSpellProto()->Id);
holder->AddAura(aur, m_effIndex);

if (addedToExisting)
Expand All @@ -769,17 +770,19 @@ void AreaAura::Update(uint32 diff)
{
Unit* caster = GetCaster();
Unit* target = GetTarget();
uint32 originalRankSpellId = m_originalRankSpellId ? m_originalRankSpellId : GetId(); // caster may have different spell id if target has lower level

Aura::Update(diff);

// remove aura if out-of-range from caster (after teleport for example)
// or caster is isolated or caster no longer has the aura
// or caster is (no longer) friendly
bool needFriendly = (m_areaAuraType == AREA_AURA_ENEMY ? false : true);
if (!caster || caster->hasUnitState(UNIT_STAT_ISOLATED) ||
!caster->IsWithinDistInMap(target, m_radius) ||
!caster->HasAura(GetId(), GetEffIndex()) ||
caster->IsFriendlyTo(target) != needFriendly
if (!caster ||
caster->hasUnitState(UNIT_STAT_ISOLATED) ||
!caster->HasAura(originalRankSpellId, GetEffIndex()) ||
!caster->IsWithinDistInMap(target, m_radius) ||
caster->IsFriendlyTo(target) != needFriendly
)
{
target->RemoveSingleAuraFromSpellAuraHolder(GetId(), GetEffIndex(), GetCasterGuid());
Expand Down
3 changes: 2 additions & 1 deletion src/game/SpellAuras.h
Expand Up @@ -531,13 +531,14 @@ 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, uint32 originalRankSpellId = 0);
~AreaAura();
protected:
void Update(uint32 diff) override;
private:
float m_radius;
AreaAuraType m_areaAuraType;
uint32 m_originalRankSpellId;
};

class MANGOS_DLL_SPEC PersistentAreaAura : public Aura
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12775"
#define REVISION_NR "12776"
#endif // __REVISION_NR_H__

0 comments on commit 43caf20

Please sign in to comment.