From 5d7faa5a29c0eb014b973c34e057b8774d3f0db9 Mon Sep 17 00:00:00 2001 From: Lyberta Date: Wed, 25 Jul 2018 18:42:54 +0300 Subject: [PATCH] Fixed JoinBestTeam. --- qcsrc/server/bot/default/bot.qc | 4 ++-- qcsrc/server/client.qc | 9 +++------ qcsrc/server/teamplay.qc | 27 ++------------------------- qcsrc/server/teamplay.qh | 6 ++---- 4 files changed, 9 insertions(+), 37 deletions(-) diff --git a/qcsrc/server/bot/default/bot.qc b/qcsrc/server/bot/default/bot.qc index 2b427f4fb..50c4fd06a 100644 --- a/qcsrc/server/bot/default/bot.qc +++ b/qcsrc/server/bot/default/bot.qc @@ -238,7 +238,7 @@ void bot_setnameandstuff(entity this) this.bot_config_loaded = true; - // this is really only a default, JoinBestTeam is called later + // this is really only a default, TeamBalance_JoinBestTeam is called later setcolor(this, stof(bot_shirt) * 16 + stof(bot_pants)); this.bot_preferredcolors = this.clientcolors; @@ -431,7 +431,7 @@ void bot_clientconnect(entity this) else if(this.bot_forced_team==4) this.team = NUM_TEAM_4; else - TeamBalance_JoinBestTeam(this, true); + TeamBalance_JoinBestTeam(this); havocbot_setupbot(this); } diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 53a203eb9..c356c359f 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -519,7 +519,7 @@ void PutPlayerInServer(entity this) accuracy_resend(this); if (this.team < 0) - TeamBalance_JoinBestTeam(this, true); + TeamBalance_JoinBestTeam(this); entity spot = SelectSpawnPoint(this, false); if (!spot) { @@ -913,7 +913,7 @@ void ClientKill_Now_TeamChange(entity this) { if(this.killindicator_teamchange == -1) { - TeamBalance_JoinBestTeam(this, true); + TeamBalance_JoinBestTeam(this); } else if(this.killindicator_teamchange == -2) { @@ -1298,7 +1298,6 @@ void ClientConnect(entity this) int playerid_save = this.playerid; this.playerid = 0; // silent - TeamBalance_JoinBestTeam(this, false); // if the team number is valid, keep it this.playerid = playerid_save; TRANSMUTE(Observer, this); @@ -1314,8 +1313,6 @@ void ClientConnect(entity this) if (autocvar_sv_eventlog) GameLogEcho(strcat(":join:", ftos(this.playerid), ":", ftos(etof(this)), ":", ((IS_REAL_CLIENT(this)) ? this.netaddress : "bot"), ":", playername(this, false))); - LogTeamchange(this.playerid, this.team, TEAM_CHANGE_CONNECT); - CS(this).just_joined = true; // stop spamming the eventlog with additional lines when the client connects if(teamplay && IS_PLAYER(this)) @@ -2121,7 +2118,7 @@ void Join(entity this) if(!this.team_selected) if(autocvar_g_campaign || autocvar_g_balance_teams) - TeamBalance_JoinBestTeam(this, true); + TeamBalance_JoinBestTeam(this); if(autocvar_g_campaign) campaign_bots_may_start = true; diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index 25acdd3e0..c7fbacc48 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -631,9 +631,9 @@ int TeamBalance_FindBestTeams(entity balance, entity player, bool use_score) return team_bits; } -void TeamBalance_JoinBestTeam(entity this, bool force_best_team) +void TeamBalance_JoinBestTeam(entity this) { - //PrintToChatAll(sprintf("JoinBestTeam: %s, %f", this.netname, force_best_team)); + PrintToChatAll(sprintf("JoinBestTeam: %s, %f", this.netname)); // don't join a team if we're not playing a team game if (!teamplay) { @@ -643,29 +643,6 @@ void TeamBalance_JoinBestTeam(entity this, bool force_best_team) // find out what teams are available entity balance = TeamBalance_CheckAllowedTeams(this); - // if we don't care what team they end up on, put them on whatever team they entered as. - // if they're not on a valid team, then let other code put them on the smallest team - if (!force_best_team) - { - int selected_team_index = -1; - for (int i = 1; i <= NUM_TEAMS; ++i) - { - if (TeamBalance_IsTeamAllowedInternal(balance, i) && - (Team_TeamToIndex(this.team) == i)) - { - selected_team_index = i; - break; - } - } - - if (Team_IsValidIndex(selected_team_index)) - { - SetPlayerTeam(this, selected_team_index, TEAM_CHANGE_AUTO_RELAXED); - TeamBalance_Destroy(balance); - return; - } - } - // otherwise end up on the smallest team (handled below) if (this.bot_forced_team) { TeamBalance_Destroy(balance); diff --git a/qcsrc/server/teamplay.qh b/qcsrc/server/teamplay.qh index f0ad95ce1..776a80d32 100644 --- a/qcsrc/server/teamplay.qh +++ b/qcsrc/server/teamplay.qh @@ -103,11 +103,9 @@ void KillPlayerForTeamChange(entity player); enum { - TEAM_CHANGE_CONNECT = 1, TEAM_CHANGE_AUTO = 2, TEAM_CHANGE_MANUAL = 3, - TEAM_CHANGE_SPECTATOR = 4, - TEAM_CHANGE_AUTO_RELAXED = 99 + TEAM_CHANGE_SPECTATOR = 4 }; void LogTeamchange(float player_id, float team_number, int type); @@ -176,7 +174,7 @@ int TeamBalance_FindBestTeam(entity balance, entity player, bool ignore_player); /// function. int TeamBalance_FindBestTeams(entity balance, entity player, bool use_score); -void TeamBalance_JoinBestTeam(entity this, bool force_best_team); +void TeamBalance_JoinBestTeam(entity this); /// \brief Describes the result of comparing teams. enum -- 2.39.2