]> 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

1  2 
qcsrc/server/client.qc
qcsrc/server/command/cmd.qc

diff --combined qcsrc/server/client.qc
index 3af147c21374c52f3cec6aa3cc2e3c1d09b432f0,260967eb31c4cff85bc9a4b89a4770619ffcd8bf..8950854305c472ed3463d974bf28a8890da70cb6
@@@ -235,9 -235,10 +235,10 @@@ void setplayermodel(entity e, string mo
  }
  
  /** putting a client as observer in the server */
 -void PutObserverInServer(entity this, bool is_forced)
 +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))
                if(IS_REAL_CLIENT(this))
                {
                        if (vote_called) { VoteCount(false); }
-                       ReadyCount();
+                       this.ready = false;
+                       recount_ready = true;
                }
                entcs_update_players(this);
        }
  
 -      entity spot = SelectSpawnPoint(this, true);
 -      if (!spot) LOG_FATAL("No spawnpoints for observers?!?");
 -      this.angles = vec2(spot.angles);
 +      if (use_spawnpoint)
 +      {
 +              entity spot = SelectSpawnPoint(this, true);
 +              if (!spot) LOG_FATAL("No spawnpoints for observers?!?");
 +              this.angles = vec2(spot.angles);
 +              // offset it so that the spectator spawns higher off the ground, looks better this way
 +              setorigin(this, spot.origin + STAT(PL_VIEW_OFS, this));
 +      }
 +      else // change origin to restore previous view origin
 +              setorigin(this, this.origin + STAT(PL_VIEW_OFS, this) - STAT(PL_CROUCH_VIEW_OFS, this));
        this.fixangle = true;
 -      // offset it so that the spectator spawns higher off the ground, looks better this way
 -      setorigin(this, spot.origin + STAT(PL_VIEW_OFS, this));
 +
        if (IS_REAL_CLIENT(this))
        {
                msg_entity = this;
        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)
@@@ -815,7 -812,6 +818,7 @@@ void PutClientInServer(entity this
        if (game_stopped)
                TRANSMUTE(Observer, this);
  
 +      bool use_spawnpoint = (!this.enemy); // check this.enemy here since SetSpectatee will clear it
        SetSpectatee(this, NULL);
  
        // reset player keys
        MUTATOR_CALLHOOK(PutClientInServer, this);
  
        if (IS_OBSERVER(this)) {
 -              PutObserverInServer(this, false);
 +              PutObserverInServer(this, false, use_spawnpoint);
        } else if (IS_PLAYER(this)) {
                PutPlayerInServer(this);
        }
@@@ -942,6 -938,7 +945,6 @@@ void DecodeLevelParms(entity this
  void FixClientCvars(entity e)
  {
        // send prediction settings to the client
 -      stuffcmd(e, "\nin_bindmap 0 0\n");
        if(autocvar_g_antilag == 3) // client side hitscan
                stuffcmd(e, "cl_cmd settemp cl_prydoncursor_notrace 0\n");
        if(autocvar_sv_gentle)
@@@ -1804,7 -1801,7 +1807,7 @@@ bool SpectateSet(entity this
        accuracy_resend(this);
  
        if(!SpectateUpdate(this))
 -              PutObserverInServer(this, false);
 +              PutObserverInServer(this, false, true);
  
        return true;
  }
@@@ -1846,18 -1843,18 +1849,18 @@@ void SetSpectatee(entity this, entity s
                                old_spectatee.(weaponentity).arc_beam.SendFlags |= ARC_SF_SETTINGS;
                }
        }
 -      if(this.enemy)
 +      if(spectatee)
        {
                for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
                        .entity weaponentity = weaponentities[slot];
 -                      if(this.enemy.(weaponentity).arc_beam)
 -                              this.enemy.(weaponentity).arc_beam.SendFlags |= ARC_SF_SETTINGS;
 +                      if(spectatee.(weaponentity).arc_beam)
 +                              spectatee.(weaponentity).arc_beam.SendFlags |= ARC_SF_SETTINGS;
                }
        }
  
 -      if (this.enemy)
 -              SetSpectatee_status(this, etof(this.enemy));
 +      if (spectatee)
 +              SetSpectatee_status(this, etof(spectatee));
  
        // needed to update spectator list
        if(old_spectatee) { ClientData_Touch(old_spectatee); }
@@@ -2307,7 -2304,7 +2310,7 @@@ void ObserverOrSpectatorThink(entity th
                                TRANSMUTE(Observer, this);
                                PutClientInServer(this);
                        } else if(!SpectateUpdate(this) && !SpectateNext(this)) {
 -                              PutObserverInServer(this, false);
 +                              PutObserverInServer(this, false, true);
                                this.would_spectate = true;
                        }
                }
                        }
                }
                if(is_spec && !SpectateUpdate(this))
 -                      PutObserverInServer(this, false);
 +                      PutObserverInServer(this, false, true);
        }
        if (is_spec)
                this.flags |= FL_CLIENT | FL_NOTARGET;
@@@ -2517,9 -2514,12 +2520,9 @@@ void PlayerPreThink (entity this
                this.last_vehiclecheck = time + 1;
        }
  
 -      if(!CS_CVAR(this).cvar_cl_newusekeysupported) // FIXME remove this - it was a stupid idea to begin with, we can JUST use the button
 -      {
 -              if(PHYS_INPUT_BUTTON_USE(this) && !CS(this).usekeypressed)
 -                      PlayerUseKey(this);
 -              CS(this).usekeypressed = PHYS_INPUT_BUTTON_USE(this);
 -      }
 +      if(PHYS_INPUT_BUTTON_USE(this) && !CS(this).usekeypressed)
 +              PlayerUseKey(this);
 +      CS(this).usekeypressed = PHYS_INPUT_BUTTON_USE(this);
  
        if (IS_REAL_CLIENT(this))
                PrintWelcomeMessage(this);
@@@ -2704,7 -2704,7 +2707,7 @@@ void PlayerPostThink (entity this
                                if (IS_PLAYER(this) && autocvar_sv_maxidle_playertospectator > 0)
                                {
                                        Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_MOVETOSPEC_IDLING, this.netname, maxidle_time);
 -                                      PutObserverInServer(this, true);
 +                                      PutObserverInServer(this, true, true);
                                }
                                else
                                {
index 672079ef421a2fa82988dd8941887eb19872366d,f92e151fec16d87995e0479e4c1dc5970e4e3147..9feb068a812bdd377f7bf9a6822cdf0217a52104
@@@ -73,8 -73,8 +73,8 @@@ void ClientCommand_autoswitch(entity ca
                {
                        if (argv(1) != "")
                        {
 -                              CS_CVAR(caller).autoswitch = InterpretBoolean(argv(1));
 -                              sprint(caller, strcat("^1autoswitch is currently turned ", (CS_CVAR(caller).autoswitch ? "on" : "off"), ".\n"));
 +                              CS_CVAR(caller).cvar_cl_autoswitch = InterpretBoolean(argv(1));
 +                              sprint(caller, strcat("^1autoswitch is currently turned ", (CS_CVAR(caller).cvar_cl_autoswitch ? "on" : "off"), ".\n"));
                                return;
                        }
                }
@@@ -366,13 -366,13 +366,13 @@@ void ClientCommand_physics(entity calle
        }
  }
  
- 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)
                                {
                                                        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();
                                }