]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
sv_maxidle_playertospectator: print only 1 CHATCON notification when a player is...
authorbones_was_here <bones_was_here@xa.org.au>
Sat, 17 Apr 2021 09:29:17 +0000 (19:29 +1000)
committerbones_was_here <bones_was_here@xa.org.au>
Sun, 18 Apr 2021 09:31:13 +0000 (19:31 +1000)
qcsrc/server/client.qc
qcsrc/server/teamplay.qc

index 08a0b68da2fb55fceddcba709ed6bc669ddaca8c..b5bdc30755590520f54ec218700ebb9b2e0b9df2 100644 (file)
@@ -241,13 +241,6 @@ void PutObserverInServer(entity this)
 
        if (IS_PLAYER(this))
        {
-               if (autocvar_sv_maxidle_playertospectator > 0 && CS(this).idlekick_lasttimeleft)
-               {
-                       Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_IDLING);
-                       CS(this).idlekick_lasttimeleft = 0;
-                       CS(this).parm_idlesince = time;
-               }
-
                if(GetResource(this, RES_HEALTH) >= 1)
                {
                        // despawn effect
@@ -2751,7 +2744,6 @@ void PlayerPostThink (entity this)
                                        if (this.caplayer)
                                                this.caplayer = 0;
                                        PutObserverInServer(this);
-                                       CS(this).parm_idlesince = time;
                                }
                                else
                                {
index 7abd4e6bc47f100d307a8d4fb63e4cff05e2e7e5..5877bb37d4e7788ba02150bc02d2ca516c1ea17f 100644 (file)
@@ -214,33 +214,31 @@ bool SetPlayerTeam(entity player, int team_index, int type)
                return false;
        }
        LogTeamChange(player.playerid, player.team, type);
-       if (team_index != old_team_index)
+       if (team_index == -1)
        {
-               PlayerScore_Clear(player);
-               if (team_index != -1)
+               if (autocvar_sv_maxidle_playertospectator > 0 && CS(player).idlekick_lasttimeleft)
                {
-                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(
-                               player.team, INFO_JOIN_PLAY_TEAM), player.netname);
+                       // centerprint is killed and timestamps are reset here to ensure
+                       // it's done even when manually speccing during the countdown
+                       Kill_Notification(NOTIF_ONE_ONLY, player, MSG_CENTER, CPID_IDLING);
+                       CS(player).parm_idlesince = time;
+                       CS(player).idlekick_lasttimeleft = 0;
                }
-               else
+               else if (!CS(player).just_joined && player.frags != FRAGS_SPECTATOR)
                {
-                       if (!CS(player).just_joined)
-                       {
-                               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE,
-                                       player.netname);
-                       }
+                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE, player.netname);
                }
+       }
+       else if (team_index != old_team_index)
+       {
+               PlayerScore_Clear(player);
+               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(player.team, INFO_JOIN_PLAY_TEAM), player.netname);
                KillPlayerForTeamChange(player);
                if (!IS_BOT_CLIENT(player))
                {
                        TeamBalance_AutoBalanceBots();
                }
        }
-       else if (team_index == -1)
-       {
-               if (!CS(player).just_joined && player.frags != FRAGS_SPECTATOR)
-                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE, player.netname);
-       }
        return true;
 }