Core/Players: Fixed loading and saving skill data PK violations

This commit is contained in:
Shauren
2015-01-10 20:59:08 +01:00
parent ec5800c845
commit 2dfd1594cd

View File

@@ -25007,6 +25007,7 @@ void Player::_LoadSkills(PreparedQueryResult result)
uint32 count = 0;
uint8 professionCount = 0;
std::unordered_map<uint32, uint32> loadedSkillValues;
if (result)
{
do
@@ -25083,8 +25084,7 @@ void Player::_LoadSkills(PreparedQueryResult result)
SetUInt16Value(PLAYER_SKILL_LINEID + SKILL_PERM_BONUS_OFFSET + field, offset, 0);
mSkillStatus.insert(SkillStatusMap::value_type(skill, SkillStatusData(count, SKILL_UNCHANGED)));
LearnSkillRewardedSpells(skill, value);
loadedSkillValues[skill] = value;
++count;
@@ -25097,6 +25097,10 @@ void Player::_LoadSkills(PreparedQueryResult result)
while (result->NextRow());
}
// 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)
LearnSkillRewardedSpells(skill.first, skill.second);
if (HasSkill(SKILL_FIST_WEAPONS))
SetSkill(SKILL_FIST_WEAPONS, 0, GetSkillValue(SKILL_UNARMED), GetMaxSkillValueForLevel());