fix(Core/Player): Fix skill rewarded spell learning to properly handle skill-rewarded spells with out-of-order IDs (#24581)

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Andrew
2026-02-15 15:14:42 -03:00
committed by GitHub
parent 7a7f455ca2
commit c7a8c9ae9a

View File

@@ -11993,7 +11993,17 @@ void Player::learnSkillRewardedSpells(uint32 skill_id, uint32 skill_value)
{
uint32 raceMask = getRaceMask();
uint32 classMask = getClassMask();
for (SkillLineAbilityEntry const* pAbility : GetSkillLineAbilitiesBySkillLine(skill_id))
// Get all abilities for this skill and sort by MinSkillLineRank (lowest to highest)
auto abilities = GetSkillLineAbilitiesBySkillLine(skill_id);
std::vector<SkillLineAbilityEntry const*> sortedAbilities(abilities.begin(), abilities.end());
std::sort(sortedAbilities.begin(), sortedAbilities.end(),
[](SkillLineAbilityEntry const* a, SkillLineAbilityEntry const* b)
{
return a->MinSkillLineRank < b->MinSkillLineRank;
});
for (SkillLineAbilityEntry const* pAbility : sortedAbilities)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(pAbility->Spell);
if (!spellInfo)