diff options
-rw-r--r-- | src/game/g_admin.c | 22 | ||||
-rw-r--r-- | src/game/g_local.h | 3 | ||||
-rw-r--r-- | src/game/g_main.c | 6 |
3 files changed, 29 insertions, 2 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c index 3b5c8a3..8a77326 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -7997,9 +7997,13 @@ int G_admin_autorevert( gentity_t *ent ) return count; } +static int lastRevertCookie = 0; +static int lastRevertTime = 0; +static int consoleRevertCookie = 0; + qboolean G_admin_revert( gentity_t *ent, int skiparg ) { - int i = 0, j = 0, repeat = 1, ID = 0, len, matchlen=0; + int i = 0, j = 0, repeat = 1, ID = 0, len, matchlen=0, *cookie; pTeam_t team = PTE_NONE; qboolean force = qfalse, reached = qfalse; gentity_t *builder = NULL, *targ; @@ -8017,6 +8021,18 @@ qboolean G_admin_revert( gentity_t *ent, int skiparg ) ADMP( "^3!revert: ^7usage: !revert (^5xnum^7) (^5#ID^7) (^5-name|num^7) (^5a|h^7)\n" ); return qfalse; } + if( ent ) + cookie = &ent->client->revertCookie; + else + cookie = &consoleRevertCookie; + if( lastRevertCookie > 0 && + ( lastRevertTime + g_revertCooldownTime.integer * 1000 > level.time ) && + *cookie < lastRevertCookie ) + { + ADMP( "^3!revert: ^7someone just reverted, repeat this command if it's not an error\n" ); + *cookie = lastRevertCookie; + return qfalse; + } for( i = 1; i + skiparg < G_SayArgc( ); i++ ) { char arg[ 64 ], err[ MAX_STRING_CHARS ]; @@ -8224,6 +8240,10 @@ qboolean G_admin_revert( gentity_t *ent, int skiparg ) { ADMP( va( "^3!revert: ^7reverted %d buildlog events\n", matchlen ) ); } + + lastRevertTime = level.time; + lastRevertCookie++; + *cookie = lastRevertCookie; return qtrue; } diff --git a/src/game/g_local.h b/src/game/g_local.h index 46c53ba..6e077bd 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -549,6 +549,7 @@ struct gclient_s int tkcredits[ MAX_CLIENTS ]; + int revertCookie; }; @@ -1541,6 +1542,8 @@ extern vmCvar_t g_reportWelcomeComment; extern vmCvar_t g_scrimMode; +extern vmCvar_t g_revertCooldownTime; + void trap_Printf( const char *fmt ); void trap_Error( const char *fmt ); int trap_Milliseconds( void ); diff --git a/src/game/g_main.c b/src/game/g_main.c index a8677eb..5cfc383 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -282,6 +282,8 @@ vmCvar_t g_reportWelcomeComment; vmCvar_t g_scrimMode; +vmCvar_t g_revertCooldownTime; + static cvarTable_t gameCvarTable[ ] = { // don't override the cheat state set by the system @@ -541,7 +543,9 @@ static cvarTable_t gameCvarTable[ ] = { &g_reportWelcomeComment, "g_reportWelcomeComment", "", CVAR_ARCHIVE, 0, qfalse }, - { &g_scrimMode, "g_scrimMode", "0", CVAR_ARCHIVE, 0, qfalse } + { &g_scrimMode, "g_scrimMode", "0", CVAR_ARCHIVE, 0, qfalse }, + + { &g_revertCooldownTime, "g_revertCooldownTime", "30", CVAR_ARCHIVE, 0, qfalse } }; static int gameCvarTableSize = sizeof( gameCvarTable ) / sizeof( gameCvarTable[ 0 ] ); |