aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegamage <none@none>2009-08-27 16:41:10 -0500
committermegamage <none@none>2009-08-27 16:41:10 -0500
commitee3c766bc95f05018e7de30d9a0768fd1246be87 (patch)
tree8f44200c1871fb0c9ab5b0a87e89295b33bee3e5
parentd8290149206a5f8a0a7d5d742fa6f2da280ff695 (diff)
*Use one dynobj to handle multiple aura effects.
--HG-- branch : trunk
-rw-r--r--src/game/DynamicObject.cpp13
-rw-r--r--src/game/DynamicObject.h8
-rw-r--r--src/game/GridNotifiersImpl.h21
-rw-r--r--src/game/Spell.cpp11
-rw-r--r--src/game/Spell.h2
-rw-r--r--src/game/SpellEffects.cpp12
-rw-r--r--src/game/Unit.cpp31
-rw-r--r--src/game/Unit.h1
8 files changed, 48 insertions, 51 deletions
diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp
index 7316bb58884..34b009bc7d4 100644
--- a/src/game/DynamicObject.cpp
+++ b/src/game/DynamicObject.cpp
@@ -53,7 +53,7 @@ void DynamicObject::RemoveFromWorld()
///- Remove the dynamicObject from the accessor
if(IsInWorld())
{
- if(m_effIndex == 4)
+ if(m_isWorldObject)
{
if(Unit *caster = GetCaster())
{
@@ -70,7 +70,7 @@ void DynamicObject::RemoveFromWorld()
}
}
-bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32 effIndex, float x, float y, float z, int32 duration, float radius )
+bool DynamicObject::Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32 effMask, float x, float y, float z, int32 duration, float radius, bool active)
{
SetMap(caster->GetMap());
@@ -78,7 +78,7 @@ bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32
if(!IsPositionValid())
{
- sLog.outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effIndex,GetPositionX(),GetPositionY());
+ sLog.outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effMask,GetPositionX(),GetPositionY());
return false;
}
@@ -97,12 +97,11 @@ bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32
m_aliveDuration = duration;
m_radius = radius;
- m_effIndex = effIndex;
+ m_effMask = effMask;
m_spellId = spellId;
m_updateTimer = 0;
- if(m_effIndex == 4)
- m_isWorldObject = true;
+ m_isWorldObject = active;
return true;
}
@@ -129,7 +128,7 @@ void DynamicObject::Update(uint32 p_time)
else
deleteThis = true;
- if(m_effIndex < 4)
+ if(m_effMask)
{
if(m_updateTimer < p_time)
{
diff --git a/src/game/DynamicObject.h b/src/game/DynamicObject.h
index 22009b92d14..94985f247d7 100644
--- a/src/game/DynamicObject.h
+++ b/src/game/DynamicObject.h
@@ -35,11 +35,13 @@ class DynamicObject : public WorldObject
void AddToWorld();
void RemoveFromWorld();
- bool Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32 effIndex, float x, float y, float z, int32 duration, float radius);
+ bool Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32 effMask, float x, float y, float z, int32 duration, float radius, bool active);
void Update(uint32 p_time);
void Delete();
uint32 GetSpellId() const { return m_spellId; }
- uint32 GetEffIndex() const { return m_effIndex; }
+ uint32 GetEffectMask() const { return m_effMask; }
+ void AddEffect(uint32 effIndex) { m_effMask |= (1<<effIndex); }
+ bool HasEffect(uint32 effIndex) const { return m_effMask & (1<<effIndex); }
uint32 GetDuration() const { return m_aliveDuration; }
uint64 GetCasterGUID() const { return GetUInt64Value(DYNAMICOBJECT_CASTER); }
Unit* GetCaster() const;
@@ -59,7 +61,7 @@ class DynamicObject : public WorldObject
GridReference<DynamicObject> &GetGridRef() { return m_gridRef; }
protected:
uint32 m_spellId;
- uint32 m_effIndex;
+ uint32 m_effMask;
int32 m_aliveDuration;
uint32 m_updateTimer;
time_t m_nextThinkTime;
diff --git a/src/game/GridNotifiersImpl.h b/src/game/GridNotifiersImpl.h
index 7deeb2ec5fd..23b781cab4c 100644
--- a/src/game/GridNotifiersImpl.h
+++ b/src/game/GridNotifiersImpl.h
@@ -178,8 +178,16 @@ inline void Trinity::DynamicObjectUpdater::VisitHelper(Unit* target)
if (i_dynobject.IsAffecting(target))
return;
- uint32 eff_index = i_dynobject.GetEffIndex();
- if(target->HasAuraEffect(i_dynobject.GetSpellId(), eff_index, i_check->GetGUID()))
+ if(target->HasAura(i_dynobject.GetSpellId(), i_check->GetGUID()))
+ return;
+
+
+ uint32 eff_index = 0;
+ for(; eff_index < MAX_SPELL_EFFECTS; ++eff_index)
+ if(i_dynobject.HasEffect(eff_index))
+ break;
+
+ if(eff_index == MAX_SPELL_EFFECTS)
return;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(i_dynobject.GetSpellId());
@@ -207,11 +215,12 @@ inline void Trinity::DynamicObjectUpdater::VisitHelper(Unit* target)
// Check target immune to spell or aura
if (target->IsImmunedToSpell(spellInfo) || target->IsImmunedToSpellEffect(spellInfo, eff_index))
return;
- // Apply PersistentAreaAura on target
- if(Aura *aur = target->AddAuraEffect(spellInfo, eff_index, &i_dynobject, i_dynobject.GetCaster()))
- aur->SetAuraDuration(i_dynobject.GetDuration());
- i_dynobject.AddAffected(target);
+ // Apply PersistentAreaAura on target
+ Aura *aur = new Aura(spellInfo, i_dynobject.GetEffectMask(), target, &i_dynobject, i_check);
+ aur->SetAuraDuration(i_dynobject.GetDuration());
+ if(target->AddAura(aur, true))
+ i_dynobject.AddAffected(target);
}
template<>
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 863530d953a..80636557f79 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -450,6 +450,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi
m_preCastSpell = 0;
m_triggeredByAuraSpell = NULL;
m_spellAura = NULL;
+ m_spellDynObj = NULL;
//Auto Shot & Shoot (wand)
m_autoRepeat = IsAutoRepeatRangedSpell(m_spellInfo);
@@ -6048,13 +6049,9 @@ void Spell::DelayedChannel()
}
}
- for(int j = 0; j < 3; ++j)
- {
- // partially interrupt persistent area auras
- DynamicObject* dynObj = m_caster->GetDynObject(m_spellInfo->Id, j);
- if(dynObj)
- dynObj->Delay(delaytime);
- }
+ // partially interrupt persistent area auras
+ if(DynamicObject* dynObj = m_caster->GetDynObject(m_spellInfo->Id))
+ dynObj->Delay(delaytime);
SendChannelUpdate(m_timer);
}
diff --git a/src/game/Spell.h b/src/game/Spell.h
index d100f9e6ee2..93b383bed3d 100644
--- a/src/game/Spell.h
+++ b/src/game/Spell.h
@@ -27,6 +27,7 @@
class Unit;
class Player;
class GameObject;
+class DynamicObject;
class Aura;
enum SpellCastTargetFlags
@@ -555,6 +556,7 @@ class Spell
GameObject* gameObjTarget;
int32 damage;
Aura * m_spellAura; // only used in DoAllEffectOnTarget
+ DynamicObject *m_spellDynObj; // only used in DoAllEffectOnTarget
// this is set in Spell Hit, but used in Apply Aura handler
DiminishingLevels m_diminishLevel;
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index b23efd27312..24a1a5c104a 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -2926,6 +2926,13 @@ void Spell::EffectCreateRandomItem(uint32 i)
void Spell::EffectPersistentAA(uint32 i)
{
+ if(m_spellDynObj)
+ {
+ assert(ObjectAccessor::GetObjectInWorld(m_spellDynObj->GetGUID(), (DynamicObject*)NULL) == m_spellDynObj);
+ m_spellDynObj->AddEffect(i);
+ return;
+ }
+
float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
if(Player* modOwner = m_originalCaster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius);
@@ -2933,7 +2940,7 @@ void Spell::EffectPersistentAA(uint32 i)
Unit *caster = m_caster->GetEntry() == WORLD_TRIGGER ? m_originalCaster : m_caster;
int32 duration = GetSpellDuration(m_spellInfo);
DynamicObject* dynObj = new DynamicObject;
- if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius))
+ if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, m_spellInfo->Id, 1<<i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius, false))
{
delete dynObj;
return;
@@ -2941,6 +2948,7 @@ void Spell::EffectPersistentAA(uint32 i)
dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x01eeeeee);
caster->AddDynObject(dynObj);
dynObj->GetMap()->Add(dynObj);
+ m_spellDynObj = dynObj;
}
void Spell::EffectEnergize(uint32 i)
@@ -3718,7 +3726,7 @@ void Spell::EffectAddFarsight(uint32 i)
float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
int32 duration = GetSpellDuration(m_spellInfo);
DynamicObject* dynObj = new DynamicObject;
- if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, 4, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius))
+ if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, 0, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius, true))
{
delete dynObj;
return;
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 89f730e2fda..b19c88ba376 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -4109,6 +4109,10 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)
++m_removedAurasCount;
+ if(Aur->IsPersistent())
+ if(DynamicObject *dynObj = ObjectAccessor::GetObjectInWorld(Aur->GetSourceGUID(), (DynamicObject*)NULL))
+ dynObj->RemoveAffected(this);
+
Aur->UnregisterSingleCastAura();
if(Aur->GetSpellProto()->AuraInterruptFlags)
@@ -4428,24 +4432,6 @@ void Unit::RemoveAllDynObjects()
}
}
-DynamicObject * Unit::GetDynObject(uint32 spellId, uint32 effIndex)
-{
- for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();)
- {
- DynamicObject* dynObj = GetMap()->GetDynamicObject(*i);
- if(!dynObj)
- {
- i = m_dynObjGUIDs.erase(i);
- continue;
- }
-
- if (dynObj->GetSpellId() == spellId && dynObj->GetEffIndex() == effIndex)
- return dynObj;
- ++i;
- }
- return NULL;
-}
-
DynamicObject * Unit::GetDynObject(uint32 spellId)
{
for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();)
@@ -14489,17 +14475,12 @@ void Unit::HandleAuraEffect(AuraEffect * aureff, bool apply)
{
if (!aureff->IsApplied())
return;
+
aureff->SetApplied(false);
// remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order)
m_modAuras[aureff->GetAuraName()].remove(aureff);
aureff->ApplyModifier(false, true);
- Unit * caster = aureff->GetParentAura()->GetCaster();
- if(caster && aureff->IsPersistent())
- {
- DynamicObject *dynObj = caster->GetDynObject(aureff->GetId(), aureff->GetEffIndex());
- if (dynObj)
- dynObj->RemoveAffected(this);
- }
+
// Remove all triggered by aura spells vs unlimited duration
aureff->CleanupTriggeredSpells();
}
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 6b1304f9839..b1a0c6e4d8c 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1688,7 +1688,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void setTransForm(uint32 spellid) { m_transform = spellid;}
uint32 getTransForm() const { return m_transform;}
- DynamicObject* GetDynObject(uint32 spellId, uint32 effIndex);
DynamicObject* GetDynObject(uint32 spellId);
void AddDynObject(DynamicObject* dynObj);
void RemoveDynObject(uint32 spellid);