added servertime, serverprevtime, serverdeltatime globals to csqc
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 16 Jan 2009 18:03:27 +0000 (18:03 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 16 Jan 2009 18:03:27 +0000 (18:03 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8655 d7cf8633-e32d-0410-b094-e92efae38249

cl_parse.c
csprogs.c
progsvm.h

index 0229f79..fc654c9 100644 (file)
@@ -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);
index 3961e6b..1abf913 100644 (file)
--- 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)
 {
index ccf69f8..f614f8c 100644 (file)
--- 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;