*Update add/remove aura code.
--HG-- branch : trunk
This commit is contained in:
+21
-22
@@ -806,6 +806,8 @@ void Aura::_AddAura()
|
|||||||
if(itr->second->GetCasterGUID()==GetCasterGUID())
|
if(itr->second->GetCasterGUID()==GetCasterGUID())
|
||||||
{
|
{
|
||||||
slot = itr->second->GetAuraSlot();
|
slot = itr->second->GetAuraSlot();
|
||||||
|
if(slot >= MAX_AURAS)
|
||||||
|
return;
|
||||||
secondaura = true;
|
secondaura = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -813,23 +815,25 @@ void Aura::_AddAura()
|
|||||||
if (secondaura)
|
if (secondaura)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookup free slot
|
// Lookup free slot
|
||||||
if (!secondaura && m_target->GetVisibleAurasCount() < MAX_AURAS )
|
if (!secondaura)
|
||||||
{
|
{
|
||||||
Unit::VisibleAuraMap const *visibleAuras = m_target->GetVisibleAuras();
|
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() || itr->first != freeSlot)
|
||||||
if(itr == visibleAuras->end())
|
|
||||||
{
|
{
|
||||||
slot = i;
|
slot = freeSlot;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
assert(slot < MAX_AURAS); // assert that we find a slot and it is valid
|
||||||
|
|
||||||
if (!secondaura)
|
|
||||||
{
|
|
||||||
AuraSlotEntry t_entry;
|
AuraSlotEntry t_entry;
|
||||||
t_entry.m_Flags=(IsPositive() ? AFLAG_POSITIVE : AFLAG_NEGATIVE) | AFLAG_NOT_CASTER | ((GetAuraMaxDuration() > 0) ? AFLAG_DURATION : AFLAG_NONE);
|
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));
|
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++)
|
for(uint8 i = 0; i < 3; i++)
|
||||||
t_entry.m_slotAuras[i]=NULL;
|
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);
|
m_target->SetVisibleAura(slot, t_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
AuraSlotEntry * entry;
|
AuraSlotEntry *entry = m_target->GetVisibleAura(slot);
|
||||||
entry=m_target->GetVisibleAura(slot);
|
|
||||||
if(!entry)
|
if(!entry)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -921,30 +923,27 @@ void Aura::_RemoveAura()
|
|||||||
// return;
|
// return;
|
||||||
|
|
||||||
uint8 slot = GetAuraSlot();
|
uint8 slot = GetAuraSlot();
|
||||||
|
|
||||||
if(slot >= MAX_AURAS) // slot not set
|
if(slot >= MAX_AURAS) // slot not set
|
||||||
return;
|
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;
|
return;
|
||||||
|
|
||||||
|
entry->m_slotAuras[GetEffIndex()]=NULL; //unregister aura
|
||||||
|
|
||||||
bool lastaura = true;
|
bool lastaura = true;
|
||||||
|
for(uint8 i = 0; i < 3; ++i) //check slot for more auras of the spell
|
||||||
AuraSlotEntry * entry=m_target->GetVisibleAura(slot);
|
|
||||||
|
|
||||||
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
|
|
||||||
{
|
{
|
||||||
if (entry->m_slotAuras[i])
|
if(entry->m_slotAuras[i])
|
||||||
{
|
{
|
||||||
ptr=entry->m_slotAuras[i];
|
lastaura = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// only remove icon when the last aura of the spell is removed (current aura already removed from list)
|
// 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)
|
// unregister aura diminishing (and store last time)
|
||||||
if (getDiminishGroup() != DIMINISHING_NONE )
|
if (getDiminishGroup() != DIMINISHING_NONE )
|
||||||
|
|||||||
@@ -1347,7 +1347,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
|||||||
HostilRefManager& getHostilRefManager() { return m_HostilRefManager; }
|
HostilRefManager& getHostilRefManager() { return m_HostilRefManager; }
|
||||||
|
|
||||||
VisibleAuraMap const *GetVisibleAuras() { return &m_visibleAuras; }
|
VisibleAuraMap const *GetVisibleAuras() { return &m_visibleAuras; }
|
||||||
uint8 GetVisibleAurasCount() { return m_visibleAuras.size(); }
|
|
||||||
AuraSlotEntry * GetVisibleAura(uint8 slot)
|
AuraSlotEntry * GetVisibleAura(uint8 slot)
|
||||||
{
|
{
|
||||||
VisibleAuraMap::iterator itr = m_visibleAuras.find(slot);
|
VisibleAuraMap::iterator itr = m_visibleAuras.find(slot);
|
||||||
|
|||||||
Reference in New Issue
Block a user