From 60f27ea3dcba4c262774678049364d3edc63b13d Mon Sep 17 00:00:00 2001 From: Lyberta Date: Sat, 17 Jun 2017 16:05:00 +0300 Subject: [PATCH] FindBestTeams and AutoBalanceBots fixes. --- qcsrc/server/teamplay.qc | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index c991f72ec..985c683e8 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -645,7 +645,12 @@ int FindBestTeams(entity player, bool usescore) } if (c2 >= 0) { - if (IsTeamSmallerThanTeam(2, previousteam, player, usescore)) + if (previousteam == 0) + { + teambits = BIT(1); + previousteam = 2; + } + else if (IsTeamSmallerThanTeam(2, previousteam, player, usescore)) { teambits = BIT(1); previousteam = 2; @@ -658,7 +663,12 @@ int FindBestTeams(entity player, bool usescore) } if (c3 >= 0) { - if (IsTeamSmallerThanTeam(3, previousteam, player, usescore)) + if (previousteam == 0) + { + teambits = BIT(2); + previousteam = 3; + } + else if (IsTeamSmallerThanTeam(3, previousteam, player, usescore)) { teambits = BIT(2); previousteam = 3; @@ -671,7 +681,11 @@ int FindBestTeams(entity player, bool usescore) } if (c4 >= 0) { - if (IsTeamSmallerThanTeam(4, previousteam, player, usescore)) + if (previousteam == 0) + { + teambits = BIT(3); + } + else if (IsTeamSmallerThanTeam(4, previousteam, player, usescore)) { teambits = BIT(3); } @@ -927,10 +941,20 @@ void AutoBalanceBots(int sourceteam, int destinationteam) break; } } - if ((numplayersdestinationteam > numplayerssourceteam) && (lowestbotdestinationteam != NULL)) + if ((numplayersdestinationteam <= numplayerssourceteam) || + (lowestbotdestinationteam == NULL)) { - SetPlayerTeamSimple(lowestbotdestinationteam, Team_NumberToTeam(sourceteam)); + return; + } + SetPlayerTeamSimple(lowestbotdestinationteam, Team_NumberToTeam(sourceteam)); + if (IS_DEAD(lowestbotdestinationteam) || (MUTATOR_CALLHOOK( + Player_ChangeTeamKill, lowestbotdestinationteam) == true)) + { + return; } + Damage(lowestbotdestinationteam, lowestbotdestinationteam, + lowestbotdestinationteam, 100000, DEATH_TEAMCHANGE.m_id, + lowestbotdestinationteam.origin, '0 0 0'); } void ShufflePlayerOutOfTeam (float source_team) -- 2.39.2