]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'z411/ready_improvements' into 'master'
authorterencehill <piuntn@gmail.com>
Thu, 3 Mar 2022 07:57:32 +0000 (07:57 +0000)
committerterencehill <piuntn@gmail.com>
Thu, 3 Mar 2022 07:57:32 +0000 (07:57 +0000)
Improvements for Ready system in warmup

See merge request xonotic/xonotic-data.pk3dir!966

qcsrc/server/client.qc
qcsrc/server/command/cmd.qc
qcsrc/server/command/vote.qh

index 3af147c21374c52f3cec6aa3cc2e3c1d09b432f0..8950854305c472ed3463d974bf28a8890da70cb6 100644 (file)
@@ -238,6 +238,7 @@ void setplayermodel(entity e, string modelname)
 void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint)
 {
        bool mutator_returnvalue = MUTATOR_CALLHOOK(MakePlayerObserver, this, is_forced);
+       bool recount_ready = false;
        PlayerState_detach(this);
 
        if (IS_PLAYER(this))
@@ -252,7 +253,8 @@ void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint)
                if(IS_REAL_CLIENT(this))
                {
                        if (vote_called) { VoteCount(false); }
-                       ReadyCount();
+                       this.ready = false;
+                       recount_ready = true;
                }
                entcs_update_players(this);
        }
@@ -317,6 +319,7 @@ void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint)
        this.monster_attack = false;
        STAT(HUD, this) = HUD_NORMAL;
        TRANSMUTE(Observer, this);
+       if(recount_ready) ReadyCount();
        this.iscreature = false;
        this.teleportable = TELEPORT_SIMPLE;
        if(this.damagedbycontents)
index 672079ef421a2fa82988dd8941887eb19872366d..9feb068a812bdd377f7bf9a6822cdf0217a52104 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)