[Client] Read ActorPosition packets sent from Lua script cell loads

This commit is contained in:
David Cernat 2017-05-01 21:55:50 +03:00
parent 4c35c328a9
commit a77bd6652f
3 changed files with 22 additions and 2 deletions

View file

@ -99,6 +99,18 @@ void Cell::readPositions(ActorList& actorList)
DedicatedActor *actor = dedicatedActors[mapIndex];
actor->position = baseActor.position;
actor->direction = baseActor.direction;
if (!actor->hasPositionData)
{
actor->hasPositionData = true;
// If this is our first packet about this actor's position, force an update
// now instead of waiting for its frame
//
// That way, if this actor is about to become a LocalActor, initial data about it
// received from the server still gets set
actor->setPosition();
}
}
}
}

View file

@ -29,6 +29,7 @@ DedicatedActor::DedicatedActor()
animation.groupname = "";
sound = "";
hasPositionData = false;
hasStatsDynamicData = false;
hasChangedCell = true;
@ -77,7 +78,7 @@ void DedicatedActor::move(float dt)
}
else
{
world->moveObject(ptr, position.pos[0], position.pos[1], position.pos[2]);
setPosition();
hasChangedCell = false;
}
@ -89,6 +90,12 @@ void DedicatedActor::move(float dt)
world->rotateObject(ptr, position.rot[0], position.rot[1], position.rot[2]);
}
void DedicatedActor::setPosition()
{
MWBase::World *world = MWBase::Environment::get().getWorld();
world->moveObject(ptr, position.pos[0], position.pos[1], position.pos[2]);
}
void DedicatedActor::setAnimFlags()
{
using namespace MWMechanics;

View file

@ -15,8 +15,9 @@ namespace mwmp
virtual ~DedicatedActor();
void update(float dt);
void setCell(MWWorld::CellStore *cellStore);
void move(float dt);
void setCell(MWWorld::CellStore *cellStore);
void setPosition();
void setAnimFlags();
void playAnimation();
void playSound();