about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/game/g_variables.h1
-rw-r--r--src/game/server/gs_common.h3
-rw-r--r--src/game/server/gs_server.cpp12
3 files changed, 15 insertions, 1 deletions
diff --git a/src/game/g_variables.h b/src/game/g_variables.h
index 84725ee4..e95b1e4e 100644
--- a/src/game/g_variables.h
+++ b/src/game/g_variables.h
@@ -52,5 +52,6 @@ MACRO_CONFIG_INT(sv_scorelimit, 20, 0, 1000)
 MACRO_CONFIG_INT(sv_timelimit, 0, 0, 1000)
 MACRO_CONFIG_STR(sv_gametype, 32, "dm")
 MACRO_CONFIG_INT(sv_tournament_mode, 0, 0, 1)
+MACRO_CONFIG_INT(sv_spamprotection, 1, 0, 1)
 
 MACRO_CONFIG_INT(sv_spectator_slots, 0, 0, 12)
diff --git a/src/game/server/gs_common.h b/src/game/server/gs_common.h
index 1dd60e81..5986c17a 100644
--- a/src/game/server/gs_common.h
+++ b/src/game/server/gs_common.h
@@ -316,6 +316,9 @@ public:
 
 	// the player core for the physics	
 	player_core core;
+	
+	//
+	int64 last_chat;
 
 	//
 	player();
diff --git a/src/game/server/gs_server.cpp b/src/game/server/gs_server.cpp
index d41ffd9c..7e25e691 100644
--- a/src/game/server/gs_server.cpp
+++ b/src/game/server/gs_server.cpp
@@ -683,6 +683,7 @@ void player::reset()
 	die_tick = 0;
 	die_pos = vec2(0,0);
 	damage_taken = 0;
+	last_chat = 0;
 	player_state = PLAYERSTATE_UNKNOWN;
 
 	mem_zero(&input, sizeof(input));
@@ -2113,7 +2114,16 @@ void mods_message(int msgtype, int client_id)
 			team = players[client_id].team;
 		else
 			team = -1;
-		send_chat(client_id, team, msg->message);
+		
+		if(config.sv_spamprotection && players[client_id].last_chat+time_freq() > time_get())
+		{
+			// consider this as spam
+		}
+		else
+		{
+			players[client_id].last_chat = time_get();
+			send_chat(client_id, team, msg->message);
+		}
 	}
 	else if (msgtype == NETMSGTYPE_CL_SETTEAM)
 	{