From 7b56e23b2643937f50c60105c2c1333c0f00034a Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Mon, 13 Jul 2020 16:00:10 +0000 Subject: [PATCH] host: Add "restless" variable to host_t. True means don't sleep (timedemo, etc) This is meant to reduce client code in the common Host_Main. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12798 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_demo.c | 4 ++-- cl_main.c | 2 +- host.c | 4 +++- quakedef.h | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cl_demo.c b/cl_demo.c index 56c301b3..b8445419 100644 --- a/cl_demo.c +++ b/cl_demo.c @@ -499,7 +499,7 @@ static void CL_FinishTimeDemo (void) static int benchmark_runs = 0; char vabuf[1024]; - cls.timedemo = false; + cls.timedemo = host.restless = false; frames = cls.td_frames; time = host.realtime - cls.td_starttime; @@ -614,7 +614,7 @@ void CL_TimeDemo_f(cmd_state_t *cmd) key_consoleactive = 0; scr_con_current = 0; - cls.timedemo = true; + cls.timedemo = host.restless = true; cls.td_frames = -2; // skip the first frame cls.demonum = -1; // stop demo loop } diff --git a/cl_main.c b/cl_main.c index c03ff082..3424e67c 100644 --- a/cl_main.c +++ b/cl_main.c @@ -403,7 +403,7 @@ void CL_Disconnect(void) cls.state = ca_disconnected; cl.islocalgame = false; - cls.demoplayback = cls.timedemo = false; + cls.demoplayback = cls.timedemo = host.restless = false; cls.signon = 0; // If we're dropped mid-connection attempt, it won't clear otherwise. diff --git a/host.c b/host.c index 3812d498..b134a923 100644 --- a/host.c +++ b/host.c @@ -407,6 +407,8 @@ void Host_Main(void) char vabuf[1024]; qboolean playing; + host.restless = false; + Host_Init(); host.realtime = 0; @@ -518,7 +520,7 @@ void Host_Main(void) else wait = max(cl_timer, sv_timer) * -1000000.0; - if (!cls.timedemo && wait >= 1) + if (!host.restless && wait >= 1) { double time0, delta; diff --git a/quakedef.h b/quakedef.h index da267345..9ade07f6 100644 --- a/quakedef.h +++ b/quakedef.h @@ -534,6 +534,7 @@ typedef struct host_s int framecount; // incremented every frame, never reset (checked by Host_Error and Host_SaveConfig_f) double realtime; // the accumulated mainloop time since application started (with filtering), without any slowmo or clamping double dirtytime; // the main loop wall time for this frame, equal to Sys_DirtyTime() at the start of this host frame + qboolean restless; // don't sleep } host_t; extern host_t host; -- 2.39.2