]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Teamplay: Forced teams improvements.
authorLyberta <lyberta@lyberta.net>
Wed, 25 Jul 2018 22:31:24 +0000 (01:31 +0300)
committerLyberta <lyberta@lyberta.net>
Wed, 25 Jul 2018 22:31:24 +0000 (01:31 +0300)
qcsrc/server/teamplay.qc
qcsrc/server/teamplay.qh

index 6b2778b0916c99a4cf0dadd1da21d9ac4e60d957..f16846294ca48376de00d8172fbfc0874e7fc369 100644 (file)
@@ -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)
index 5e8b9fea718bcd22fab37eff9f39c3b64e382371..1bc2056af9ca5df80edf4b6113cb0491312b0d75 100644 (file)
@@ -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 =================================