Skip to content

Commit

Permalink
Core/Commands: Fixed crash in all commands expecting SpellInfo* argum…
Browse files Browse the repository at this point in the history
…ents if they are given a chat link to not learned talent (at 0 rank)

Closes TrinityCore#29823
  • Loading branch information
Shauren committed Mar 20, 2024
1 parent 73fdf91 commit 6a54dc5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
5 changes: 1 addition & 4 deletions src/server/game/Chat/ChatCommands/ChatCommandArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ struct SpellInfoVisitor
value_type operator()(Hyperlink<enchant> enchant) const { return enchant; };
value_type operator()(Hyperlink<glyph> glyph) const { return operator()(glyph->Glyph->SpellID); };
value_type operator()(Hyperlink<spell> spell) const { return *spell; }
value_type operator()(Hyperlink<talent> talent) const
{
return operator()(talent->Talent->SpellRank[talent->Rank - 1]);
};
value_type operator()(Hyperlink<talent> talent) const { return talent->Spell; };
value_type operator()(Hyperlink<trade> trade) const { return trade->Spell; };

value_type operator()(uint32 spellId) const { return sSpellMgr->GetSpellInfo(spellId); }
Expand Down
18 changes: 4 additions & 14 deletions src/server/game/Chat/HyperlinkTags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int32>(rank, 0)]);
if (!val.Spell)
return false;
return true;
}

Expand Down

0 comments on commit 6a54dc5

Please sign in to comment.