diff options
author | Mattes D <github@xoft.cz> | 2014-12-07 15:01:36 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-12-07 15:01:36 +0100 |
commit | d00ebd7ee700fcd7f30ea27d238ba1f0d56dfe21 (patch) | |
tree | b0dbd8a8396ad22cf77cb4b367295d25ad3055a7 /src/Server.cpp | |
parent | Reduced river height (diff) | |
parent | Merge remote-tracking branch 'origin/master' into c++11 (diff) | |
download | cuberite-d00ebd7ee700fcd7f30ea27d238ba1f0d56dfe21.tar cuberite-d00ebd7ee700fcd7f30ea27d238ba1f0d56dfe21.tar.gz cuberite-d00ebd7ee700fcd7f30ea27d238ba1f0d56dfe21.tar.bz2 cuberite-d00ebd7ee700fcd7f30ea27d238ba1f0d56dfe21.tar.lz cuberite-d00ebd7ee700fcd7f30ea27d238ba1f0d56dfe21.tar.xz cuberite-d00ebd7ee700fcd7f30ea27d238ba1f0d56dfe21.tar.zst cuberite-d00ebd7ee700fcd7f30ea27d238ba1f0d56dfe21.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Server.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/Server.cpp b/src/Server.cpp index bbb5ecff3..db1522602 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -4,7 +4,6 @@ #include "Server.h" #include "ClientHandle.h" -#include "OSSupport/Timer.h" #include "Mobs/Monster.h" #include "OSSupport/Socket.h" #include "Root.h" @@ -20,8 +19,6 @@ #include "Protocol/ProtocolRecognizer.h" #include "CommandOutput.h" -#include "MersenneTwister.h" - #include "IniFile.h" #include "Vector3.h" @@ -75,22 +72,19 @@ cServer::cTickThread::cTickThread(cServer & a_Server) : void cServer::cTickThread::Execute(void) { - cTimer Timer; - - long long msPerTick = 50; - long long LastTime = Timer.GetNowTime(); + auto LastTime = std::chrono::steady_clock::now(); + static const auto msPerTick = std::chrono::milliseconds(50); while (!m_ShouldTerminate) { - long long NowTime = Timer.GetNowTime(); - float DeltaTime = (float)(NowTime-LastTime); - m_ShouldTerminate = !m_Server.Tick(DeltaTime); - long long TickTime = Timer.GetNowTime() - NowTime; + auto NowTime = std::chrono::steady_clock::now(); + m_ShouldTerminate = !m_Server.Tick(static_cast<float>(std::chrono::duration_cast<std::chrono::milliseconds>(NowTime - LastTime).count())); + auto TickTime = std::chrono::steady_clock::now() - NowTime; if (TickTime < msPerTick) { // Stretch tick time until it's at least msPerTick - cSleep::MilliSleep((unsigned int)(msPerTick - TickTime)); + std::this_thread::sleep_for(msPerTick - TickTime); } LastTime = NowTime; |