]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Added anti-flood to ready command
authorz411 <z411@omaera.org>
Tue, 18 Jan 2022 20:03:16 +0000 (17:03 -0300)
committerz411 <z411@omaera.org>
Tue, 18 Jan 2022 20:03:16 +0000 (17:03 -0300)
qcsrc/server/command/cmd.qc
qcsrc/server/command/vote.qh

index c9ceb31b6dc14cc09d4fe24c4d1a9446ec27cb97..f92e151fec16d87995e0479e4c1dc5970e4e3147 100644 (file)
@@ -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();
                                }
index 63c9e8e453765892bff4823cc41de0e7865e1453..7c96223a71318d736040fa6fa5d091275843c564 100644 (file)
@@ -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)