]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix not working notification about missing teams in KeyHunt (outdated notification...
authorterencehill <piuntn@gmail.com>
Fri, 7 Aug 2015 15:01:31 +0000 (17:01 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 7 Aug 2015 16:32:28 +0000 (18:32 +0200)
qcsrc/common/notifications.qh
qcsrc/server/mutators/gamemode_keyhunt.qc

index 1f1e9828c160c276b5976f92792335a79fec2b88..f7a6cef38cddd77e335ea675e0baf4f79c2f479a 100644 (file)
@@ -718,7 +718,6 @@ void Send_Notification_WOCOVA(
     MSG_CENTER_NOTIF(1, CENTER_KEYHUNT_ROUNDSTART,          0, 1, "",              CPID_KEYHUNT_OTHER,    "1 f1", _("^F4Round will start in ^COUNT"), "") \
     MSG_CENTER_NOTIF(1, CENTER_KEYHUNT_SCAN,                0, 1, "",              CPID_KEYHUNT_OTHER,    "f1 0", _("^BGScanning frequency range..."), "") \
     MULTITEAM_CENTER(1, CENTER_KEYHUNT_START_, 4,           0, 0, "",              CPID_KEYHUNT,          "0 0", _("^BGYou are starting with the ^TC^TT Key"), "") \
-    MSG_CENTER_NOTIF(1, CENTER_KEYHUNT_WAIT,                0, 1, "missing_teams", CPID_KEYHUNT_OTHER,    "0 0", _("^BGWaiting for players to join...\nNeed active players for: %s"), "") \
     MSG_CENTER_NOTIF(1, CENTER_LMS_NOLIVES,                 0, 0, "",              CPID_LMS,              "0 0", _("^BGYou have no lives left, you must wait until the next match"), "") \
     MSG_CENTER_NOTIF(1, CENTER_MISSING_TEAMS,               0, 1, "missing_teams", CPID_MISSING_TEAMS,    "-1 0", _("^BGWaiting for players to join...\nNeed active players for: %s"), "") \
     MSG_CENTER_NOTIF(1, CENTER_MISSING_PLAYERS,             0, 1, "f1",            CPID_MISSING_PLAYERS,  "-1 0", _("^BGWaiting for %s player(s) to join..."), "") \
index 3771093a20a193de21ac10029961d24f61f4b438..5fa2f6db2b7a9ea384a442664612681cca80f108 100644 (file)
@@ -871,6 +871,8 @@ float kh_CheckPlayers(float num)
        return 0;
 }
 
+#define KH_READY_TEAMS() (!p1 + !p2 + ((kh_teams >= 3) ? !p3 : p3) + ((kh_teams >= 4) ? !p4 : p4))
+#define KH_READY_TEAMS_OK() (KH_READY_TEAMS() == kh_teams)
 void kh_WaitForPlayers()  // delay start of the round until enough players are present
 {
        if(time < game_starttime)
@@ -879,15 +881,35 @@ void kh_WaitForPlayers()  // delay start of the round until enough players are p
                return;
        }
 
+       static float prev_missing_teams_mask;
        float p1 = kh_CheckPlayers(0), p2 = kh_CheckPlayers(1), p3 = kh_CheckPlayers(2), p4 = kh_CheckPlayers(3);
-       if (!(p1 || p2 || p3 || p4))
+       if(KH_READY_TEAMS_OK())
        {
+               if(prev_missing_teams_mask > 0)
+                       Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_MISSING_TEAMS);
+               prev_missing_teams_mask = -1;
                Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_KEYHUNT_ROUNDSTART, autocvar_g_balance_keyhunt_delay_round);
                kh_Controller_SetThink(autocvar_g_balance_keyhunt_delay_round, kh_StartRound);
        }
        else
        {
-               Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_KEYHUNT_WAIT, p1, p2, p3, p4);
+               if(player_count == 0)
+               {
+                       if(prev_missing_teams_mask > 0)
+                               Kill_Notification(NOTIF_ALL, world, MSG_CENTER_CPID, CPID_MISSING_TEAMS);
+                       prev_missing_teams_mask = -1;
+               }
+               else
+               {
+                       float missing_teams_mask = (!!p1) + (!!p2) * 2;
+                       if(kh_teams >= 3) missing_teams_mask += (!!p3) * 4;
+                       if(kh_teams >= 4) missing_teams_mask += (!!p4) * 8;
+                       if(prev_missing_teams_mask != missing_teams_mask)
+                       {
+                               Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_MISSING_TEAMS, missing_teams_mask);
+                               prev_missing_teams_mask = missing_teams_mask;
+                       }
+               }
                kh_Controller_SetThink(1, kh_WaitForPlayers);
        }
 }
@@ -912,10 +934,9 @@ void kh_StartRound()  // runs at the start of each round
        }
 
        float p1 = kh_CheckPlayers(0), p2 = kh_CheckPlayers(1), p3 = kh_CheckPlayers(2), p4 = kh_CheckPlayers(3);
-       if(p1 || p2 || p3 || p4)
+       if(!KH_READY_TEAMS_OK())
        {
                kh_Controller_SetThink(1, kh_WaitForPlayers);
-               Send_Notification(NOTIF_ALL, world, MSG_CENTER, CENTER_KEYHUNT_WAIT, p1, p2, p3, p4);
                return;
        }