From: drjaska Date: Sun, 28 Nov 2021 04:51:38 +0000 (+0200) Subject: added functions to support storing and fetching data for total amount of players... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=refs%2Fheads%2Fdrjaska%2Fteamplaytotalplayers;p=xonotic%2Fxonotic-data.pk3dir.git added functions to support storing and fetching data for total amount of players on a team not just the alive players anymore. --- diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index c26a0b165..348045ba1 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -35,6 +35,7 @@ const int TEAM_NOT_ALLOWED = -1; .int m_num_players; ///< Number of players (both humans and bots) in a team. .int m_num_bots; ///< Number of bots in a team. .int m_num_players_alive; ///< Number of alive players in a team. +.int m_num_players_total; ///< Number of total players in a team. .int m_num_control_points; ///< Number of control points owned by a team. string autocvar_g_forced_team_red; @@ -92,6 +93,16 @@ void Team_SetNumberOfAlivePlayers(entity team_ent, int number) team_ent.m_num_players_alive = number; } +int Team_GetNumberOfTotalPlayers(entity team_ent) +{ + return team_ent.m_num_players_total; +} + +void Team_SetNumberOfTotalPlayers(entity team_ent, int number) +{ + team_ent.m_num_players_total = number; +} + int Team_GetNumberOfAliveTeams() { int result = 0; @@ -105,6 +116,19 @@ int Team_GetNumberOfAliveTeams() return result; } +int Team_GetNumberOfTotalTeams() +{ + int result = 0; + for (int i = 0; i < NUM_TEAMS; ++i) + { + if (g_team_entities[i].m_num_players_total > 0) + { + ++result; + } + } + return result; +} + int Team_GetNumberOfControlPoints(entity team_ent) { return team_ent.m_num_control_points; diff --git a/qcsrc/server/teamplay.qh b/qcsrc/server/teamplay.qh index 06787c6ff..43e06dabd 100644 --- a/qcsrc/server/teamplay.qh +++ b/qcsrc/server/teamplay.qh @@ -46,15 +46,29 @@ void Team_SetTeamScore(entity team_ent, float score); /// \return Number of alive players in a team. int Team_GetNumberOfAlivePlayers(entity team_ent); +/// \brief Returns the number of total players in a team. +/// \param[in] team_ent Team entity. +/// \return Number of total players in a team. +int Team_GetNumberOfTotalPlayers(entity team_ent); + /// \brief Sets the number of alive players in a team. /// \param[in,out] team_ent Team entity. /// \param[in] number Number of players to set. void Team_SetNumberOfAlivePlayers(entity team_ent, int number); +/// \brief Sets the number of total players in a team. +/// \param[in,out] team_ent Team entity. +/// \param[in] number Number of players to set. +void Team_SetNumberOfTotalPlayers(entity team_ent, int number); + /// \brief Returns the number of alive teams. /// \return Number of alive teams. int Team_GetNumberOfAliveTeams(); +/// \brief Returns the number of total teams. +/// \return Number of total teams. +int Team_GetNumberOfTotalTeams(); + /// \brief Returns the number of control points owned by a team. /// \param[in] team_ent Team entity. /// \return Number of control points owned by a team.