From 422e511aac3f15635aa9d5a497056f2f72d71fdf Mon Sep 17 00:00:00 2001 From: Josh K Date: Sun, 23 Dec 2018 07:32:13 -0500 Subject: [PATCH] Added the 'sleeptime' cvar and behavior from the 'Old Engine'. --- engine/common/host.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/engine/common/host.c b/engine/common/host.c index 0fd6dec7..45f9439f 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -54,6 +54,7 @@ convar_t *host_clientloaded; convar_t *host_limitlocal; convar_t *host_maxfps; convar_t *host_framerate; +convar_t *host_sleeptime; convar_t *con_gamemaps; convar_t *build, *ver; @@ -168,17 +169,18 @@ Host_CheckSleep */ void Host_CheckSleep( void ) { + int sleeptime = host_sleeptime->value; if( Host_IsDedicated() ) { // let the dedicated server some sleep - Sys_Sleep( 1 ); + Sys_Sleep( sleeptime ); } else { if( host.status == HOST_NOFOCUS ) { if( SV_Active() && CL_IsInGame( )) - Sys_Sleep( 1 ); // listenserver + Sys_Sleep( sleeptime ); // listenserver else Sys_Sleep( 20 ); // sleep 20 ms otherwise } else if( host.status == HOST_SLEEP ) @@ -186,6 +188,10 @@ void Host_CheckSleep( void ) // completely sleep in minimized state Sys_Sleep( 20 ); } + else + { + Sys_Sleep( sleeptime ); + } } } @@ -944,6 +950,7 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa host_maxfps = Cvar_Get( "fps_max", "72", FCVAR_ARCHIVE, "host fps upper limit" ); host_framerate = Cvar_Get( "host_framerate", "0", 0, "locks frame timing to this value in seconds" ); + host_sleeptime = Cvar_Get( "sleeptime", "1", FCVAR_ARCHIVE, "milliseconds to sleep for each frame. higher values reduce fps accuracy" ); host_gameloaded = Cvar_Get( "host_gameloaded", "0", FCVAR_READ_ONLY, "inidcates a loaded game.dll" ); host_clientloaded = Cvar_Get( "host_clientloaded", "0", FCVAR_READ_ONLY, "inidcates a loaded client.dll" ); host_limitlocal = Cvar_Get( "host_limitlocal", "0", 0, "apply cl_cmdrate and rate to loopback connection" );