]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
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 0229f79485cbd3c6a3bed648097372a91e46a44f..fc654c9e3d5f9ea547dc2c5c46eef823e6807f5a 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 3961e6bf85f38f4cb072b47afd9a8cc079d45ff2..1abf913a93fcb667efcc1fa5ee4cc27500341465 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 ccf69f857fb6db97ac6cefd7c48b074e6454b638..f614f8c36e69c8410c24ec16eeb14a38bee0f80e 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;