Core/Auras: Move repeating code for aura packet creation to separate function. Fixes usage of SPELL_ATTR5_HIDE_DURATION attribute.
This commit is contained in:
@@ -21710,28 +21710,7 @@ void Player::SendAurasForTarget(Unit *target)
|
||||
for (Unit::VisibleAuraMap::const_iterator itr = visibleAuras->begin(); itr != visibleAuras->end(); ++itr)
|
||||
{
|
||||
AuraApplication * auraApp = itr->second;
|
||||
Aura * aura = auraApp->GetBase();
|
||||
data << uint8(auraApp->GetSlot());
|
||||
data << uint32(aura->GetId());
|
||||
|
||||
// flags
|
||||
uint32 flags = auraApp->GetFlags();
|
||||
if (aura->GetMaxDuration() > 0)
|
||||
flags |= AFLAG_DURATION;
|
||||
data << uint8(flags);
|
||||
// level
|
||||
data << uint8(aura->GetCasterLevel());
|
||||
// charges
|
||||
data << uint8(aura->GetStackAmount() > 1 ? aura->GetStackAmount() : (aura->GetCharges()) ? aura->GetCharges() : 1);
|
||||
|
||||
if (!(flags & AFLAG_CASTER))
|
||||
data.appendPackGUID(aura->GetCasterGUID());
|
||||
|
||||
if (flags & AFLAG_DURATION) // include aura duration
|
||||
{
|
||||
data << uint32(aura->GetMaxDuration());
|
||||
data << uint32(aura->GetDuration());
|
||||
}
|
||||
auraApp->BuildUpdatePacket(data, false);
|
||||
}
|
||||
|
||||
GetSession()->SendPacket(&data);
|
||||
|
||||
@@ -41,7 +41,7 @@ m_effectsToApply(effMask), m_removeMode(AURA_REMOVE_NONE), m_needClientUpdate(fa
|
||||
{
|
||||
ASSERT(GetTarget() && GetBase());
|
||||
|
||||
if (GetBase()->IsVisible())
|
||||
if (GetBase()->CanBeSentToClient())
|
||||
{
|
||||
// Try find slot for aura
|
||||
uint8 slot = MAX_AURAS;
|
||||
@@ -174,20 +174,14 @@ void AuraApplication::_HandleEffect(uint8 effIndex, bool apply)
|
||||
SetNeedClientUpdate();
|
||||
}
|
||||
|
||||
void AuraApplication::ClientUpdate(bool remove)
|
||||
void AuraApplication::BuildUpdatePacket(ByteBuffer& data, bool remove) const
|
||||
{
|
||||
m_needClientUpdate = false;
|
||||
|
||||
WorldPacket data(SMSG_AURA_UPDATE);
|
||||
data.append(GetTarget()->GetPackGUID());
|
||||
data << uint8(m_slot);
|
||||
|
||||
if (remove)
|
||||
{
|
||||
ASSERT(!m_target->GetVisibleAura(m_slot));
|
||||
data << uint32(0);
|
||||
sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "Aura %u removed slot %u", GetBase()->GetId(), m_slot);
|
||||
m_target->SendMessageToSet(&data, true);
|
||||
return;
|
||||
}
|
||||
ASSERT(m_target->GetVisibleAura(m_slot));
|
||||
@@ -209,6 +203,15 @@ void AuraApplication::ClientUpdate(bool remove)
|
||||
data << uint32(aura->GetMaxDuration());
|
||||
data << uint32(aura->GetDuration());
|
||||
}
|
||||
}
|
||||
|
||||
void AuraApplication::ClientUpdate(bool remove)
|
||||
{
|
||||
m_needClientUpdate = false;
|
||||
|
||||
WorldPacket data(SMSG_AURA_UPDATE);
|
||||
data.append(GetTarget()->GetPackGUID());
|
||||
BuildUpdatePacket(data, remove);
|
||||
|
||||
m_target->SendMessageToSet(&data, true);
|
||||
}
|
||||
@@ -839,7 +842,7 @@ bool Aura::CanBeSaved() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Aura::IsVisible() const
|
||||
bool Aura::CanBeSentToClient() const
|
||||
{
|
||||
return !IsPassive() || HasAreaAuraEffect(GetSpellProto()) || HasEffectType(SPELL_AURA_ABILITY_IGNORE_AURASTATE);
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ class AuraApplication
|
||||
|
||||
void SetNeedClientUpdate() { m_needClientUpdate = true;}
|
||||
bool IsNeedClientUpdate() const { return m_needClientUpdate;}
|
||||
void BuildUpdatePacket(ByteBuffer& data, bool remove) const;
|
||||
void ClientUpdate(bool remove = false);
|
||||
};
|
||||
|
||||
@@ -147,7 +148,7 @@ class Aura
|
||||
bool IsRemovedOnShapeLost(Unit * target) const { return (GetCasterGUID() == target->GetGUID() && m_spellProto->Stances && !(m_spellProto->AttributesEx2 & SPELL_ATTR2_NOT_NEED_SHAPESHIFT) && !(m_spellProto->Attributes & SPELL_ATTR0_NOT_SHAPESHIFT)); }
|
||||
bool CanBeSaved() const;
|
||||
bool IsRemoved() const { return m_isRemoved; }
|
||||
bool IsVisible() const;
|
||||
bool CanBeSentToClient() const;
|
||||
// Single cast aura helpers
|
||||
bool IsSingleTarget() const {return m_isSingleTarget;}
|
||||
void SetIsSingleTarget(bool val) { m_isSingleTarget = val;}
|
||||
|
||||
Reference in New Issue
Block a user