[Client] Improve logic for updating LocalActors & sending their packets

This commit is contained in:
David Cernat 2017-04-13 18:59:22 +03:00
parent 9e25a95861
commit de8d28e2c3
4 changed files with 18 additions and 9 deletions

View file

@ -54,16 +54,22 @@ void ActorList::addDrawStateActor(LocalActor localActor)
void ActorList::sendPositionActors() void ActorList::sendPositionActors()
{ {
baseActors = positionActors; if (positionActors.size() > 0)
Main::get().getNetworking()->getActorPacket(ID_ACTOR_POSITION)->setActorList(this); {
Main::get().getNetworking()->getActorPacket(ID_ACTOR_POSITION)->Send(); baseActors = positionActors;
Main::get().getNetworking()->getActorPacket(ID_ACTOR_POSITION)->setActorList(this);
Main::get().getNetworking()->getActorPacket(ID_ACTOR_POSITION)->Send();
}
} }
void ActorList::sendDrawStateActors() void ActorList::sendDrawStateActors()
{ {
baseActors = drawStateActors; if (drawStateActors.size() > 0)
Main::get().getNetworking()->getActorPacket(ID_ACTOR_DRAW_STATE)->setActorList(this); {
Main::get().getNetworking()->getActorPacket(ID_ACTOR_DRAW_STATE)->Send(); baseActors = drawStateActors;
Main::get().getNetworking()->getActorPacket(ID_ACTOR_DRAW_STATE)->setActorList(this);
Main::get().getNetworking()->getActorPacket(ID_ACTOR_DRAW_STATE)->Send();
}
} }
// TODO: Finish this // TODO: Finish this

View file

@ -45,7 +45,9 @@ void Cell::updateLocal(bool forceUpdate)
} }
else else
{ {
actor->update(forceUpdate); if (actor->getPtr().getRefData().isEnabled())
actor->update(forceUpdate);
++it; ++it;
} }
} }

View file

@ -15,7 +15,8 @@ using namespace std;
DedicatedActor::DedicatedActor() DedicatedActor::DedicatedActor()
{ {
drawState = 0;
movementFlags = 0;
} }
DedicatedActor::~DedicatedActor() DedicatedActor::~DedicatedActor()

View file

@ -66,7 +66,7 @@ void LocalActor::updateDrawStateAndFlags(bool forceUpdate)
bool isForceMoveJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump); bool isForceMoveJumping = ptrNpcStats.getMovementFlag(CreatureStats::Flag_ForceMoveJump);
isFlying = world->isFlying(ptr); 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(); MWMechanics::DrawState_ currentDrawState = ptr.getClass().getNpcStats(ptr).getDrawState();