Core/Auras: Store non-unit caster guids in auras (#27625)

This allows retrieving any caster object, not just units
This commit is contained in:
Jeremy
2022-01-18 21:18:25 +01:00
committed by GitHub
parent 12d00e2e5f
commit bbed5dc3e8
3 changed files with 13 additions and 17 deletions

View File

@@ -3064,14 +3064,6 @@ Aura* Unit::_TryStackingOrRefreshingExistingAura(AuraCreateInfo& createInfo)
if (!createInfo.CasterGUID && !createInfo.GetSpellInfo()->IsStackableOnOneSlotWithDifferentCasters())
createInfo.CasterGUID = createInfo.Caster->GetGUID();
// world gameobjects can't own auras and they send empty casterguid
// checked on sniffs with spell 22247
if (createInfo.CasterGUID.IsGameObject())
{
createInfo.Caster = nullptr;
createInfo.CasterGUID.Clear();
}
// passive and Incanter's Absorption and auras with different type can stack with themselves any number of times
if (!createInfo.GetSpellInfo()->IsMultiSlotAura())
{

View File

@@ -249,7 +249,9 @@ void AuraApplication::BuildUpdatePacket(WorldPackets::Spells::AuraInfo& auraInfo
// 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)
auraData.Applications = aura->IsUsingStacks() ? aura->GetStackAmount() : aura->GetCharges();
if (!(auraData.Flags & AFLAG_NOCASTER))
if (!aura->GetCasterGUID().IsUnit())
auraData.CastUnit = ObjectGuid::Empty; // optional data is filled in, but cast unit contains empty guid in packet
else if (!(auraData.Flags & AFLAG_NOCASTER))
auraData.CastUnit = aura->GetCasterGUID();
if (auraData.Flags & AFLAG_DURATION)
@@ -392,14 +394,7 @@ Aura* Aura::Create(AuraCreateInfo& createInfo)
// try to get caster of aura
if (!createInfo.CasterGUID.IsEmpty())
{
// world gameobjects can't own auras and they send empty casterguid
// checked on sniffs with spell 22247
if (createInfo.CasterGUID.IsGameObject())
{
createInfo.Caster = nullptr;
createInfo.CasterGUID.Clear();
}
else
if (createInfo.CasterGUID.IsUnit())
{
if (createInfo._owner->GetGUID() == createInfo.CasterGUID)
createInfo.Caster = createInfo._owner->ToUnit();
@@ -527,6 +522,14 @@ Unit* Aura::GetCaster() const
return ObjectAccessor::GetUnit(*GetOwner(), GetCasterGUID());
}
WorldObject* Aura::GetWorldObjectCaster() const
{
if (GetCasterGUID().IsUnit())
return GetCaster();
return ObjectAccessor::GetWorldObject(*GetOwner(), GetCasterGUID());
}
AuraEffect* Aura::GetEffect(uint32 index) const
{
if (index >= _effects.size())

View File

@@ -145,6 +145,7 @@ class TC_GAME_API Aura
int32 GetCastItemLevel() const { return m_castItemLevel; }
SpellCastVisual GetSpellVisual() const { return m_spellVisual; }
Unit* GetCaster() const;
WorldObject* GetWorldObjectCaster() const;
WorldObject* GetOwner() const { return m_owner; }
Unit* GetUnitOwner() const { ASSERT(GetType() == UNIT_AURA_TYPE); return m_owner->ToUnit(); }
DynamicObject* GetDynobjOwner() const { ASSERT(GetType() == DYNOBJ_AURA_TYPE); return m_owner->ToDynObject(); }