}
}
-bool SetPlayerTeamSimple(entity player, int teamnum)
+bool SetPlayerTeamSimple(entity player, int team_num)
{
- if (player.team == teamnum)
+ if (player.team == team_num)
{
// This is important when players join the game and one of their color
// matches the team color while other doesn't. For example [BOT]Lion.
- SetPlayerColors(player, teamnum - 1);
+ SetPlayerColors(player, team_num - 1);
return true;
}
if (MUTATOR_CALLHOOK(Player_ChangeTeam, player, Team_TeamToNumber(
- player.team), Team_TeamToNumber(teamnum)) == true)
+ player.team), Team_TeamToNumber(team_num)) == true)
{
// Mutator has blocked team change.
return false;
}
- int oldteam = player.team;
- SetPlayerColors(player, teamnum - 1);
- MUTATOR_CALLHOOK(Player_ChangedTeam, player, oldteam, player.team);
+ int old_team = player.team;
+ SetPlayerColors(player, team_num - 1);
+ MUTATOR_CALLHOOK(Player_ChangedTeam, player, old_team, player.team);
return true;
}
-bool SetPlayerTeam(entity player, int destinationteam, int sourceteam, bool noprint)
+bool SetPlayerTeam(entity player, int destination_team, int source_team,
+ bool no_print)
{
- int teamnum = Team_NumberToTeam(destinationteam);
- if (!SetPlayerTeamSimple(player, teamnum))
+ int team_num = Team_NumberToTeam(destination_team);
+ if (!SetPlayerTeamSimple(player, team_num))
{
return false;
}
LogTeamchange(player.playerid, player.team, 3); // log manual team join
- if (noprint)
+ if (no_print)
{
return true;
}
- bprint(playername(player, false), "^7 has changed from ", Team_NumberToColoredFullName(sourceteam), "^7 to ", Team_NumberToColoredFullName(destinationteam), "\n");
+ bprint(playername(player, false), "^7 has changed from ", Team_NumberToColoredFullName(source_team), "^7 to ", Team_NumberToColoredFullName(destination_team), "\n");
return true;
}
// set c1...c4 to show what teams are allowed
-void CheckAllowedTeams (entity for_whom)
+void CheckAllowedTeams(entity for_whom)
{
int teams_mask = 0;
c1 = c2 = c3 = c4 = -1;
- numbotsteam1 = numbotsteam2 = numbotsteam3 = numbotsteam4 = 0;
+ num_bots_team1 = num_bots_team2 = num_bots_team3 = num_bots_team4 = 0;
string teament_name = string_null;
{
if (c1 >= 0)
{
- MUTATOR_CALLHOOK(GetTeamCount, NUM_TEAM_1, ignore, c1, numbotsteam1,
- lowesthumanteam1, lowestbotteam1);
+ MUTATOR_CALLHOOK(GetTeamCount, NUM_TEAM_1, ignore, c1,
+ num_bots_team1, lowest_human_team1, lowest_bot_team1);
c1 = M_ARGV(2, float);
- numbotsteam1 = M_ARGV(3, float);
- lowesthumanteam1 = M_ARGV(4, entity);
- lowestbotteam1 = M_ARGV(5, entity);
+ num_bots_team1 = M_ARGV(3, float);
+ lowest_human_team1 = M_ARGV(4, entity);
+ lowest_bot_team1 = M_ARGV(5, entity);
}
if (c2 >= 0)
{
- MUTATOR_CALLHOOK(GetTeamCount, NUM_TEAM_2, ignore, c2, numbotsteam2,
- lowesthumanteam2, lowestbotteam2);
+ MUTATOR_CALLHOOK(GetTeamCount, NUM_TEAM_2, ignore, c2,
+ num_bots_team2, lowest_human_team2, lowest_bot_team2);
c2 = M_ARGV(2, float);
- numbotsteam2 = M_ARGV(3, float);
- lowesthumanteam2 = M_ARGV(4, entity);
- lowestbotteam2 = M_ARGV(5, entity);
+ num_bots_team2 = M_ARGV(3, float);
+ lowest_human_team2 = M_ARGV(4, entity);
+ lowest_bot_team2 = M_ARGV(5, entity);
}
if (c3 >= 0)
{
- MUTATOR_CALLHOOK(GetTeamCount, NUM_TEAM_3, ignore, c3, numbotsteam3,
- lowesthumanteam3, lowestbotteam3);
+ MUTATOR_CALLHOOK(GetTeamCount, NUM_TEAM_3, ignore, c3,
+ num_bots_team3, lowest_human_team3, lowest_bot_team3);
c3 = M_ARGV(2, float);
- numbotsteam3 = M_ARGV(3, float);
- lowesthumanteam3 = M_ARGV(4, entity);
- lowestbotteam3 = M_ARGV(5, entity);
+ num_bots_team3 = M_ARGV(3, float);
+ lowest_human_team3 = M_ARGV(4, entity);
+ lowest_bot_team3 = M_ARGV(5, entity);
}
if (c4 >= 0)
{
- MUTATOR_CALLHOOK(GetTeamCount, NUM_TEAM_4, ignore, c4, numbotsteam4,
- lowesthumanteam4, lowestbotteam4);
+ MUTATOR_CALLHOOK(GetTeamCount, NUM_TEAM_4, ignore,
+ c4, num_bots_team4, lowest_human_team4, lowest_bot_team4);
c4 = M_ARGV(2, float);
- numbotsteam4 = M_ARGV(3, float);
- lowesthumanteam4 = M_ARGV(4, entity);
- lowestbotteam4 = M_ARGV(5, entity);
+ num_bots_team4 = M_ARGV(3, float);
+ lowest_human_team4 = M_ARGV(4, entity);
+ lowest_bot_team4 = M_ARGV(5, entity);
}
}
else
{
float value, bvalue;
// now count how many players are on each team already
- float lowesthumanscore1 = FLOAT_MAX;
- float lowestbotscore1 = FLOAT_MAX;
- float lowesthumanscore2 = FLOAT_MAX;
- float lowestbotscore2 = FLOAT_MAX;
- float lowesthumanscore3 = FLOAT_MAX;
- float lowestbotscore3 = FLOAT_MAX;
- float lowesthumanscore4 = FLOAT_MAX;
- float lowestbotscore4 = FLOAT_MAX;
+ float lowest_human_score1 = FLOAT_MAX;
+ float lowest_bot_score1 = FLOAT_MAX;
+ float lowest_human_score2 = FLOAT_MAX;
+ float lowest_bot_score2 = FLOAT_MAX;
+ float lowest_human_score3 = FLOAT_MAX;
+ float lowest_bot_score3 = FLOAT_MAX;
+ float lowest_human_score4 = FLOAT_MAX;
+ float lowest_bot_score4 = FLOAT_MAX;
FOREACH_CLIENT(true,
{
float t;
break;
}
c1 += value;
- numbotsteam1 += bvalue;
- float tempscore = PlayerScore_Get(it, SP_SCORE);
+ num_bots_team1 += bvalue;
+ float temp_score = PlayerScore_Get(it, SP_SCORE);
if (!bvalue)
{
- if (tempscore < lowesthumanscore1)
+ if (temp_score < lowest_human_score1)
{
- lowesthumanteam1 = it;
- lowesthumanscore1 = tempscore;
+ lowest_human_team1 = it;
+ lowest_human_score1 = temp_score;
}
break;
}
- if (tempscore < lowestbotscore1)
+ if (temp_score < lowest_bot_score1)
{
- lowestbotteam1 = it;
- lowestbotscore1 = tempscore;
+ lowest_bot_team1 = it;
+ lowest_bot_score1 = temp_score;
}
break;
}
break;
}
c2 += value;
- numbotsteam2 += bvalue;
- float tempscore = PlayerScore_Get(it, SP_SCORE);
+ num_bots_team2 += bvalue;
+ float temp_score = PlayerScore_Get(it, SP_SCORE);
if (!bvalue)
{
- if (tempscore < lowesthumanscore2)
+ if (temp_score < lowest_human_score2)
{
- lowesthumanteam2 = it;
- lowesthumanscore2 = tempscore;
+ lowest_human_team2 = it;
+ lowest_human_score2 = temp_score;
}
break;
}
- if (tempscore < lowestbotscore2)
+ if (temp_score < lowest_bot_score2)
{
- lowestbotteam2 = it;
- lowestbotscore2 = tempscore;
+ lowest_bot_team2 = it;
+ lowest_bot_score2 = temp_score;
}
break;
}
break;
}
c3 += value;
- numbotsteam3 += bvalue;
- float tempscore = PlayerScore_Get(it, SP_SCORE);
+ num_bots_team3 += bvalue;
+ float temp_score = PlayerScore_Get(it, SP_SCORE);
if (!bvalue)
{
- if (tempscore < lowesthumanscore3)
+ if (temp_score < lowest_human_score3)
{
- lowesthumanteam3 = it;
- lowesthumanscore3 = tempscore;
+ lowest_human_team3 = it;
+ lowest_human_score3 = temp_score;
}
break;
}
- if (tempscore < lowestbotscore3)
+ if (temp_score < lowest_bot_score3)
{
- lowestbotteam3 = it;
- lowestbotscore3 = tempscore;
+ lowest_bot_team3 = it;
+ lowest_bot_score3 = temp_score;
}
break;
}
break;
}
c4 += value;
- numbotsteam4 += bvalue;
- float tempscore = PlayerScore_Get(it, SP_SCORE);
+ num_bots_team4 += bvalue;
+ float temp_score = PlayerScore_Get(it, SP_SCORE);
if (!bvalue)
{
- if (tempscore < lowesthumanscore4)
+ if (temp_score < lowest_human_score4)
{
- lowesthumanteam4 = it;
- lowesthumanscore4 = tempscore;
+ lowest_human_team4 = it;
+ lowest_human_score4 = temp_score;
}
break;
}
- if (tempscore < lowestbotscore4)
+ if (temp_score < lowest_bot_score4)
{
- lowestbotteam4 = it;
- lowestbotscore4 = tempscore;
+ lowest_bot_team4 = it;
+ lowest_bot_score4 = temp_score;
}
break;
}
{
switch(autocvar_g_campaign_forceteam)
{
- case 1: if(c1 == numbotsteam1) ++c1; break;
- case 2: if(c2 == numbotsteam2) ++c2; break;
- case 3: if(c3 == numbotsteam3) ++c3; break;
- case 4: if(c4 == numbotsteam4) ++c4; break;
+ case 1: if(c1 == num_bots_team1) ++c1; break;
+ case 2: if(c2 == num_bots_team2) ++c2; break;
+ case 3: if(c3 == num_bots_team3) ++c3; break;
+ case 4: if(c4 == num_bots_team4) ++c4; break;
}
}
}
-bool IsTeamSmallerThanTeam(int teama, int teamb, entity e, bool usescore)
+bool IsTeamSmallerThanTeam(int team_a, int team_b, entity player,
+ bool use_score)
{
- // equal
- if (teama == teamb)
+ if (team_a == team_b)
{
return false;
}
// we assume that CheckAllowedTeams and GetTeamCounts have already been called
- float numplayersteama = -1, numplayersteamb = -1;
- float numbotsteama = 0, numbotsteamb = 0;
- float scoreteama = 0, scoreteamb = 0;
-
- switch (teama)
+ int num_players_team_a = -1, num_players_team_b = -1;
+ int num_bots_team_a = 0, num_bots_team_b = 0;
+ float score_team_a = 0, score_team_b = 0;
+ switch (team_a)
{
- case 1: numplayersteama = c1; numbotsteama = numbotsteam1; scoreteama = team1_score; break;
- case 2: numplayersteama = c2; numbotsteama = numbotsteam2; scoreteama = team2_score; break;
- case 3: numplayersteama = c3; numbotsteama = numbotsteam3; scoreteama = team3_score; break;
- case 4: numplayersteama = c4; numbotsteama = numbotsteam4; scoreteama = team4_score; break;
+ case 1:
+ {
+ num_players_team_a = c1;
+ num_bots_team_a = num_bots_team1;
+ score_team_a = team1_score;
+ break;
+ }
+ case 2:
+ {
+ num_players_team_a = c2;
+ num_bots_team_a = num_bots_team2;
+ score_team_a = team2_score;
+ break;
+ }
+ case 3:
+ {
+ num_players_team_a = c3;
+ num_bots_team_a = num_bots_team3;
+ score_team_a = team3_score;
+ break;
+ }
+ case 4:
+ {
+ num_players_team_a = c4;
+ num_bots_team_a = num_bots_team4;
+ score_team_a = team4_score;
+ break;
+ }
}
- switch (teamb)
+ switch (team_b)
{
- case 1: numplayersteamb = c1; numbotsteamb = numbotsteam1; scoreteamb = team1_score; break;
- case 2: numplayersteamb = c2; numbotsteamb = numbotsteam2; scoreteamb = team2_score; break;
- case 3: numplayersteamb = c3; numbotsteamb = numbotsteam3; scoreteamb = team3_score; break;
- case 4: numplayersteamb = c4; numbotsteamb = numbotsteam4; scoreteamb = team4_score; break;
+ case 1:
+ {
+ num_players_team_b = c1;
+ num_bots_team_b = num_bots_team1;
+ score_team_b = team1_score;
+ break;
+ }
+ case 2:
+ {
+ num_players_team_b = c2;
+ num_bots_team_b = num_bots_team2;
+ score_team_b = team2_score;
+ break;
+ }
+ case 3:
+ {
+ num_players_team_b = c3;
+ num_bots_team_b = num_bots_team3;
+ score_team_b = team3_score;
+ break;
+ }
+ case 4:
+ {
+ num_players_team_b = c4;
+ num_bots_team_b = num_bots_team4;
+ score_team_b = team4_score;
+ break;
+ }
}
-
// invalid
- if (numplayersteama < 0 || numplayersteamb < 0)
+ if (num_players_team_a < 0 || num_players_team_b < 0)
+ {
return false;
-
- if (IS_REAL_CLIENT(e) && bots_would_leave)
+ }
+ if (IS_REAL_CLIENT(player) && bots_would_leave)
{
- numplayersteama -= numbotsteama;
- numplayersteamb -= numbotsteamb;
+ num_players_team_a -= num_bots_team_a;
+ num_players_team_b -= num_bots_team_b;
}
- if (!usescore)
+ if (!use_score)
{
- return numplayersteama < numplayersteamb;
+ return num_players_team_a < num_players_team_b;
}
- if (numplayersteama < numplayersteamb)
+ if (num_players_team_a < num_players_team_b)
{
return true;
}
- if (numplayersteama > numplayersteamb)
+ if (num_players_team_a > num_players_team_b)
{
return false;
}
- return scoreteama < scoreteamb;
+ return score_team_a < score_team_b;
}
-bool IsTeamEqualToTeam(int teama, int teamb, entity e, bool usescore)
+bool IsTeamEqualToTeam(int team_a, int team_b, entity player, bool use_score)
{
- // equal
- if (teama == teamb)
+ if (team_a == team_b)
{
return true;
}
// we assume that CheckAllowedTeams and GetTeamCounts have already been called
- float numplayersteama = -1, numplayersteamb = -1;
- float numbotsteama = 0, numbotsteamb = 0;
- float scoreteama = 0, scoreteamb = 0;
-
- switch (teama)
+ int num_players_team_a = -1, num_players_team_b = -1;
+ int num_bots_team_a = 0, num_bots_team_b = 0;
+ float score_team_a = 0, score_team_b = 0;
+ switch (team_a)
{
- case 1: numplayersteama = c1; numbotsteama = numbotsteam1; scoreteama = team1_score; break;
- case 2: numplayersteama = c2; numbotsteama = numbotsteam2; scoreteama = team2_score; break;
- case 3: numplayersteama = c3; numbotsteama = numbotsteam3; scoreteama = team3_score; break;
- case 4: numplayersteama = c4; numbotsteama = numbotsteam4; scoreteama = team4_score; break;
+ case 1:
+ {
+ num_players_team_a = c1;
+ num_bots_team_a = num_bots_team1;
+ score_team_a = team1_score;
+ break;
+ }
+ case 2:
+ {
+ num_players_team_a = c2;
+ num_bots_team_a = num_bots_team2;
+ score_team_a = team2_score;
+ break;
+ }
+ case 3:
+ {
+ num_players_team_a = c3;
+ num_bots_team_a = num_bots_team3;
+ score_team_a = team3_score;
+ break;
+ }
+ case 4:
+ {
+ num_players_team_a = c4;
+ num_bots_team_a = num_bots_team4;
+ score_team_a = team4_score;
+ break;
+ }
}
- switch (teamb)
+ switch (team_b)
{
- case 1: numplayersteamb = c1; numbotsteamb = numbotsteam1; scoreteamb = team1_score; break;
- case 2: numplayersteamb = c2; numbotsteamb = numbotsteam2; scoreteamb = team2_score; break;
- case 3: numplayersteamb = c3; numbotsteamb = numbotsteam3; scoreteamb = team3_score; break;
- case 4: numplayersteamb = c4; numbotsteamb = numbotsteam4; scoreteamb = team4_score; break;
+ case 1:
+ {
+ num_players_team_b = c1;
+ num_bots_team_b = num_bots_team1;
+ score_team_b = team1_score;
+ break;
+ }
+ case 2:
+ {
+ num_players_team_b = c2;
+ num_bots_team_b = num_bots_team2;
+ score_team_b = team2_score;
+ break;
+ }
+ case 3:
+ {
+ num_players_team_b = c3;
+ num_bots_team_b = num_bots_team3;
+ score_team_b = team3_score;
+ break;
+ }
+ case 4:
+ {
+ num_players_team_b = c4;
+ num_bots_team_b = num_bots_team4;
+ score_team_b = team4_score;
+ break;
+ }
}
-
// invalid
- if (numplayersteama < 0 || numplayersteamb < 0)
+ if (num_players_team_a < 0 || num_players_team_b < 0)
return false;
- if (IS_REAL_CLIENT(e) && bots_would_leave)
- {
- numplayersteama -= numbotsteama;
- numplayersteamb -= numbotsteamb;
- }
- if (!usescore)
+ if (IS_REAL_CLIENT(player) && bots_would_leave)
{
- return numplayersteama == numplayersteamb;
+ num_players_team_a -= num_bots_team_a;
+ num_players_team_b -= num_bots_team_b;
}
- if (numplayersteama < numplayersteamb)
+ if (!use_score)
{
- return false;
+ return num_players_team_a == num_players_team_b;
}
- if (numplayersteama > numplayersteamb)
+ if (num_players_team_a != num_players_team_b)
{
return false;
}
- return scoreteama == scoreteamb;
+ return score_team_a == score_team_b;
}
-int FindBestTeams(entity player, bool usescore)
+int FindBestTeams(entity player, bool use_score)
{
if (MUTATOR_CALLHOOK(FindBestTeams, player) == true)
{
return M_ARGV(1, float);
}
- int teambits = 0;
- int previousteam = 0;
+ int team_bits = 0;
+ int previous_team = 0;
if (c1 >= 0)
{
- teambits = BIT(0);
- previousteam = 1;
+ team_bits = BIT(0);
+ previous_team = 1;
}
if (c2 >= 0)
{
- if (previousteam == 0)
+ if (previous_team == 0)
{
- teambits = BIT(1);
- previousteam = 2;
+ team_bits = BIT(1);
+ previous_team = 2;
}
- else if (IsTeamSmallerThanTeam(2, previousteam, player, usescore))
+ else if (IsTeamSmallerThanTeam(2, previous_team, player, use_score))
{
- teambits = BIT(1);
- previousteam = 2;
+ team_bits = BIT(1);
+ previous_team = 2;
}
- else if (IsTeamEqualToTeam(2, previousteam, player, usescore))
+ else if (IsTeamEqualToTeam(2, previous_team, player, use_score))
{
- teambits |= BIT(1);
- previousteam = 2;
+ team_bits |= BIT(1);
+ previous_team = 2;
}
}
if (c3 >= 0)
{
- if (previousteam == 0)
+ if (previous_team == 0)
{
- teambits = BIT(2);
- previousteam = 3;
+ team_bits = BIT(2);
+ previous_team = 3;
}
- else if (IsTeamSmallerThanTeam(3, previousteam, player, usescore))
+ else if (IsTeamSmallerThanTeam(3, previous_team, player, use_score))
{
- teambits = BIT(2);
- previousteam = 3;
+ team_bits = BIT(2);
+ previous_team = 3;
}
- else if (IsTeamEqualToTeam(3, previousteam, player, usescore))
+ else if (IsTeamEqualToTeam(3, previous_team, player, use_score))
{
- teambits |= BIT(2);
- previousteam = 3;
+ team_bits |= BIT(2);
+ previous_team = 3;
}
}
if (c4 >= 0)
{
- if (previousteam == 0)
+ if (previous_team == 0)
{
- teambits = BIT(3);
+ team_bits = BIT(3);
}
- else if (IsTeamSmallerThanTeam(4, previousteam, player, usescore))
+ else if (IsTeamSmallerThanTeam(4, previous_team, player, use_score))
{
- teambits = BIT(3);
+ team_bits = BIT(3);
}
- else if (IsTeamEqualToTeam(4, previousteam, player, usescore))
+ else if (IsTeamEqualToTeam(4, previous_team, player, use_score))
{
- teambits |= BIT(3);
+ team_bits |= BIT(3);
}
}
- return teambits;
+ return team_bits;
}
// returns # of smallest team (1, 2, 3, 4)
// NOTE: Assumes CheckAllowedTeams has already been called!
-float FindSmallestTeam(entity player, float ignore_player)
+int FindSmallestTeam(entity player, float ignore_player)
{
// count how many players are in each team
if (ignore_player)
{
GetTeamCounts(NULL);
}
- int teambits = FindBestTeams(player, true);
- if (teambits == 0)
+ int team_bits = FindBestTeams(player, true);
+ if (team_bits == 0)
{
error(sprintf("No teams available for %s\n", MapInfo_Type_ToString(MapInfo_CurrentGametype())));
}
RandomSelection_Init();
- if ((teambits & BIT(0)) != 0)
+ if ((team_bits & BIT(0)) != 0)
{
RandomSelection_AddFloat(1, 1, 1);
}
- if ((teambits & BIT(1)) != 0)
+ if ((team_bits & BIT(1)) != 0)
{
RandomSelection_AddFloat(2, 1, 1);
}
- if ((teambits & BIT(2)) != 0)
+ if ((team_bits & BIT(2)) != 0)
{
RandomSelection_AddFloat(3, 1, 1);
}
- if ((teambits & BIT(3)) != 0)
+ if ((team_bits & BIT(3)) != 0)
{
RandomSelection_AddFloat(4, 1, 1);
}
return RandomSelection_chosen_float;
}
-int JoinBestTeam(entity this, bool only_return_best, bool forcebestteam)
+int JoinBestTeam(entity this, bool only_return_best, bool force_best_team)
{
// don't join a team if we're not playing a team game
if (!teamplay)
// find out what teams are available
CheckAllowedTeams(this);
- float selectedteam;
+ int selected_team;
// 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)
+ if (!force_best_team)
{
if( c1 >= 0 && this.team == NUM_TEAM_1)
- selectedteam = this.team;
+ selected_team = this.team;
else if(c2 >= 0 && this.team == NUM_TEAM_2)
- selectedteam = this.team;
+ selected_team = this.team;
else if(c3 >= 0 && this.team == NUM_TEAM_3)
- selectedteam = this.team;
+ selected_team = this.team;
else if(c4 >= 0 && this.team == NUM_TEAM_4)
- selectedteam = this.team;
+ selected_team = this.team;
else
- selectedteam = -1;
+ selected_team = -1;
- if (selectedteam > 0)
+ if (selected_team > 0)
{
if (!only_return_best)
{
- SetPlayerTeamSimple(this, selectedteam);
+ SetPlayerTeamSimple(this, selected_team);
// 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
LogTeamchange(this.playerid, this.team, 99);
}
- return selectedteam;
+ return selected_team;
}
// otherwise end up on the smallest team (handled below)
}
- float bestteam = FindSmallestTeam(this, true);
+ int best_team = FindSmallestTeam(this, true);
if (only_return_best || this.bot_forced_team)
{
- return bestteam;
+ return best_team;
}
- bestteam = Team_NumberToTeam(bestteam);
- if (bestteam == -1)
+ best_team = Team_NumberToTeam(best_team);
+ if (best_team == -1)
{
error("JoinBestTeam: invalid team\n");
}
- int oldteam = Team_TeamToNumber(this.team);
+ int old_team = Team_TeamToNumber(this.team);
TeamchangeFrags(this);
- SetPlayerTeamSimple(this, bestteam);
+ SetPlayerTeamSimple(this, best_team);
LogTeamchange(this.playerid, this.team, 2); // log auto join
if (!IS_BOT_CLIENT(this))
{
- AutoBalanceBots(oldteam, Team_TeamToNumber(bestteam));
+ AutoBalanceBots(old_team, Team_TeamToNumber(best_team));
}
if (!IS_DEAD(this) && (MUTATOR_CALLHOOK(Player_ChangeTeamKill, this) ==
false))
{
Damage(this, this, this, 100000, DEATH_TEAMCHANGE.m_id, this.origin, '0 0 0');
}
- return bestteam;
+ return best_team;
}
void SV_ChangeTeam(entity this, float _color)
{
- float sourcecolor, destinationcolor, sourceteam, destinationteam;
+ float source_color, destination_color, source_team, destination_team;
// in normal deathmatch we can just apply the color and we're done
if(!teamplay)
if(!teamplay)
return;
- sourcecolor = this.clientcolors & 0x0F;
- destinationcolor = _color & 0x0F;
+ source_color = this.clientcolors & 0x0F;
+ destination_color = _color & 0x0F;
- sourceteam = Team_TeamToNumber(sourcecolor + 1);
- destinationteam = Team_TeamToNumber(destinationcolor + 1);
+ source_team = Team_TeamToNumber(source_color + 1);
+ destination_team = Team_TeamToNumber(destination_color + 1);
CheckAllowedTeams(this);
- if (destinationteam == 1 && c1 < 0) destinationteam = 4;
- if (destinationteam == 4 && c4 < 0) destinationteam = 3;
- if (destinationteam == 3 && c3 < 0) destinationteam = 2;
- if (destinationteam == 2 && c2 < 0) destinationteam = 1;
+ if (destination_team == 1 && c1 < 0) destination_team = 4;
+ if (destination_team == 4 && c4 < 0) destination_team = 3;
+ if (destination_team == 3 && c3 < 0) destination_team = 2;
+ if (destination_team == 2 && c2 < 0) destination_team = 1;
// not changing teams
- if (sourcecolor == destinationcolor)
+ if (source_color == destination_color)
{
- SetPlayerTeam(this, destinationteam, sourceteam, true);
+ SetPlayerTeam(this, destination_team, source_team, true);
return;
}
if (autocvar_g_balance_teams && autocvar_g_balance_teams_prevent_imbalance)
{
GetTeamCounts(this);
- if ((BIT(destinationteam - 1) & FindBestTeams(this, false)) == 0)
+ if ((BIT(destination_team - 1) & FindBestTeams(this, false)) == 0)
{
Send_Notification(NOTIF_ONE, this, MSG_INFO, INFO_TEAMCHANGE_LARGERTEAM);
return;
}
}
- if(IS_PLAYER(this) && sourceteam != destinationteam)
+ if(IS_PLAYER(this) && source_team != destination_team)
{
// reduce frags during a team change
TeamchangeFrags(this);
}
- if (!SetPlayerTeam(this, destinationteam, sourceteam, !IS_CLIENT(this)))
+ if (!SetPlayerTeam(this, destination_team, source_team, !IS_CLIENT(this)))
{
return;
}
- AutoBalanceBots(sourceteam, destinationteam);
- if (!IS_PLAYER(this) || (sourceteam == destinationteam))
+ AutoBalanceBots(source_team, destination_team);
+ if (!IS_PLAYER(this) || (source_team == destination_team))
{
return;
}
Damage(this, this, this, 100000, DEATH_TEAMCHANGE.m_id, this.origin, '0 0 0');
}
-void AutoBalanceBots(int sourceteam, int destinationteam)
+void AutoBalanceBots(int source_team, int destination_team)
{
- if ((sourceteam == -1) || (destinationteam == -1))
+ if ((source_team == -1) || (destination_team == -1))
{
return;
}
{
return;
}
- int numplayerssourceteam = 0;
- int numplayersdestinationteam = 0;
- entity lowestbotdestinationteam = NULL;
- switch (sourceteam)
+ int num_players_source_team = 0;
+ int num_players_destination_team = 0;
+ entity lowest_bot_destination_team = NULL;
+ switch (source_team)
{
case 1:
{
- numplayerssourceteam = c1;
+ num_players_source_team = c1;
break;
}
case 2:
{
- numplayerssourceteam = c2;
+ num_players_source_team = c2;
break;
}
case 3:
{
- numplayerssourceteam = c3;
+ num_players_source_team = c3;
break;
}
case 4:
{
- numplayerssourceteam = c4;
+ num_players_source_team = c4;
break;
}
}
- switch (destinationteam)
+ switch (destination_team)
{
case 1:
{
- numplayersdestinationteam = c1;
- lowestbotdestinationteam = lowestbotteam1;
+ num_players_destination_team = c1;
+ lowest_bot_destination_team = lowest_bot_team1;
break;
}
case 2:
{
- numplayersdestinationteam = c2;
- lowestbotdestinationteam = lowestbotteam2;
+ num_players_destination_team = c2;
+ lowest_bot_destination_team = lowest_bot_team2;
break;
}
case 3:
{
- numplayersdestinationteam = c3;
- lowestbotdestinationteam = lowestbotteam3;
+ num_players_destination_team = c3;
+ lowest_bot_destination_team = lowest_bot_team3;
break;
}
case 4:
{
- numplayersdestinationteam = c4;
- lowestbotdestinationteam = lowestbotteam4;
+ num_players_destination_team = c4;
+ lowest_bot_destination_team = lowest_bot_team4;
break;
}
}
- if ((numplayersdestinationteam <= numplayerssourceteam) ||
- (lowestbotdestinationteam == NULL))
+ if ((num_players_destination_team <= num_players_source_team) ||
+ (lowest_bot_destination_team == NULL))
{
return;
}
- SetPlayerTeamSimple(lowestbotdestinationteam, Team_NumberToTeam(sourceteam));
- if (IS_DEAD(lowestbotdestinationteam) || (MUTATOR_CALLHOOK(
- Player_ChangeTeamKill, lowestbotdestinationteam) == true))
+ SetPlayerTeamSimple(lowest_bot_destination_team,
+ Team_NumberToTeam(source_team));
+ if (IS_DEAD(lowest_bot_destination_team) || (MUTATOR_CALLHOOK(
+ Player_ChangeTeamKill, lowest_bot_destination_team) == true))
{
return;
}
- Damage(lowestbotdestinationteam, lowestbotdestinationteam,
- lowestbotdestinationteam, 100000, DEATH_TEAMCHANGE.m_id,
- lowestbotdestinationteam.origin, '0 0 0');
+ Damage(lowest_bot_destination_team, lowest_bot_destination_team,
+ lowest_bot_destination_team, 100000, DEATH_TEAMCHANGE.m_id,
+ lowest_bot_destination_team.origin, '0 0 0');
}
float c2;
float c3;
float c4;
-float numbotsteam1; ///< Number of bots in the first team.
-float numbotsteam2; ///< Number of bots in the second team.
-float numbotsteam3; ///< Number of bots in the third team.
-float numbotsteam4; ///< Number of bots in the fourth team.
-entity lowesthumanteam1; ///< Human with the lowest score in the first team.
-entity lowesthumanteam2; ///< Human with the lowest score in the second team.
-entity lowesthumanteam3; ///< Human with the lowest score in the third team.
-entity lowesthumanteam4; ///< Human with the lowest score in the fourth team.
-entity lowestbotteam1; ///< Bot with the lowest score in the first team.
-entity lowestbotteam2; ///< Bot with the lowest score in the second team.
-entity lowestbotteam3; ///< Bot with the lowest score in the third team.
-entity lowestbotteam4; ///< Bot with the lowest score in the fourth team.
+float num_bots_team1; ///< Number of bots in the first team.
+float num_bots_team2; ///< Number of bots in the second team.
+float num_bots_team3; ///< Number of bots in the third team.
+float num_bots_team4; ///< Number of bots in the fourth team.
+entity lowest_human_team1; ///< Human with the lowest score in the first team.
+entity lowest_human_team2; ///< Human with the lowest score in the second team.
+entity lowest_human_team3; ///< Human with the lowest score in the third team.
+entity lowest_human_team4; ///< Human with the lowest score in the fourth team.
+entity lowest_bot_team1; ///< Bot with the lowest score in the first team.
+entity lowest_bot_team2; ///< Bot with the lowest score in the second team.
+entity lowest_bot_team3; ///< Bot with the lowest score in the third team.
+entity lowest_bot_team4; ///< Bot with the lowest score in the fourth team.
int redowned, blueowned, yellowowned, pinkowned;
/// \brief Sets the team of the player.
/// \param[in,out] player Player to adjust.
-/// \param[in] teamnum Team number to set. See TEAM_NUM constants.
+/// \param[in] team_num Team number to set. See TEAM_NUM constants.
/// \return True if team switch was successful, false otherwise.
-bool SetPlayerTeamSimple(entity player, int teamnum);
+bool SetPlayerTeamSimple(entity player, int team_num);
/// \brief Sets the team of the player.
/// \param[in,out] player Player to adjust.
-/// \param[in] destinationteam Team to set.
-/// \param[in] sourceteam Previous team of the player.
-/// \param[in] noprint Whether to print this event to players' console.
+/// \param[in] destination_team Team to set.
+/// \param[in] source_team Previous team of the player.
+/// \param[in] no_print Whether to print this event to players' console.
/// \return True if team switch was successful, false otherwise.
-bool SetPlayerTeam(entity player, int destinationteam, int sourceteam, bool noprint);
+bool SetPlayerTeam(entity player, int destination_team, int source_team,
+ bool no_print);
// set c1...c4 to show what teams are allowed
-void CheckAllowedTeams (entity for_whom);
+void CheckAllowedTeams(entity for_whom);
float PlayerValue(entity p);
void GetTeamCounts(entity ignore);
/// \brief Returns whether one team is smaller than the other.
-/// \param[in] teama First team.
-/// \param[in] teamb Second team.
-/// \param[in] e Player to check.
-/// \param[in] usescore Whether to take into account team scores.
+/// \param[in] team_a First team.
+/// \param[in] team_b Second team.
+/// \param[in] player Player to check.
+/// \param[in] use_score Whether to take into account team scores.
/// \return True if first team is smaller than the second one, false otherwise.
/// \note This function assumes that CheckAllowedTeams and GetTeamCounts have
/// been called.
-bool IsTeamSmallerThanTeam(int teama, int teamb, entity e, bool usescore);
+bool IsTeamSmallerThanTeam(int team_a, int team_b, entity player,
+ bool use_score);
/// \brief Returns whether one team is equal to the other.
-/// \param[in] teama First team.
-/// \param[in] teamb Second team.
-/// \param[in] e Player to check.
-/// \param[in] usescore Whether to take into account team scores.
+/// \param[in] team_a First team.
+/// \param[in] team_b Second team.
+/// \param[in] player Player to check.
+/// \param[in] use_score Whether to take into account team scores.
/// \return True if first team is equal to the second one, false otherwise.
/// \note This function assumes that CheckAllowedTeams and GetTeamCounts have
/// been called.
-bool IsTeamEqualToTeam(int teama, int teamb, entity e, bool usescore);
+bool IsTeamEqualToTeam(int team_a, int team_b, entity player, bool use_score);
/// \brief Returns the bitmask of the best teams for the player to join.
/// \param[in] player Player to check.
-/// \param[in] usescore Whether to take into account team scores.
+/// \param[in] use_score Whether to take into account team scores.
/// \return Bitmask of the best teams for the player to join.
/// \note This function assumes that CheckAllowedTeams and GetTeamCounts have
/// been called.
-int FindBestTeams(entity player, bool usescore);
+int FindBestTeams(entity player, bool use_score);
// returns # of smallest team (1, 2, 3, 4)
// NOTE: Assumes CheckAllowedTeams has already been called!
-float FindSmallestTeam(entity player, float ignore_player);
+int FindSmallestTeam(entity player, float ignore_player);
-int JoinBestTeam(entity this, bool only_return_best, bool forcebestteam);
+int JoinBestTeam(entity this, bool only_return_best, bool force_best_team);
/// \brief Auto balances bots in teams after the player has changed team.
-/// \param[in] sourceteam Previous team of the player (1, 2, 3, 4).
-/// \param[in] destinationteam Current team of the player (1, 2, 3, 4).
+/// \param[in] source_team Previous team of the player (1, 2, 3, 4).
+/// \param[in] destination_team Current team of the player (1, 2, 3, 4).
/// \return No return.
/// \note This function assumes that CheckAllowedTeams and GetTeamCounts have
/// been called.
-void AutoBalanceBots(int sourceteam, int destinationteam);
+void AutoBalanceBots(int source_team, int destination_team);
void setcolor(entity this, int clr);