-static void Host_Init(void);
-double Host_Frame(double time)
-{
- double cl_timer = 0;
- double sv_timer = 0;
- static double wait;
-
- TaskQueue_Frame(false);
-
- // keep the random time dependent, but not when playing demos/benchmarking
- if(!*sv_random_seed.string && !host.restless)
- rand();
-
- NetConn_UpdateSockets();
-
- Log_DestBuffer_Flush();
-
- Curl_Run();
-
- // check for commands typed to the host
- Host_GetConsoleCommands();
-
- // process console commands
-// R_TimeReport("preconsole");
- Cbuf_Frame(&cmd_client);
- Cbuf_Frame(&cmd_server);
-
- if(sv.active)
- Cbuf_Frame(&cmd_serverfromclient);
-
-// R_TimeReport("console");
-
- //Con_Printf("%6.0f %6.0f\n", cl_timer * 1000000.0, sv_timer * 1000000.0);
-
- R_TimeReport("---");
-
- sv_timer = SV_Frame(time);
- cl_timer = CL_Frame(time);
-
- Mem_CheckSentinelsGlobal();
-
- // if the accumulators haven't become positive yet, wait a while
- if (cls.state == ca_dedicated)
- wait = sv_timer * -1000000.0; // dedicated
- else if (!sv.active || svs.threaded)
- wait = cl_timer * -1000000.0; // connected to server, main menu, or server is on different thread
- else
- wait = max(cl_timer, sv_timer) * -1000000.0; // listen server or singleplayer
-
- if (!host.restless && wait >= 1)
- return wait;
- else
- return 0;
-}
-
-static inline void Host_Sleep(double time)
-{
- double time0, delta;
-
- if(host_maxwait.value <= 0)
- time = min(time, 1000000.0);
- else
- time = min(time, host_maxwait.value * 1000.0);
- if(time < 1)
- time = 1; // because we cast to int
-
- time0 = Sys_DirtyTime();
- if (sv_checkforpacketsduringsleep.integer && !sys_usenoclockbutbenchmark.integer && !svs.threaded) {
- NetConn_SleepMicroseconds((int)time);
- if (cls.state != ca_dedicated)
- NetConn_ClientFrame(); // helps server browser get good ping values
- // TODO can we do the same for ServerFrame? Probably not.
- }
- else
- Sys_Sleep((int)time);
- delta = Sys_DirtyTime() - time0;
- if (delta < 0 || delta >= 1800)
- delta = 0;
- host.sleeptime += delta;
-// R_TimeReport("sleep");
- return;
-}
-
-// Cloudwalk: Most overpowered function declaration...
-static inline double Host_UpdateTime (double newtime, double oldtime)
-{
- double time = newtime - oldtime;
-
- if (time < 0)
- {
- // warn if it's significant
- if (time < -0.01)
- Con_Printf(CON_WARN "Host_GetTime: time stepped backwards (went from %f to %f, difference %f)\n", oldtime, newtime, time);
- time = 0;
- }
- else if (time >= 1800)
- {
- Con_Printf(CON_WARN "Host_GetTime: time stepped forward (went from %f to %f, difference %f)\n", oldtime, newtime, time);
- time = 0;
- }
-
- return time;
-}
-
-void Host_Main(void)