/* * Sv_Frame */ void Sv_Frame(unsigned int msec) { unsigned int frame_millis; // if server is not active, do nothing if (!svs.initialized) return; // update time reference svs.real_time += msec; // keep the random time dependent rand(); // check timeouts Sv_CheckTimeouts(); // get packets from clients Sv_ReadPackets(); frame_millis = 1000 / svs.frame_rate; // keep the game module's time in sync with reality if (!time_demo->value && svs.real_time < sv.time) { // if the server has fallen far behind the game, try to catch up if (sv.time - svs.real_time > frame_millis) { Com_Debug("Sv_Frame: Low clamp: %dms.\n", (sv.time - svs.real_time - frame_millis)); svs.real_time = sv.time - frame_millis; } else { // wait until its time to run the next frame Net_Sleep(sv.time - svs.real_time); return; } } // update ping based on the last known frame from all clients Sv_UpdatePings(); // give the clients some timeslices Sv_CheckCommandTimes(); // let everything in the world think and move Sv_RunGameFrame(); // send messages back to the clients that had packets read this frame Sv_SendClientMessages(); // send a heartbeat to the master if needed Sv_HeartbeatMasters(); // clear entity flags, etc for next frame Sv_ResetEntities(); #ifdef HAVE_CURSES Curses_Frame(msec); #endif }
/* * @brief */ void Sv_Frame(const uint32_t msec) { // if server is not active, do nothing if (!svs.initialized) return; // read any pending packets from clients Sv_ReadPackets(); // keep simulation time in sync with reality if (!time_demo->value){ const uint32_t frame_millis = 1000 / svs.frame_rate; svs.frame_delta += msec; if (svs.frame_delta < frame_millis) { Net_Sleep(frame_millis - svs.frame_delta); return; } } svs.frame_delta = 0; // check timeouts Sv_CheckTimeouts(); // check command times for attempted cheating Sv_CheckCommandTimes(); // update ping based on the last known frame from all clients Sv_UpdatePings(); // let everything in the world think and move Sv_RunGameFrame(); // send messages back to the clients that had packets read this frame Sv_SendClientPackets(); // send a heartbeat to the master if needed Sv_HeartbeatMasters(); // clear entity flags, etc for next frame Sv_ResetEntities(); // redraw the console Sv_DrawConsole(); }