]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
SetPlayerTeam now returns bool.
authorLyberta <lyberta@lyberta.net>
Wed, 2 Aug 2017 03:31:29 +0000 (06:31 +0300)
committerLyberta <lyberta@lyberta.net>
Wed, 2 Aug 2017 03:31:29 +0000 (06:31 +0300)
qcsrc/server/teamplay.qc
qcsrc/server/teamplay.qh

index 8f06ec67d36cedad514b251ddfbcc44419971fc2..61e2690c85c57359d2f5270864e92356b03e76e2 100644 (file)
@@ -204,19 +204,20 @@ bool SetPlayerTeamSimple(entity player, int teamnum)
        return true;
 }
 
-void SetPlayerTeam(entity player, int destinationteam, int sourceteam, bool noprint)
+bool SetPlayerTeam(entity player, int destinationteam, int sourceteam, bool noprint)
 {
        int teamnum = Team_NumberToTeam(destinationteam);
        if (!SetPlayerTeamSimple(player, teamnum))
        {
-               return;
+               return false;
        }
        LogTeamchange(player.playerid, player.team, 3);  // log manual team join
        if (noprint)
        {
-               return;
+               return true;
        }
        bprint(playername(player, false), "^7 has changed from ", Team_NumberToColoredFullName(sourceteam), "^7 to ", Team_NumberToColoredFullName(destinationteam), "\n");
+       return true;
 }
 
 // set c1...c4 to show what teams are allowed
@@ -862,7 +863,10 @@ void SV_ChangeTeam(entity this, float _color)
                // reduce frags during a team change
                TeamchangeFrags(this);
        }
-       SetPlayerTeam(this, destinationteam, sourceteam, !IS_CLIENT(this));
+       if (!SetPlayerTeam(this, destinationteam, sourceteam, !IS_CLIENT(this)))
+       {
+               return;
+       }
        AutoBalanceBots(sourceteam, destinationteam);
        if (!IS_PLAYER(this) || (sourceteam == destinationteam))
        {
@@ -1086,8 +1090,10 @@ void ShufflePlayerOutOfTeam (float source_team)
 
        // move the player to the new team
        TeamchangeFrags(selected);
-       SetPlayerTeam(selected, smallestteam, source_team, false);
-
+       if (!SetPlayerTeam(selected, smallestteam, source_team, false))
+       {
+               return;
+       }
        if (IS_DEAD(selected) || MUTATOR_CALLHOOK(Player_ChangeTeamKill, selected) == true)
        {
                return;
index df5605ef978d8895bcd6f8b522ce0b1590b1e921..5d1130d5e6a8c3a3ffdc078776d549671da30279 100644 (file)
@@ -50,8 +50,8 @@ bool SetPlayerTeamSimple(entity player, int teamnum);
 /// \param[in] destinationteam Team to set.
 /// \param[in] sourceteam Previous team of the player.
 /// \param[in] noprint Whether to print this event to players' console.
-/// \return No return.
-void SetPlayerTeam(entity player, int destinationteam, int sourceteam, bool noprint);
+/// \return True if team switch was successful, false otherwise.
+bool SetPlayerTeam(entity player, int destinationteam, int sourceteam, bool noprint);
 
 // set c1...c4 to show what teams are allowed
 void CheckAllowedTeams (entity for_whom);