LMS: fix visible leaders message appearing even when there are no leaders
authorterencehill <piuntn@gmail.com>
Wed, 31 Aug 2022 20:17:30 +0000 (22:17 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 31 Aug 2022 20:17:30 +0000 (22:17 +0200)
qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc

index e3ebfefd31fc9a6562590a1650ffc9b506b1e5d9..947111a08f66e80c566c4c5cc92ad0dd9d409bb4 100644 (file)
@@ -451,14 +451,22 @@ MUTATOR_HOOKFUNCTION(lms, PlayerPreThink)
 
 MUTATOR_HOOKFUNCTION(lms, SV_StartFrame)
 {
+       if (intermission_running)
+               return;
+
+       lms_leaders = 0;
+       FOREACH_CLIENT(true, {
+               if (IS_PLAYER(it) && it.frags != FRAGS_PLAYER_OUT_OF_GAME && it.lms_leader)
+                       lms_leaders++;
+       });
+
        float leader_time = autocvar_g_lms_leader_wp_time;
        float leader_interval = leader_time + autocvar_g_lms_leader_wp_interval;
        lms_visible_leaders_prev = lms_visible_leaders;
-       lms_visible_leaders = (time > lms_visible_leaders_time && time < lms_visible_leaders_time + leader_time);
-       if (lms_visible_leaders_prev && !lms_visible_leaders)
+       lms_visible_leaders = (lms_leaders && time > lms_visible_leaders_time && time < lms_visible_leaders_time + leader_time);
+       if (!lms_leaders || (lms_visible_leaders_prev && !lms_visible_leaders))
                lms_visible_leaders_time = time + leader_interval + random() * autocvar_g_lms_leader_wp_interval_jitter;
 
-       lms_leaders = 0;
        FOREACH_CLIENT(true, {
                STAT(OBJECTIVE_STATUS, it) = lms_visible_leaders;
                if (IS_PLAYER(it) && it.frags != FRAGS_PLAYER_OUT_OF_GAME)
@@ -476,7 +484,6 @@ MUTATOR_HOOKFUNCTION(lms, SV_StartFrame)
                                }
                                if (!lms_visible_leaders_prev && lms_visible_leaders && IS_REAL_CLIENT(it))
                                        Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_LMS_VISIBLE_LEADER);
-                               lms_leaders++;
                        }
                        else // if (!it.lms_leader)
                        {