From 6ca4b8150cad3f7e46e16d454ab0159a6b608576 Mon Sep 17 00:00:00 2001 From: z411 Date: Tue, 18 Jan 2022 17:03:16 -0300 Subject: [PATCH] Added anti-flood to ready command --- qcsrc/server/command/cmd.qc | 6 ++++-- qcsrc/server/command/vote.qh | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index c9ceb31b6..f92e151fe 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -366,13 +366,13 @@ void ClientCommand_physics(entity caller, int request, int argc) } } -void ClientCommand_ready(entity caller, int request) // todo: anti-spam for toggling readyness +void ClientCommand_ready(entity caller, int request) { switch (request) { case CMD_REQUEST_COMMAND: { - if (IS_CLIENT(caller)) + if (IS_CLIENT(caller) && caller.last_ready < time - 3) { if (warmup_stage || g_race_qualifying == 2) { @@ -391,6 +391,8 @@ void ClientCommand_ready(entity caller, int request) // todo: anti-spam for tog bprint(playername(caller.netname, caller.team, false), "^2 is ready\n"); } + caller.last_ready = time; + // cannot reset the game while a timeout is active! if (!timeout_status) ReadyCount(); } diff --git a/qcsrc/server/command/vote.qh b/qcsrc/server/command/vote.qh index 63c9e8e45..7c96223a7 100644 --- a/qcsrc/server/command/vote.qh +++ b/qcsrc/server/command/vote.qh @@ -64,6 +64,7 @@ const float RESTART_COUNTDOWN = 10; entity nagger; float readycount; // amount of players who are ready .float ready; // flag for if a player is ready +.float last_ready; // last ready time for anti-spam .int team_saved; // team number to restore upon map reset .void(entity this) reset; // if set, an entity is reset using this .void(entity this) reset2; // if set, an entity is reset using this (after calling ALL the reset functions for other entities) -- 2.39.2