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:
QAston
2011-06-08 10:41:32 +02:00
parent 0575dddbb3
commit 0c3e99c450
3 changed files with 15 additions and 32 deletions
+1 -22
View File
@@ -21710,28 +21710,7 @@ void Player::SendAurasForTarget(Unit *target)
for (Unit::VisibleAuraMap::const_iterator itr = visibleAuras->begin(); itr != visibleAuras->end(); ++itr) for (Unit::VisibleAuraMap::const_iterator itr = visibleAuras->begin(); itr != visibleAuras->end(); ++itr)
{ {
AuraApplication * auraApp = itr->second; AuraApplication * auraApp = itr->second;
Aura * aura = auraApp->GetBase(); auraApp->BuildUpdatePacket(data, false);
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());
}
} }
GetSession()->SendPacket(&data); GetSession()->SendPacket(&data);
+12 -9
View File
@@ -41,7 +41,7 @@ m_effectsToApply(effMask), m_removeMode(AURA_REMOVE_NONE), m_needClientUpdate(fa
{ {
ASSERT(GetTarget() && GetBase()); ASSERT(GetTarget() && GetBase());
if (GetBase()->IsVisible()) if (GetBase()->CanBeSentToClient())
{ {
// Try find slot for aura // Try find slot for aura
uint8 slot = MAX_AURAS; uint8 slot = MAX_AURAS;
@@ -174,20 +174,14 @@ void AuraApplication::_HandleEffect(uint8 effIndex, bool apply)
SetNeedClientUpdate(); 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); data << uint8(m_slot);
if (remove) if (remove)
{ {
ASSERT(!m_target->GetVisibleAura(m_slot)); ASSERT(!m_target->GetVisibleAura(m_slot));
data << uint32(0); data << uint32(0);
sLog->outDebug(LOG_FILTER_SPELLS_AURAS, "Aura %u removed slot %u", GetBase()->GetId(), m_slot);
m_target->SendMessageToSet(&data, true);
return; return;
} }
ASSERT(m_target->GetVisibleAura(m_slot)); ASSERT(m_target->GetVisibleAura(m_slot));
@@ -209,6 +203,15 @@ void AuraApplication::ClientUpdate(bool remove)
data << uint32(aura->GetMaxDuration()); data << uint32(aura->GetMaxDuration());
data << uint32(aura->GetDuration()); 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); m_target->SendMessageToSet(&data, true);
} }
@@ -839,7 +842,7 @@ bool Aura::CanBeSaved() const
return true; return true;
} }
bool Aura::IsVisible() const bool Aura::CanBeSentToClient() const
{ {
return !IsPassive() || HasAreaAuraEffect(GetSpellProto()) || HasEffectType(SPELL_AURA_ABILITY_IGNORE_AURASTATE); return !IsPassive() || HasAreaAuraEffect(GetSpellProto()) || HasEffectType(SPELL_AURA_ABILITY_IGNORE_AURASTATE);
} }
+2 -1
View File
@@ -74,6 +74,7 @@ class AuraApplication
void SetNeedClientUpdate() { m_needClientUpdate = true;} void SetNeedClientUpdate() { m_needClientUpdate = true;}
bool IsNeedClientUpdate() const { return m_needClientUpdate;} bool IsNeedClientUpdate() const { return m_needClientUpdate;}
void BuildUpdatePacket(ByteBuffer& data, bool remove) const;
void ClientUpdate(bool remove = false); 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 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 CanBeSaved() const;
bool IsRemoved() const { return m_isRemoved; } bool IsRemoved() const { return m_isRemoved; }
bool IsVisible() const; bool CanBeSentToClient() const;
// Single cast aura helpers // Single cast aura helpers
bool IsSingleTarget() const {return m_isSingleTarget;} bool IsSingleTarget() const {return m_isSingleTarget;}
void SetIsSingleTarget(bool val) { m_isSingleTarget = val;} void SetIsSingleTarget(bool val) { m_isSingleTarget = val;}