*Update function _AddAura code. only check aura state for first aura.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-03-15 17:01:46 -06:00
parent 5ea9d6fa23
commit e8fcd81e26
+21 -17
View File
@@ -809,7 +809,7 @@ void Aura::_AddAura()
// Second aura if some spell
bool secondaura = false;
// Try find slot for aura
uint8 slot = NULL_AURA_SLOT;
uint8 slot = MAX_AURAS;
// Lookup for auras already applied from spell
for(uint8 i = 0; i < 3; ++i)
{
@@ -828,14 +828,17 @@ void Aura::_AddAura()
break;
}
Unit::VisibleAuraMap const *visibleAuras = m_target->GetVisibleAuras();
if(visibleAuras->size() < MAX_AURAS || slot < MAX_AURAS) // got free slot
{
// Register Visible Aura
AuraSlotEntry *entry = NULL;
// Lookup free slot
if (!secondaura)
if(slot < MAX_AURAS)
entry = m_target->GetVisibleAura(slot);
else
{
Unit::VisibleAuraMap const *visibleAuras = m_target->GetVisibleAuras();
if(visibleAuras->size() < MAX_AURAS)
{
// Even if this is the second aura and slot == MAX_AURAS,
// it is still possible that a free slot can be founded
Unit::VisibleAuraMap::const_iterator itr = visibleAuras->begin();
for(int freeSlot = 0; freeSlot < MAX_AURAS; ++itr, ++freeSlot)
{
@@ -845,23 +848,25 @@ void Aura::_AddAura()
break;
}
}
assert(slot < MAX_AURAS); // assert that we find a slot and it is valid
assert(slot < MAX_AURAS); // assert that we find a slot and it is valid
entry = m_target->GetVisibleAuraSlot(slot);
entry->m_Flags=(IsPositive() ? AFLAG_POSITIVE : AFLAG_NEGATIVE) | ((GetCasterGUID() == m_target->GetGUID()) ? AFLAG_CASTER : AFLAG_NONE) | ((GetAuraMaxDuration() > 0) ? AFLAG_DURATION : AFLAG_NONE);
entry->m_Level=(caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
entry->m_Flags = (IsPositive() ? AFLAG_POSITIVE : AFLAG_NEGATIVE) |
(GetCasterGUID() == m_target->GetGUID() ? AFLAG_CASTER : AFLAG_NONE) |
(GetAuraMaxDuration() > 0 ? AFLAG_DURATION : AFLAG_NONE);
entry->m_Level = (caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
entry->m_spellId = GetId();
//init pointers-prevent unexpected behaviour
for(uint8 i = 0; i < 3; ++i)
entry->m_slotAuras[i] = NULL;
}
else
entry = m_target->GetVisibleAura(slot);
}
if(entry)
{
entry->m_Flags |= (1 << GetEffIndex());
entry->m_slotAuras[GetEffIndex()]=this;
entry->m_slotAuras[GetEffIndex()] = this;
SetAuraSlot( slot );
@@ -869,17 +874,17 @@ void Aura::_AddAura()
m_target->UpdateAuraForGroup(slot);
sLog.outDebug("Aura: %u Effect: %d put to unit visible auras slot: %u",GetId(), GetEffIndex(), slot);
}
}
else
sLog.outDebug("Aura: %u Effect: %d could not find empty unit visible slot",GetId(), GetEffIndex());
if(secondaura)
return;
//*****************************************************
// Update target aura state flag
// TODO: Make it easer
//*****************************************************
if (!secondaura)
{
// Sitdown on apply aura req seated
if (m_spellProto->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED && !m_target->IsSitState())
m_target->SetStandState(UNIT_STAND_STATE_SIT);
@@ -899,7 +904,6 @@ void Aura::_AddAura()
else if(Unit* caster = GetCaster())
m_target->AddAura(*itr, m_target);
}
}
// Update Seals information
if (IsSealSpell(m_spellProto))