summaryrefslogtreecommitdiff
path: root/src/game/g_admin.c
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-04-13 11:30:00 +0000
committer/dev/humancontroller <devhc@example.com>2017-04-15 17:24:22 +0200
commit5510cfbeec0bcb59eac770fdb9b5132d7c61b426 (patch)
tree2a71ecfe949c306bbeadc5eca7b69e23dbbdf477 /src/game/g_admin.c
parent56d892b6df06a88694988a2c8410dfaebc9bf9ac (diff)
Add a cool down timer to !revert.
This will prevent two (or more) admins from trying to !revert simultaneously and accidentally undoing innocent players' progress.
Diffstat (limited to 'src/game/g_admin.c')
-rw-r--r--src/game/g_admin.c22
1 files changed, 21 insertions, 1 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;
}