Core/ChatCommands: Parse SpellInfo also from enchant, glyph, talent and trade links (PR #25270)

(cherry picked from commit 9df61fd111a39983d751ac0bed767137b330c547)
This commit is contained in:
Peter Keresztes Schmidt
2022-02-02 21:08:29 +01:00
committed by Shauren
parent c8b0d4e6d8
commit 1c246cc980
2 changed files with 18 additions and 9 deletions
@@ -68,12 +68,21 @@ char const* Trinity::ChatCommands::ArgInfo<GameTele const*>::TryConsume(GameTele
struct SpellInfoVisitor
{
using value_type = SpellInfo const*;
value_type operator()(Hyperlink<apower> artifactPower) const { return operator()(artifactPower->ArtifactPower->SpellID); }
value_type operator()(Hyperlink<conduit> soulbindConduit) const { return operator()((*soulbindConduit)->SpellID); }
value_type operator()(Hyperlink<enchant> enchant) const { return enchant; }
value_type operator()(Hyperlink<mawpower> mawPower) const { return operator()((*mawPower)->SpellID); }
value_type operator()(Hyperlink<pvptal> pvpTalent) const { return operator()((*pvpTalent)->SpellID); }
value_type operator()(Hyperlink<spell> spell) const { return spell->Spell; }
value_type operator()(Hyperlink<talent> talent) const { return operator()((*talent)->SpellID); }
value_type operator()(Hyperlink<trade> trade) const { return trade->Spell; }
value_type operator()(uint32 spellId) const { return sSpellMgr->GetSpellInfo(spellId, DIFFICULTY_NONE); }
};
char const* Trinity::ChatCommands::ArgInfo<SpellInfo const*>::TryConsume(SpellInfo const*& data, char const* args)
{
Variant<Hyperlink<spell>, uint32> val;
Variant<Hyperlink<apower>, Hyperlink<conduit>, Hyperlink<enchant>, Hyperlink<mawpower>, Hyperlink<pvptal>, Hyperlink<spell>, Hyperlink<talent>, Hyperlink<trade>, uint32> val;
if ((args = CommandArgsConsumerSingle<decltype(val)>::TryConsumeTo(val, args)))
data = val.visit(SpellInfoVisitor());
return args;