diff options
| author | Treeston <treeston.mmoc@gmail.com> | 2017-12-30 20:28:41 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-04-16 15:22:42 +0200 |
| commit | 9b141207d170e4b2b4e6d9290d5f921f76cbcea0 (patch) | |
| tree | 47d65d966a66699f6de7e308047e408bdb255bff /src/server/game/Entities/GameObject | |
| parent | 2ea8f5e6fced094f28c45ac84123c85477122567 (diff) | |
[3.3.5] CastSpell unclusterfucking (that's a word now) (#21123)
Core/Spell: The giant CastSpell unclusterfucking (that's a word now) of this generation.
- CastSpell now always takes three arguments - target, spellId, and a struct containing extra arguments
- This struct (CastSpellExtraArgs, see SpellDefines.h) serves as a conglomerate of every previous combination of the 20 billion different CastSpell overloads, all merged into one
- It has some great utility constructors - check them out! All of these can be used to implicitly construct the ExtraArgs object.
- A gajillion refactors to make everything behave the way it always has
(cherry picked from commit d507a7e3388382960108b24143da48e5f912b4a7)
Diffstat (limited to 'src/server/game/Entities/GameObject')
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 13ecb688257..e6f90796b89 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -2123,8 +2123,7 @@ void GameObject::Use(Unit* user) if (!spellId) return; - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, GetMap()->GetDifficultyID()); - if (!spellInfo) + if (!sSpellMgr->GetSpellInfo(spellId, GetMap()->GetDifficultyID())) { if (user->GetTypeId() != TYPEID_PLAYER || !sOutdoorPvPMgr->HandleCustomSpell(user->ToPlayer(), spellId, this)) TC_LOG_ERROR("misc", "WORLD: unknown spell id %u at use action for gameobject (Entry: %u GoType: %u)", spellId, GetEntry(), GetGoType()); @@ -2137,7 +2136,7 @@ void GameObject::Use(Unit* user) sOutdoorPvPMgr->HandleCustomSpell(player, spellId, this); if (spellCaster) - spellCaster->CastSpell(user, spellInfo, triggered); + spellCaster->CastSpell(user, spellId, triggered); else CastSpell(user, spellId); } @@ -2166,7 +2165,7 @@ void GameObject::CastSpell(Unit* target, uint32 spellId, TriggerCastFlags trigge if (self) { if (target) - target->CastSpell(target, spellInfo, triggered); + target->CastSpell(target, spellInfo->Id, triggered); return; } @@ -2179,6 +2178,8 @@ void GameObject::CastSpell(Unit* target, uint32 spellId, TriggerCastFlags trigge trigger->SetImmuneToAll(false); PhasingHandler::InheritPhaseShift(trigger, this); + CastSpellExtraArgs args; + args.TriggerFlags = triggered; if (Unit* owner = GetOwner()) { trigger->SetFaction(owner->GetFaction()); @@ -2188,14 +2189,17 @@ void GameObject::CastSpell(Unit* target, uint32 spellId, TriggerCastFlags trigge trigger->SetPvpFlags(owner->GetPvpFlags()); // needed for GO casts for proper target validation checks trigger->SetOwnerGUID(owner->GetGUID()); - trigger->CastSpell(target ? target : trigger, spellInfo, triggered, nullptr, nullptr, owner->GetGUID()); + + args.OriginalCaster = owner->GetGUID(); + trigger->CastSpell(target ? target : trigger, spellInfo->Id, args); } else { trigger->SetFaction(spellInfo->IsPositive() ? FACTION_FRIENDLY : FACTION_MONSTER); // Set owner guid for target if no owner available - needed by trigger auras // - trigger gets despawned and there's no caster avalible (see AuraEffect::TriggerSpell()) - trigger->CastSpell(target ? target : trigger, spellInfo, triggered, nullptr, nullptr, target ? target->GetGUID() : ObjectGuid::Empty); + args.OriginalCaster = target ? target->GetGUID() : ObjectGuid::Empty; + trigger->CastSpell(target ? target : trigger, spellInfo->Id, args); } } |
