]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_user.c
added back r_speeds2, with masses of information (6 lines high), and made it print...
[xonotic/darkplaces.git] / sv_user.c
index 400627942b1960f3d1b7ee82544ca88ee48cd35b..8ddff9948e7a980a1d89973871eb62bd6f3a8c26 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -25,6 +25,7 @@ edict_t       *sv_player;
 
 extern cvar_t  sv_friction;
 cvar_t sv_edgefriction = {"edgefriction", "2"};
+cvar_t sv_predict = {"sv_predict", "1"};
 extern cvar_t  sv_stopspeed;
 
 static vec3_t          forward, right, up;
@@ -456,16 +457,26 @@ void SV_ReadClientMove (usercmd_t *move)
        host_client->ping_times[host_client->num_pings%NUM_PING_TIMES]
                = sv.time - MSG_ReadFloat ();
        host_client->num_pings++;
+       for (i=0, total = 0;i < NUM_PING_TIMES;i++)
+               total += host_client->ping_times[i];
+       host_client->ping = total / NUM_PING_TIMES; // can be used for prediction
+       host_client->latency = 0;
+       if (sv_predict.value && (svs.maxclients > 1) && (!sv.paused)) // if paused or a local game, don't predict
+               host_client->latency = host_client->ping;
        if ((val = GETEDICTFIELDVALUE(host_client->edict, eval_ping)))
+               val->_float = host_client->ping * 1000.0;
+
+// read current angles
+       if (dpprotocol)
        {
-               for (i=0, total = 0;i < NUM_PING_TIMES;i++)
-                       total += host_client->ping_times[i];
-               val->_float = 1000.0 / NUM_PING_TIMES;
+               for (i=0 ; i<3 ; i++)
+                       angle[i] = MSG_ReadPreciseAngle ();
+       }
+       else
+       {
+               for (i=0 ; i<3 ; i++)
+                       angle[i] = MSG_ReadAngle ();
        }
-
-// read current angles 
-       for (i=0 ; i<3 ; i++)
-               angle[i] = MSG_ReadAngle ();
 
        VectorCopy (angle, host_client->edict->v.v_angle);