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
|
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)
|
Host_SimulationTime (float time)
|
||||||
{
|
{
|
||||||
float fps;
|
float fps;
|
||||||
float timescale = 1.0;
|
float timescale = 1.0;
|
||||||
|
float timedifference;
|
||||||
|
|
||||||
if (cls.demoplayback) {
|
if (cls.demoplayback) {
|
||||||
timescale = max (0, cl_demospeed->value);
|
timescale = max (0, cl_demospeed->value);
|
||||||
|
@ -1427,9 +1429,11 @@ Host_SimulationTime (float time)
|
||||||
else
|
else
|
||||||
fps = bound (30, rate->value / 80.0, 72);
|
fps = bound (30, rate->value / 80.0, 72);
|
||||||
|
|
||||||
if (!cls.timedemo && ((realtime - oldrealtime) < (timescale / fps)))
|
timedifference = (timescale / fps) - (realtime - oldrealtime);
|
||||||
return false; // framerate is too high
|
|
||||||
return true;
|
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 time2 = 0;
|
||||||
static double time3 = 0;
|
static double time3 = 0;
|
||||||
int pass1, pass2, pass3;
|
int pass1, pass2, pass3;
|
||||||
|
float sleeptime;
|
||||||
|
|
||||||
if (setjmp (host_abort)) // something bad happened, or the server disconnected
|
if (setjmp (host_abort)) // something bad happened, or the server disconnected
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// decide the simulation time
|
// 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
|
return; // framerate is too high
|
||||||
|
}
|
||||||
|
|
||||||
host_frametime = realtime - oldrealtime;
|
host_frametime = realtime - oldrealtime;
|
||||||
oldrealtime = realtime;
|
oldrealtime = realtime;
|
||||||
|
|
Loading…
Reference in a new issue