]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
try fixing g_campaign_forceteam too (off by default)
authorRudolf Polzer <divVerent@xonotic.org>
Tue, 7 Dec 2010 10:19:38 +0000 (11:19 +0100)
committerRudolf Polzer <divVerent@xonotic.org>
Tue, 7 Dec 2010 10:19:38 +0000 (11:19 +0100)
qcsrc/server/cl_client.qc
qcsrc/server/teamplay.qc

index 430913466f1475f01db7c449f3a25f14bb753aba..5ff519bd70695e15627a7680d7342b2ef9f441d7 100644 (file)
@@ -1527,7 +1527,21 @@ void ClientConnect (void)
        //      dom_player_join_team(self);
 
        // identify the right forced team
-       if(PlayerInIDList(self, autocvar_g_forced_team_red))
+       if(autocvar_g_campaign)
+       {
+               if(clienttype(self) == CLIENTTYPE_REAL) // only players, not bots
+               {
+                       switch(autocvar_g_campaign_forceteam)
+                       {
+                               case 1: self.team_forced = COLOR_TEAM1; break;
+                               case 2: self.team_forced = COLOR_TEAM2; break;
+                               case 3: self.team_forced = COLOR_TEAM3; break;
+                               case 4: self.team_forced = COLOR_TEAM4; break;
+                               default: self.team_forced = 0;
+                       }
+               }
+       }
+       else if(PlayerInIDList(self, autocvar_g_forced_team_red))
                self.team_forced = COLOR_TEAM1;
        else if(PlayerInIDList(self, autocvar_g_forced_team_blue))
                self.team_forced = COLOR_TEAM2;
index 488767e48dd3fab2f7e9ee0fb1009d31cd9322ae..1c8f51734c7e894cdc9d24d845f0628bad9ed9b3 100644 (file)
@@ -743,8 +743,15 @@ void GetTeamCounts(entity ignore)
        // FIXME: also find and memorize the lowest-scoring bot on each team (in case players must be shuffled around)
        // also remember the lowest-scoring player
 
-       FOR_EACH_PLAYER(head)
+       FOR_EACH_CLIENT(head)
        {
+               float t;
+               if(head.classname == "player")
+                       t = head.team;
+               else if(head.team_forced > 0)
+                       t = head.team_forced; // reserve the spot
+               else
+                       continue;
                if(head != ignore)// && head.netname != "")
                {
                        value = PlayerValue(head);
@@ -752,7 +759,7 @@ void GetTeamCounts(entity ignore)
                                bvalue = value;
                        else
                                bvalue = 0;
-                       if(head.team == COLOR_TEAM1)
+                       if(t == COLOR_TEAM1)
                        {
                                if(c1 >= 0)
                                {
@@ -760,7 +767,7 @@ void GetTeamCounts(entity ignore)
                                        cb1 = cb1 + bvalue;
                                }
                        }
-                       if(head.team == COLOR_TEAM2)
+                       if(t == COLOR_TEAM2)
                        {
                                if(c2 >= 0)
                                {
@@ -768,7 +775,7 @@ void GetTeamCounts(entity ignore)
                                        cb2 = cb2 + bvalue;
                                }
                        }
-                       if(head.team == COLOR_TEAM3)
+                       if(t == COLOR_TEAM3)
                        {
                                if(c3 >= 0)
                                {
@@ -776,7 +783,7 @@ void GetTeamCounts(entity ignore)
                                        cb3 = cb3 + bvalue;
                                }
                        }
-                       if(head.team == COLOR_TEAM4)
+                       if(t == COLOR_TEAM4)
                        {
                                if(c4 >= 0)
                                {
@@ -786,6 +793,18 @@ void GetTeamCounts(entity ignore)
                        }
                }
        }
+
+       // if the player who has a forced team has not joined yet, reserve the spot
+       if(autocvar_g_campaign)
+       {
+               switch(autocvar_g_campaign_forceteam)
+               {
+                       case 1: if(c1 == cb1) ++c1; break;
+                       case 2: if(c2 == cb2) ++c2; break;
+                       case 3: if(c3 == cb3) ++c3; break;
+                       case 4: if(c4 == cb4) ++c4; break;
+               }
+       }
 }
 
 // returns # of smallest team (1, 2, 3, 4)
@@ -890,33 +909,6 @@ float JoinBestTeam(entity pl, float only_return_best, float forcebestteam)
        // find out what teams are available
        CheckAllowedTeams(pl);
 
-       // if we want the player in a certain team for campaign, force him there
-       if(autocvar_g_campaign)
-       if(clienttype(pl) == CLIENTTYPE_REAL) // only players, not bots
-       {
-               switch(autocvar_g_campaign_forceteam)
-               {
-                       case 1:
-                               SetPlayerColors(pl, COLOR_TEAM1 - 1);
-                               LogTeamchange(pl.playerid, pl.team, 2);
-                               return COLOR_TEAM1;
-                       case 2:
-                               SetPlayerColors(pl, COLOR_TEAM2 - 1);
-                               LogTeamchange(pl.playerid, pl.team, 2);
-                               return COLOR_TEAM2;
-                       case 3:
-                               SetPlayerColors(pl, COLOR_TEAM3 - 1);
-                               LogTeamchange(pl.playerid, pl.team, 2);
-                               return COLOR_TEAM3;
-                       case 4:
-                               SetPlayerColors(pl, COLOR_TEAM4 - 1);
-                               LogTeamchange(pl.playerid, pl.team, 2);
-                               return COLOR_TEAM4;
-                       default:
-                               break;
-               }
-       }
-
        // if we don't care what team he ends up on, put him on whatever team he entered as.
        // if he's not on a valid team, then let other code put him on the smallest team
        if(!forcebestteam)