From aa19a3afb0b94e8b5fe055eeb38b1fb2ee1a67b0 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 19 Oct 2014 14:10:18 +0100 Subject: Migrated random generators to std::random --- src/Server.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/Server.cpp') diff --git a/src/Server.cpp b/src/Server.cpp index 8e5755a75..c5f4f9042 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -20,8 +20,6 @@ #include "Protocol/ProtocolRecognizer.h" #include "CommandOutput.h" -#include "MersenneTwister.h" - #include "inifile/iniFile.h" #include "Vector3.h" -- cgit v1.2.3 From bde99d684e0bb51adaa053a240abe61cf4af07fb Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 20 Oct 2014 18:59:40 +0100 Subject: Migrated cSleep and cTimer to std::chrono --- src/Server.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/Server.cpp') diff --git a/src/Server.cpp b/src/Server.cpp index c5f4f9042..f29683b21 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" @@ -73,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(std::chrono::duration_cast(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; -- cgit v1.2.3 From 987f79afdd8945966d0dfa2d52539e005f771590 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 20 Oct 2014 21:55:07 +0100 Subject: En masse NULL -> nullptr replace --- src/Server.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/Server.cpp') diff --git a/src/Server.cpp b/src/Server.cpp index 38e5cebb3..11da36868 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -332,7 +332,7 @@ void cServer::OnConnectionAccepted(cSocket & a_Socket) LOGERROR("Client \"%s\" cannot be handled, server probably unstable", ClientIP.c_str()); a_Socket.CloseSocket(); delete NewHandle; - NewHandle = NULL; + NewHandle = nullptr; return; } @@ -631,17 +631,17 @@ void cServer::PrintHelp(const AStringVector & a_Split, cCommandOutputCallback & void cServer::BindBuiltInConsoleCommands(void) { cPluginManager * PlgMgr = cPluginManager::Get(); - PlgMgr->BindConsoleCommand("help", NULL, " - Shows the available commands"); - PlgMgr->BindConsoleCommand("reload", NULL, " - Reloads all plugins"); - PlgMgr->BindConsoleCommand("restart", NULL, " - Restarts the server cleanly"); - PlgMgr->BindConsoleCommand("stop", NULL, " - Stops the server cleanly"); - PlgMgr->BindConsoleCommand("chunkstats", NULL, " - Displays detailed chunk memory statistics"); - PlgMgr->BindConsoleCommand("load ", NULL, " - Adds and enables the specified plugin"); - PlgMgr->BindConsoleCommand("unload ", NULL, " - Disables the specified plugin"); - PlgMgr->BindConsoleCommand("destroyentities", NULL, " - Destroys all entities in all worlds"); + PlgMgr->BindConsoleCommand("help", nullptr, " - Shows the available commands"); + PlgMgr->BindConsoleCommand("reload", nullptr, " - Reloads all plugins"); + PlgMgr->BindConsoleCommand("restart", nullptr, " - Restarts the server cleanly"); + PlgMgr->BindConsoleCommand("stop", nullptr, " - Stops the server cleanly"); + PlgMgr->BindConsoleCommand("chunkstats", nullptr, " - Displays detailed chunk memory statistics"); + PlgMgr->BindConsoleCommand("load ", nullptr, " - Adds and enables the specified plugin"); + PlgMgr->BindConsoleCommand("unload ", nullptr, " - Disables the specified plugin"); + PlgMgr->BindConsoleCommand("destroyentities", nullptr, " - Destroys all entities in all worlds"); #if defined(_MSC_VER) && defined(_DEBUG) && defined(ENABLE_LEAK_FINDER) - PlgMgr->BindConsoleCommand("dumpmem", NULL, " - Dumps all used memory blocks together with their callstacks into memdump.xml"); + PlgMgr->BindConsoleCommand("dumpmem", nullptr, " - Dumps all used memory blocks together with their callstacks into memdump.xml"); #endif } @@ -710,7 +710,7 @@ void cServer::AuthenticateUser(int a_ClientID, const AString & a_Name, const ASt cServer::cNotifyWriteThread::cNotifyWriteThread(void) : super("ClientPacketThread"), - m_Server(NULL) + m_Server(nullptr) { } -- cgit v1.2.3 From 3e0f7c2b1c9b371307a570e445d0178599abd92d Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 21 Oct 2014 14:17:36 +0100 Subject: Missing space. --- src/Server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Server.cpp') diff --git a/src/Server.cpp b/src/Server.cpp index 11da36868..6f7d494be 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -84,7 +84,7 @@ void cServer::cTickThread::Execute(void) if (TickTime < msPerTick) { // Stretch tick time until it's at least msPerTick - std::this_thread::sleep_for(msPerTick -TickTime); + std::this_thread::sleep_for(msPerTick - TickTime); } LastTime = NowTime; -- cgit v1.2.3 From f206f34a3d1d5bdda7625a61dcf35514f485af79 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Wed, 3 Dec 2014 18:04:21 +0100 Subject: Server: Fixed a MSVC warning. --- src/Server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Server.cpp') diff --git a/src/Server.cpp b/src/Server.cpp index 8759d5747..db1522602 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -78,7 +78,7 @@ void cServer::cTickThread::Execute(void) while (!m_ShouldTerminate) { auto NowTime = std::chrono::steady_clock::now(); - m_ShouldTerminate = !m_Server.Tick(std::chrono::duration_cast(NowTime - LastTime).count()); + m_ShouldTerminate = !m_Server.Tick(static_cast(std::chrono::duration_cast(NowTime - LastTime).count())); auto TickTime = std::chrono::steady_clock::now() - NowTime; if (TickTime < msPerTick) -- cgit v1.2.3