mirror of
https://git.code.sf.net/p/quake/newtree
synced 2024-11-24 21:12:27 +00:00
Apply usleep patch, so we don't busy-wait so much. cl_maxfps will
now release your CPU :)
This commit is contained in:
parent
3fc2675cb8
commit
d97095fe87
1 changed files with 14 additions and 6 deletions
|
@ -1405,13 +1405,15 @@ Host_WriteConfiguration (void)
|
|||
/*
|
||||
Host_SimulationTime
|
||||
|
||||
This determines if enough time has passed to run a simulation frame
|
||||
This determines if enough time has passed to run a simulation frame, or
|
||||
returns the amount of time that has to be waited
|
||||
*/
|
||||
static inline qboolean
|
||||
static inline float
|
||||
Host_SimulationTime (float time)
|
||||
{
|
||||
float fps;
|
||||
float timescale = 1.0;
|
||||
float timedifference;
|
||||
|
||||
if (cls.demoplayback) {
|
||||
timescale = max (0, cl_demospeed->value);
|
||||
|
@ -1427,9 +1429,11 @@ Host_SimulationTime (float time)
|
|||
else
|
||||
fps = bound (30, rate->value / 80.0, 72);
|
||||
|
||||
if (!cls.timedemo && ((realtime - oldrealtime) < (timescale / fps)))
|
||||
return false; // framerate is too high
|
||||
return true;
|
||||
timedifference = (timescale / fps) - (realtime - oldrealtime);
|
||||
|
||||
if (!cls.timedemo && (timedifference > 0))
|
||||
return timedifference; // framerate is too high
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1445,13 +1449,17 @@ Host_Frame (float time)
|
|||
static double time2 = 0;
|
||||
static double time3 = 0;
|
||||
int pass1, pass2, pass3;
|
||||
float sleeptime;
|
||||
|
||||
if (setjmp (host_abort)) // something bad happened, or the server disconnected
|
||||
return;
|
||||
|
||||
// decide the simulation time
|
||||
if (!Host_SimulationTime (time))
|
||||
if ((sleeptime = Host_SimulationTime (time)) != 0) {
|
||||
if (sleeptime > 0.01) // minimum sleep time
|
||||
usleep((unsigned long)((sleeptime - 0.001) * 1000000));
|
||||
return; // framerate is too high
|
||||
}
|
||||
|
||||
host_frametime = realtime - oldrealtime;
|
||||
oldrealtime = realtime;
|
||||
|
|
Loading…
Reference in a new issue