summaryrefslogtreecommitdiffstats
path: root/src/Server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Server.cpp')
-rw-r--r--src/Server.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/src/Server.cpp b/src/Server.cpp
index bbb5ecff3..3eaf6e096 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,20 @@ 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();
+ auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(NowTime - LastTime).count();
+ m_ShouldTerminate = !m_Server.Tick(static_cast<float>(msec));
+ 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;
@@ -201,6 +196,7 @@ bool cServer::InitServer(cIniFile & a_SettingsIni, bool a_ShouldAuth)
m_Description = a_SettingsIni.GetValueSet("Server", "Description", "MCServer - in C++!");
m_MaxPlayers = a_SettingsIni.GetValueSetI("Server", "MaxPlayers", 100);
m_bIsHardcore = a_SettingsIni.GetValueSetB("Server", "HardcoreEnabled", false);
+ m_bAllowMultiLogin = a_SettingsIni.GetValueSetB("Server", "AllowMultiLogin", false);
m_PlayerCount = 0;
m_PlayerCountDiff = 0;
@@ -303,6 +299,23 @@ int cServer::GetNumPlayers(void) const
+bool cServer::IsPlayerInQueue(AString a_Username)
+{
+ cCSLock Lock(m_CSClients);
+ for (auto client : m_Clients)
+ {
+ if ((client->GetUsername()).compare(a_Username) == 0)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+
void cServer::PrepareKeys(void)
{
LOGD("Generating protocol encryption keypair...");