]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/teamplay.qh
Teamplay: First pass at the new autobalance algorithm. Fixes #1982.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / teamplay.qh
index 91b9bdd8b0637bba031bbf1fb3a4809b1ee69578..05578be7aaf0ad7efd4dc8c5805217b52d496c1a 100644 (file)
@@ -71,7 +71,8 @@ int Entity_GetTeamIndex(entity this);
 
 /// \brief Returns the team entity of the given entity.
 /// \param[in] this Entity to check.
-/// \return Team entity of the given entity.
+/// \return Team entity of the given entity or NULL if the entity doesn't belong
+/// to any team.
 entity Entity_GetTeam(entity this);
 
 void SetPlayerColors(entity player, float _color);
@@ -102,22 +103,47 @@ 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);
 
+enum
+{
+       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 =================================
 
 /// \brief Checks whether the player can join teams according to global
 /// configuration and mutator settings.
 /// \param[in] for_whom Player to check for. Pass NULL for global rules.
 /// \return Team balance entity that holds information about teams. This entity
-/// must be manually destroyed by calling TeamBalance_Destroy.
+/// will be automatically destroyed on the next frame but you are encouraged to
+/// manually destroy it by calling TeamBalance_Destroy for performance reasons.
 entity TeamBalance_CheckAllowedTeams(entity for_whom);
 
 /// \brief Destroy the team balance entity.
@@ -174,7 +200,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
@@ -198,10 +224,7 @@ int TeamBalance_CompareTeams(entity balance, int team_index_a, int team_index_b,
        entity player, bool use_score);
 
 /// \brief Switches a bot from one team to another if teams are not balanced.
-/// \param[in] source_team_index Index of the team to switch from.
-/// \param[in] destination_team_index Index of the team to switch to.
-void TeamBalance_AutoBalanceBots(int source_team_index,
-       int destination_team_index);
+void TeamBalance_AutoBalanceBots();
 
 // ============================ Internal API ==================================