diff options
Diffstat (limited to 'src/qcommon/common.c')
-rw-r--r-- | src/qcommon/common.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/qcommon/common.c b/src/qcommon/common.c index 586c334c..f16234c2 100644 --- a/src/qcommon/common.c +++ b/src/qcommon/common.c @@ -81,7 +81,9 @@ cvar_t *sv_packetdelay; cvar_t *com_cameraMode; cvar_t *com_ansiColor; cvar_t *com_unfocused; +cvar_t *com_maxfpsUnfocused; cvar_t *com_minimized; +cvar_t *com_maxfpsMinimized; // com_speeds times int time_game; @@ -2481,7 +2483,9 @@ void Com_Init( char *commandLine ) { com_ansiColor = Cvar_Get( "com_ansiColor", "0", CVAR_ARCHIVE ); com_unfocused = Cvar_Get( "com_unfocused", "0", CVAR_ROM ); + com_maxfpsUnfocused = Cvar_Get( "com_maxfpsUnfocused", "0", CVAR_ARCHIVE ); com_minimized = Cvar_Get( "com_minimized", "0", CVAR_ROM ); + com_maxfpsMinimized = Cvar_Get( "com_maxfpsMinimized", "0", CVAR_ARCHIVE ); if ( com_developer && com_developer->integer ) { Cmd_AddCommand ("error", Com_Error_f); @@ -2696,12 +2700,30 @@ void Com_Frame( void ) { } // we may want to spin here if things are going too fast - if ( !com_dedicated->integer && com_maxfps->integer > 0 && !com_timedemo->integer ) { - minMsec = 1000 / com_maxfps->integer; + if ( !com_dedicated->integer && !com_timedemo->integer ) { + if( com_minimized->integer && com_maxfpsMinimized->integer > 0 ) { + minMsec = 1000 / com_maxfpsMinimized->integer; + } else if( com_unfocused->integer && com_maxfpsUnfocused->integer > 0 ) { + minMsec = 1000 / com_maxfpsUnfocused->integer; + } else if( com_maxfps->integer > 0 ) { + minMsec = 1000 / com_maxfps->integer; + } else { + minMsec = 1; + } } else { minMsec = 1; } + + msec = minMsec; do { + int timeRemaining = minMsec - msec; + + // The existing Sys_Sleep implementations aren't really + // precise enough to be of use beyond 100fps + // FIXME: implement a more precise sleep (RDTSC or something) + if( timeRemaining >= 10 ) + Sys_Sleep( timeRemaining ); + com_frameTime = Com_EventLoop(); if ( lastTime > com_frameTime ) { lastTime = com_frameTime; // possible on first frame |