From 83660e08531d3f8f00e33377a7fb75d6e963871b Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Sat, 29 Mar 2008 14:39:45 +0000 Subject: [PATCH] added spam protection --- src/game/g_variables.h | 1 + src/game/server/gs_common.h | 3 +++ src/game/server/gs_server.cpp | 12 +++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/game/g_variables.h b/src/game/g_variables.h index 84725ee49..e95b1e4e8 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 1dd60e816..5986c17a6 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 d41ffd9c3..7e25e6912 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) {