Throttle the client to 1000 FPS.

This is more than enough for everyone and prevents wasting CPU time.
Without this change as many client frames as possible are rendered,
Quake II uses a complete core.
This commit is contained in:
Yamagi Burmeister 2016-08-05 07:49:47 +02:00
parent 7ea4db4ace
commit 2baf97bdf6
4 changed files with 26 additions and 1 deletions

View File

@ -99,6 +99,12 @@ Sys_Milliseconds(void)
return curtime;
}
void
Sys_Sleep(int msec)
{
usleep((unsigned int)1000 * msec);
}
void
Sys_Mkdir(char *path)
{

View File

@ -429,6 +429,12 @@ Sys_Milliseconds(void)
return curtime;
}
void
Sys_Sleep(int msec)
{
Sleep(msec);
}
/* ======================================================================= */
static qboolean

View File

@ -807,7 +807,19 @@ CL_Frame(int msec)
miscframe = false;
}
// TODO: Do we need the cl_sleep stuff?
// Throttle the game a little bit. 1000 FPS are enough.
if (!packetframe && !renderframe && !cls.forcePacket && !userinfo_modified)
{
double frametime = (1000.0 / cl_maxfps->value - packetdelta) <= (1000.0 / gl_maxfps->value - renderdelta) ?
(1000.0 / cl_maxfps->value - packetdelta) : (1000.0 / gl_maxfps->value - renderdelta);
if (frametime > 1)
{
Sys_Sleep(1);
}
return;
}
}
else if (msec < 1)
{

View File

@ -764,6 +764,7 @@ void Sys_Error(char *error, ...);
void Sys_Quit(void);
char *Sys_GetHomeDir(void);
const char *Sys_GetBinaryDir(void);
void Sys_Sleep(int msec);
void Sys_FreeLibrary(void *handle);
void *Sys_LoadLibrary(const char *path, const char *sym, void **handle);