diff options
author | Shauren <shauren.trinity@gmail.com> | 2022-04-16 10:41:50 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-04-16 12:15:37 +0200 |
commit | d1209a83889ce26e29edc1ac19717eb6012e3a1d (patch) | |
tree | ec27c4a5913081a2aa080657a270d425a1075db3 | |
parent | 342eefcb361900741c17cc40a48fd10436908175 (diff) |
Core/Players: Add player race argument to Player::LearnSkillRewardedSpells
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 21 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 2 |
2 files changed, 12 insertions, 11 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index e309571b936..6d6a27316dd 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -5613,7 +5613,7 @@ bool Player::UpdateSkillPro(uint16 skillId, int32 chance, uint32 step) { if (value < bsl && new_value >= bsl) { - LearnSkillRewardedSpells(skillId, new_value); + LearnSkillRewardedSpells(skillId, new_value, Races(GetRace())); break; } } @@ -5639,6 +5639,7 @@ void Player::ModifySkillBonus(uint32 skillid, int32 val, bool talent) void Player::UpdateSkillsForLevel() { + Races race = Races(GetRace()); uint32 maxSkill = GetMaxSkillValueForLevel(); for (SkillStatusMap::iterator itr = mSkillStatus.begin(); itr != mSkillStatus.end(); ++itr) @@ -5662,7 +5663,7 @@ void Player::UpdateSkillsForLevel() } // Update level dependent skillline spells - LearnSkillRewardedSpells(rcEntry->SkillID, m_activePlayerData->Skill->SkillRank[itr->second.pos]); + LearnSkillRewardedSpells(rcEntry->SkillID, m_activePlayerData->Skill->SkillRank[itr->second.pos], race); } } @@ -5710,7 +5711,7 @@ void Player::SetSkill(uint32 id, uint16 step, uint16 newVal, uint16 maxVal) SetSkillRank(itr->second.pos, newVal); SetSkillMaxRank(itr->second.pos, maxVal); - LearnSkillRewardedSpells(id, newVal); + LearnSkillRewardedSpells(id, newVal, Races(GetRace())); // if skill value is going up, update enchantments after setting the new value if (newVal > currVal) { @@ -5857,7 +5858,7 @@ void Player::SetSkill(uint32 id, uint16 step, uint16 newVal, uint16 maxVal) effect->HandleEffect(this, AURA_EFFECT_HANDLE_SKILL, true); // Learn all spells for skill - LearnSkillRewardedSpells(id, newVal); + LearnSkillRewardedSpells(id, newVal, Races(GetRace())); UpdateCriteria(CriteriaType::SkillRaised, id); UpdateCriteria(CriteriaType::AchieveSkillStep, id); } @@ -24957,9 +24958,8 @@ void Player::LearnQuestRewardedSpells() } } -void Player::LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue) +void Player::LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue, Races race) { - uint8 race = GetRace(); uint32 classMask = GetClassMask(); std::vector<SkillLineAbilityEntry const*> const* skillLineAbilities = sDB2Manager.GetSkillLineAbilitiesBySkill(skillId); if (!skillLineAbilities) @@ -26652,6 +26652,7 @@ void Player::_LoadSkills(PreparedQueryResult result) // 0 1 2 // SetPQuery(PLAYER_LOGIN_QUERY_LOADSKILLS, "SELECT skill, value, max FROM character_skills WHERE guid = '%u'", GUID_LOPART(m_guid)); + Races race = Races(GetRace()); uint32 count = 0; std::unordered_map<uint32, uint32> loadedSkillValues; if (result) @@ -26670,11 +26671,11 @@ void Player::_LoadSkills(PreparedQueryResult result) uint16 value = fields[1].GetUInt16(); uint16 max = fields[2].GetUInt16(); - SkillRaceClassInfoEntry const* rcEntry = sDB2Manager.GetSkillRaceClassInfo(skill, GetRace(), GetClass()); + SkillRaceClassInfoEntry const* rcEntry = sDB2Manager.GetSkillRaceClassInfo(skill, race, GetClass()); if (!rcEntry) { TC_LOG_ERROR("entities.player", "Player::_LoadSkills: Player '%s' (%s, Race: %u, Class: %u) has forbidden skill %u for his race/class combination", - GetName().c_str(), GetGUID().ToString().c_str(), uint32(GetRace()), uint32(GetClass()), skill); + GetName().c_str(), GetGUID().ToString().c_str(), uint32(race), uint32(GetClass()), skill); mSkillStatus.insert(SkillStatusMap::value_type(skill, SkillStatusData(0, SKILL_DELETED))); continue; @@ -26734,9 +26735,9 @@ void Player::_LoadSkills(PreparedQueryResult result) } // Learn skill rewarded spells after all skills have been loaded to prevent learning a skill from them before its loaded with proper value from DB - for (auto& skill : loadedSkillValues) + for (auto const& skill : loadedSkillValues) { - LearnSkillRewardedSpells(skill.first, skill.second); + LearnSkillRewardedSpells(skill.first, skill.second, race); if (std::vector<SkillLineEntry const*> const* childSkillLines = sDB2Manager.GetSkillLinesForParentSkill(skill.first)) { for (auto childItr = childSkillLines->begin(); childItr != childSkillLines->end() && mSkillStatus.size() < PLAYER_MAX_SKILLS; ++childItr) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index ec63651d666..a013473c3ec 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -2183,7 +2183,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> int16 GetSkillTempBonusValue(uint32 skill) const; uint16 GetSkillStep(uint32 skill) const; // 0...6 bool HasSkill(uint32 skill) const; - void LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue); + void LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue, Races race); int32 FindProfessionSlotFor(uint32 skillId) const; void SetSkillLineId(uint32 pos, uint16 skillLineId) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::Skill).ModifyValue(&UF::SkillInfo::SkillLineID, pos), skillLineId); } void SetSkillStep(uint32 pos, uint16 step) { SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::Skill).ModifyValue(&UF::SkillInfo::SkillStep, pos), step); }; |