]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/teamplay.qc
Removed global alive variables.
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / teamplay.qc
index e2b16cab9a2babf7aa10e8bdece8cf4a3b93a002..325252bcdb161f6ce936cf4ec9d8e19d99675a8b 100644 (file)
@@ -34,6 +34,7 @@ const int TEAM_NOT_ALLOWED = -1;
 .float m_team_score; ///< The score of the team.
 .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.
 .entity m_lowest_human; ///< Human with the lowest score in a team.
 .entity m_lowest_bot; ///< Bot with the lowest score in a team.
 
@@ -75,6 +76,29 @@ void Team_SetTeamScore(entity team_, float score)
        team_.m_team_score = score;
 }
 
+int Team_GetNumberOfAlivePlayers(entity team_)
+{
+       return team_.m_num_players_alive;
+}
+
+void Team_SetNumberOfAlivePlayers(entity team_, int number)
+{
+       team_.m_num_players_alive = number;
+}
+
+int Team_GetNumberOfAliveTeams()
+{
+       int result = 0;
+       for (int i = 0; i < NUM_TEAMS; ++i)
+       {
+               if (g_team_entities[i].m_num_players_alive > 0)
+               {
+                       ++result;
+               }
+       }
+       return result;
+}
+
 void TeamchangeFrags(entity e)
 {
        PlayerScore_Clear(e);
@@ -226,11 +250,26 @@ void setcolor(entity this, int clr)
 #endif
 }
 
+bool Entity_HasValidTeam(entity this)
+{
+       return Team_IsValidTeam(this.team);
+}
+
 int Entity_GetTeamIndex(entity this)
 {
        return Team_TeamToIndex(this.team);
 }
 
+entity Entity_GetTeam(entity this)
+{
+       int index = Entity_GetTeamIndex(this);
+       if (!Team_IsValidIndex(index))
+       {
+               return NULL;
+       }
+       return Team_GetTeamFromIndex(index);
+}
+
 void SetPlayerColors(entity player, float _color)
 {
        float pants = _color & 0x0F;