aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy <Golrag@users.noreply.github.com>2022-01-18 21:18:25 +0100
committerGitHub <noreply@github.com>2022-01-18 21:18:25 +0100
commitbbed5dc3e8327535e3842650b966291dd90c9bc7 (patch)
tree04130e6191c3076f4b0b7d82429170fa99f4d8c5 /src
parent12d00e2e5f7e2cc7efe1ea8d126f9408055c05f8 (diff)
Core/Auras: Store non-unit caster guids in auras (#27625)
This allows retrieving any caster object, not just units
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp8
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp21
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.h1
3 files changed, 13 insertions, 17 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 5b193947b3d..4ba9ff12efd 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -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())
{
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 1a7ca313a2d..3b39f084c5f 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -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())
diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h
index 212e44ececd..0c1bb5b4f32 100644
--- a/src/server/game/Spells/Auras/SpellAuras.h
+++ b/src/server/game/Spells/Auras/SpellAuras.h
@@ -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(); }