summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2015-01-11 02:54:18 +0100
committerTycho <work.tycho+git@gmail.com>2015-01-11 02:54:18 +0100
commit4f75b94c99eeb1642a5ec46144542bfcd18af934 (patch)
tree886f5e75a134e2ae3b42691076f76fe8fb1b77e6 /src/World.cpp
parentCMake: Check libs in submodules before configuring. (diff)
downloadcuberite-4f75b94c99eeb1642a5ec46144542bfcd18af934.tar
cuberite-4f75b94c99eeb1642a5ec46144542bfcd18af934.tar.gz
cuberite-4f75b94c99eeb1642a5ec46144542bfcd18af934.tar.bz2
cuberite-4f75b94c99eeb1642a5ec46144542bfcd18af934.tar.lz
cuberite-4f75b94c99eeb1642a5ec46144542bfcd18af934.tar.xz
cuberite-4f75b94c99eeb1642a5ec46144542bfcd18af934.tar.zst
cuberite-4f75b94c99eeb1642a5ec46144542bfcd18af934.zip
Diffstat (limited to '')
-rw-r--r--src/World.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/World.cpp b/src/World.cpp
index c08b44f77..2dd03497b 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -233,8 +233,7 @@ cWorld::cTickThread::cTickThread(cWorld & a_World) :
void cWorld::cTickThread::Execute(void)
{
auto LastTime = std::chrono::steady_clock::now();
- static const auto msPerTick = std::chrono::milliseconds(50);
- auto TickTime = std::chrono::steady_clock::duration(50);
+ auto TickTime = std::chrono::duration_cast<std::chrono::milliseconds>(cTickTime(1));
while (!m_ShouldTerminate)
{
@@ -242,12 +241,12 @@ void cWorld::cTickThread::Execute(void)
auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(NowTime - LastTime).count();
auto LastTickMsec = std::chrono::duration_cast<std::chrono::duration<int>>(TickTime).count();
m_World.Tick(static_cast<float>(msec), LastTickMsec);
- TickTime = std::chrono::steady_clock::now() - NowTime;
+ TickTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - NowTime);
- if (TickTime < msPerTick)
+ if (TickTime < cTickTime(1))
{
- // Stretch tick time until it's at least msPerTick
- std::this_thread::sleep_for(msPerTick - TickTime);
+ // Stretch tick time until it's at least 1 tick
+ std::this_thread::sleep_for(cTickTime(1) - TickTime);
}
LastTime = NowTime;