]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Added KillPlayerForTeamChange.
authorLyberta <lyberta@lyberta.net>
Fri, 4 Aug 2017 21:26:41 +0000 (00:26 +0300)
committerLyberta <lyberta@lyberta.net>
Fri, 4 Aug 2017 21:26:41 +0000 (00:26 +0300)
qcsrc/server/teamplay.qc
qcsrc/server/teamplay.qh

index 1fce2694ece2b0baa63930691247ed76537b76d4..92cd8ebccedede1cfabe53bbb3211cb31df71890 100644 (file)
@@ -183,6 +183,20 @@ void SetPlayerColors(entity player, float _color)
        }
 }
 
+void KillPlayerForTeamChange(entity player)
+{
+       if (IS_DEAD(player))
+       {
+               return;
+       }
+       if (MUTATOR_CALLHOOK(Player_ChangeTeamKill, player) == true)
+       {
+               return;
+       }
+       Damage(player, player, player, 100000, DEATH_TEAMCHANGE.m_id, player.origin,
+               '0 0 0');
+}
+
 bool SetPlayerTeamSimple(entity player, int team_num)
 {
        if (player.team == team_num)
@@ -887,11 +901,7 @@ int JoinBestTeam(entity this, bool only_return_best, bool force_best_team)
        {
                AutoBalanceBots(old_team, Team_TeamToNumber(best_team));
        }
-       if (!IS_DEAD(this) && (MUTATOR_CALLHOOK(Player_ChangeTeamKill, this) ==
-               false))
-       {
-               Damage(this, this, this, 100000, DEATH_TEAMCHANGE.m_id, this.origin, '0 0 0');
-       }
+       KillPlayerForTeamChange(this);
        return best_team;
 }
 
@@ -962,12 +972,7 @@ void SV_ChangeTeam(entity this, float _color)
        {
                return;
        }
-       // kill player when changing teams
-       if (IS_DEAD(this) || (MUTATOR_CALLHOOK(Player_ChangeTeamKill, this) == true))
-       {
-               return;
-       }
-       Damage(this, this, this, 100000, DEATH_TEAMCHANGE.m_id, this.origin, '0 0 0');
+       KillPlayerForTeamChange(this);
 }
 
 void AutoBalanceBots(int source_team, int destination_team)
@@ -1041,12 +1046,5 @@ void AutoBalanceBots(int source_team, int destination_team)
        }
        SetPlayerTeamSimple(lowest_bot_destination_team,
                Team_NumberToTeam(source_team));
-       if (IS_DEAD(lowest_bot_destination_team) || (MUTATOR_CALLHOOK(
-               Player_ChangeTeamKill, lowest_bot_destination_team) == true))
-       {
-               return;
-       }
-       Damage(lowest_bot_destination_team, lowest_bot_destination_team,
-               lowest_bot_destination_team, 100000, DEATH_TEAMCHANGE.m_id,
-               lowest_bot_destination_team.origin, '0 0 0');
+       KillPlayerForTeamChange(lowest_bot_destination_team);
 }
index a2cc6ca05b88cf5c655e7af432c8885f92bf88f1..5311d4cb01d54d37c056333feb3a566e518296d6 100644 (file)
@@ -47,6 +47,11 @@ string getwelcomemessage(entity this);
 
 void SetPlayerColors(entity player, float _color);
 
+/// \brief Kills player as a result of team change.
+/// \param[in,out] player Player to kill.
+/// \return No return.
+void KillPlayerForTeamChange(entity player);
+
 /// \brief Sets the team of the player.
 /// \param[in,out] player Player to adjust.
 /// \param[in] team_num Team number to set. See TEAM_NUM constants.