[Client] Avoid updating positions and anim flags when framerate is low

Also rename DedicatedPlayer methods so they are consistent with those from DedicatedActor
0.6.1
David Cernat 8 years ago
parent 271594f0ee
commit 8f5e6531db

@ -687,7 +687,7 @@ void CharacterController::playRandomDeath(float startpoint)
Start of tes3mp addition Start of tes3mp addition
If this is a LocalActor or DedicatedActor whose death animation is supposed to be finished, If this is a LocalActor or DedicatedActor whose death animation is supposed to be finished,
set the start point to the animation's end set the startpoint to the animation's end
*/ */
if (mPtr.getClass().getCreatureStats(mPtr).isDeathAnimationFinished() && (mwmp::Main::get().getCellController()->isLocalActor(mPtr) || mwmp::Main::get().getCellController()->isDedicatedActor(mPtr))) if (mPtr.getClass().getCreatureStats(mPtr).isDeathAnimationFinished() && (mwmp::Main::get().getCellController()->isLocalActor(mPtr) || mwmp::Main::get().getCellController()->isDedicatedActor(mPtr)))
{ {

@ -43,8 +43,13 @@ DedicatedActor::~DedicatedActor()
void DedicatedActor::update(float dt) void DedicatedActor::update(float dt)
{ {
move(dt); // Only move and set anim flags if the framerate isn't too low
setAnimFlags(); if (dt < 0.1)
{
move(dt);
setAnimFlags();
}
playAnimation(); playAnimation();
playSound(); playSound();
setStatsDynamic(); setStatsDynamic();

@ -83,8 +83,12 @@ void DedicatedPlayer::update(float dt)
ptrCreatureStats->setAiSetting(MWMechanics::CreatureStats::AI_Flee, 0); ptrCreatureStats->setAiSetting(MWMechanics::CreatureStats::AI_Flee, 0);
ptrCreatureStats->setAiSetting(MWMechanics::CreatureStats::AI_Hello, 0); ptrCreatureStats->setAiSetting(MWMechanics::CreatureStats::AI_Hello, 0);
move(dt); // Only move and set anim flags if the framerate isn't too low
updateAnimFlags(); if (dt < 0.1)
{
move(dt);
setAnimFlags();
}
} }
void DedicatedPlayer::move(float dt) void DedicatedPlayer::move(float dt)
@ -120,7 +124,7 @@ void DedicatedPlayer::move(float dt)
world->rotateObject(ptr, position.rot[0], position.rot[1], position.rot[2]); world->rotateObject(ptr, position.rot[0], position.rot[1], position.rot[2]);
} }
void DedicatedPlayer::updateAnimFlags() void DedicatedPlayer::setAnimFlags()
{ {
using namespace MWMechanics; using namespace MWMechanics;
@ -154,7 +158,7 @@ void DedicatedPlayer::updateAnimFlags()
ptrCreatureStats->setMovementFlag(CreatureStats::Flag_ForceMoveJump, (movementFlags & CreatureStats::Flag_ForceMoveJump) != 0); ptrCreatureStats->setMovementFlag(CreatureStats::Flag_ForceMoveJump, (movementFlags & CreatureStats::Flag_ForceMoveJump) != 0);
} }
void DedicatedPlayer::updateEquipment() void DedicatedPlayer::setEquipment()
{ {
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr); MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot) for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
@ -194,7 +198,7 @@ void DedicatedPlayer::updateEquipment()
} }
} }
void DedicatedPlayer::updateCell() void DedicatedPlayer::setCell()
{ {
// Prevent cell update when player hasn't been instantiated yet // Prevent cell update when player hasn't been instantiated yet
if (state == 0) if (state == 0)

@ -34,9 +34,9 @@ namespace mwmp
void update(float dt); void update(float dt);
void move(float dt); void move(float dt);
void updateAnimFlags(); void setAnimFlags();
void updateEquipment(); void setEquipment();
void updateCell(); void setCell();
void updateMarker(); void updateMarker();
void removeMarker(); void removeMarker();

@ -183,7 +183,7 @@ void PlayerList::createPlayer(RakNet::RakNetGUID guid)
world->disable(players[guid]->ptr); world->disable(players[guid]->ptr);
dedicPlayer->setPtr(world->moveObject(dedicPlayer->ptr, cellStore, spawnPos.pos[0], spawnPos.pos[1], spawnPos.pos[2])); dedicPlayer->setPtr(world->moveObject(dedicPlayer->ptr, cellStore, spawnPos.pos[0], spawnPos.pos[1], spawnPos.pos[2]));
dedicPlayer->updateCell(); dedicPlayer->setCell();
ESM::CustomMarker mEditingMarker = Main::get().getGUIController()->CreateMarker(guid); ESM::CustomMarker mEditingMarker = Main::get().getGUIController()->CreateMarker(guid);
dedicPlayer->marker = mEditingMarker; dedicPlayer->marker = mEditingMarker;

@ -26,7 +26,7 @@ namespace mwmp
static_cast<LocalPlayer *>(player)->updateAnimFlags(true); static_cast<LocalPlayer *>(player)->updateAnimFlags(true);
} }
else if (player != 0) else if (player != 0)
static_cast<DedicatedPlayer *>(player)->updateAnimFlags(); static_cast<DedicatedPlayer *>(player)->setAnimFlags();
} }
}; };
} }

@ -28,7 +28,7 @@ namespace mwmp
static_cast<LocalPlayer *>(player)->setCell(); static_cast<LocalPlayer *>(player)->setCell();
} }
else if (player != 0) else if (player != 0)
static_cast<DedicatedPlayer*>(player)->updateCell(); static_cast<DedicatedPlayer*>(player)->setCell();
} }
}; };
} }

@ -28,7 +28,7 @@ namespace mwmp
static_cast<LocalPlayer*>(player)->setEquipment(); static_cast<LocalPlayer*>(player)->setEquipment();
} }
else if (player != 0) else if (player != 0)
static_cast<DedicatedPlayer*>(player)->updateEquipment(); static_cast<DedicatedPlayer*>(player)->setEquipment();
} }
}; };
} }

Loading…
Cancel
Save