From eef579080d56491c951c7e5a02c5e1677e436522 Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 31 Dec 2021 15:59:58 +0100 Subject: [PATCH] Rename Team_*ControlPoints functions to Team_*OwnedItems so they can be used without ambiguity to count control points in Domination and generators in Onslaught --- .../gamemode/domination/sv_domination.qc | 8 +++---- .../gamemode/onslaught/sv_onslaught.qc | 10 ++++---- qcsrc/server/teamplay.qc | 18 +++++++------- qcsrc/server/teamplay.qh | 24 +++++++++---------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc b/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc index ac8e48856..80bbf6532 100644 --- a/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc +++ b/qcsrc/common/gamemodes/gamemode/domination/sv_domination.qc @@ -311,7 +311,7 @@ void Domination_count_controlpoints() total_control_points = 0; for (int i = 1; i <= NUM_TEAMS; ++i) { - Team_SetNumberOfControlPoints(Team_GetTeamFromIndex(i), 0); + Team_SetNumberOfOwnedItems(Team_GetTeamFromIndex(i), 0); } IL_EACH(g_dompoints, true, { @@ -321,9 +321,9 @@ void Domination_count_controlpoints() continue; } entity team_ = Entity_GetTeam(it.goalentity); - int num_control_points = Team_GetNumberOfControlPoints(team_); + int num_control_points = Team_GetNumberOfOwnedItems(team_); ++num_control_points; - Team_SetNumberOfControlPoints(team_, num_control_points); + Team_SetNumberOfOwnedItems(team_, num_control_points); }); } @@ -340,7 +340,7 @@ bool Domination_CheckWinner() } Domination_count_controlpoints(); - int winner_team = Team_GetWinnerTeam_WIthControlPoints(total_control_points); + int winner_team = Team_GetWinnerTeam_WIthOwnedItems(total_control_points); if (winner_team == -1) return 0; diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc index 58fc8a366..c071be0e0 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc @@ -1126,7 +1126,7 @@ void Onslaught_count_generators() total_generators = 0; for (int i = 1; i <= NUM_TEAMS; ++i) { - Team_SetNumberOfControlPoints(Team_GetTeamFromIndex(i), 0); + Team_SetNumberOfOwnedItems(Team_GetTeamFromIndex(i), 0); } for(e = ons_worldgeneratorlist; e; e = e.ons_worldgeneratornext) { @@ -1136,9 +1136,9 @@ void Onslaught_count_generators() continue; } entity team_ = Entity_GetTeam(e); - int num_control_points = Team_GetNumberOfControlPoints(team_); - ++num_control_points; - Team_SetNumberOfControlPoints(team_, num_control_points); + int num_generators = Team_GetNumberOfOwnedItems(team_); + ++num_generators; + Team_SetNumberOfOwnedItems(team_, num_generators); } } @@ -1188,7 +1188,7 @@ bool Onslaught_CheckWinner() else { wpforenemy_announced = false; ons_stalemate = false; } Onslaught_count_generators(); - int winner_team = Team_GetWinnerTeam_WIthControlPoints(1); // actually generators + int winner_team = Team_GetWinnerTeam_WIthOwnedItems(1); if (!winner_team) return 0; diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index b1edf75e4..7257156a9 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -35,7 +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_control_points; ///< Number of control points owned by a team. +.int m_num_owned_items; ///< Number of items owned by a team. string autocvar_g_forced_team_red; string autocvar_g_forced_team_blue; @@ -120,12 +120,12 @@ int Team_GetNumberOfAliveTeams() return result; } -int Team_GetWinnerTeam_WIthControlPoints(int min_control_points) +int Team_GetWinnerTeam_WIthOwnedItems(int min_control_points) { int winner = 0; for (int i = 0; i < NUM_TEAMS; ++i) { - if (g_team_entities[i].m_num_control_points >= min_control_points) + if (g_team_entities[i].m_num_owned_items >= min_control_points) { if (winner) return 0; @@ -135,22 +135,22 @@ int Team_GetWinnerTeam_WIthControlPoints(int min_control_points) return (winner ? winner : -1); } -int Team_GetNumberOfControlPoints(entity team_ent) +int Team_GetNumberOfOwnedItems(entity team_ent) { - return team_ent.m_num_control_points; + return team_ent.m_num_owned_items; } -void Team_SetNumberOfControlPoints(entity team_ent, int number) +void Team_SetNumberOfOwnedItems(entity team_ent, int number) { - team_ent.m_num_control_points = number; + team_ent.m_num_owned_items = number; } -int Team_GetNumberOfTeamsWithControlPoints() +int Team_GetNumberOfTeamsWithOwnedItems() { int result = 0; for (int i = 0; i < NUM_TEAMS; ++i) { - if (g_team_entities[i].m_num_control_points > 0) + if (g_team_entities[i].m_num_owned_items > 0) { ++result; } diff --git a/qcsrc/server/teamplay.qh b/qcsrc/server/teamplay.qh index c7b2ac8d0..a94b247a8 100644 --- a/qcsrc/server/teamplay.qh +++ b/qcsrc/server/teamplay.qh @@ -60,23 +60,23 @@ int Team_GetWinnerAliveTeam(); int Team_GetNumberOfAliveTeams(); /// \brief Returns the winner team. -/// \param[in] min_control_points Minimum number of control points the winner team must have. -/// \return Winner team or 0 if 2 or more teams have control points or -1 if no team has any control points. -int Team_GetWinnerTeam_WIthControlPoints(int min_control_points); +/// \param[in] min_owned_items Minimum number of items the winner team must have. +/// \return Winner team or 0 if 2 or more teams own items or -1 if no team own any items. +int Team_GetWinnerTeam_WIthOwnedItems(int min_owned_items); -/// \brief Returns the number of control points owned by a team. +/// \brief Returns the number of items owned by a team. /// \param[in] team_ent Team entity. -/// \return Number of control points owned by a team. -int Team_GetNumberOfControlPoints(entity team_ent); +/// \return Number of items owned by a team. +int Team_GetNumberOfOwnedItems(entity team_ent); -/// \brief Sets the number of control points owned by a team. +/// \brief Sets the number of items owned by a team. /// \param[in,out] team_ent Team entity. -/// \param[in] number Number of control points to set. -void Team_SetNumberOfControlPoints(entity team_ent, int number); +/// \param[in] number Number of items to set. +void Team_SetNumberOfOwnedItems(entity team_ent, int number); -/// \brief Returns the number of teams that own control points. -/// \return Number of teams that own control points. -int Team_GetNumberOfTeamsWithControlPoints(); +/// \brief Returns the number of teams that own items. +/// \return Number of teams that own items. +int Team_GetNumberOfTeamsWithOwnedItems(); // ======================= Entity specific API ================================ -- 2.39.2