diff --git a/client/cl_main.c b/client/cl_main.c index b5784a9..554dfc3 100644 --- a/client/cl_main.c +++ b/client/cl_main.c @@ -64,6 +64,7 @@ cvar_t *cl_maxfps; cvar_t *cl_async; cvar_t *net_maxfps; cvar_t *r_maxfps; +cvar_t *r_maxfps_autoset; #endif cvar_t *cl_sleep; @@ -1957,6 +1958,8 @@ void CL_InitLocal (void) Cvar_SetDescription ("net_maxfps", "Framerate cap for network frames when cl_async (asynchronous frames) is set to 1."); r_maxfps = Cvar_Get ("r_maxfps", "125", 0); Cvar_SetDescription ("r_maxfps", "Framerate cap for video frames when cl_async (asynchronous frames) is set to 1."); + r_maxfps_autoset = Cvar_Get ("r_maxfps_autoset", "1", CVAR_ARCHIVE); + Cvar_SetDescription ("r_maxfps_autoset", "Enables automatic setting of framerate cap (r_maxfps) based on refresh rate. Does nothing when refresh rate is left at default."); #endif cl_sleep = Cvar_Get ("cl_sleep", "1", 0); @@ -2221,11 +2224,6 @@ void CL_InitLocal (void) Cmd_AddCommand ("weapnext", NULL); Cmd_AddCommand ("weapprev", NULL); -#ifdef CLIENT_SPLIT_NETFRAME - // auto-set r_maxfps based on r_displayrefresh - CL_SetFramerateCap (); -#endif // CLIENT_SPLIT_NETFRAME - // Chat Ignore from R1Q2/Q2Pro // Init list pointers cl_chatNickIgnores.next = NULL; @@ -2356,15 +2354,23 @@ Does nothing if r_displayrefresh is not set. void CL_SetFramerateCap (void) { int displayFreq = Cvar_VariableInteger("r_displayrefresh"); + cvar_t *autoSet = Cvar_Get ("r_maxfps_autoset", "1", CVAR_ARCHIVE); + + if (!autoSet->integer) + return; // if no refresh set, leave framerate cap at default if (displayFreq <= 0) { // Cvar_SetInteger ("r_maxfps", 125); // 8ms frame interval return; } - - // isn't 250 fps enough for any display? - if (displayFreq > 200) + + // surely refresh rates will never go over 500Hz, right? + if (displayFreq > 334) + Cvar_SetInteger ("r_maxfps", 500); // 2ms frame interval + else if (displayFreq > 250) + Cvar_SetInteger ("r_maxfps", 334); // 3ms frame interval + else if (displayFreq > 200) Cvar_SetInteger ("r_maxfps", 250); // 4ms frame interval else if (displayFreq > 167) Cvar_SetInteger ("r_maxfps", 200); // 5ms frame interval diff --git a/kmquake2_changelog.txt b/kmquake2_changelog.txt index 1f4a0ea..6ca8c50 100644 --- a/kmquake2_changelog.txt +++ b/kmquake2_changelog.txt @@ -7,6 +7,7 @@ Changes as of v0.20 update 8: - Added 160Hz and 240Hz refresh rates. - Added automatic setting of r_maxfps based on refresh rate set in video menu (r_displayrefresh). + This can be disabled by setting the cvar r_maxfps_autoset to 0. - Added support for triple-monitor surround modes via custom resolutions. Monitors must be bound as a single logical display. Keeps all menu/HUD elements on the center screen, set the cvar scr_surroundlayout to 0 to disable this. diff --git a/linux/vid_so.c b/linux/vid_so.c index de0f4a1..ede0d03 100644 --- a/linux/vid_so.c +++ b/linux/vid_so.c @@ -348,6 +348,12 @@ qboolean VID_LoadRefresh( char *name ) setegid(getgid()); Com_Printf( "------------------------------------\n"); + +#ifdef CLIENT_SPLIT_NETFRAME + // auto-set r_maxfps based on r_displayrefresh + CL_SetFramerateCap (); +#endif // CLIENT_SPLIT_NETFRAME + reflib_active = true; return true; } diff --git a/ui/ui_video.c b/ui/ui_video.c index d0a259f..330f455 100644 --- a/ui/ui_video.c +++ b/ui/ui_video.c @@ -145,11 +145,6 @@ static void prepareVideoRefresh( void ) Cvar_Set( "vid_ref", "gl" ); Cvar_Set( "gl_driver", "opengl32" ); -#ifdef CLIENT_SPLIT_NETFRAME - // auto-set r_maxfps based on r_displayrefresh - CL_SetFramerateCap (); -#endif // CLIENT_SPLIT_NETFRAME - // tell them they're modified so they refresh vid_ref->modified = true; } diff --git a/unix/vid_so.c b/unix/vid_so.c index 3ad2c2e..ffcfbc4 100644 --- a/unix/vid_so.c +++ b/unix/vid_so.c @@ -208,6 +208,11 @@ void UpdateVideoRef (void) Com_Printf( "------------------------------------\n"); +#ifdef CLIENT_SPLIT_NETFRAME + // auto-set r_maxfps based on r_displayrefresh + CL_SetFramerateCap (); +#endif // CLIENT_SPLIT_NETFRAME + kmgl_active = true; //========================== } diff --git a/win32/vid_dll.c b/win32/vid_dll.c index 4b90fab..49aff7c 100644 --- a/win32/vid_dll.c +++ b/win32/vid_dll.c @@ -666,6 +666,11 @@ void UpdateVideoRef (void) Com_Printf( "------------------------------------\n"); +#ifdef CLIENT_SPLIT_NETFRAME + // auto-set r_maxfps based on r_displayrefresh + CL_SetFramerateCap (); +#endif // CLIENT_SPLIT_NETFRAME + kmgl_active = true; //========================== }