diff options
| author | QAston <qaston@gmail.com> | 2011-06-08 10:41:32 +0200 | 
|---|---|---|
| committer | QAston <qaston@gmail.com> | 2011-06-08 10:41:32 +0200 | 
| commit | 0c3e99c450b6524e22d14a83dd41467230584435 (patch) | |
| tree | ba13c72fde9c5909525ac5aaed1d1f0cef836043 | |
| parent | 0575dddbb3865cfd4f822fefdff92aa4e024afc9 (diff) | |
Core/Auras: Move repeating code for aura packet creation to separate function. Fixes usage of SPELL_ATTR5_HIDE_DURATION attribute.
| -rwxr-xr-x | src/server/game/Entities/Player/Player.cpp | 23 | ||||
| -rwxr-xr-x | src/server/game/Spells/Auras/SpellAuras.cpp | 21 | ||||
| -rwxr-xr-x | src/server/game/Spells/Auras/SpellAuras.h | 3 | 
3 files changed, 15 insertions, 32 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index e4b203adb38..53a431f93da 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -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); diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 0630abe1ca1..fe62d786689 100755 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -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);  } diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h index 3dd9c651692..342ff59b02c 100755 --- a/src/server/game/Spells/Auras/SpellAuras.h +++ b/src/server/game/Spells/Auras/SpellAuras.h @@ -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;}  | 
