Skip to content

Commit

Permalink
[10519] Fix delaying spell with 2 or more persistent area auras and s…
Browse files Browse the repository at this point in the history
…tore ObjectGuid instead of Unit* on DynamicObject affected set
  • Loading branch information
Laise committed Sep 23, 2010
1 parent f168a15 commit 605c333
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
37 changes: 34 additions & 3 deletions src/game/DynamicObject.cpp
Expand Up @@ -147,9 +147,40 @@ void DynamicObject::Delete()
void DynamicObject::Delay(int32 delaytime)
{
m_aliveDuration -= delaytime;
for(AffectedSet::iterator iunit= m_affected.begin(); iunit != m_affected.end(); ++iunit)
if (*iunit)
(*iunit)->DelaySpellAuraHolder(m_spellId, delaytime, GetCasterGUID());
for(AffectedSet::iterator iter = m_affected.begin(); iter != m_affected.end(); )
{
Unit *target = GetMap()->GetUnit((*iter));
if (target)
{
SpellAuraHolder *holder = target->GetSpellAuraHolder(m_spellId, GetCasterGUID());
if (!holder)
{
++iter;
continue;
}

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])
{
foundAura = true;
break;
}
}

if (foundAura)
{
++iter;
continue;
}

target->DelaySpellAuraHolder(m_spellId, delaytime, GetCasterGUID());
++iter;
}
else
m_affected.erase(iter);
}
}

bool DynamicObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const
Expand Down
8 changes: 4 additions & 4 deletions src/game/DynamicObject.h
Expand Up @@ -28,7 +28,7 @@ struct SpellEntry;
class DynamicObject : public WorldObject
{
public:
typedef std::set<Unit*> AffectedSet;
typedef std::set<ObjectGuid> AffectedSet;
explicit DynamicObject();

void AddToWorld();
Expand All @@ -43,9 +43,9 @@ class DynamicObject : public WorldObject
uint64 GetCasterGUID() const { return GetUInt64Value(DYNAMICOBJECT_CASTER); }
Unit* GetCaster() const;
float GetRadius() const { return m_radius; }
bool IsAffecting(Unit *unit) const { return m_affected.find(unit) != m_affected.end(); }
void AddAffected(Unit *unit) { m_affected.insert(unit); }
void RemoveAffected(Unit *unit) { m_affected.erase(unit); }
bool IsAffecting(Unit *unit) const { return m_affected.find(unit->GetObjectGuid()) != m_affected.end(); }
void AddAffected(Unit *unit) { m_affected.insert(unit->GetObjectGuid()); }
void RemoveAffected(Unit *unit) { m_affected.erase(unit->GetObjectGuid()); }
void Delay(int32 delaytime);

bool IsHostileTo(Unit const* unit) const;
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 "10518"
#define REVISION_NR "10519"
#endif // __REVISION_NR_H__

0 comments on commit 605c333

Please sign in to comment.