From f943da12a4200b5093936a9644a6f67efa68bb97 Mon Sep 17 00:00:00 2001 From: Lyberta Date: Thu, 26 Jul 2018 01:31:24 +0300 Subject: [PATCH] Teamplay: Forced teams improvements. --- qcsrc/server/teamplay.qc | 22 +++++++++++++++++++++- qcsrc/server/teamplay.qh | 16 ++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index 6b2778b09..f16846294 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -273,7 +273,27 @@ int Player_GetForcedTeamIndex(entity player) void Player_SetForcedTeamIndex(entity player, int team_index) { - player.team_forced = team_index; + switch (team_index) + { + case TEAM_FORCE_SPECTATOR: + case TEAM_FORCE_DEFAULT: + { + player.team_forced = team_index; + break; + } + default: + { + if (!Team_IsValidIndex(team_index)) + { + LOG_FATAL("Player_SetForcedTeamIndex: Invalid team index."); + } + else + { + player.team_forced = team_index; + break; + } + } + } } void Player_DetermineForcedTeam(entity player) diff --git a/qcsrc/server/teamplay.qh b/qcsrc/server/teamplay.qh index 5e8b9fea7..1bc2056af 100644 --- a/qcsrc/server/teamplay.qh +++ b/qcsrc/server/teamplay.qh @@ -112,16 +112,28 @@ void LogTeamchange(float player_id, float team_number, int type); enum { - TEAM_FORCE_SPECTATOR = -1, - TEAM_FORCE_DEFAULT = 0 + TEAM_FORCE_SPECTATOR = -1, ///< Force the player to spectator team. + TEAM_FORCE_DEFAULT = 0 ///< Don't force any team. }; +/// \brief Returns whether player has real forced team. Spectator team is +/// ignored. +/// \param[in] player Player to check. +/// \return True if player has real forced team, false otherwise. bool Player_HasRealForcedTeam(entity player); +/// \brief Returns the index of the forced team of the given player. +/// \param[in] player Player to check. +/// \return Index of the forced team. int Player_GetForcedTeamIndex(entity player); +/// \brief Sets the index of the forced team of the given player. +/// \param[in,out] player Player to adjust. +/// \param[in] team_index Index of the team to set. void Player_SetForcedTeamIndex(entity player, int team_index); +/// \brief Determines the forced team of the player using current global config. +/// \param[in,out] player Player to adjust. void Player_DetermineForcedTeam(entity player); // ========================= Team balance API ================================= -- 2.39.2