]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
my code broke forced team balance, and that code was very bad and annoying anyway...
authorRudolf Polzer <divverent@xonotic.org>
Fri, 6 Jul 2012 10:26:45 +0000 (12:26 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Fri, 6 Jul 2012 10:26:45 +0000 (12:26 +0200)
defaultXonotic.cfg
qcsrc/server/autocvars.qh
qcsrc/server/cl_client.qc
qcsrc/server/domination.qc
qcsrc/server/g_world.qc
qcsrc/server/teamplay.qc

index 063ea1fa936fdf682c2032160aea11294b6561f5..faa1aabd060037ff2e745c0446e8307bd9f5cc4b 100644 (file)
@@ -575,7 +575,6 @@ seta g_teamdamage_threshold 40      "for teamplay 4: threshold over which to apply mi
 seta g_teamdamage_resetspeed 20        "for teamplay 4: how fast player's teamdamage count decreases"
 
 seta g_balance_teams 0 "automatically balance out players entering instead of asking them for their preferred team"
-seta g_balance_teams_force 0   "automatically balance out teams when players move or disconnect"
 seta g_balance_teams_prevent_imbalance 0       "prevent players from changing to larger teams"
 set g_balance_teams_scorefactor 0.5 "at the end of the game, take score into account instead of team size by this amount"
 set g_tdm_teams 2 "how many teams are in team deathmatch (set by mapinfo)"
index 61ae1bd30c5f7e2a0a5a3ea6d61052ce41b39f89..12a343eb726b6fac85a0ff52693bc9bec340b8d2 100644 (file)
@@ -686,7 +686,6 @@ float autocvar_g_balance_shotgun_secondary_refire;
 float autocvar_g_balance_shotgun_reload_ammo;
 float autocvar_g_balance_shotgun_reload_time;
 float autocvar_g_balance_teams;
-float autocvar_g_balance_teams_force;
 float autocvar_g_balance_teams_prevent_imbalance;
 float autocvar_g_balance_teams_scorefactor;
 float autocvar_g_balance_tuba_animtime;
index d59bd2f032e94b268662e2153030186097268952..715bdab450cac3e329f8aaf6a98189f2704e97ce 100644 (file)
@@ -1438,7 +1438,7 @@ void ClientConnect (void)
        } else {
                if(teamplay)
                {
-                       if(autocvar_g_balance_teams || autocvar_g_balance_teams_force)
+                       if(autocvar_g_balance_teams)
                        {
                                self.classname = "player";
                                campaign_bots_may_start = 1;
@@ -2326,7 +2326,7 @@ void LeaveSpectatorMode()
                if(!teamplay || autocvar_g_campaign || autocvar_g_balance_teams || (self.wasplayer && autocvar_g_changeteam_banned) || self.team_forced > 0) {
                        self.classname = "player";
 
-                       if(autocvar_g_campaign || autocvar_g_balance_teams || autocvar_g_balance_teams_force)
+                       if(autocvar_g_campaign || autocvar_g_balance_teams)
                                JoinBestTeam(self, FALSE, TRUE);
 
                        if(autocvar_g_campaign)
index 9e56023cb500ebb5425d08321fbff54d55d4a7e8..0a2fe02b66fcf13c88c02240c0fb5b653f31ed88 100644 (file)
@@ -395,196 +395,6 @@ void dom_controlpoint_setup()
 
 
 
-// player has joined game, get him on a team
-// depreciated
-/*void dom_player_join_team(entity pl)
-{
-       entity head;
-       float c1, c2, c3, c4, totalteams, smallestteam, smallestteam_count, selectedteam;
-       float balance_teams, force_balance, balance_type;
-
-       balance_teams = autocvar_g_balance_teams;
-       balance_teams = autocvar_g_balance_teams_force;
-
-       c1 = c2 = c3 = c4 = -1;
-       totalteams = 0;
-
-       // first find out what teams are allowed
-       head = find(world, classname, "dom_team");
-       while(head)
-       {
-               if(head.netname != "")
-               {
-                       //if(head.team == pl.team)
-                       //      selected = head;
-                       if(head.team == COLOR_TEAM1)
-                       {
-                                       c1 = 0;
-                       }
-                       if(head.team == COLOR_TEAM2)
-                       {
-                                       c2 = 0;
-                       }
-                       if(head.team == COLOR_TEAM3)
-                       {
-                                       c3 = 0;
-                       }
-                       if(head.team == COLOR_TEAM4)
-                       {
-                                       c4 = 0;
-                       }
-               }
-               head = find(head, classname, "dom_team");
-       }
-
-       // make sure there are at least 2 teams to join
-       if(c1 >= 0)
-               totalteams = totalteams + 1;
-       if(c2 >= 0)
-               totalteams = totalteams + 1;
-       if(c3 >= 0)
-               totalteams = totalteams + 1;
-       if(c4 >= 0)
-               totalteams = totalteams + 1;
-
-       if(totalteams <= 1)
-               error("dom_player_join_team: Too few teams available for domination\n");
-
-       // whichever teams that are available are set to 0 instead of -1
-
-       // 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 put him on the smallest team
-       if(!balance_teams && !force_balance)
-       {
-               if(     c1 >= 0 && pl.team == COLOR_TEAM1)
-                       selectedteam = pl.team;
-               else if(c2 >= 0 && pl.team == COLOR_TEAM2)
-                       selectedteam = pl.team;
-               else if(c3 >= 0 && pl.team == COLOR_TEAM3)
-                       selectedteam = pl.team;
-               else if(c4 >= 0 && pl.team == COLOR_TEAM4)
-                       selectedteam = pl.team;
-               else
-                       selectedteam = -1;
-               if(selectedteam > 0)
-               {
-                       SetPlayerColors(pl, selectedteam - 1);
-                       return;
-               }
-               // otherwise end up on the smallest team (handled below)
-       }
-
-       // now count how many players are on each team already
-
-       head = find(world, classname, "player");
-       while(head)
-       {
-               //if(head.netname != "")
-               {
-                       if(head.team == COLOR_TEAM1)
-                       {
-                               if(c1 >= 0)
-                                       c1 = c1 + 1;
-                       }
-                       if(head.team == COLOR_TEAM2)
-                       {
-                               if(c2 >= 0)
-                                       c2 = c2 + 1;
-                       }
-                       if(head.team == COLOR_TEAM3)
-                       {
-                               if(c3 >= 0)
-                                       c3 = c3 + 1;
-                       }
-                       if(head.team == COLOR_TEAM4)
-                       {
-                               if(c4 >= 0)
-                                       c4 = c4 + 1;
-                       }
-               }
-               head = find(head, classname, "player");
-       }
-
-       // c1...c4 now have counts of each team
-       // figure out which is smallest, giving priority to the team the player is already on as a tie-breaker
-
-       smallestteam = 0;
-       smallestteam_count = 999;
-
-       // 2 gives priority to what team you're already on, 1 goes in order
-       balance_type = 1;
-
-       if(balance_type == 1)
-       {
-               if(c1 >= 0 && c1 < smallestteam_count)
-               {
-                       smallestteam = 1;
-                       smallestteam_count = c1;
-               }
-               if(c2 >= 0 && c2 < smallestteam_count)
-               {
-                       smallestteam = 2;
-                       smallestteam_count = c2;
-               }
-               if(c3 >= 0 && c3 < smallestteam_count)
-               {
-                       smallestteam = 3;
-                       smallestteam_count = c3;
-               }
-               if(c4 >= 0 && c4 < smallestteam_count)
-               {
-                       smallestteam = 4;
-                       smallestteam_count = c4;
-               }
-       }
-       else
-       {
-               if(c1 >= 0 && (c1 < smallestteam_count ||
-                                       (c1 == smallestteam_count && self.team == COLOR_TEAM1) ) )
-               {
-                       smallestteam = 1;
-                       smallestteam_count = c1;
-               }
-               if(c2 >= 0 && c2 < (c2 < smallestteam_count ||
-                                       (c2 == smallestteam_count && self.team == COLOR_TEAM2) ) )
-               {
-                       smallestteam = 2;
-                       smallestteam_count = c2;
-               }
-               if(c3 >= 0 && c3 < (c3 < smallestteam_count ||
-                                       (c3 == smallestteam_count && self.team == COLOR_TEAM3) ) )
-               {
-                       smallestteam = 3;
-                       smallestteam_count = c3;
-               }
-               if(c4 >= 0 && c4 < (c4 < smallestteam_count ||
-                                       (c4 == smallestteam_count && self.team == COLOR_TEAM4) ) )
-               {
-                       smallestteam = 4;
-                       smallestteam_count = c4;
-               }
-       }
-
-       if(smallestteam == 1)
-       {
-               selectedteam = COLOR_TEAM1 - 1;
-       }
-       if(smallestteam == 2)
-       {
-               selectedteam = COLOR_TEAM2 - 1;
-       }
-       if(smallestteam == 3)
-       {
-               selectedteam = COLOR_TEAM3 - 1;
-       }
-       if(smallestteam == 4)
-       {
-               selectedteam = COLOR_TEAM4 - 1;
-       }
-
-       SetPlayerColors(pl, selectedteam);
-}
-*/
 /*QUAKED spawnfunc_dom_controlpoint (0 .5 .8) (-16 -16 -24) (16 16 32)
 Control point for Domination gameplay.
 */
index 7c632c1e508bf185e6b5680d7723f96c55103f07..36fddb3398173175bd7473992fd7f75e3676a293 100644 (file)
@@ -348,7 +348,6 @@ void cvar_changes_init()
                BADCVAR("gametype");
                BADCVAR("g_antilag");
                BADCVAR("g_balance_teams");
-               BADCVAR("g_balance_teams_force");
                BADCVAR("g_ban_sync_trusted_servers");
                BADCVAR("g_ban_sync_uri");
                BADCVAR("g_ctf_ignore_frags");
index 64013bd2c69e773379661b7af3ac54821cf9cad3..ed9927dd7ba1f557ba0fd3f5ea17cc2d6ec50571 100644 (file)
@@ -8,21 +8,6 @@ float cb1, cb2, cb3, cb4;
 
 float audit_teams_time;
 
-float IsTeamBalanceForced()
-{
-       if(intermission_running)
-               return 0; // no rebalancing whatsoever please
-       if(!teamplay)
-               return 0;
-       if(autocvar_g_campaign)
-               return 0;
-       if(autocvar_bot_vs_human && (c3==-1 && c4==-1))
-               return 0;
-       if(!autocvar_g_balance_teams_force)
-               return -1;
-       return 1;
-}
-
 void TeamchangeFrags(entity e)
 {
        PlayerScore_Clear(e);
@@ -562,8 +547,6 @@ void CheckAllowedTeams (entity for_whom)
 
 float PlayerValue(entity p)
 {
-       if(IsTeamBalanceForced() == 1)
-               return 1;
        return 1;
        // FIXME: it always returns 1...
 }
@@ -1062,87 +1045,6 @@ void ShufflePlayerOutOfTeam (float source_team)
        centerprint(selected, strcat("You have been moved into a different team to improve team balance\nYou are now on: ", ColoredTeamName(selected.team)));
 }
 
-void CauseRebalance(float source_team, float howmany_toomany)
-{
-       if(IsTeamBalanceForced() == 1)
-       {
-               bprint("Rebalancing Teams\n");
-               ShufflePlayerOutOfTeam(source_team);
-       }
-}
-
-// part of g_balance_teams_force
-// occasionally perform an audit of the teams to make
-// sure they're more or less balanced in player count.
-void AuditTeams()
-{
-       float numplayers, numteams, smallest, toomany;
-       float balance;
-       balance = IsTeamBalanceForced();
-       if(balance == 0)
-               return;
-
-       if(audit_teams_time > time)
-               return;
-
-       audit_teams_time = time + 4 + random();
-
-//     bprint("Auditing teams\n");
-
-       CheckAllowedTeams(world);
-       GetTeamCounts(world);
-
-
-       numteams = numplayers = smallest = 0;
-       if(c1 >= 0)
-       {
-               numteams = numteams + 1;
-               numplayers = numplayers + c1;
-               smallest = c1;
-       }
-       if(c2 >= 0)
-       {
-               numteams = numteams + 1;
-               numplayers = numplayers + c2;
-               if(c2 < smallest)
-                       smallest = c2;
-       }
-       if(c3 >= 0)
-       {
-               numteams = numteams + 1;
-               numplayers = numplayers + c3;
-               if(c3 < smallest)
-                       smallest = c3;
-       }
-       if(c4 >= 0)
-       {
-               numteams = numteams + 1;
-               numplayers = numplayers + c4;
-               if(c4 < smallest)
-                       smallest = c4;
-       }
-
-       if(numplayers <= 0)
-               return; // no players to move around
-       if(numteams < 2)
-               return; // don't bother shuffling if for some reason there aren't any teams
-
-       toomany = smallest + 1;
-
-       if(c1 && c1 > toomany)
-               CauseRebalance(1, c1 - toomany);
-       if(c2 && c2 > toomany)
-               CauseRebalance(2, c2 - toomany);
-       if(c3 && c3 > toomany)
-               CauseRebalance(3, c3 - toomany);
-       if(c4 && c4 > toomany)
-               CauseRebalance(4, c4 - toomany);
-
-       // if teams are still unbalanced, balance them further in the next audit,
-       // which will happen sooner (keep doing rapid audits until things are in order)
-       audit_teams_time = time + 0.7 + random()*0.3;
-}
-
 // code from here on is just to support maps that don't have team entities
 void tdm_spawnteam (string teamname, float teamcolor)
 {