]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/teamplay.qc
Using MoveToTeam instead.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / teamplay.qc
index d16bb781b821998383b8be8460745309cb7b4783..fdecfb3fd0573595a56547e6cbca520d3640528a 100644 (file)
@@ -190,28 +190,25 @@ void SetPlayerColors(entity pl, float _color)
        }
 }
 
-void SetPlayerTeam(entity pl, float t, float s, float noprint)
+bool SetPlayerTeamSimple(entity player, int teamnum)
 {
-       float _color;
-
-       if(t == 4)
-               _color = NUM_TEAM_4 - 1;
-       else if(t == 3)
-               _color = NUM_TEAM_3 - 1;
-       else if(t == 2)
-               _color = NUM_TEAM_2 - 1;
-       else
-               _color = NUM_TEAM_1 - 1;
-
-       SetPlayerColors(pl,_color);
-
-       if(t != s) {
-               LogTeamchange(pl.playerid, pl.team, 3);  // log manual team join
+       return MoveToTeam(player, teamnum, 6);
+}
 
-               if(!noprint)
-               bprint(pl.netname, "^7 has changed from ", Team_NumberToColoredFullName(s), "^7 to ", Team_NumberToColoredFullName(t), "\n");
+void SetPlayerTeam(entity pl, float t, float s, float noprint)
+{
+       if (t == s)
+       {
+               return;
        }
-
+       float teamnum = Team_NumberToTeam(t);
+       SetPlayerTeamSimple(pl, teamnum);
+       LogTeamchange(pl.playerid, pl.team, 3);  // log manual team join
+       if (noprint)
+       {
+               return;
+       }
+       bprint(playername(pl, false), "^7 has changed from ", Team_NumberToColoredFullName(s), "^7 to ", Team_NumberToColoredFullName(t), "\n");
 }
 
 // set c1...c4 to show what teams are allowed
@@ -224,7 +221,7 @@ void CheckAllowedTeams (entity for_whom)
 
        string teament_name = string_null;
 
-       bool mutator_returnvalue = MUTATOR_CALLHOOK(CheckAllowedTeams, teams_mask, teament_name);
+       bool mutator_returnvalue = MUTATOR_CALLHOOK(CheckAllowedTeams, teams_mask, teament_name, for_whom);
        teams_mask = M_ARGV(0, float);
        teament_name = M_ARGV(1, string);
 
@@ -550,7 +547,7 @@ int JoinBestTeam(entity this, bool only_return_best, bool forcebestteam)
                {
                        if(!only_return_best)
                        {
-                               SetPlayerColors(this, selectedteam - 1);
+                               SetPlayerTeamSimple(this, selectedteam);
 
                                // when JoinBestTeam is called by client.qc/ClientKill_Now_TeamChange the players team is -1 and thus skipped
                                // when JoinBestTeam is called by client.qc/ClientConnect the player_id is 0 the log attempt is rejected
@@ -565,22 +562,11 @@ int JoinBestTeam(entity this, bool only_return_best, bool forcebestteam)
 
        if(!only_return_best && !this.bot_forced_team)
        {
-               TeamchangeFrags(this);
-               if(smallest == 1)
-               {
-                       SetPlayerColors(this, NUM_TEAM_1 - 1);
-               }
-               else if(smallest == 2)
+               smallest = Team_NumberToTeam(smallest);
+               if (smallest != -1)
                {
-                       SetPlayerColors(this, NUM_TEAM_2 - 1);
-               }
-               else if(smallest == 3)
-               {
-                       SetPlayerColors(this, NUM_TEAM_3 - 1);
-               }
-               else if(smallest == 4)
-               {
-                       SetPlayerColors(this, NUM_TEAM_4 - 1);
+                       TeamchangeFrags(this);
+                       SetPlayerTeamSimple(this, smallest);
                }
                else
                {
@@ -645,7 +631,6 @@ void SV_ChangeTeam(entity this, float _color)
        // not changing teams
        if(scolor == dcolor)
        {
-               //bprint("same team change\n");
                SetPlayerTeam(this, dteam, steam, true);
                return;
        }
@@ -674,8 +659,6 @@ void SV_ChangeTeam(entity this, float _color)
                TeamchangeFrags(this);
        }
 
-       MUTATOR_CALLHOOK(Player_ChangeTeam, this, steam, dteam);
-
        SetPlayerTeam(this, dteam, steam, !IS_CLIENT(this));
 
        if(IS_PLAYER(this) && steam != dteam)