From a01fc577f12e428fe7b31684b48544c284fbb155 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 13 Apr 2018 16:59:48 +0300 Subject: [PATCH] [Client] Add setAttributes() and setSkills() methods to DedicatedPlayer --- apps/openmw/mwmp/DedicatedPlayer.cpp | 27 +++++++++++++++++++ apps/openmw/mwmp/DedicatedPlayer.hpp | 2 ++ .../player/ProcessorPlayerAttribute.hpp | 10 +------ .../player/ProcessorPlayerSkill.hpp | 14 +--------- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index 5ce364450..dc96c71fd 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -274,6 +274,33 @@ void DedicatedPlayer::setAnimFlags() ptrCreatureStats->setMovementFlag(CreatureStats::Flag_ForceMoveJump, (movementFlags & CreatureStats::Flag_ForceMoveJump) != 0); } +void DedicatedPlayer::setAttributes() +{ + MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr); + MWMechanics::AttributeValue attributeValue; + + for (int i = 0; i < 8; ++i) + { + attributeValue.readState(creatureStats.mAttributes[i]); + ptrCreatureStats->setAttribute(i, attributeValue); + } +} + +void DedicatedPlayer::setSkills() +{ + // Go no further if the player is disguised as a creature + if (ptr.getTypeName() != typeid(ESM::NPC).name()) return; + + MWMechanics::NpcStats *ptrNpcStats = &ptr.getClass().getNpcStats(ptr); + MWMechanics::SkillValue skillValue; + + for (int i = 0; i < 27; ++i) + { + skillValue.readState(npcStats.mSkills[i]); + ptrNpcStats->setSkill(i, skillValue); + } +} + void DedicatedPlayer::setEquipment() { // Go no further if the player is disguised as a creature diff --git a/apps/openmw/mwmp/DedicatedPlayer.hpp b/apps/openmw/mwmp/DedicatedPlayer.hpp index f77585477..b9ead74e1 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.hpp +++ b/apps/openmw/mwmp/DedicatedPlayer.hpp @@ -40,6 +40,8 @@ namespace mwmp void setBaseInfo(); void setShapeshift(); void setAnimFlags(); + void setAttributes(); + void setSkills(); void setEquipment(); void setCell(); diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerAttribute.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerAttribute.hpp index c49c065a7..2bf358e65 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerAttribute.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerAttribute.hpp @@ -31,15 +31,7 @@ namespace mwmp } else if (player != 0) { - MWWorld::Ptr ptrPlayer = static_cast(player)->getPtr(); - MWMechanics::CreatureStats *ptrCreatureStats = &ptrPlayer.getClass().getCreatureStats(ptrPlayer); - MWMechanics::AttributeValue attributeValue; - - for (int i = 0; i < 8; ++i) - { - attributeValue.readState(player->creatureStats.mAttributes[i]); - ptrCreatureStats->setAttribute(i, attributeValue); - } + static_cast(player)->setAttributes(); } } }; diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerSkill.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerSkill.hpp index eeee67a80..180c2ab49 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerSkill.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerSkill.hpp @@ -29,19 +29,7 @@ namespace mwmp } else if (player != 0) { - MWWorld::Ptr ptrPlayer = static_cast(player)->getPtr(); - - // Go no further if the player is disguised as a creature - if (ptrPlayer.getTypeName() != typeid(ESM::NPC).name()) return; - - MWMechanics::NpcStats *ptrNpcStats = &ptrPlayer.getClass().getNpcStats(ptrPlayer); - MWMechanics::SkillValue skillValue; - - for (int i = 0; i < 27; ++i) - { - skillValue.readState(player->npcStats.mSkills[i]); - ptrNpcStats->setSkill(i, skillValue); - } + static_cast(player)->setSkills(); } } };