From: Lyberta Date: Wed, 25 Jul 2018 22:31:24 +0000 (+0300) Subject: Teamplay: Forced teams improvements. X-Git-Tag: xonotic-v0.8.5~1899^2~15 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f943da12a4200b5093936a9644a6f67efa68bb97;p=xonotic%2Fxonotic-data.pk3dir.git Teamplay: Forced teams improvements. --- 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 =================================