]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Improved LogTeamchange.
authorLyberta <lyberta@lyberta.net>
Sun, 18 Mar 2018 11:04:21 +0000 (14:04 +0300)
committerLyberta <lyberta@lyberta.net>
Sun, 18 Mar 2018 11:04:21 +0000 (14:04 +0300)
qcsrc/server/client.qc
qcsrc/server/teamplay.qc
qcsrc/server/teamplay.qh

index abd3cb17923479440a0ff0ebc8a3e10aafa307fe..93072e264e0c94a6c1c0fbc9a0f7430e9abcc70d 100644 (file)
@@ -297,7 +297,7 @@ void PutObserverInServer(entity this)
                        Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_CHAT_NOSPECTATORS);
 
                if(!CS(this).just_joined)
-                       LogTeamchange(this.playerid, -1, 4);
+                       LogTeamchange(this.playerid, -1, TEAM_CHANGE_SPECTATOR);
                else
                        CS(this).just_joined = false;
        }
@@ -1315,7 +1315,7 @@ void ClientConnect(entity this)
        if (autocvar_sv_eventlog)
                GameLogEcho(strcat(":join:", ftos(this.playerid), ":", ftos(etof(this)), ":", ((IS_REAL_CLIENT(this)) ? this.netaddress : "bot"), ":", playername(this, false)));
 
-       LogTeamchange(this.playerid, this.team, 1);
+       LogTeamchange(this.playerid, this.team, TEAM_CHANGE_CONNECT);
 
        CS(this).just_joined = true;  // stop spamming the eventlog with additional lines when the client connects
 
index 51e360a1978d6d508985438cbd632a036b240c89..4cc9ff960ee37a0f074585d916ff9781bee338a7 100644 (file)
@@ -123,22 +123,6 @@ int Team_GetNumberOfTeamsWithControlPoints()
        return result;
 }
 
-void TeamchangeFrags(entity e)
-{
-       PlayerScore_Clear(e);
-}
-
-void LogTeamchange(float player_id, float team_number, float type)
-{
-       if(!autocvar_sv_eventlog)
-               return;
-
-       if(player_id < 1)
-               return;
-
-       GameLogEcho(strcat(":team:", ftos(player_id), ":", ftos(team_number), ":", ftos(type)));
-}
-
 void setcolor(entity this, int clr)
 {
 #if 0
@@ -211,7 +195,7 @@ bool SetPlayerTeam(entity player, int destination_team_index,
        {
                return false;
        }
-       LogTeamchange(player.playerid, player.team, 3);  // log manual team join
+       LogTeamchange(player.playerid, player.team, TEAM_CHANGE_MANUAL);
        if (no_print)
        {
                return true;
@@ -226,7 +210,7 @@ bool MoveToTeam(entity client, int team_index, int type)
 {
        int lockteams_backup = lockteams;  // backup any team lock
        lockteams = 0;  // disable locked teams
-       TeamchangeFrags(client);  // move the players frags
+       PlayerScore_Clear(client);
        if (!Player_SetTeamIndex(client, team_index))
        {
                lockteams = lockteams_backup;  // restore the team lock
@@ -252,6 +236,17 @@ void KillPlayerForTeamChange(entity player)
                player.origin, '0 0 0');
 }
 
+void LogTeamchange(float player_id, float team_number, int type)
+{
+       if(!autocvar_sv_eventlog)
+               return;
+
+       if(player_id < 1)
+               return;
+
+       GameLogEcho(strcat(":team:", ftos(player_id), ":", ftos(team_number), ":", ftos(type)));
+}
+
 entity TeamBalance_CheckAllowedTeams(entity for_whom)
 {
        entity balance = spawn();
@@ -687,7 +682,7 @@ void TeamBalance_JoinBestTeam(entity this, bool force_best_team)
                if (Team_IsValidIndex(selected_team_index))
                {
                        Player_SetTeamIndex(this, selected_team_index);
-                       LogTeamchange(this.playerid, this.team, 99);
+                       LogTeamchange(this.playerid, this.team, TEAM_CHANGE_AUTO_RELAXED);
                        TeamBalance_Destroy(balance);
                        return;
                }
@@ -700,9 +695,9 @@ void TeamBalance_JoinBestTeam(entity this, bool force_best_team)
        }
        int best_team_index = TeamBalance_FindBestTeam(balance, this, true);
        int old_team_index = Team_TeamToIndex(this.team);
-       TeamchangeFrags(this);
+       PlayerScore_Clear(this);
        Player_SetTeamIndex(this, best_team_index);
-       LogTeamchange(this.playerid, this.team, 2); // log auto join
+       LogTeamchange(this.playerid, this.team, TEAM_CHANGE_AUTO);
        if ((old_team_index != -1) && !IS_BOT_CLIENT(this))
        {
                TeamBalance_AutoBalanceBots(balance, old_team_index, best_team_index);
@@ -967,7 +962,7 @@ void SV_ChangeTeam(entity this, float _color)
        if (IS_PLAYER(this) && source_team_index != destination_team_index)
        {
                // reduce frags during a team change
-               TeamchangeFrags(this);
+               PlayerScore_Clear(this);
        }
        if (!SetPlayerTeam(this, destination_team_index, source_team_index,
                !IS_CLIENT(this)))
index a7fc34b56facac35cd8b8fd45608824738a2d4a5..444c25d3c494120fd7f573f72ba77d086b5cd709 100644 (file)
@@ -55,10 +55,6 @@ void Team_SetNumberOfControlPoints(entity team_, int number);
 /// \return Number of teams that own control points.
 int Team_GetNumberOfTeamsWithControlPoints();
 
-void TeamchangeFrags(entity e);
-
-void LogTeamchange(float player_id, float team_number, float type);
-
 // ======================= Entity specific API ================================
 
 void setcolor(entity this, int clr);
@@ -100,12 +96,23 @@ bool SetPlayerTeam(entity player, int destination_team_index,
 /// \param[in] team_index Index of the team.
 /// \param[in] type ???
 /// \return True on success, false otherwise.
-bool MoveToTeam(entity client, int team_index, float type);
+bool MoveToTeam(entity client, int team_index, int type);
 
 /// \brief Kills player as a result of team change.
 /// \param[in,out] player Player to kill.
 void KillPlayerForTeamChange(entity player);
 
+enum
+{
+       TEAM_CHANGE_CONNECT = 1,
+       TEAM_CHANGE_AUTO = 2,
+       TEAM_CHANGE_MANUAL = 3,
+       TEAM_CHANGE_SPECTATOR = 4,
+       TEAM_CHANGE_AUTO_RELAXED = 99
+};
+
+void LogTeamchange(float player_id, float team_number, int type);
+
 // ========================= Team balance API =================================
 
 /// \brief Checks whether the player can join teams according to global