From cd7ed86b51412a283ccd47a703b36be79bb117b8 Mon Sep 17 00:00:00 2001 From: Lyberta Date: Sat, 18 Mar 2017 21:53:51 +0300 Subject: [PATCH] Using MoveToTeam instead. --- qcsrc/server/player.qc | 15 ++++++++++++++- qcsrc/server/player.qh | 7 ++++++- qcsrc/server/teamplay.qc | 15 +-------------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index 9458f1dc0..584931c40 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -661,15 +661,28 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, } } -void MoveToTeam(entity client, int team_colour, int type) +bool MoveToTeam(entity client, int team_colour, int type) { + if (client.team == teamnum) + { + return true; + } + if (MUTATOR_CALLHOOK(Player_ChangeTeam, client, Team_TeamToNumber( + client.team), Team_TeamToNumber(team_colour)) == true) + { + // Mutator has blocked team change. + return false; + } int lockteams_backup = lockteams; // backup any team lock lockteams = 0; // disable locked teams + int oldteam = client.team; TeamchangeFrags(client); // move the players frags SetPlayerColors(client, team_colour - 1); // set the players colour Damage(client, client, client, 100000, DEATH_AUTOTEAMCHANGE.m_id, client.origin, '0 0 0'); // kill the player lockteams = lockteams_backup; // restore the team lock LogTeamchange(client.playerid, client.team, type); + MUTATOR_CALLHOOK(Player_ChangedTeam, client, oldteam, client.team); + return true; } /** print(), but only print if the server is not local */ diff --git a/qcsrc/server/player.qh b/qcsrc/server/player.qh index c6cdd3880..f527e1768 100644 --- a/qcsrc/server/player.qh +++ b/qcsrc/server/player.qh @@ -38,7 +38,12 @@ void calculate_player_respawn_time(entity this); void ClientKill_Now_TeamChange(entity this); -void MoveToTeam(entity client, float team_colour, float type); +/// \brief Moves player to the specified team. +/// \param[in,out] client Client to move. +/// \param[in] team_colour Color of the team. +/// \param[in] type ??? +/// \return True on success, false otherwise. +bool MoveToTeam(entity client, float team_colour, float type); void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force); diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index 70dc937e5..fdecfb3fd 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -192,20 +192,7 @@ void SetPlayerColors(entity pl, float _color) bool SetPlayerTeamSimple(entity player, int teamnum) { - if (player.team == teamnum) - { - return true; - } - if (MUTATOR_CALLHOOK(Player_ChangeTeam, player, Team_TeamToNumber( - player.team), Team_TeamToNumber(teamnum)) == true) - { - // Mutator has blocked team change. - return false; - } - int oldteam = player.team; - SetPlayerColors(player, teamnum - 1); - MUTATOR_CALLHOOK(Player_ChangedTeam, player, oldteam, player.team); - return true; + return MoveToTeam(player, teamnum, 6); } void SetPlayerTeam(entity pl, float t, float s, float noprint) -- 2.39.2