From debe81f9f63b498dc6b1fd48d1478170d5d9fff3 Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Sun, 11 Apr 2021 16:46:12 +0000 Subject: [PATCH] cl_parse: Further optimize CL_NetworkTimeReceived Authored by bones_was_here https://gitlab.com/xonotic/darkplaces/-/merge_requests/112 git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13111 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_parse.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cl_parse.c b/cl_parse.c index 99777714..ea55f8e6 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -3278,7 +3278,6 @@ extern cvar_t host_timescale; extern cvar_t cl_lerpexcess; static void CL_NetworkTimeReceived(double newtime) { - double timehigh; cl.mtime[1] = cl.mtime[0]; cl.mtime[0] = newtime; if (cl_nolerp.integer || cls.timedemo || cl.mtime[1] == cl.mtime[0] || cls.signon < SIGNONS) @@ -3293,7 +3292,9 @@ static void CL_NetworkTimeReceived(double newtime) } else if (cls.protocol != PROTOCOL_QUAKEWORLD) { + double timehigh; cl.mtime[1] = max(cl.mtime[1], cl.mtime[0] - 0.1); + if (developer_extra.integer && vid_activewindow) { if (cl.time < cl.mtime[1] - (cl.mtime[0] - cl.mtime[1])) @@ -3301,8 +3302,14 @@ static void CL_NetworkTimeReceived(double newtime) else if (cl.time > cl.mtime[0] + (cl.mtime[0] - cl.mtime[1])) Con_DPrintf("--- cl.time > cl.mtime[0] (%f > %f ... %f)\n", cl.time, cl.mtime[1], cl.mtime[0]); } - cl.time += (cl.mtime[1] - cl.time) * bound(0, cl_nettimesyncfactor.value, 1); - timehigh = cl.mtime[1] + (cl.mtime[0] - cl.mtime[1]) * cl_nettimesyncboundtolerance.value; + + if (cl_nettimesyncboundmode.integer < 4) + { + // doesn't make sense for modes > 3 + cl.time += (cl.mtime[1] - cl.time) * bound(0, cl_nettimesyncfactor.value, 1); + timehigh = cl.mtime[1] + (cl.mtime[0] - cl.mtime[1]) * cl_nettimesyncboundtolerance.value; + } + switch (cl_nettimesyncboundmode.integer) { case 1: -- 2.39.2