From 841e6a63f8f2ddc3bf87b85b76722f400e992e81 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Mon, 24 Apr 2017 11:58:39 +0300 Subject: [PATCH] [Client] Initialize Creatures as LocalActors --- apps/openmw/mwmp/Cell.cpp | 10 ++++++++++ apps/openmw/mwmp/DedicatedActor.cpp | 22 +++++++++++----------- apps/openmw/mwmp/LocalActor.cpp | 16 ++++++++-------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/apps/openmw/mwmp/Cell.cpp b/apps/openmw/mwmp/Cell.cpp index dd4c91c5e..a7762473f 100644 --- a/apps/openmw/mwmp/Cell.cpp +++ b/apps/openmw/mwmp/Cell.cpp @@ -254,6 +254,16 @@ void Cell::initializeLocalActors() initializeLocalActor(ptr); } + + MWWorld::CellRefList *creatureList = store->getCreatures(); + + for (typename MWWorld::CellRefList::List::iterator listIter(creatureList->mList.begin()); + listIter != creatureList->mList.end(); ++listIter) + { + MWWorld::Ptr ptr(&*listIter, store); + + initializeLocalActor(ptr); + } } void Cell::initializeDedicatedActor(const MWWorld::Ptr& ptr) diff --git a/apps/openmw/mwmp/DedicatedActor.cpp b/apps/openmw/mwmp/DedicatedActor.cpp index 003d4ea52..d47d8dc10 100644 --- a/apps/openmw/mwmp/DedicatedActor.cpp +++ b/apps/openmw/mwmp/DedicatedActor.cpp @@ -4,9 +4,9 @@ #include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" +#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/mechanicsmanagerimp.hpp" #include "../mwmechanics/movement.hpp" -#include "../mwmechanics/npcstats.hpp" #include "../mwrender/animation.hpp" @@ -95,17 +95,17 @@ void DedicatedActor::setAnimFlags() using namespace MWMechanics; if (drawState == 0) - ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Nothing); + ptr.getClass().getCreatureStats(ptr).setDrawState(DrawState_Nothing); else if (drawState == 1) - ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Weapon); + ptr.getClass().getCreatureStats(ptr).setDrawState(DrawState_Weapon); else if (drawState == 2) - ptr.getClass().getNpcStats(ptr).setDrawState(DrawState_Spell); + ptr.getClass().getCreatureStats(ptr).setDrawState(DrawState_Spell); - MWMechanics::NpcStats *ptrNpcStats = &ptr.getClass().getNpcStats(ptr); - ptrNpcStats->setMovementFlag(CreatureStats::Flag_Run, (movementFlags & CreatureStats::Flag_Run) != 0); - ptrNpcStats->setMovementFlag(CreatureStats::Flag_Sneak, (movementFlags & CreatureStats::Flag_Sneak) != 0); - ptrNpcStats->setMovementFlag(CreatureStats::Flag_ForceJump, (movementFlags & CreatureStats::Flag_ForceJump) != 0); - ptrNpcStats->setMovementFlag(CreatureStats::Flag_ForceMoveJump, (movementFlags & CreatureStats::Flag_ForceMoveJump) != 0); + MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr); + ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Run, (movementFlags & CreatureStats::Flag_Run) != 0); + ptrCreatureStats->setMovementFlag(CreatureStats::Flag_Sneak, (movementFlags & CreatureStats::Flag_Sneak) != 0); + ptrCreatureStats->setMovementFlag(CreatureStats::Flag_ForceJump, (movementFlags & CreatureStats::Flag_ForceJump) != 0); + ptrCreatureStats->setMovementFlag(CreatureStats::Flag_ForceMoveJump, (movementFlags & CreatureStats::Flag_ForceMoveJump) != 0); } void DedicatedActor::playAnimation() @@ -138,13 +138,13 @@ void DedicatedActor::setStatsDynamic() // Only set dynamic stats if they have valid values if (creatureStats->mDynamic[0].mBase == -1) return; - MWMechanics::NpcStats *ptrNpcStats = &ptr.getClass().getNpcStats(ptr); + MWMechanics::CreatureStats *ptrCreatureStats = &ptr.getClass().getCreatureStats(ptr); MWMechanics::DynamicStat value; for (int i = 0; i < 3; ++i) { value.readState(creatureStats->mDynamic[i]); - ptrNpcStats->setDynamic(i, value); + ptrCreatureStats->setDynamic(i, value); } } diff --git a/apps/openmw/mwmp/LocalActor.cpp b/apps/openmw/mwmp/LocalActor.cpp index 059c8039a..11242fec7 100644 --- a/apps/openmw/mwmp/LocalActor.cpp +++ b/apps/openmw/mwmp/LocalActor.cpp @@ -82,18 +82,18 @@ void LocalActor::updatePosition(bool forceUpdate) void LocalActor::updateAnimFlags(bool forceUpdate) { MWBase::World *world = MWBase::Environment::get().getWorld(); - MWMechanics::NpcStats ptrNpcStats = ptr.getClass().getNpcStats(ptr); + MWMechanics::CreatureStats ptrCreatureStats = ptr.getClass().getCreatureStats(ptr); using namespace MWMechanics; - bool isRunning = ptrNpcStats.getMovementFlag(CreatureStats::Flag_Run); - bool isSneaking = ptrNpcStats.getMovementFlag(CreatureStats::Flag_Sneak); - bool isForceJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceJump); - bool isForceMoveJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump); + bool isRunning = ptrCreatureStats.getMovementFlag(CreatureStats::Flag_Run); + bool isSneaking = ptrCreatureStats.getMovementFlag(CreatureStats::Flag_Sneak); + bool isForceJumping = ptrCreatureStats.getMovementFlag(CreatureStats::Flag_ForceJump); + bool isForceMoveJumping = ptrCreatureStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump); isFlying = world->isFlying(ptr); - MWMechanics::DrawState_ currentDrawState = ptr.getClass().getNpcStats(ptr).getDrawState(); + MWMechanics::DrawState_ currentDrawState = ptr.getClass().getCreatureStats(ptr).getDrawState(); if (wasRunning != isRunning || wasSneaking != isSneaking || wasForceJumping != isForceJumping || @@ -183,7 +183,7 @@ void LocalActor::updateAttack() { if (attack.type == Attack::MAGIC) { - MWMechanics::CreatureStats &attackerStats = ptr.getClass().getNpcStats(ptr); + MWMechanics::CreatureStats &attackerStats = ptr.getClass().getCreatureStats(ptr); attack.spellId = attackerStats.getSpells().getSelectedSpell(); attack.success = mwmp::Main::get().getMechanicsHelper()->getSpellSuccess(attack.spellId, ptr); } @@ -206,7 +206,7 @@ void LocalActor::setPtr(const MWWorld::Ptr& newPtr) refNumIndex = ptr.getCellRef().getRefNum().mIndex; mpNum = ptr.getCellRef().getMpNum(); - lastDrawState = ptr.getClass().getNpcStats(ptr).getDrawState(); + lastDrawState = ptr.getClass().getCreatureStats(ptr).getDrawState(); oldHealth = ptr.getClass().getCreatureStats(ptr).getHealth(); oldMagicka = ptr.getClass().getCreatureStats(ptr).getMagicka(); oldFatigue = ptr.getClass().getCreatureStats(ptr).getFatigue();