]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sv_user.c
qw support is 99% working
[xonotic/darkplaces.git] / sv_user.c
index 2c148e852d87e1c2d0d538c3c612a420a522de6d..e152d4242b9814a9df30b6f6c136b8bcbb258827 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -604,6 +604,7 @@ SV_ReadClientMove
 */
 qboolean SV_ReadClientMove (void)
 {
+       qboolean kickplayer = false;
        int i;
        double oldmovetime;
        usercmd_t *move = &host_client->cmd;
@@ -685,7 +686,7 @@ qboolean SV_ReadClientMove (void)
 
        if (!host_client->spawned)
                memset(move, 0, sizeof(*move));
-       else if (move->time > sv.time + 0.01) // add a little fuzz factor due to float precision issues
+       else if (move->time > (float)sv.time + 0.001f) // add a little fuzz factor due to float precision issues
        {
                Con_DPrintf("client move->time %f > sv.time %f, kicking\n", move->time, sv.time);
                // if the client is lying about time, we have definitively detected a
@@ -694,7 +695,7 @@ qboolean SV_ReadClientMove (void)
                // this fixes the timestamp to prevent a speed cheat from working
                move->time = sv.time;
                // but we kick the player for good measure
-               return true;
+               kickplayer = true;
        }
        else
        {
@@ -702,16 +703,16 @@ qboolean SV_ReadClientMove (void)
                host_client->movesequence = move->sequence;
                if (host_client->movesequence)
                {
-                       double frametime = move->time - oldmovetime;
+                       double frametime = bound(0, move->time - oldmovetime, 0.1);
                        double oldframetime = prog->globals.server->frametime;
-                       if (frametime > 0.1)
-                               frametime = 0.1;
+                       //if (move->time - oldmovetime >= 0.1001)
+                       //      Con_DPrintf("client move exceeds 100ms!  (time %f -> time %f)\n", oldmovetime, move->time);
                        prog->globals.server->frametime = frametime;
                        SV_Physics_ClientEntity(host_client->edict);
                        prog->globals.server->frametime = oldframetime;
                }
        }
-       return false;
+       return kickplayer;
 }
 
 void SV_ApplyClientMove (void)
@@ -814,7 +815,7 @@ void SV_ReadClientMessage(void)
                        return;
                }
 
-               cmd = MSG_ReadChar ();
+               cmd = MSG_ReadByte ();
                if (cmd == -1)
                {
                        // end of message