Revert timestep values to default, make configurable

This commit is contained in:
Kae 2023-06-29 00:12:05 +10:00
parent 99846487b9
commit 45493ca8dd
2 changed files with 14 additions and 3 deletions

View File

@ -168,7 +168,6 @@ void ClientApplication::applicationInit(ApplicationControllerPtr appController)
m_guiContext = make_shared<GuiContext>(m_mainMixer->mixer(), appController);
appController->setTargetUpdateRate(1.0f / WorldTimestep);
auto configuration = m_root->configuration();
bool vsync = configuration->get("vsync").toBool();
@ -178,6 +177,16 @@ void ClientApplication::applicationInit(ApplicationControllerPtr appController)
bool borderless = configuration->get("borderless").toBool();
bool maximized = configuration->get("maximized").toBool();
float updateRate = 1.0f / WorldTimestep;
if (auto jUpdateRate = configuration->get("updateRate")) {
updateRate = jUpdateRate.toFloat();
WorldTimestep = 1.0f / updateRate;
}
if (auto jServerUpdateRate = configuration->get("serverUpdateRate"))
ServerWorldTimestep = 1.0f / jServerUpdateRate.toFloat();
appController->setTargetUpdateRate(updateRate);
appController->setApplicationTitle(assets->json("/client.config:windowTitle").toString());
appController->setVSyncEnabled(vsync);

View File

@ -2,8 +2,10 @@
namespace Star {
float WorldTimestep = 1.0f / 120.0f;
float ServerWorldTimestep = 1.0f / 20.0f;
float WorldTimestep = 1.0f / 60.0f;
// This is used to correct interpolation. It must match the timestep of the server you are connected to.
float ServerWorldTimestep = 1.0f / 60.0f;
EnumMap<Direction> const DirectionNames{
{Direction::Left, "left"},