summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/g_cmds.c94
1 files changed, 25 insertions, 69 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 17ec730..565d4c8 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -354,40 +354,29 @@ Determine whether a user is flood limited, and adjust their flood demerits
qboolean G_Flood_Limited( gentity_t *ent )
{
- int millisSinceLastCommand;
- int maximumDemerits;
+ int deltatime, ms;
+
+ if( g_floodMinTime.integer <= 0 )
+ return 0;
- // This shouldn't be called if g_floodMinTime isn't set, but handle it anyway.
- if( !g_floodMinTime.integer )
- return qfalse;
-
- // Do not limit admins with no censor/flood flag
if( G_admin_permission( ent, ADMF_NOCENSORFLOOD ) )
- return qfalse;
-
- millisSinceLastCommand = level.time - ent->client->pers.lastFloodTime;
- if( millisSinceLastCommand < g_floodMinTime.integer )
- ent->client->pers.floodDemerits += ( g_floodMinTime.integer - millisSinceLastCommand );
- else
- {
- ent->client->pers.floodDemerits -= ( millisSinceLastCommand - g_floodMinTime.integer );
- if( ent->client->pers.floodDemerits < 0 )
- ent->client->pers.floodDemerits = 0;
- }
+ return 0;
- ent->client->pers.lastFloodTime = level.time;
+ deltatime = level.time - ent->client->pers.lastFloodTime;
- // If g_floodMaxDemerits == 0, then we go against g_floodMinTime^2.
-
- if( !g_floodMaxDemerits.integer )
- maximumDemerits = g_floodMinTime.integer * g_floodMinTime.integer / 1000;
- else
- maximumDemerits = g_floodMaxDemerits.integer;
+ ent->client->pers.floodDemerits += g_floodMinTime.integer - deltatime;
+ if( ent->client->pers.floodDemerits < 0 )
+ ent->client->pers.floodDemerits = 0;
+ ent->client->pers.lastFloodTime = level.time;
- if( ent->client->pers.floodDemerits > maximumDemerits )
- return qtrue;
+ ms = ent->client->pers.floodDemerits - g_floodMaxDemerits.integer;
+ if( ms <= 0 )
+ return 0;
- return qfalse;
+ trap_SendServerCommand( ent - g_entities, va( "print \"You are flooding: "
+ "please wait %d second%s before trying again\n",
+ ( ms + 999 ) / 1000, ( ms > 1000 ) ? "s" : "" ) );
+ return ms;
}
/*
@@ -1078,10 +1067,7 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText )
// Flood limit. If they're talking too fast, determine that and return.
if( g_floodMinTime.integer )
if ( G_Flood_Limited( ent ) )
- {
- trap_SendServerCommand( ent-g_entities, "print \"Your chat is flood-limited; wait before chatting again\n\"" );
return;
- }
if (g_chatTeamPrefix.integer && ent && ent->client )
{
@@ -1260,11 +1246,8 @@ static void Cmd_SayArea_f( gentity_t *ent )
range[ i ] = g_sayAreaRange.value;
if( g_floodMinTime.integer )
- if ( G_Flood_Limited( ent ) )
- {
- trap_SendServerCommand( ent-g_entities, "print \"Your chat is flood-limited; wait before chatting again\n\"" );
- return;
- }
+ if ( G_Flood_Limited( ent ) )
+ return;
if (g_chatTeamPrefix.integer)
{
@@ -1519,11 +1502,7 @@ void Cmd_Join_f( gentity_t *ent )
if( g_floodMinTime.integer &&
G_Flood_Limited( ent ) )
- {
- trap_SendServerCommand( ent-g_entities,
- "print \"Your chat is flood-limited; wait before chatting again\n\"" );
return;
- }
G_SayArgv( skipargs, arg, sizeof( arg ) );
if( !Q_stricmp( arg, "say" ) )
@@ -1611,10 +1590,7 @@ void Cmd_Part_f( gentity_t *ent )
if( g_floodMinTime.integer &&
G_Flood_Limited( ent ) )
- {
- trap_SendServerCommand( ent-g_entities, "print \"Your chat is flood-limited; wait before chatting again\n\"" );
return;
- }
G_SayArgv( 1 + skipargs, arg, sizeof( arg ) );
chan = atoi( arg );
@@ -1673,10 +1649,7 @@ void Cmd_Channel_f( gentity_t *ent )
if( g_floodMinTime.integer &&
G_Flood_Limited( ent ) )
- {
- trap_SendServerCommand( ent-g_entities, "print \"Your chat is flood-limited; wait before chatting again\n\"" );
return;
- }
G_SayArgv( skipargs, arg, sizeof( arg ) );
if( !Q_stricmp( arg, "say" ) )
@@ -1847,10 +1820,7 @@ void Cmd_CallVote_f( gentity_t *ent )
// Flood limit. If they're talking too fast, determine that and return.
if( g_floodMinTime.integer )
if ( G_Flood_Limited( ent ) )
- {
- trap_SendServerCommand( ent-g_entities, "print \"Your /callvote attempt is flood-limited; wait before chatting again\n\"" );
return;
- }
if( g_voteMinTime.integer
&& ent->client->pers.firstConnect
@@ -3351,11 +3321,7 @@ void DBCommand( gentity_t *builder, pTeam_t team, const char *text )
gentity_t *ent;
if( g_floodMinTime.integer && G_Flood_Limited( builder ) )
- {
- trap_SendServerCommand( builder-g_entities,
- "print \"Your deconstruct attempt is flood-limited; wait before trying again\n\"" );
return;
- }
trap_SendServerCommand( builder-g_entities,
"print \"This structure is protected by designated builder\n\"" );
@@ -5123,11 +5089,8 @@ static void Cmd_Ignore_f( gentity_t *ent )
}
if( g_floodMinTime.integer )
- if ( G_Flood_Limited( ent ) )
- {
- trap_SendServerCommand( ent-g_entities, "print \"Your chat is flood-limited; wait before chatting again\n\"" );
- return;
- }
+ if ( G_Flood_Limited( ent ) )
+ return;
team = ent->client->pers.teamSelection;
@@ -5330,12 +5293,8 @@ static void Cmd_Ignore_f( gentity_t *ent )
}
if( g_floodMinTime.integer )
- if ( G_Flood_Limited( ent ) )
- {
- trap_SendServerCommand( ent-g_entities, "print \"Your chat is flood-limited; wait before chatting again\n\"" );
- return;
- }
-
+ if ( G_Flood_Limited( ent ) )
+ return;
if( ent->client->pers.teamSelection == PTE_ALIENS )
divisor = level.numAlienClients-1;
@@ -5814,11 +5773,8 @@ void G_PrivateMessage( gentity_t *ent )
}
if( g_floodMinTime.integer )
- if ( G_Flood_Limited( ent ) )
- {
- trap_SendServerCommand( ent-g_entities, "print \"Your chat is flood-limited; wait before chatting again\n\"" );
- return;
- }
+ if ( G_Flood_Limited( ent ) )
+ return;
G_SayArgv( 0, cmd, sizeof( cmd ) );
if( !Q_stricmp( cmd, "say" ) || !Q_stricmp( cmd, "say_team" ) )