The full info on what this does and how it works is available there; meanwhile here's the Quake version:
Code: Select all
void Host_ServerFrame (void)
{
static double accumulated = 0.0;
double alpha;
static double prevtime = 0.0;
const double delta = (1.0 / 72.0);
double new_frametime;
accumulated += host_frametime;
pr_global_struct->frametime = host_frametime;
SV_ClearDatagram ();
SV_CheckForNewClients ();
while (accumulated >= delta)
{
host_frametime = delta;
pr_global_struct->frametime = delta;
SV_RunClients ();
if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game))
SV_Physics ();
accumulated -= delta;
}
alpha = accumulated / delta;
// assign the remainder of the timestep to a new interpolated time
new_frametime = host_frametime * alpha + prevtime * (1.0 - alpha);
prevtime = host_frametime;
host_frametime = new_frametime;
pr_global_struct->frametime = host_frametime;
// send all messages to the clients
SV_SendClientMessages ();
}