From 6e47b652051b8f6b3bab2faee1b1fe72267a8c81 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 11 Jan 2019 14:26:13 +0200 Subject: [PATCH] [Client] Set attribute increases & level progress after correct packets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Originally, the PlayerSkill packet contained skills, attribute increases and level progress. In 78441c769a23c23b98deca1725d3ccfc0ced7f75, the attribute increases were moved to the PlayerAttribute packet and the level progress was moved to the PlayerLevel packet, but – due to an oversight – attribute increases and level progress were still being applied to the local player only when a PlayerSkill packet was received, based on whatever values were stored from the last PlayerAttribute and PlayerLevel packets. --- apps/openmw/mwmp/LocalPlayer.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 7eb31db2c..421e98ec4 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -920,7 +920,7 @@ void LocalPlayer::setAttributes() { MWWorld::Ptr ptrPlayer = getPlayerPtr(); - MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer); + MWMechanics::NpcStats *ptrNpcStats = &ptrPlayer.getClass().getNpcStats(ptrPlayer); MWMechanics::AttributeValue attributeValue; for (int attributeIndex = 0; attributeIndex < 8; ++attributeIndex) @@ -928,14 +928,14 @@ void LocalPlayer::setAttributes() // If the server wants to clear our attribute's non-zero modifier, we need to remove // the spell effect causing it, to avoid an infinite loop where the effect keeps resetting // the modifier - if (creatureStats.mAttributes[attributeIndex].mMod == 0 && ptrCreatureStats->getAttribute(attributeIndex).getModifier() > 0) + if (creatureStats.mAttributes[attributeIndex].mMod == 0 && ptrNpcStats->getAttribute(attributeIndex).getModifier() > 0) { - ptrCreatureStats->getActiveSpells().purgeEffectByArg(ESM::MagicEffect::FortifyAttribute, attributeIndex); + ptrNpcStats->getActiveSpells().purgeEffectByArg(ESM::MagicEffect::FortifyAttribute, attributeIndex); MWBase::Environment::get().getMechanicsManager()->updateMagicEffects(ptrPlayer); // Is the modifier for this attribute still higher than 0? If so, unequip items that // fortify the attribute - if (ptrCreatureStats->getAttribute(attributeIndex).getModifier() > 0) + if (ptrNpcStats->getAttribute(attributeIndex).getModifier() > 0) { MechanicsHelper::unequipItemsByEffect(ptrPlayer, ESM::Enchantment::ConstantEffect, ESM::MagicEffect::FortifyAttribute, attributeIndex, -1); mwmp::Main::get().getGUIController()->refreshGuiMode(MWGui::GM_Inventory); @@ -943,7 +943,9 @@ void LocalPlayer::setAttributes() } attributeValue.readState(creatureStats.mAttributes[attributeIndex]); - ptrCreatureStats->setAttribute(attributeIndex, attributeValue); + ptrNpcStats->setAttribute(attributeIndex, attributeValue); + + ptrNpcStats->setSkillIncrease(attributeIndex, npcStats.mSkillIncrease[attributeIndex]); } } @@ -976,11 +978,6 @@ void LocalPlayer::setSkills() skillValue.readState(npcStats.mSkills[skillIndex]); ptrNpcStats->setSkill(skillIndex, skillValue); } - - for (int attributeIndex = 0; attributeIndex < 8; ++attributeIndex) - ptrNpcStats->setSkillIncrease(attributeIndex, npcStats.mSkillIncrease[attributeIndex]); - - ptrNpcStats->setLevelProgress(npcStats.mLevelProgress); } void LocalPlayer::setLevel() @@ -988,8 +985,9 @@ void LocalPlayer::setLevel() MWBase::World *world = MWBase::Environment::get().getWorld(); MWWorld::Ptr ptrPlayer = world->getPlayerPtr(); - MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer); - ptrCreatureStats->setLevel(creatureStats.mLevel); + MWMechanics::NpcStats *ptrNpcStats = &ptrPlayer.getClass().getNpcStats(ptrPlayer); + ptrNpcStats->setLevel(creatureStats.mLevel); + ptrNpcStats->setLevelProgress(npcStats.mLevelProgress); } void LocalPlayer::setBounty()