]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
sv_clmovement_maxnetfps (default: 80), should prevent issues with high netfps
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 12 Apr 2009 19:13:11 +0000 (19:13 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 12 Apr 2009 19:13:11 +0000 (19:13 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@8914 d7cf8633-e32d-0410-b094-e92efae38249

server.h
sv_main.c
sv_user.c

index 1d717035951a9d643257265279d95cc9d79e0260..86e07a764e3748eaa5770a8b88aa1dcc6890d32b 100644 (file)
--- a/server.h
+++ b/server.h
@@ -382,6 +382,7 @@ extern cvar_t sv_clmovement_enable;
 extern cvar_t sv_clmovement_minping;
 extern cvar_t sv_clmovement_minping_disabletime;
 extern cvar_t sv_clmovement_inputtimeout;
+extern cvar_t sv_clmovement_maxnetfps;
 extern cvar_t sv_cullentities_nevercullbmodels;
 extern cvar_t sv_cullentities_pvs;
 extern cvar_t sv_cullentities_stats;
index 6b43589da595aa75a0cc20d4600e5b0c0f141711..b796428a1c9b7ba43a3875714231b9a251095500 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -59,6 +59,7 @@ cvar_t sv_areagrid_mingridsize = {CVAR_NOTIFY, "sv_areagrid_mingridsize", "64",
 cvar_t sv_checkforpacketsduringsleep = {0, "sv_checkforpacketsduringsleep", "0", "uses select() function to wait between frames which can be interrupted by packets being received, instead of Sleep()/usleep()/SDL_Sleep() functions which do not check for packets"};
 cvar_t sv_clmovement_enable = {0, "sv_clmovement_enable", "1", "whether to allow clients to use cl_movement prediction, which can cause choppy movement on the server which may annoy other players"};
 cvar_t sv_clmovement_minping = {0, "sv_clmovement_minping", "0", "if client ping is below this time in milliseconds, then their ability to use cl_movement prediction is disabled for a while (as they don't need it)"};
+cvar_t sv_clmovement_maxnetfps = {0, "sv_clmovement_maxnetfps", "80", "max amount of movement packets to accept per second"};
 cvar_t sv_clmovement_minping_disabletime = {0, "sv_clmovement_minping_disabletime", "1000", "when client falls below minping, disable their prediction for this many milliseconds (should be at least 1000 or else their prediction may turn on/off frequently)"};
 cvar_t sv_clmovement_inputtimeout = {0, "sv_clmovement_inputtimeout", "0.2", "when a client does not send input for this many seconds, force them to move anyway (unlike QuakeWorld)"};
 cvar_t sv_cullentities_nevercullbmodels = {0, "sv_cullentities_nevercullbmodels", "0", "if enabled the clients are always notified of moving doors and lifts and other submodels of world (warning: eats a lot of network bandwidth on some levels!)"};
@@ -336,6 +337,7 @@ void SV_Init (void)
        Cvar_RegisterVariable (&sv_areagrid_mingridsize);
        Cvar_RegisterVariable (&sv_checkforpacketsduringsleep);
        Cvar_RegisterVariable (&sv_clmovement_enable);
+       Cvar_RegisterVariable (&sv_clmovement_maxnetfps);
        Cvar_RegisterVariable (&sv_clmovement_minping);
        Cvar_RegisterVariable (&sv_clmovement_minping_disabletime);
        Cvar_RegisterVariable (&sv_clmovement_inputtimeout);
index ec6f7a18c14d1c375e129fdaec6a362ade5fd7bb..f5c822e8f7334559430d7271993b3b02a5407406 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -586,6 +586,14 @@ void SV_ExecuteClientMoves(void)
                                move->time = bound(sv.time - 1, move->time, sv.time); // prevent slowhack/speedhack combos
                                move->time = max(move->time, host_client->cmd.time); // prevent backstepping of time
                                moveframetime = bound(0, move->time - host_client->cmd.time, min(0.1, sv_clmovement_inputtimeout.value));
+
+                               // discard (treat like lost) moves with too low distance from
+                               // the previous one to prevent hacks using float inaccuracy
+                               // clients will see this as packet loss in the netgraph
+                               if(sv_clmovement_maxnetfps.value > 0)
+                               if(moveframetime < 1 / sv_clmovement_maxnetfps.value)
+                                       continue;
+
                                //Con_Printf("movesequence = %i (%i lost), moveframetime = %f\n", move->sequence, move->sequence ? move->sequence - host_client->movesequence - 1 : 0, moveframetime);
                                host_client->cmd = *move;
                                host_client->movesequence = move->sequence;