From 44476248b74b08df4ea534899946504bfba4f817 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 24 Apr 2017 18:38:57 +0300 Subject: [PATCH] [Client] Add and use DedicatedPlayer::update() --- apps/openmw/mwmp/DedicatedPlayer.cpp | 77 +++++++++++++++------------- apps/openmw/mwmp/DedicatedPlayer.hpp | 2 + 2 files changed, 43 insertions(+), 36 deletions(-) diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index 2beacd62e..2ab546dfa 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -56,43 +56,10 @@ void PlayerList::update(float dt) { for (std::map ::iterator it = players.begin(); it != players.end(); it++) { - DedicatedPlayer *pl = it->second; - if (pl == 0) continue; + DedicatedPlayer *player = it->second; + if (player == 0) continue; - MWMechanics::NpcStats *ptrNpcStats = &pl->ptr.getClass().getNpcStats(pl->getPtr()); - - MWMechanics::DynamicStat value; - - if (pl->creatureStats.mDead) - { - value.readState(pl->creatureStats.mDynamic[0]); - ptrNpcStats->setHealth(value); - continue; - } - - value.readState(pl->creatureStats.mDynamic[0]); - ptrNpcStats->setHealth(value); - value.readState(pl->creatureStats.mDynamic[1]); - ptrNpcStats->setMagicka(value); - value.readState(pl->creatureStats.mDynamic[2]); - ptrNpcStats->setFatigue(value); - - if (ptrNpcStats->isDead()) - ptrNpcStats->resurrect(); - - ptrNpcStats->setAttacked(false); - - ptrNpcStats->getAiSequence().stopCombat(); - - ptrNpcStats->setAlarmed(false); - ptrNpcStats->setAiSetting(MWMechanics::CreatureStats::AI_Alarm, 0); - ptrNpcStats->setAiSetting(MWMechanics::CreatureStats::AI_Fight, 0); - ptrNpcStats->setAiSetting(MWMechanics::CreatureStats::AI_Flee, 0); - ptrNpcStats->setAiSetting(MWMechanics::CreatureStats::AI_Hello, 0); - - ptrNpcStats->setBaseDisposition(255); - pl->move(dt); - pl->updateAnimFlags(); + player->update(dt); } } @@ -241,6 +208,44 @@ bool PlayerList::isDedicatedPlayer(const MWWorld::Ptr &ptr) return (getPlayer(ptr) != 0); } +void DedicatedPlayer::update(float dt) +{ + MWMechanics::NpcStats *ptrNpcStats = &ptr.getClass().getNpcStats(ptr); + + MWMechanics::DynamicStat value; + + if (creatureStats.mDead) + { + value.readState(creatureStats.mDynamic[0]); + ptrNpcStats->setHealth(value); + return; + } + + value.readState(creatureStats.mDynamic[0]); + ptrNpcStats->setHealth(value); + value.readState(creatureStats.mDynamic[1]); + ptrNpcStats->setMagicka(value); + value.readState(creatureStats.mDynamic[2]); + ptrNpcStats->setFatigue(value); + + if (ptrNpcStats->isDead()) + ptrNpcStats->resurrect(); + + ptrNpcStats->setAttacked(false); + + ptrNpcStats->getAiSequence().stopCombat(); + + ptrNpcStats->setAlarmed(false); + ptrNpcStats->setAiSetting(MWMechanics::CreatureStats::AI_Alarm, 0); + ptrNpcStats->setAiSetting(MWMechanics::CreatureStats::AI_Fight, 0); + ptrNpcStats->setAiSetting(MWMechanics::CreatureStats::AI_Flee, 0); + ptrNpcStats->setAiSetting(MWMechanics::CreatureStats::AI_Hello, 0); + + ptrNpcStats->setBaseDisposition(255); + move(dt); + updateAnimFlags(); +} + void DedicatedPlayer::move(float dt) { if (state != 2) return; diff --git a/apps/openmw/mwmp/DedicatedPlayer.hpp b/apps/openmw/mwmp/DedicatedPlayer.hpp index d13a9d5d4..e1e2215ed 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.hpp +++ b/apps/openmw/mwmp/DedicatedPlayer.hpp @@ -53,6 +53,8 @@ namespace mwmp public: + void update(float dt); + void move(float dt); void updateAnimFlags(); void updateEquipment();