added spam protection

This commit is contained in:
Magnus Auvinen 2008-03-29 14:39:45 +00:00
parent ae71bff086
commit 83660e0853
3 changed files with 15 additions and 1 deletions

View file

@ -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)

View file

@ -316,6 +316,9 @@ public:
// the player core for the physics
player_core core;
//
int64 last_chat;
//
player();

View file

@ -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)
{