From 738b1b3467e5556667464bc33294a7485d37097b Mon Sep 17 00:00:00 2001 From: faketruth Date: Sun, 22 Jan 2012 20:15:11 +0000 Subject: Improved Core's WebAmin interface a bit. Can now kick players through WebAdmin Can now enable/disable whitelist through WebAdmin Tick speed is limited in a better way now, instead of always sleeping 50ms before each tick, it now add only sleeps additional time when the tick time was faster than 50ms. Server should run slightly faster because of this (and use more cpu%) git-svn-id: http://mc-server.googlecode.com/svn/trunk@167 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cServer.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source/cServer.cpp') diff --git a/source/cServer.cpp b/source/cServer.cpp index 8d4f9ea16..326bbf9ce 100644 --- a/source/cServer.cpp +++ b/source/cServer.cpp @@ -278,11 +278,9 @@ void cServer::StartListenClient() bool cServer::Tick(float a_Dt) { - //LOG("1. Tick"); + //LOG("1. Tick %0.2f", a_Dt); if( a_Dt > 100.f ) a_Dt = 100.f; // Don't go over 1/10 second - cSleep::MilliSleep( 50 ); // Don't tick too much - m_Millisecondsf += a_Dt; if( m_Millisecondsf > 1.f ) { @@ -331,6 +329,7 @@ void ServerTickThread( void * a_Param ) cTimer Timer; + long long msPerTick = 50; // TODO - Put this in server config file long long LastTime = Timer.GetNowTime(); bool bKeepGoing = true; @@ -339,6 +338,13 @@ void ServerTickThread( void * a_Param ) long long NowTime = Timer.GetNowTime(); float DeltaTime = (float)(NowTime-LastTime); bKeepGoing = CServerObj->Tick( DeltaTime ); + long long TickTime = Timer.GetNowTime() - NowTime; + + if( TickTime < msPerTick ) // Stretch tick time until it's at least msPerTick + { + cSleep::MilliSleep( (unsigned int)( msPerTick - TickTime ) ); + } + LastTime = NowTime; } -- cgit v1.2.3