aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/SpellAuras.cpp43
-rw-r--r--src/game/Unit.h1
2 files changed, 21 insertions, 23 deletions
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 49c309c9502..6c442963c3f 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -806,6 +806,8 @@ void Aura::_AddAura()
if(itr->second->GetCasterGUID()==GetCasterGUID())
{
slot = itr->second->GetAuraSlot();
+ if(slot >= MAX_AURAS)
+ return;
secondaura = true;
break;
}
@@ -813,23 +815,25 @@ void Aura::_AddAura()
if (secondaura)
break;
}
+
// Lookup free slot
- if (!secondaura && m_target->GetVisibleAurasCount() < MAX_AURAS )
+ if (!secondaura)
{
Unit::VisibleAuraMap const *visibleAuras = m_target->GetVisibleAuras();
- for(uint8 i = 0; i < MAX_AURAS; ++i)
+ if(visibleAuras->size() >= MAX_AURAS) // no free slot
+ return;
+
+ Unit::VisibleAuraMap::const_iterator itr = visibleAuras->begin();
+ for(int freeSlot = 0; freeSlot < MAX_AURAS; ++itr, ++freeSlot)
{
- Unit::VisibleAuraMap::const_iterator itr = visibleAuras->find(i);
- if(itr == visibleAuras->end())
+ if(itr == visibleAuras->end() || itr->first != freeSlot)
{
- slot = i;
+ slot = freeSlot;
break;
}
}
- }
+ assert(slot < MAX_AURAS); // assert that we find a slot and it is valid
- if (!secondaura)
- {
AuraSlotEntry t_entry;
t_entry.m_Flags=(IsPositive() ? AFLAG_POSITIVE : AFLAG_NEGATIVE) | AFLAG_NOT_CASTER | ((GetAuraMaxDuration() > 0) ? AFLAG_DURATION : AFLAG_NONE);
t_entry.m_Level=(caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
@@ -838,12 +842,10 @@ void Aura::_AddAura()
for(uint8 i = 0; i < 3; i++)
t_entry.m_slotAuras[i]=NULL;
- t_entry.m_Level=(caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
m_target->SetVisibleAura(slot, t_entry);
}
- AuraSlotEntry * entry;
- entry=m_target->GetVisibleAura(slot);
+ AuraSlotEntry *entry = m_target->GetVisibleAura(slot);
if(!entry)
return;
@@ -921,30 +923,27 @@ void Aura::_RemoveAura()
// return;
uint8 slot = GetAuraSlot();
-
if(slot >= MAX_AURAS) // slot not set
return;
- if(!m_target->GetVisibleAura(slot)) //slot already removed-shouldn't happen
+ AuraSlotEntry *entry = m_target->GetVisibleAura(slot);
+ if(!entry) //slot already removed-shouldn't happen
return;
- bool lastaura = true;
-
- AuraSlotEntry * entry=m_target->GetVisibleAura(slot);
+ entry->m_slotAuras[GetEffIndex()]=NULL; //unregister aura
- entry->m_slotAuras[GetEffIndex()]=NULL; //unregister aura
- Aura * ptr= NULL;
- for (uint8 i=0 ; i<3; i++) //check slot for more auras of the spell
+ bool lastaura = true;
+ for(uint8 i = 0; i < 3; ++i) //check slot for more auras of the spell
{
- if (entry->m_slotAuras[i])
+ if(entry->m_slotAuras[i])
{
- ptr=entry->m_slotAuras[i];
+ lastaura = false;
break;
}
}
// only remove icon when the last aura of the spell is removed (current aura already removed from list)
- if(!ptr)
+ if(lastaura)
{
// unregister aura diminishing (and store last time)
if (getDiminishGroup() != DIMINISHING_NONE )
diff --git a/src/game/Unit.h b/src/game/Unit.h
index f24a0705128..a767bbe08eb 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1347,7 +1347,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
HostilRefManager& getHostilRefManager() { return m_HostilRefManager; }
VisibleAuraMap const *GetVisibleAuras() { return &m_visibleAuras; }
- uint8 GetVisibleAurasCount() { return m_visibleAuras.size(); }
AuraSlotEntry * GetVisibleAura(uint8 slot)
{
VisibleAuraMap::iterator itr = m_visibleAuras.find(slot);