From 27c2c92fedc3be47904c071b04f328c142e3dc21 Mon Sep 17 00:00:00 2001 From: sezero Date: Sun, 27 Feb 2011 07:05:18 +0000 Subject: [PATCH] cvar'ize the game loop throttling by adding the new sys_throttle with a default value of 0.02. changing its value to 0 disables throttling. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@427 af15c1b1-3010-417e-b628-4374ebc0bcbd --- quakespasm/Quake/host.c | 1 + quakespasm/Quake/main_sdl.c | 6 ++++-- quakespasm/Quake/quakedef.h | 1 + quakespasm/Quake/sys_sdl_unix.c | 1 + quakespasm/Quake/sys_sdl_win.c | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/quakespasm/Quake/host.c b/quakespasm/Quake/host.c index 70d1e29f..b964494a 100644 --- a/quakespasm/Quake/host.c +++ b/quakespasm/Quake/host.c @@ -242,6 +242,7 @@ void Host_InitLocal (void) Cvar_RegisterVariable (&devstats, NULL); //johnfitz Cvar_RegisterVariable (&sys_ticrate, NULL); + Cvar_RegisterVariable (&sys_throttle, NULL); Cvar_RegisterVariable (&serverprofile, NULL); Cvar_RegisterVariable (&fraglimit, NULL); diff --git a/quakespasm/Quake/main_sdl.c b/quakespasm/Quake/main_sdl.c index 9e562111..aafd6ad6 100644 --- a/quakespasm/Quake/main_sdl.c +++ b/quakespasm/Quake/main_sdl.c @@ -170,8 +170,10 @@ int main(int argc, char *argv[]) time = newtime - oldtime; Host_Frame(time); - // throttle the game loop just a little bit - noone needs more than 1000fps, I think - if (newtime - oldtime < 1) + /* throttle the game loop just a little bit + and make the game run a little cooler: + noone needs more than 1000fps, I think */ + if (time < sys_throttle.value) SDL_Delay(1); oldtime = newtime; diff --git a/quakespasm/Quake/quakedef.h b/quakespasm/Quake/quakedef.h index f100f815..12394484 100644 --- a/quakespasm/Quake/quakedef.h +++ b/quakespasm/Quake/quakedef.h @@ -268,6 +268,7 @@ extern qboolean noclip_anglehack; extern quakeparms_t host_parms; extern cvar_t sys_ticrate; +extern cvar_t sys_throttle; extern cvar_t sys_nostdout; extern cvar_t developer; extern cvar_t max_edicts; //johnfitz diff --git a/quakespasm/Quake/sys_sdl_unix.c b/quakespasm/Quake/sys_sdl_unix.c index ec0abf35..f0f1586c 100644 --- a/quakespasm/Quake/sys_sdl_unix.c +++ b/quakespasm/Quake/sys_sdl_unix.c @@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. qboolean isDedicated; +cvar_t sys_throttle = {"sys_throttle", "0.02", true}; #define MAX_HANDLES 32 /* johnfitz -- was 10 */ static FILE *sys_handles[MAX_HANDLES]; diff --git a/quakespasm/Quake/sys_sdl_win.c b/quakespasm/Quake/sys_sdl_win.c index 4ecfba1a..da42a778 100644 --- a/quakespasm/Quake/sys_sdl_win.c +++ b/quakespasm/Quake/sys_sdl_win.c @@ -37,6 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. qboolean isDedicated; qboolean Win95, Win95old, WinNT, WinVista; +cvar_t sys_throttle = {"sys_throttle", "0.02", true}; static HANDLE hinput, houtput;