From de2d7a8bfd53784e967b1d8f9436a09b26ca4b45 Mon Sep 17 00:00:00 2001 From: Shauren Date: Fri, 18 Apr 2025 23:58:18 +0200 Subject: Core/DataStores: Convert SkillLineAbilityAcquireMethod to enum class (cherry picked from commit 531afa6bcc485db7c115e5ab5d874bda2cbf642e) --- src/server/game/DataStores/DB2Structure.h | 1 + src/server/game/DataStores/DBCEnums.h | 10 ++++++---- src/server/game/Entities/Player/Player.cpp | 14 +++++++------- src/server/game/Spells/SpellMgr.cpp | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/server/game/DataStores/DB2Structure.h b/src/server/game/DataStores/DB2Structure.h index 56d713c1a68..5090201adf7 100644 --- a/src/server/game/DataStores/DB2Structure.h +++ b/src/server/game/DataStores/DB2Structure.h @@ -3068,6 +3068,7 @@ struct SkillLineAbilityEntry int16 SkillupSkillLineID; std::array CharacterPoints; + SkillLineAbilityAcquireMethod GetAcquireMethod() const { return static_cast(AcquireMethod); } EnumFlag GetFlags() const { return static_cast(Flags); } }; diff --git a/src/server/game/DataStores/DBCEnums.h b/src/server/game/DataStores/DBCEnums.h index 4121681e77b..fdd3562ef53 100644 --- a/src/server/game/DataStores/DBCEnums.h +++ b/src/server/game/DataStores/DBCEnums.h @@ -1820,11 +1820,13 @@ enum class SkillLineFlags : uint16 DEFINE_ENUM_FLAG(SkillLineFlags); -enum AbilytyLearnType +enum class SkillLineAbilityAcquireMethod : int32 { - SKILL_LINE_ABILITY_LEARNED_ON_SKILL_VALUE = 1, // Spell state will update depending on skill value - SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN = 2, // Spell will be learned/removed together with entire skill - SKILL_LINE_ABILITY_REWARDED_FROM_QUEST = 4 // Learned as quest reward, also re-learned if missing + Learned = 0, + AutomaticSkillRank = 1, // Spell state will update depending on skill value + AutomaticCharLevel = 2, // Spell will be learned/removed together with entire skill + NeverLearned = 3, + LearnedOrAutomaticCharLevel = 4, }; enum class SkillLineAbilityFlags diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index d117f3739e7..07119b7fabd 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -2759,7 +2759,7 @@ bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent continue; // Runeforging special case - if ((_spell_idx->second->AcquireMethod == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN && !HasSkill(_spell_idx->second->SkillLine)) || ((_spell_idx->second->SkillLine == SKILL_RUNEFORGING) && _spell_idx->second->TrivialSkillLineRankHigh == 0)) + if ((_spell_idx->second->GetAcquireMethod() == SkillLineAbilityAcquireMethod::AutomaticCharLevel && !HasSkill(_spell_idx->second->SkillLine)) || ((_spell_idx->second->SkillLine == SKILL_RUNEFORGING) && _spell_idx->second->TrivialSkillLineRankHigh == 0)) if (SkillRaceClassInfoEntry const* rcInfo = sDB2Manager.GetSkillRaceClassInfo(_spell_idx->second->SkillLine, GetRace(), GetClass())) LearnDefaultSkill(rcInfo); } @@ -23728,7 +23728,7 @@ void Player::LearnQuestRewardedSpells(Quest const* quest) SkillLineAbilityMapBounds skills = sSpellMgr->GetSkillLineAbilityMapBounds(learned_0); for (auto skillItr = skills.first; skillItr != skills.second; ++skillItr) { - if (skillItr->second->AcquireMethod == SKILL_LINE_ABILITY_REWARDED_FROM_QUEST) + if (skillItr->second->GetAcquireMethod() == SkillLineAbilityAcquireMethod::LearnedOrAutomaticCharLevel) { found = true; break; @@ -23768,12 +23768,12 @@ void Player::LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue, Races r if (!spellInfo) continue; - switch (ability->AcquireMethod) + switch (ability->GetAcquireMethod()) { - case SKILL_LINE_ABILITY_LEARNED_ON_SKILL_VALUE: - case SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN: + case SkillLineAbilityAcquireMethod::AutomaticSkillRank: + case SkillLineAbilityAcquireMethod::AutomaticCharLevel: break; - case SKILL_LINE_ABILITY_REWARDED_FROM_QUEST: + case SkillLineAbilityAcquireMethod::LearnedOrAutomaticCharLevel: if (!ability->GetFlags().HasFlag(SkillLineAbilityFlags::CanFallbackToLearnedOnSkillLearn) || !spellInfo->MeetsFutureSpellPlayerCondition(this)) continue; @@ -23805,7 +23805,7 @@ void Player::LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue, Races r continue; // need unlearn spell - if (int32(skillValue) < ability->MinSkillLineRank && ability->AcquireMethod == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_VALUE) + if (int32(skillValue) < ability->MinSkillLineRank && ability->GetAcquireMethod() == SkillLineAbilityAcquireMethod::AutomaticSkillRank) RemoveSpell(ability->Spell); // need learn else if (!IsInWorld()) diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 08c66eeffee..93bb74ce7fe 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -2302,7 +2302,7 @@ void SpellMgr::LoadPetLevelupSpellMap() for (SkillLineAbilityEntry const* skillLine : *skillLineAbilities) { - if (skillLine->AcquireMethod != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN) + if (skillLine->GetAcquireMethod() != SkillLineAbilityAcquireMethod::AutomaticCharLevel) continue; SpellInfo const* spell = GetSpellInfo(skillLine->Spell, DIFFICULTY_NONE); @@ -4950,7 +4950,7 @@ void SpellMgr::LoadPetFamilySpellsStore() if (skillLine->SkillLine != cFamily->SkillLine[0] && skillLine->SkillLine != cFamily->SkillLine[1]) continue; - if (skillLine->AcquireMethod != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN) + if (skillLine->GetAcquireMethod() != SkillLineAbilityAcquireMethod::AutomaticCharLevel) continue; sPetFamilySpellsStore[cFamily->ID].insert(spellInfo->Id); -- cgit v1.2.3