aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Object
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2021-10-03 19:58:03 +0200
committerShauren <shauren.trinity@gmail.com>2021-10-03 19:58:03 +0200
commitcbf1f2883ad1bc611f08af4838d892bf13057490 (patch)
tree98bf2a96df0e362b798986166d5625d5d979154b /src/server/game/Entities/Object
parent555b2d40ecc22eb0ea4bf913b534ffa7197fa6fe (diff)
Core/Spells: Reduce number of CastSpell overloads to 1
Diffstat (limited to 'src/server/game/Entities/Object')
-rw-r--r--src/server/game/Entities/Object/Object.cpp35
-rw-r--r--src/server/game/Entities/Object/Object.h4
2 files changed, 9 insertions, 30 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 130f6ffd8d9..5eac3047a38 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -2629,7 +2629,7 @@ bool WorldObject::IsNeutralToAll() const
return my_faction->IsNeutralToAll();
}
-void WorldObject::CastSpell(SpellCastTargets const& targets, uint32 spellId, CastSpellExtraArgs const& args /*= { }*/)
+void WorldObject::CastSpell(CastSpellTargetArg const& targets, uint32 spellId, CastSpellExtraArgs const& args /*= { }*/)
{
SpellInfo const* info = sSpellMgr->GetSpellInfo(spellId, args.CastDifficulty != DIFFICULTY_NONE ? args.CastDifficulty : GetMap()->GetDifficultyID());
if (!info)
@@ -2638,37 +2638,18 @@ void WorldObject::CastSpell(SpellCastTargets const& targets, uint32 spellId, Cas
return;
}
+ if (!targets.Targets)
+ {
+ TC_LOG_ERROR("entities.unit", "CastSpell: Invalid target passed to spell cast %u by %s", spellId, GetGUID().ToString().c_str());
+ return;
+ }
+
Spell* spell = new Spell(this, info, args.TriggerFlags, args.OriginalCaster, args.OriginalCastId);
for (auto const& pair : args.SpellValueOverrides)
spell->SetSpellValue(pair.first, pair.second);
spell->m_CastItem = args.CastItem;
- spell->prepare(targets, args.TriggeringAura);
-}
-
-void WorldObject::CastSpell(WorldObject* target, uint32 spellId, CastSpellExtraArgs const& args /*= { }*/)
-{
- SpellCastTargets targets;
- if (target)
- {
- if (Unit* unitTarget = target->ToUnit())
- targets.SetUnitTarget(unitTarget);
- else if (GameObject* goTarget = target->ToGameObject())
- targets.SetGOTarget(goTarget);
- else
- {
- TC_LOG_ERROR("entities.unit", "CastSpell: Invalid target %s passed to spell cast by %s", target->GetGUID().ToString().c_str(), GetGUID().ToString().c_str());
- return;
- }
- }
- CastSpell(targets, spellId, args);
-}
-
-void WorldObject::CastSpell(Position const& dest, uint32 spellId, CastSpellExtraArgs const& args /*= { }*/)
-{
- SpellCastTargets targets;
- targets.SetDst(dest);
- CastSpell(targets, spellId, args);
+ spell->prepare(*targets.Targets, args.TriggeringAura);
}
// function based on function Unit::CanAttack from 13850 client
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index 3a51700cc63..874d45ea7c5 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -596,9 +596,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
bool IsNeutralToAll() const;
// CastSpell's third arg can be a variety of things - check out CastSpellExtraArgs' constructors!
- void CastSpell(SpellCastTargets const& targets, uint32 spellId, CastSpellExtraArgs const& args = { });
- void CastSpell(WorldObject* target, uint32 spellId, CastSpellExtraArgs const& args = { });
- void CastSpell(Position const& dest, uint32 spellId, CastSpellExtraArgs const& args = { });
+ void CastSpell(CastSpellTargetArg const& targets, uint32 spellId, CastSpellExtraArgs const& args = { });
bool IsValidAttackTarget(WorldObject const* target, SpellInfo const* bySpell = nullptr) const;
bool IsValidAssistTarget(WorldObject const* target, SpellInfo const* bySpell = nullptr) const;