diff --git a/reaction/game/g_local.h b/reaction/game/g_local.h index dba9dd42..38842324 100644 --- a/reaction/game/g_local.h +++ b/reaction/game/g_local.h @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.80 2002/05/12 00:07:47 slicer +// Added Normal Radio Flood Protection +// // Revision 1.79 2002/05/11 16:22:38 slicer // Added a Repeat Flood Protection to Radio // @@ -583,6 +586,9 @@ struct gclient_s { //Slicer Flood protect: float rd_mute; //Time to be muted + int rd_Count; //Counter for the last msgs in "xx" secs allowed + float rd_time; //Time for the first radio message of the ones to follow + int rd_lastRadio; //Code of the last radio used int rd_repCount; //Counter for the number of repeated radio msgs float rd_repTime; //The time for the last repeated radio msg @@ -1184,6 +1190,8 @@ extern vmCvar_t g_RQ3_NextMapID; extern vmCvar_t g_RQ3_radioRepeat; extern vmCvar_t g_RQ3_radioRepeatTime; extern vmCvar_t g_RQ3_radioBan; +extern vmCvar_t g_RQ3_radioFlood; +extern vmCvar_t g_RQ3_radioFloodTime; void trap_Printf( const char *fmt ); void trap_Error( const char *fmt ); diff --git a/reaction/game/g_main.c b/reaction/game/g_main.c index 08c43b5d..2ab6c83b 100644 --- a/reaction/game/g_main.c +++ b/reaction/game/g_main.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.57 2002/05/12 00:07:47 slicer +// Added Normal Radio Flood Protection +// // Revision 1.56 2002/05/11 16:22:38 slicer // Added a Repeat Flood Protection to Radio // @@ -257,6 +260,8 @@ vmCvar_t g_RQ3_NextMapID; vmCvar_t g_RQ3_radioRepeat; vmCvar_t g_RQ3_radioRepeatTime; vmCvar_t g_RQ3_radioBan; +vmCvar_t g_RQ3_radioFlood; +vmCvar_t g_RQ3_radioFloodTime; #ifdef MISSIONPACK @@ -366,6 +371,8 @@ static cvarTable_t gameCvarTable[] = { //Slicer: Matchmode { &g_RQ3_matchmode, "g_RQ3_matchmode", "0", CVAR_SERVERINFO | CVAR_USERINFO | CVAR_LATCH, 0, qfalse }, //Slicer: radio protect + { &g_RQ3_radioFlood, "g_RQ3_radioFlood", "3", 0 , 0, qfalse }, + { &g_RQ3_radioFloodTime, "g_RQ3_radioFloodTime", "2", 0 , 0, qfalse }, { &g_RQ3_radioRepeat, "g_RQ3_radioRepeat", "2", 0 , 0, qfalse }, { &g_RQ3_radioRepeatTime, "g_RQ3_radioRepeat", "1", 0 , 0, qfalse }, { &g_RQ3_radioBan, "g_RQ3_radioBan", "10", 0 , 0, qfalse }, diff --git a/reaction/game/g_teamplay.c b/reaction/game/g_teamplay.c index 85856613..f8cc2cdd 100644 --- a/reaction/game/g_teamplay.c +++ b/reaction/game/g_teamplay.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.88 2002/05/12 00:07:47 slicer +// Added Normal Radio Flood Protection +// // Revision 1.87 2002/05/11 16:22:38 slicer // Added a Repeat Flood Protection to Radio // @@ -1202,6 +1205,39 @@ radio_msg_t female_radio_msgs[] = { { "END", 0 }, // end of list delimiter }; //Slicer Adding Flood Protection Functions +qboolean CheckForFlood (gentity_t * ent) +{ + //If he's muted.. + if (ent->client->rd_mute) { + if (ent->client->rd_mute > level.time) // Still muted.. + return qfalse; + else + ent->client->rd_mute = 0; // No longer muted.. + } + if(!ent->client->rd_Count) { + ent->client->rd_time = level.time; + ++ent->client->rd_Count; + } + else { + ++ent->client->rd_Count; + if(level.time - ent->client->rd_time < g_RQ3_radioFloodTime.integer) { + if(ent->client->rd_Count >= g_RQ3_radioFlood.integer) { + trap_SendServerCommand(ent-g_entities, va("print \"Radio Flood Detected, you are silenced for %i secs\n\"", + (int) g_RQ3_radioBan.integer)); + ent->client->rd_mute = level.time + g_RQ3_radioBan.integer*1000; + return qfalse; + } + } + else { + ent->client->rd_Count = 0; + } + } + + return qtrue; + +} + + qboolean CheckForRepeat (gentity_t *ent, int radioCode) { int lastRadioCode; //If he's muted.. @@ -1260,8 +1296,8 @@ void RQ3_Cmd_Radio_f(gentity_t *ent) while (Q_stricmp(radio_msgs[x].msg, "END")) { if (!Q_stricmp(radio_msgs[x].msg, msg)) { - //Slicer Checking for repeat flood - if(!CheckForRepeat(ent,x)) + //Slicer Checking for flood protections + if(!CheckForRepeat(ent,x) || !CheckForFlood (ent)) return; if (!Q_stricmp(radio_msgs[x].msg, "enemyd")) { kills = ent->client->killStreak;