mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-30 13:47:23 +01:00
Core/Packets: converted SMSG_AURA_UPDATE and SMSG_AURA_UPDATE_ALL to packet class
This commit is contained in:
@@ -92,6 +92,7 @@
|
||||
#include "SpellAuras.h"
|
||||
#include "SpellHistory.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "SpellPackets.h"
|
||||
#include "TicketMgr.h"
|
||||
#include "TradeData.h"
|
||||
#include "Trainer.h"
|
||||
@@ -23931,17 +23932,20 @@ void Player::SendAurasForTarget(Unit* target) const
|
||||
if (target->HasAuraType(SPELL_AURA_HOVER))
|
||||
target->SetHover(true, true);
|
||||
|
||||
WorldPacket data(SMSG_AURA_UPDATE_ALL);
|
||||
data << target->GetPackGUID();
|
||||
|
||||
Unit::VisibleAuraMap const* visibleAuras = target->GetVisibleAuras();
|
||||
|
||||
WorldPackets::Spells::AuraUpdateAll update;
|
||||
update.UnitGUID = target->GetGUID();
|
||||
update.Auras.reserve(visibleAuras->size());
|
||||
|
||||
for (Unit::VisibleAuraMap::const_iterator itr = visibleAuras->begin(); itr != visibleAuras->end(); ++itr)
|
||||
{
|
||||
AuraApplication * auraApp = itr->second;
|
||||
auraApp->BuildUpdatePacket(data, false);
|
||||
WorldPackets::Spells::AuraInfo auraInfo;
|
||||
AuraApplication* auraApp = itr->second;
|
||||
auraApp->BuildUpdatePacket(auraInfo, false);
|
||||
update.Auras.push_back(auraInfo);
|
||||
}
|
||||
|
||||
SendDirectMessage(&data);
|
||||
GetSession()->SendPacket(update.Write());
|
||||
}
|
||||
|
||||
void Player::SetDailyQuestStatus(uint32 quest_id)
|
||||
|
||||
@@ -205,3 +205,56 @@ WorldPacket const* WorldPackets::Spells::MountResult::Write()
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::AuraDataInfo const& auraData)
|
||||
{
|
||||
data << int32(auraData.SpellID);
|
||||
if (auraData.SpellID <= 0)
|
||||
return data;
|
||||
|
||||
data << int16(auraData.Flags);
|
||||
data << uint8(auraData.CastLevel);
|
||||
data << uint8(auraData.Applications);
|
||||
|
||||
if (auraData.CastUnit)
|
||||
data << auraData.CastUnit.get().WriteAsPacked();
|
||||
|
||||
if (auraData.Duration)
|
||||
data << int32(*auraData.Duration);
|
||||
|
||||
if (auraData.Remaining)
|
||||
data << int32(*auraData.Remaining);
|
||||
|
||||
for (int32 amount : auraData.Points)
|
||||
data << int32(amount);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Spells::AuraInfo const& aura)
|
||||
{
|
||||
data << uint8(aura.Slot);
|
||||
data << aura.AuraData;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Spells::AuraUpdate::Write()
|
||||
{
|
||||
_worldPacket << UnitGUID.WriteAsPacked();
|
||||
|
||||
for (AuraInfo const& aura : Auras)
|
||||
_worldPacket << aura;
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Spells::AuraUpdateAll::Write()
|
||||
{
|
||||
_worldPacket << UnitGUID.WriteAsPacked();
|
||||
|
||||
for (AuraInfo const& aura : Auras)
|
||||
_worldPacket << aura;
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
@@ -178,6 +178,46 @@ namespace WorldPackets
|
||||
|
||||
uint32 Result = 0;
|
||||
};
|
||||
|
||||
struct AuraDataInfo
|
||||
{
|
||||
int32 SpellID = 0;
|
||||
int16 Flags = 0;
|
||||
uint8 CastLevel = 0;
|
||||
uint8 Applications = 0;
|
||||
Optional<ObjectGuid> CastUnit;
|
||||
Optional<int32> Duration;
|
||||
Optional<int32> Remaining;
|
||||
std::vector<int32> Points;
|
||||
};
|
||||
|
||||
struct AuraInfo
|
||||
{
|
||||
uint8 Slot = 0;
|
||||
AuraDataInfo AuraData;
|
||||
};
|
||||
|
||||
class AuraUpdate final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
AuraUpdate() : ServerPacket(SMSG_AURA_UPDATE) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
ObjectGuid UnitGUID;
|
||||
std::vector<AuraInfo> Auras;
|
||||
};
|
||||
|
||||
class AuraUpdateAll final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
AuraUpdateAll() : ServerPacket(SMSG_AURA_UPDATE_ALL) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
ObjectGuid UnitGUID;
|
||||
std::vector<AuraInfo> Auras;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "SpellAuraEffects.h"
|
||||
#include "SpellHistory.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "SpellPackets.h"
|
||||
#include "SpellScript.h"
|
||||
#include "Unit.h"
|
||||
#include "Util.h"
|
||||
@@ -181,54 +182,60 @@ void AuraApplication::_HandleEffect(uint8 effIndex, bool apply)
|
||||
SetNeedClientUpdate();
|
||||
}
|
||||
|
||||
void AuraApplication::BuildUpdatePacket(ByteBuffer& data, bool remove) const
|
||||
void AuraApplication::BuildUpdatePacket(WorldPackets::Spells::AuraInfo& auraInfo, bool remove) const
|
||||
{
|
||||
data << uint8(_slot);
|
||||
auraInfo.Slot = GetSlot();
|
||||
|
||||
WorldPackets::Spells::AuraDataInfo& auraData = auraInfo.AuraData;
|
||||
|
||||
if (remove)
|
||||
{
|
||||
ASSERT(!_target->GetVisibleAura(_slot));
|
||||
data << uint32(0);
|
||||
return;
|
||||
}
|
||||
ASSERT(_target->GetVisibleAura(_slot));
|
||||
|
||||
|
||||
Aura const* aura = GetBase();
|
||||
data << uint32(aura->GetId());
|
||||
uint32 flags = _flags;
|
||||
auraData.SpellID = aura->GetId();
|
||||
auraData.Flags = GetFlags();
|
||||
if (aura->GetType() != DYNOBJ_AURA_TYPE && aura->GetMaxDuration() > 0 && !aura->GetSpellInfo()->HasAttribute(SPELL_ATTR5_HIDE_DURATION))
|
||||
flags |= AFLAG_DURATION;
|
||||
data << uint16(flags);
|
||||
data << uint8(aura->GetCasterLevel());
|
||||
auraData.Flags |= AFLAG_DURATION;
|
||||
|
||||
auraData.CastLevel = uint16(aura->GetCasterLevel());
|
||||
|
||||
// send stack amount for aura which could be stacked (never 0 - causes incorrect display) or charges
|
||||
// stack amount has priority over charges (checked on retail with spell 50262)
|
||||
data << uint8(aura->GetSpellInfo()->StackAmount ? aura->GetStackAmount() : aura->GetCharges());
|
||||
auraData.Applications = aura->GetSpellInfo()->StackAmount ? aura->GetStackAmount() : aura->GetCharges();
|
||||
|
||||
if (!(flags & AFLAG_CASTER))
|
||||
data << aura->GetCasterGUID().WriteAsPacked();
|
||||
if (!(auraData.Flags & AFLAG_CASTER))
|
||||
auraData.CastUnit = aura->GetCasterGUID();
|
||||
|
||||
if (flags & AFLAG_DURATION)
|
||||
if (auraData.Flags & AFLAG_DURATION)
|
||||
{
|
||||
data << uint32(aura->GetMaxDuration());
|
||||
data << uint32(aura->GetDuration());
|
||||
auraData.Duration = aura->GetMaxDuration();
|
||||
auraData.Remaining = aura->GetDuration();
|
||||
}
|
||||
|
||||
if (flags & AFLAG_ANY_EFFECT_AMOUNT_SENT)
|
||||
if (auraData.Flags & AFLAG_ANY_EFFECT_AMOUNT_SENT)
|
||||
for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||
if (AuraEffect const* eff = aura->GetEffect(i))
|
||||
if (AuraEffect const* effect = aura->GetEffect(i))
|
||||
if (HasEffect(i)) // Not all of aura's effects have to be applied on every target
|
||||
data << int32(eff->GetAmount());
|
||||
auraData.Points.push_back(effect->GetAmount());
|
||||
}
|
||||
|
||||
void AuraApplication::ClientUpdate(bool remove)
|
||||
{
|
||||
_needClientUpdate = false;
|
||||
|
||||
WorldPacket data(SMSG_AURA_UPDATE);
|
||||
data << GetTarget()->GetPackGUID();
|
||||
BuildUpdatePacket(data, remove);
|
||||
WorldPackets::Spells::AuraUpdate update;
|
||||
update.UnitGUID = GetTarget()->GetGUID();
|
||||
|
||||
_target->SendMessageToSet(&data, true);
|
||||
WorldPackets::Spells::AuraInfo auraInfo;
|
||||
BuildUpdatePacket(auraInfo, remove);
|
||||
update.Auras.push_back(auraInfo);
|
||||
|
||||
_target->SendMessageToSet(update.Write(), true);
|
||||
}
|
||||
|
||||
uint8 Aura::BuildEffectMaskForOwner(SpellInfo const* spellProto, uint8 availableEffectMask, WorldObject* owner)
|
||||
|
||||
@@ -28,6 +28,14 @@ struct SpellModifier;
|
||||
struct ProcTriggerSpell;
|
||||
struct SpellProcEntry;
|
||||
|
||||
namespace WorldPackets
|
||||
{
|
||||
namespace Spells
|
||||
{
|
||||
struct AuraInfo;
|
||||
}
|
||||
}
|
||||
|
||||
// forward decl
|
||||
class AuraEffect;
|
||||
class Aura;
|
||||
@@ -78,7 +86,7 @@ class TC_GAME_API AuraApplication
|
||||
|
||||
void SetNeedClientUpdate() { _needClientUpdate = true;}
|
||||
bool IsNeedClientUpdate() const { return _needClientUpdate;}
|
||||
void BuildUpdatePacket(ByteBuffer& data, bool remove) const;
|
||||
void BuildUpdatePacket(WorldPackets::Spells::AuraInfo& auraInfo, bool remove) const;
|
||||
void ClientUpdate(bool remove = false);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user