Core/Spells: Reduce number of CastSpell overloads to 1
This commit is contained in:
1 parent
78de91a487
commit
e503f96adb
42 files changed
+275
-251
No files matched your search
@@ -2941,7 +2941,7 @@ bool WorldObject::IsNeutralToAll() const
|
||||
return my_faction->IsNeutralToAll();
|
||||
}
|
||||
|
||||
SpellCastResult WorldObject::CastSpell(SpellCastTargets const& targets, uint32 spellId, CastSpellExtraArgs const& args /*= { }*/)
|
||||
SpellCastResult WorldObject::CastSpell(CastSpellTargetArg const& targets, uint32 spellId, CastSpellExtraArgs const& args /*= { }*/)
|
||||
{
|
||||
SpellInfo const* info = sSpellMgr->GetSpellInfo(spellId);
|
||||
if (!info)
|
||||
@@ -2950,6 +2950,12 @@ SpellCastResult WorldObject::CastSpell(SpellCastTargets const& targets, uint32 s
|
||||
return SPELL_FAILED_SPELL_UNAVAILABLE;
|
||||
}
|
||||
|
||||
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_FAILED_BAD_TARGETS;
|
||||
}
|
||||
|
||||
Spell* spell = new Spell(this, info, args.TriggerFlags, args.OriginalCaster);
|
||||
for (CastSpellExtraArgsInit::SpellValueOverride const& value : args.SpellValueOverrides)
|
||||
spell->SetSpellValue(value);
|
||||
@@ -2968,32 +2974,7 @@ SpellCastResult WorldObject::CastSpell(SpellCastTargets const& targets, uint32 s
|
||||
|
||||
spell->m_customArg = args.CustomArg;
|
||||
|
||||
return spell->prepare(targets, args.TriggeringAura);
|
||||
}
|
||||
|
||||
SpellCastResult 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 SPELL_FAILED_BAD_TARGETS;
|
||||
}
|
||||
}
|
||||
return CastSpell(targets, spellId, args);
|
||||
}
|
||||
|
||||
SpellCastResult WorldObject::CastSpell(Position const& dest, uint32 spellId, CastSpellExtraArgs const& args /*= { }*/)
|
||||
{
|
||||
SpellCastTargets targets;
|
||||
targets.SetDst(dest);
|
||||
return CastSpell(targets, spellId, args);
|
||||
return spell->prepare(*targets.Targets, args.TriggeringAura);
|
||||
}
|
||||
|
||||
// function based on function Unit::CanAttack from 13850 client
|
||||
|
||||
Reference in new issue
Block a user