X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fteamplay.qc;h=a7c7205c1fb5781bec8edf30adc0dfa5a2a3fc12;hb=5388b5cae878b6d8712983677ba5d3353e565b88;hp=b373d9f15a4739d06f30e1f324b4e366118785a7;hpb=9c24e122b771b8afb620a1f7db98b2d6f38b04af;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index b373d9f15..a7c7205c1 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -181,7 +181,7 @@ bool Player_SetTeamIndex(entity player, int index) { // 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. + // [BOT]Lion: color 0 4. SetPlayerColors(player, new_team - 1); } return true; @@ -222,8 +222,11 @@ bool SetPlayerTeam(entity player, int team_index, int type) } else { - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE, - player.netname); + if (!CS(player).just_joined) + { + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE, + player.netname); + } } KillPlayerForTeamChange(player); if (!IS_BOT_CLIENT(player)) @@ -231,6 +234,11 @@ bool SetPlayerTeam(entity player, int team_index, int type) TeamBalance_AutoBalanceBots(); } } + else if (team_index == -1) + { + if (!CS(player).just_joined && player.frags != FRAGS_SPECTATOR) + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE, player.netname); + } return true; } @@ -456,8 +464,8 @@ entity TeamBalance_CheckAllowedTeams(entity for_whom) team_ent.m_num_bots = 0; } setthink(balance, TeamBalance_Destroy); - - int teams_mask = 0; + + int teams_mask = 0; string teament_name = string_null; bool mutator_returnvalue = MUTATOR_CALLHOOK(TeamBalance_CheckAllowedTeams, teams_mask, teament_name, for_whom); @@ -488,8 +496,7 @@ entity TeamBalance_CheckAllowedTeams(entity for_whom) } // TODO: Balance quantity of bots across > 2 teams when bot_vs_human is set (and remove next line) - if (AvailableTeams() == 2) - if (autocvar_bot_vs_human && for_whom) + if (autocvar_bot_vs_human && AvailableTeams() == 2 && for_whom) { if (autocvar_bot_vs_human > 0) { @@ -578,8 +585,8 @@ entity TeamBalance_CheckAllowedTeams(entity for_whom) TeamBalance_IsTeamAllowedInternal(balance, i)) { TeamBalance_BanTeamsExcept(balance, i); + break; } - break; } balance.m_team_balance_state = TEAM_BALANCE_TEAMS_CHECKED; return balance; @@ -857,12 +864,10 @@ int TeamBalance_CompareTeams(entity balance, int team_index_a, int team_index_b, void TeamBalance_AutoBalanceBots() { - if (!autocvar_g_balance_teams || - !autocvar_g_balance_teams_prevent_imbalance) - { - return; - } - //PrintToChatAll("TeamBalance_AutoBalanceBots"); + // checks disabled because we always want auto-balanced bots + //if (!(autocvar_g_balance_teams && autocvar_g_balance_teams_prevent_imbalance)) + // return; + entity balance = TeamBalance_CheckAllowedTeams(NULL); TeamBalance_GetTeamCounts(balance, NULL); int smallest_team_index = 0; @@ -874,16 +879,16 @@ void TeamBalance_AutoBalanceBots() { continue; } - int player_count = TeamBalanceTeam_GetNumberOfPlayers(team_); + int playercount = TeamBalanceTeam_GetNumberOfPlayers(team_); if (smallest_team_index == 0) { smallest_team_index = i; - smallest_team_player_count = player_count; + smallest_team_player_count = playercount; } - else if (player_count < smallest_team_player_count) + else if (playercount < smallest_team_player_count) { smallest_team_index = i; - smallest_team_player_count = player_count; + smallest_team_player_count = playercount; } } //PrintToChatAll(sprintf("Smallest team: %f", smallest_team_index)); @@ -942,16 +947,16 @@ int TeamBalance_GetLargestTeamIndex(entity balance, int teams) { continue; } - int player_count = TeamBalanceTeam_GetNumberOfPlayers(team_); + int playercount = TeamBalanceTeam_GetNumberOfPlayers(team_); if (largest_team_index == 0) { largest_team_index = i; - largest_team_player_count = player_count; + largest_team_player_count = playercount; } - else if (player_count > largest_team_player_count) + else if (playercount > largest_team_player_count) { largest_team_index = i; - largest_team_player_count = player_count; + largest_team_player_count = playercount; } } return largest_team_index; @@ -1006,7 +1011,7 @@ void LogTeamChange(float player_id, float team_number, int type) { return; } - GameLogEcho(sprintf(":team:%f:%f:%f", player_id, team_number, type)); + GameLogEcho(sprintf(":team:%d:%d:%d", player_id, team_number, type)); } void KillPlayerForTeamChange(entity player)