From de8d28e2c32fb5ae054abb951ba6df9dfa7e2ea8 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Thu, 13 Apr 2017 18:59:22 +0300 Subject: [PATCH] [Client] Improve logic for updating LocalActors & sending their packets --- apps/openmw/mwmp/ActorList.cpp | 18 ++++++++++++------ apps/openmw/mwmp/Cell.cpp | 4 +++- apps/openmw/mwmp/DedicatedActor.cpp | 3 ++- apps/openmw/mwmp/LocalActor.cpp | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwmp/ActorList.cpp b/apps/openmw/mwmp/ActorList.cpp index 19764f3ce..6424ebea1 100644 --- a/apps/openmw/mwmp/ActorList.cpp +++ b/apps/openmw/mwmp/ActorList.cpp @@ -54,16 +54,22 @@ void ActorList::addDrawStateActor(LocalActor localActor) void ActorList::sendPositionActors() { - baseActors = positionActors; - Main::get().getNetworking()->getActorPacket(ID_ACTOR_POSITION)->setActorList(this); - Main::get().getNetworking()->getActorPacket(ID_ACTOR_POSITION)->Send(); + if (positionActors.size() > 0) + { + baseActors = positionActors; + Main::get().getNetworking()->getActorPacket(ID_ACTOR_POSITION)->setActorList(this); + Main::get().getNetworking()->getActorPacket(ID_ACTOR_POSITION)->Send(); + } } void ActorList::sendDrawStateActors() { - baseActors = drawStateActors; - Main::get().getNetworking()->getActorPacket(ID_ACTOR_DRAW_STATE)->setActorList(this); - Main::get().getNetworking()->getActorPacket(ID_ACTOR_DRAW_STATE)->Send(); + if (drawStateActors.size() > 0) + { + baseActors = drawStateActors; + Main::get().getNetworking()->getActorPacket(ID_ACTOR_DRAW_STATE)->setActorList(this); + Main::get().getNetworking()->getActorPacket(ID_ACTOR_DRAW_STATE)->Send(); + } } // TODO: Finish this diff --git a/apps/openmw/mwmp/Cell.cpp b/apps/openmw/mwmp/Cell.cpp index f461f589a..7665109a5 100644 --- a/apps/openmw/mwmp/Cell.cpp +++ b/apps/openmw/mwmp/Cell.cpp @@ -45,7 +45,9 @@ void Cell::updateLocal(bool forceUpdate) } else { - actor->update(forceUpdate); + if (actor->getPtr().getRefData().isEnabled()) + actor->update(forceUpdate); + ++it; } } diff --git a/apps/openmw/mwmp/DedicatedActor.cpp b/apps/openmw/mwmp/DedicatedActor.cpp index 017bb3979..d6f50fb29 100644 --- a/apps/openmw/mwmp/DedicatedActor.cpp +++ b/apps/openmw/mwmp/DedicatedActor.cpp @@ -15,7 +15,8 @@ using namespace std; DedicatedActor::DedicatedActor() { - + drawState = 0; + movementFlags = 0; } DedicatedActor::~DedicatedActor() diff --git a/apps/openmw/mwmp/LocalActor.cpp b/apps/openmw/mwmp/LocalActor.cpp index 14f4b13ff..ee9e37855 100644 --- a/apps/openmw/mwmp/LocalActor.cpp +++ b/apps/openmw/mwmp/LocalActor.cpp @@ -66,7 +66,7 @@ void LocalActor::updateDrawStateAndFlags(bool forceUpdate) bool isForceMoveJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump); isFlying = world->isFlying(ptr); - bool isJumping = ptr.getRefData().isEnabled() && !world->isOnGround(ptr) && !isFlying; + bool isJumping = !world->isOnGround(ptr) && !isFlying; MWMechanics::DrawState_ currentDrawState = ptr.getClass().getNpcStats(ptr).getDrawState();