[openjk] 08/23: [MP] Added sv_floodProtectSlow (0 = don't reset timer on rejected commands). Allowed sv_floodProtect to specify flood time in ms

Simon McVittie smcv at debian.org
Thu Jan 11 17:28:59 UTC 2018


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian/master
in repository openjk.

commit 9bbba0a4de24e9f3be1c0c4f1b4144ba6b0487a0
Author: Razish <mrrazish at gmail.com>
Date:   Tue Dec 12 17:03:13 2017 +1100

    [MP] Added sv_floodProtectSlow (0 = don't reset timer on rejected commands). Allowed sv_floodProtect to specify flood time in ms
---
 codemp/server/server.h      |  3 ++-
 codemp/server/sv_client.cpp | 22 ++++++++++++++--------
 codemp/server/sv_init.cpp   |  1 +
 codemp/server/sv_main.cpp   |  1 +
 4 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/codemp/server/server.h b/codemp/server/server.h
index e64b97e..78a2617 100644
--- a/codemp/server/server.h
+++ b/codemp/server/server.h
@@ -168,7 +168,7 @@ typedef struct client_s {
 	int				downloadSendTime;	// time we last got an ack from the client
 
 	int				deltaMessage;		// frame last client usercmd message
-	int				nextReliableTime;	// svs.time when another reliable command will be allowed
+	int				lastReliableTime;	// svs.time when reliable command was last received
 	int				lastPacketTime;		// svs.time when packet was last received
 	int				lastConnectTime;	// svs.time when connection started
 	int				nextSnapshotTime;	// send another snapshot when svs.time >= nextSnapshotTime
@@ -264,6 +264,7 @@ extern	cvar_t	*sv_maxPing;
 extern	cvar_t	*sv_gametype;
 extern	cvar_t	*sv_pure;
 extern	cvar_t	*sv_floodProtect;
+extern	cvar_t	*sv_floodProtectSlow;
 extern	cvar_t	*sv_lanForceRate;
 extern	cvar_t	*sv_needpass;
 extern	cvar_t	*sv_filterCommands;
diff --git a/codemp/server/sv_client.cpp b/codemp/server/sv_client.cpp
index d88ed6e..bb8bf8d 100644
--- a/codemp/server/sv_client.cpp
+++ b/codemp/server/sv_client.cpp
@@ -1336,16 +1336,22 @@ static qboolean SV_ClientCommand( client_t *cl, msg_t *msg ) {
 	// normal to spam a lot of commands when downloading
 	if ( !com_cl_running->integer &&
 		cl->state >= CS_ACTIVE &&
-		sv_floodProtect->integer &&
-		svs.time < cl->nextReliableTime ) {
-		// ignore any other text messages from this client but let them keep playing
-		// TTimo - moved the ignored verbose to the actual processing in SV_ExecuteClientCommand, only printing if the core doesn't intercept
-		clientOk = qfalse;
+		sv_floodProtect->integer )
+	{
+		const int floodTime = (sv_floodProtect->integer == 1) ? 1000 : sv_floodProtect->integer;
+		if ( svs.time < (cl->lastReliableTime + floodTime) ) {
+			// ignore any other text messages from this client but let them keep playing
+			// TTimo - moved the ignored verbose to the actual processing in SV_ExecuteClientCommand, only printing if the core doesn't intercept
+			clientOk = qfalse;
+		}
+		else {
+			cl->lastReliableTime = svs.time;
+		}
+		if ( sv_floodProtectSlow->integer ) {
+			cl->lastReliableTime = svs.time;
+		}
 	}
 
-	// don't allow another command for one second
-	cl->nextReliableTime = svs.time + 1000;
-
 	SV_ExecuteClientCommand( cl, s, clientOk );
 
 	cl->lastClientCommand = seq;
diff --git a/codemp/server/sv_init.cpp b/codemp/server/sv_init.cpp
index 0a29a43..11ec030 100644
--- a/codemp/server/sv_init.cpp
+++ b/codemp/server/sv_init.cpp
@@ -963,6 +963,7 @@ void SV_Init (void) {
 	sv_minPing = Cvar_Get ("sv_minPing", "0", CVAR_ARCHIVE_ND | CVAR_SERVERINFO );
 	sv_maxPing = Cvar_Get ("sv_maxPing", "0", CVAR_ARCHIVE_ND | CVAR_SERVERINFO );
 	sv_floodProtect = Cvar_Get ("sv_floodProtect", "1", CVAR_ARCHIVE | CVAR_SERVERINFO, "Protect against flooding of server commands" );
+	sv_floodProtectSlow = Cvar_Get ("sv_floodProtectSlow", "1", CVAR_ARCHIVE | CVAR_SERVERINFO, "Use original method of delaying commands with flood protection" );
 	// systeminfo
 	Cvar_Get ("sv_cheats", "1", CVAR_SYSTEMINFO | CVAR_ROM, "Allow cheats on server if set to 1" );
 	sv_serverid = Cvar_Get ("sv_serverid", "0", CVAR_SYSTEMINFO | CVAR_ROM );
diff --git a/codemp/server/sv_main.cpp b/codemp/server/sv_main.cpp
index a968c4d..64f593c 100644
--- a/codemp/server/sv_main.cpp
+++ b/codemp/server/sv_main.cpp
@@ -60,6 +60,7 @@ cvar_t	*sv_maxPing;
 cvar_t	*sv_gametype;
 cvar_t	*sv_pure;
 cvar_t	*sv_floodProtect;
+cvar_t	*sv_floodProtectSlow;
 cvar_t	*sv_lanForceRate; // dedicated 1 (LAN) server forces local client rates to 99999 (bug #491)
 cvar_t	*sv_needpass;
 cvar_t	*sv_filterCommands; // strict filtering on commands (1: strip ['\r', '\n'], 2: also strip ';')

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/openjk.git



More information about the Pkg-games-commits mailing list