From dd2f9e6b03116ceb0fd7e79c734c7f4201fdadbc Mon Sep 17 00:00:00 2001 From: havoc Date: Fri, 16 Jan 2009 18:03:27 +0000 Subject: [PATCH] added servertime, serverprevtime, serverdeltatime globals to csqc git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8655 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_parse.c | 3 +++ csprogs.c | 16 ++++++++++++++++ progsvm.h | 3 +++ 3 files changed, 22 insertions(+) diff --git a/cl_parse.c b/cl_parse.c index 0229f794..fc654c9e 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -2949,6 +2949,7 @@ qboolean CL_ExaminePrintString(const char *text) } extern cvar_t slowmo; +extern void CSQC_UpdateNetworkTimes(double newtime, double oldtime); static void CL_NetworkTimeReceived(double newtime) { double timehigh; @@ -3026,6 +3027,8 @@ static void CL_NetworkTimeReceived(double newtime) cl.fixangle[0] = false; if (!cls.demoplayback) VectorCopy(cl.mviewangles[0], cl.mviewangles[1]); + // update the csqc's server timestamps, critical for proper sync + CSQC_UpdateNetworkTimes(cl.mtime[0], cl.mtime[1]); } #define SHOWNET(x) if(cl_shownet.integer==2)Con_Printf("%3i:%s(%i)\n", msg_readcount-1, x, cmd); diff --git a/csprogs.c b/csprogs.c index 3961e6bf..1abf913a 100644 --- a/csprogs.c +++ b/csprogs.c @@ -69,6 +69,22 @@ void CL_VM_UpdateDmgGlobals (int dmg_take, int dmg_save, vec3_t dmg_origin) CSQC_END } } + +void CSQC_UpdateNetworkTimes(double newtime, double oldtime) +{ + prvm_eval_t *val; + if(!cl.csqc_loaded) + return; + CSQC_BEGIN + if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.servertime))) + val->_float = newtime; + if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.serverprevtime))) + val->_float = oldtime; + if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.serverdeltatime))) + val->_float = newtime - oldtime; + CSQC_END +} + //[515]: set globals before calling R_UpdateView, WEIRD CRAP static void CSQC_SetGlobals (void) { diff --git a/progsvm.h b/progsvm.h index ccf69f85..f614f8c3 100644 --- a/progsvm.h +++ b/progsvm.h @@ -257,6 +257,9 @@ typedef struct prvm_prog_globaloffsets_s int drawfont; // csqc / menu int require_spawnfunc_prefix; // ssqc int worldstatus; // ssqc + int servertime; // csqc + int serverprevtime; // csqc + int serverdeltatime; // csqc } prvm_prog_globaloffsets_t; -- 2.39.2