X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fteamplay.qc;h=11509b5428a74f26d96fdc29c21bdfb7019317e5;hb=e4ad6899ea71b0b94c00b079477daac85e8d2fa2;hp=ff9438e76d84b205679a05982d5b8bc1eb0b57f3;hpb=af43b181a15f348a4de2045b716ebc7765ce8f9f;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index ff9438e76..11509b542 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -1,19 +1,19 @@ #include "teamplay.qh" -#include "client.qh" -#include "race.qh" -#include "scores.qh" -#include "scores_rules.qh" - -#include "bot/api.qh" - -#include "command/vote.qh" - -#include - -#include "../common/deathtypes/all.qh" +#include #include -#include "../common/teams.qh" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /// \brief Describes a state of team balance entity. enum @@ -46,11 +46,13 @@ string autocvar_g_forced_team_pink; entity g_team_entities[NUM_TEAMS]; ///< Holds global team entities. -STATIC_INIT(g_team_entities) +void Team_InitTeams() { + if (g_team_entities[0]) + return; for (int i = 0; i < NUM_TEAMS; ++i) { - g_team_entities[i] = spawn(); + g_team_entities[i] = new_pure(team_entity); } } @@ -207,38 +209,39 @@ bool Player_SetTeamIndex(entity player, int index) bool SetPlayerTeam(entity player, int team_index, int type) { int old_team_index = Entity_GetTeamIndex(player); + if (!Player_SetTeamIndex(player, team_index)) - { return false; - } + LogTeamChange(player.playerid, player.team, type); + if (team_index != old_team_index) { - PlayerScore_Clear(player); - if (team_index != -1) - { - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM( - player.team, INFO_JOIN_PLAY_TEAM), player.netname); - } - else - { - if (!CS(player).just_joined) - { - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE, - player.netname); - } - } KillPlayerForTeamChange(player); + PlayerScore_Clear(player); + CS(player).parm_idlesince = time; + if (!IS_BOT_CLIENT(player)) - { TeamBalance_AutoBalanceBots(); - } + + if (team_index != -1) + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(player.team, INFO_JOIN_PLAY_TEAM), player.netname); } - else if (team_index == -1) + + if (team_index == -1) { - if (!CS(player).just_joined && player.frags != FRAGS_SPECTATOR) + if (autocvar_sv_maxidle_playertospectator > 0 && CS(player).idlekick_lasttimeleft) + { + // this done here so it happens even when manually speccing during the countdown + Kill_Notification(NOTIF_ONE_ONLY, player, MSG_CENTER, CPID_IDLING); + CS(player).idlekick_lasttimeleft = 0; + } + else if (!CS(player).just_joined && player.frags != FRAGS_SPECTATOR) + { Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE, player.netname); + } } + return true; } @@ -464,6 +467,7 @@ entity TeamBalance_CheckAllowedTeams(entity for_whom) team_ent.m_num_bots = 0; } setthink(balance, TeamBalance_Destroy); + balance.nextthink = time; int teams_mask = 0; string teament_name = string_null; @@ -496,8 +500,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) { @@ -1123,18 +1126,13 @@ void SV_ChangeTeam(entity player, int new_color) { SetPlayerColors(player, new_color); } - // TODO: Should we really bother with this? if(!IS_CLIENT(player)) { - // since this is an engine function, and gamecode doesn't have any calls earlier than this, do the connecting message here - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_CONNECTING, - player.netname); return; } if (!teamplay) { return; } - Player_SetTeamIndexChecked(player, Team_TeamToIndex((new_color & 0x0F) + - 1)); + Player_SetTeamIndexChecked(player, Team_TeamToIndex((new_color & 0x0F) + 1)); }