From 6a54dc5a34665e54937d1300e73a087b5938c1ab Mon Sep 17 00:00:00 2001 From: Shauren Date: Wed, 20 Mar 2024 19:58:37 +0100 Subject: [PATCH] Core/Commands: Fixed crash in all commands expecting SpellInfo* arguments if they are given a chat link to not learned talent (at 0 rank) Closes #29823 --- .../game/Chat/ChatCommands/ChatCommandArgs.cpp | 5 +---- src/server/game/Chat/HyperlinkTags.cpp | 18 ++++-------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/server/game/Chat/ChatCommands/ChatCommandArgs.cpp b/src/server/game/Chat/ChatCommands/ChatCommandArgs.cpp index a19f9571d0e46..91af31cc41c6a 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommandArgs.cpp +++ b/src/server/game/Chat/ChatCommands/ChatCommandArgs.cpp @@ -100,10 +100,7 @@ struct SpellInfoVisitor value_type operator()(Hyperlink enchant) const { return enchant; }; value_type operator()(Hyperlink glyph) const { return operator()(glyph->Glyph->SpellID); }; value_type operator()(Hyperlink spell) const { return *spell; } - value_type operator()(Hyperlink talent) const - { - return operator()(talent->Talent->SpellRank[talent->Rank - 1]); - }; + value_type operator()(Hyperlink talent) const { return talent->Spell; }; value_type operator()(Hyperlink trade) const { return trade->Spell; }; value_type operator()(uint32 spellId) const { return sSpellMgr->GetSpellInfo(spellId); } diff --git a/src/server/game/Chat/HyperlinkTags.cpp b/src/server/game/Chat/HyperlinkTags.cpp index 5c343a9abe9db..84f1986cd9146 100644 --- a/src/server/game/Chat/HyperlinkTags.cpp +++ b/src/server/game/Chat/HyperlinkTags.cpp @@ -199,22 +199,12 @@ bool Trinity::Hyperlinks::LinkTags::talent::StoreTo(TalentLinkData& val, std::st if (rank < -1 || rank >= MAX_TALENT_RANK) return false; val.Talent = sTalentStore.LookupEntry(talentId); - val.Rank = rank+1; + val.Rank = rank + 1; if (!val.Talent) return false; - if (val.Rank > 0) - { - uint32 const spellId = val.Talent->SpellRank[val.Rank - 1]; - if (!spellId) - return false; - val.Spell = sSpellMgr->GetSpellInfo(spellId); - if (!val.Spell) - return false; - } - else - { - val.Spell = nullptr; - } + val.Spell = sSpellMgr->GetSpellInfo(val.Talent->SpellRank[std::max(rank, 0)]); + if (!val.Spell) + return false; return true; }