]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/command/sv_cmd.qc
Merge branch 'master' into Mario/q3compat_sanity
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / sv_cmd.qc
index 16008bd5932650733a7e88c699f1edc85565bb3c..235ae9b9a1f2026d70dffd1240a03f86a0af27c6 100644 (file)
@@ -23,6 +23,7 @@
 #include <server/ipban.qh>
 #include <server/mutators/_mod.qh>
 #include <server/player.qh>
+#include <server/scores_rules.qh>
 #include <server/teamplay.qh>
 #include <server/world.qh>
 
@@ -728,7 +729,7 @@ void GameCommand_gametype(int request, int argc)
                        if (argv(1) != "")
                        {
                                string s = argv(1);
-                               Gametype t = MapInfo_Type_FromString(s, false), tsave = MapInfo_CurrentGametype();
+                               Gametype t = MapInfo_Type_FromString(s, false, false), tsave = MapInfo_CurrentGametype();
 
                                if (t)
                                {
@@ -1004,6 +1005,7 @@ void GameCommand_moveplayer(int request, int argc)
                                        // Check to see if the player is a valid target
                                        client = GetFilteredEntity(t);
                                        accepted = VerifyClientEntity(client, false, false);
+                                       string client_num_str = ftos(etof(client));
 
                                        if (accepted <= 0)
                                        {
@@ -1020,7 +1022,7 @@ void GameCommand_moveplayer(int request, int argc)
                                                }
                                                else
                                                {
-                                                       LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", pl_name, ") is already spectating.");
+                                                       LOG_INFO("Player #", client_num_str, " (", pl_name, ") is already spectating.");
                                                }
                                        }
                                        else
@@ -1035,7 +1037,7 @@ void GameCommand_moveplayer(int request, int argc)
                                                if (IS_SPEC(client) || IS_OBSERVER(client))
                                                {
                                                        // well technically we could, but should we allow that? :P
-                                                       LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", pl_name, ") is not in the game.");
+                                                       LOG_INFO("Player #", client_num_str, " (", pl_name, ") is not in the game.");
                                                        continue;
                                                }
 
@@ -1049,7 +1051,7 @@ void GameCommand_moveplayer(int request, int argc)
                                                if (team_num == client.team)  // already on the destination team
                                                {
                                                        // keep the forcing undone
-                                                       LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", pl_name, ") is already on the ", Team_ColoredFullName(team_num), ".");
+                                                       LOG_INFO("Player #", client_num_str, " (", pl_name, ") is already on the ", Team_ColoredFullName(team_num), "^7.");
                                                        continue;
                                                }
                                                else if (team_num == 0)  // auto team
@@ -1067,16 +1069,22 @@ void GameCommand_moveplayer(int request, int argc)
                                                int team_id = Team_TeamToIndex(team_num);
                                                if (team_id == -1)
                                                {
-                                                       LOG_INFO("Sorry, can't move player here if team ", destination, " doesn't exist.");
+                                                       LOG_INFO("Can't move player to ", destination, " team because it doesn't exist.");
                                                        TeamBalance_Destroy(balance);
                                                        return;
                                                }
-                                               if (!TeamBalance_IsTeamAllowed(balance, team_id))
+                                               if (!IsTeamAvailable(team_num))
                                                {
-                                                       LOG_INFOF("Sorry, can't move player to %s team if it doesn't exist.", destination);
+                                                       LOG_INFO("Can't move player to ", destination, " team because it isn't available.");
                                                        TeamBalance_Destroy(balance);
                                                        return;
                                                }
+                                               if (!TeamBalance_IsTeamAllowed(balance, team_id))
+                                               {
+                                                       LOG_INFO("Player #", client_num_str, " (", pl_name, ") is not allowed to join the ", Team_ColoredFullName(team_num), "^7.");
+                                                       TeamBalance_Destroy(balance);
+                                                       continue;
+                                               }
                                                TeamBalance_Destroy(balance);
 
                                                // If so, lets continue and finally move the player
@@ -1084,11 +1092,11 @@ void GameCommand_moveplayer(int request, int argc)
                                                if (MoveToTeam(client, team_id, 6))
                                                {
                                                        successful = strcat(successful, (successful ? ", " : ""), pl_name);
-                                                       LOG_INFO("Player ", ftos(GetFilteredNumber(t)), " (", pl_name, ") has been moved to the ", Team_ColoredFullName(team_num), "^7.");
+                                                       LOG_INFO("Player #", client_num_str, " (", pl_name, ") has been moved to the ", Team_ColoredFullName(team_num), "^7.");
                                                }
                                                else
                                                {
-                                                       LOG_INFO("Unable to move player ", ftos(GetFilteredNumber(t)), " (", pl_name, ")");
+                                                       LOG_INFO("Unable to move player #", client_num_str, " (", pl_name, ")");
                                                }
                                        }
                                } // loop end
@@ -1124,12 +1132,9 @@ void GameCommand_nospectators(int request)
                {
                        blockSpectators = 1;
                        // give every spectator <g_maxplayers_spectator_blocktime> seconds time to become a player
-                       FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_SPEC(it) || IS_OBSERVER(it)) && !it.caplayer, {
-                               if(!it.caplayer)
-                               {
-                                       CS(it).spectatortime = time;
-                                       Send_Notification(NOTIF_ONE_ONLY, it, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
-                               }
+                       FOREACH_CLIENT(IS_REAL_CLIENT(it) && (IS_SPEC(it) || IS_OBSERVER(it)) && !INGAME(it), {
+                               CS(it).spectatortime = time;
+                               Send_Notification(NOTIF_ONE_ONLY, it, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime);
                        });
                        bprint(strcat("^7All spectators will be automatically kicked when not joining the game after ", ftos(autocvar_g_maxplayers_spectator_blocktime), " seconds!\n"));
                        return;
@@ -1245,7 +1250,7 @@ void shuffleteams()
                return;
        }
 
-       FOREACH_CLIENT(IS_PLAYER(it) || it.caplayer, {
+       FOREACH_CLIENT(IS_PLAYER(it) || INGAME(it), {
                if (Player_HasRealForcedTeam(it)) {
                        // we could theoretically assign forced players to their teams
                        // and shuffle the rest to fill the empty spots but in practise
@@ -1267,7 +1272,7 @@ void shuffleteams()
        TeamBalance_Destroy(balance);
 
        int team_index = 0;
-       FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, {
+       FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || INGAME(it), {
                int target_team_index = team_index + 1;
                if (Entity_GetTeamIndex(it) != target_team_index)
                {