diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-03-29 14:39:45 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-03-29 14:39:45 +0000 |
| commit | 83660e08531d3f8f00e33377a7fb75d6e963871b (patch) | |
| tree | df96ed920f8c7307d49a35180eed45bd50957977 | |
| parent | ae71bff0869ad0cf8854f79a8429b4699635ab65 (diff) | |
| download | zcatch-83660e08531d3f8f00e33377a7fb75d6e963871b.tar.gz zcatch-83660e08531d3f8f00e33377a7fb75d6e963871b.zip | |
added spam protection
| -rw-r--r-- | src/game/g_variables.h | 1 | ||||
| -rw-r--r-- | src/game/server/gs_common.h | 3 | ||||
| -rw-r--r-- | src/game/server/gs_server.cpp | 12 |
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) { |