From 45493ca8dd67cdb62e4aca97b5010e08f5e0d02a Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Thu, 29 Jun 2023 00:12:05 +1000 Subject: [PATCH] Revert timestep values to default, make configurable --- source/client/StarClientApplication.cpp | 11 ++++++++++- source/game/StarGameTypes.cpp | 6 ++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/source/client/StarClientApplication.cpp b/source/client/StarClientApplication.cpp index fa8d97b..fb26dcc 100644 --- a/source/client/StarClientApplication.cpp +++ b/source/client/StarClientApplication.cpp @@ -168,7 +168,6 @@ void ClientApplication::applicationInit(ApplicationControllerPtr appController) m_guiContext = make_shared(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); diff --git a/source/game/StarGameTypes.cpp b/source/game/StarGameTypes.cpp index 0ea2c6e..e1069d5 100644 --- a/source/game/StarGameTypes.cpp +++ b/source/game/StarGameTypes.cpp @@ -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 const DirectionNames{ {Direction::Left, "left"},