]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/command/cmd.qc
Merge branch 'master' into terencehill/bot_waypoints
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / cmd.qc
index 1d5ab7b3980b63f24ac4d72371a070466a9e9185..47e94f52034bf8b1a0255c8ca76b419d9772d891 100644 (file)
@@ -1,4 +1,8 @@
 #include "cmd.qh"
+
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
+
 #include <common/command/_mod.qh>
 
 #include "common.qh"
@@ -45,17 +49,19 @@ void ClientKill_TeamChange(entity this, float targetteam);  // 0 = don't change,
 
 bool SV_ParseClientCommand_floodcheck(entity this)
 {
+       entity store = IS_CLIENT(this) ? CS(this) : this; // unfortunately, we need to store these on the client initially
+
        if (!timeout_status)  // not while paused
        {
-               if (time <= (this.cmd_floodtime + autocvar_sv_clientcommand_antispam_time))
+               if (time <= (store.cmd_floodtime + autocvar_sv_clientcommand_antispam_time))
                {
-                       this.cmd_floodcount += 1;
-                       if (this.cmd_floodcount > autocvar_sv_clientcommand_antispam_count)   return false;  // too much spam, halt
+                       store.cmd_floodcount += 1;
+                       if (store.cmd_floodcount > autocvar_sv_clientcommand_antispam_count)   return false;  // too much spam, halt
                }
                else
                {
-                       this.cmd_floodtime = time;
-                       this.cmd_floodcount = 1;
+                       store.cmd_floodtime = time;
+                       store.cmd_floodcount = 1;
                }
        }
        return true;  // continue, as we're not flooding yet
@@ -74,8 +80,8 @@ void ClientCommand_autoswitch(entity caller, float request, float argc)
                {
                        if (argv(1) != "")
                        {
-                               caller.autoswitch = InterpretBoolean(argv(1));
-                               sprint(caller, strcat("^1autoswitch is currently turned ", (caller.autoswitch ? "on" : "off"), ".\n"));
+                               CS(caller).autoswitch = InterpretBoolean(argv(1));
+                               sprint(caller, strcat("^1autoswitch is currently turned ", (CS(caller).autoswitch ? "on" : "off"), ".\n"));
                                return;
                        }
                }
@@ -214,7 +220,7 @@ void ClientCommand_physics(entity caller, float request, float argc)
                }
 
                default:
-                       sprint(caller, strcat("Current physics set: ^3", caller.cvar_cl_physics, "\n"));
+                       sprint(caller, strcat("Current physics set: ^3", CS(caller).cvar_cl_physics, "\n"));
                case CMD_REQUEST_USAGE:
                {
                        sprint(caller, "\nUsage:^3 cmd physics <physics>\n");
@@ -233,9 +239,9 @@ void ClientCommand_ready(entity caller, float request)  // todo: anti-spam for t
                {
                        if (IS_CLIENT(caller))
                        {
-                               if (warmup_stage || autocvar_sv_ready_restart || g_race_qualifying == 2)
+                               if (warmup_stage || sv_ready_restart || g_race_qualifying == 2)
                                {
-                                       if (!readyrestart_happened || autocvar_sv_ready_restart_repeatable)
+                                       if (!readyrestart_happened || sv_ready_restart_repeatable)
                                        {
                                                if (time < game_starttime) // game is already restarting
                                                        return;
@@ -380,21 +386,13 @@ void ClientCommand_selectteam(entity caller, float request, float argc)
                                sprint(caller, "^7You already are on that team.\n");
                                return;
                        }
-                       if (caller.wasplayer && autocvar_g_changeteam_banned)
+                       if (CS(caller).wasplayer && autocvar_g_changeteam_banned)
                        {
                                sprint(caller, "^1You cannot change team, forbidden by the server.\n");
                                return;
                        }
-                       if (selection == -1)
-                       {
-                               ClientKill_TeamChange(caller, selection);
-                               if (!IS_PLAYER(caller))
-                               {
-                                       caller.team_selected = true; // avoids asking again for team selection on join
-                               }
-                               return;
-                       }
-                       if (autocvar_g_balance_teams && autocvar_g_balance_teams_prevent_imbalance)
+                       if ((selection != -1) && autocvar_g_balance_teams &&
+                               autocvar_g_balance_teams_prevent_imbalance)
                        {
                                CheckAllowedTeams(caller);
                                GetTeamCounts(caller);
@@ -464,7 +462,7 @@ void ClientCommand_sentcvar(entity caller, float request, float argc, string com
                                        tokenize_console(s);
                                }
 
-                               GetCvars(caller, 1);
+                               GetCvars(caller, CS(caller), 1);
 
                                return;
                        }
@@ -616,8 +614,10 @@ void ClientCommand_voice(entity caller, float request, float argc, string comman
                                        sprint(caller, sprintf("Invalid voice. Use one of: %s\n", allvoicesamples));
                                        return;
                                }
-                               if (argc >= 3) VoiceMessage(caller, e, substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2)));
-                               else VoiceMessage(caller, e, "");
+                               string msg = "";
+                               if (argc >= 3)
+                                       msg = substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2));
+                               VoiceMessage(caller, e, msg);
 
                                return;
                        }