]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
moveplayer: fix / improve error handling and messages
authorterencehill <piuntn@gmail.com>
Sat, 30 Oct 2021 19:45:24 +0000 (21:45 +0200)
committerterencehill <piuntn@gmail.com>
Sat, 30 Oct 2021 19:45:24 +0000 (21:45 +0200)
qcsrc/server/command/sv_cmd.qc
qcsrc/server/scores_rules.qc
qcsrc/server/scores_rules.qh

index 47e9f922abe4daf27b5f8e696b05ff87b908d654..4ed6e83ee3693b8f9cb7c302274fb7ac6adf9f77 100644 (file)
@@ -1043,7 +1043,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 ", ftos(GetFilteredNumber(t)), " (", pl_name, ") is already on the ", Team_ColoredFullName(team_num), "^7.");
                                                        continue;
                                                }
                                                else if (team_num == 0)  // auto team
@@ -1061,16 +1061,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 ", ftos(GetFilteredNumber(t)), " (", 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
index ac060dab532174d6782108c91857918c64d352a4..2749db38e63c081aa3aa9425c0e674c4e10c270e 100644 (file)
@@ -9,6 +9,11 @@
 
 int ScoreRules_teams;
 
+bool IsTeamAvailable(int team_num)
+{
+       return boolean(ScoreRules_teams & Team_TeamToBit(team_num));
+}
+
 int NumTeams(int teams)
 {
        return boolean(teams & BIT(0)) + boolean(teams & BIT(1)) + boolean(teams & BIT(2)) + boolean(teams & BIT(3));
index 9d1caf5395bff7453a6e558266bc4f1cd0ad3c92..921864d2622bca71412fcff9bcc3cd186ac8a0d6 100644 (file)
@@ -1,5 +1,6 @@
 #pragma once
 
+bool IsTeamAvailable(int team_num);
 int NumTeams(int teams);
 int AvailableTeams();
 void ScoreRules_basics(int teams, float sprio, float stprio, float score_enabled);