From 98228cce0dfe6591dc1b3a1c44852be0ca2adb4f Mon Sep 17 00:00:00 2001 From: tma Date: Mon, 21 Jul 2008 22:02:54 +0000 Subject: * Use Sys_Sleep to limit FPS, which will save CPU * Add com_maxfpsUnfocused and com_maxfpsMinimized; self explanatory * Fix reopening of bug 3703, I hope git-svn-id: svn://svn.icculus.org/quake3/trunk@1431 edf5b092-35ff-0310-97b2-ce42778d08ea --- code/sys/sys_main.c | 44 +++++++------------------------------------- code/sys/sys_unix.c | 3 +++ code/sys/sys_win32.c | 3 +++ 3 files changed, 13 insertions(+), 37 deletions(-) (limited to 'code/sys') diff --git a/code/sys/sys_main.c b/code/sys/sys_main.c index a1a57b4..dc846dd 100644 --- a/code/sys/sys_main.c +++ b/code/sys/sys_main.c @@ -439,42 +439,6 @@ void *Sys_LoadDll( const char *name, char *fqpath , return libHandle; } -/* -================= -Sys_Idle -================= -*/ -static void Sys_Idle( void ) -{ -#ifndef DEDICATED - int appState = SDL_GetAppState( ); - int sleep = 0; - - // If we have no input focus at all, sleep a bit - if( !( appState & ( SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS ) ) ) - { - Cvar_SetValue( "com_unfocused", 1 ); - sleep += 16; - } - else - Cvar_SetValue( "com_unfocused", 0 ); - - // If we're minimised, sleep a bit more - if( !( appState & SDL_APPACTIVE ) ) - { - Cvar_SetValue( "com_minimized", 1 ); - sleep += 32; - } - else - Cvar_SetValue( "com_minimized", 0 ); - - if( !com_dedicated->integer && sleep ) - SDL_Delay( sleep ); -#else - // Dedicated server idles via NET_Sleep -#endif -} - /* ================= Sys_ParseArgs @@ -602,7 +566,13 @@ int main( int argc, char **argv ) while( 1 ) { - Sys_Idle( ); +#ifndef DEDICATED + int appState = SDL_GetAppState( ); + + Cvar_SetValue( "com_unfocused", !( appState & SDL_APPINPUTFOCUS ) ); + Cvar_SetValue( "com_minimized", !( appState & SDL_APPACTIVE ) ); +#endif + IN_Frame( ); Com_Frame( ); } diff --git a/code/sys/sys_unix.c b/code/sys/sys_unix.c index 9d9d5aa..40479b9 100644 --- a/code/sys/sys_unix.c +++ b/code/sys/sys_unix.c @@ -463,6 +463,9 @@ void Sys_Sleep( int msec ) { fd_set fdset; + if( msec == 0 ) + return; + FD_ZERO(&fdset); FD_SET(fileno(stdin), &fdset); if( msec < 0 ) diff --git a/code/sys/sys_win32.c b/code/sys/sys_win32.c index 18724b3..fb924e6 100644 --- a/code/sys/sys_win32.c +++ b/code/sys/sys_win32.c @@ -519,6 +519,9 @@ Block execution for msec or until input is recieved. */ void Sys_Sleep( int msec ) { + if( msec == 0 ) + return; + if( msec < 0 ) WaitForSingleObject( GetStdHandle( STD_INPUT_HANDLE ), INFINITE ); else -- cgit v1.2.3