]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add warning before removing an excess player
authorz411 <z411@omaera.org>
Mon, 5 Jun 2023 22:05:03 +0000 (18:05 -0400)
committerz411 <z411@omaera.org>
Mon, 5 Jun 2023 22:05:03 +0000 (18:05 -0400)
qcsrc/common/notifications/all.inc
qcsrc/common/notifications/all.qh
qcsrc/server/teamplay.qc

index b854c04a1ca9c518902de8dc89455ad7185767a7..10008a20047761fe1d3670bf4a314a904c5d354c 100644 (file)
@@ -680,6 +680,7 @@ string multiteam_info_sprintf(string input, string teamname) { return ((input !=
 
     MSG_CENTER_NOTIF(DISCONNECT_IDLING,                 N_ENABLE,    0, 1, "",               CPID_IDLING,            "1 f1", BOLD(_("^K1Stop idling!\n^BGDisconnecting in ^COUNT...")), "")
     MSG_CENTER_NOTIF(MOVETOSPEC_IDLING,                 N_ENABLE,    0, 1, "",               CPID_IDLING,            "1 f1", BOLD(_("^K1Stop idling!\n^BGMoving to spectators in ^COUNT...")), "")
 
     MSG_CENTER_NOTIF(DISCONNECT_IDLING,                 N_ENABLE,    0, 1, "",               CPID_IDLING,            "1 f1", BOLD(_("^K1Stop idling!\n^BGDisconnecting in ^COUNT...")), "")
     MSG_CENTER_NOTIF(MOVETOSPEC_IDLING,                 N_ENABLE,    0, 1, "",               CPID_IDLING,            "1 f1", BOLD(_("^K1Stop idling!\n^BGMoving to spectators in ^COUNT...")), "")
+    MSG_CENTER_NOTIF(MOVETOSPEC_REMOVE,                 N_ENABLE,    1, 1, "s1",             CPID_REMOVE,            "1 f1", BOLD(_("^K1Teams unbalanced!\n^BGMoving %s^BG to spectators in ^COUNT...")), "")
 
     MSG_CENTER_NOTIF(DOOR_LOCKED_NEED,                  N_ENABLE,    1, 0, "s1",             CPID_Null,              "0 0",  _("^BGYou need %s^BG!"), "")
     MSG_CENTER_NOTIF(DOOR_LOCKED_ALSONEED,              N_ENABLE,    1, 0, "s1",             CPID_Null,              "0 0",  _("^BGYou also need %s^BG!"), "")
 
     MSG_CENTER_NOTIF(DOOR_LOCKED_NEED,                  N_ENABLE,    1, 0, "s1",             CPID_Null,              "0 0",  _("^BGYou need %s^BG!"), "")
     MSG_CENTER_NOTIF(DOOR_LOCKED_ALSONEED,              N_ENABLE,    1, 0, "s1",             CPID_Null,              "0 0",  _("^BGYou also need %s^BG!"), "")
index 00bd94bb740066bc03810210ece3d6238d895da8..680e339e0f096e58958ae92feaef18003280b9f1 100644 (file)
@@ -52,6 +52,7 @@ ENUMCLASS(CPID)
        CASE(CPID, STALEMATE)
        CASE(CPID, NADES)
        CASE(CPID, IDLING)
        CASE(CPID, STALEMATE)
        CASE(CPID, NADES)
        CASE(CPID, IDLING)
+       CASE(CPID, REMOVE)
        CASE(CPID, ITEM)
        CASE(CPID, PREVENT_JOIN)
        CASE(CPID, KEEPAWAY)
        CASE(CPID, ITEM)
        CASE(CPID, PREVENT_JOIN)
        CASE(CPID, KEEPAWAY)
index f0e68ce263bc966f8b866c2b8183091e524ec1d9..148c514618ed7441bb778332efba7adf4c6e9913 100644 (file)
@@ -717,6 +717,36 @@ bool TeamBalance_AreEqual(entity ignore)
        return true;
 }
 
        return true;
 }
 
+entity remove_countdown;
+entity remove_player;
+int remove_time;
+
+void Remove_Countdown(entity this)
+{
+       if(remove_time <= 0 || TeamBalance_AreEqual(NULL))
+       {
+               if(remove_time <= 0)
+               {
+                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_MOVETOSPEC_REMOVE, remove_player.netname);
+                       PutObserverInServer(remove_player, true, true);
+               }
+
+               Kill_Notification(NOTIF_ALL, NULL, MSG_CENTER, CPID_REMOVE);
+
+               delete(this);
+               remove_countdown = NULL;
+               remove_player = NULL;
+               remove_time = 0;
+
+               TeamBalance_RemoveExcessPlayers(NULL); // Check again for excess players in case someone also left while in countdown
+               return;
+       }
+
+       Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_MOVETOSPEC_REMOVE, remove_player.netname, remove_time);
+       --remove_time;
+       this.nextthink = time + 1;
+}
+
 void TeamBalance_RemoveExcessPlayers(entity ignore)
 {
        if(AVAILABLE_TEAMS != 2 || autocvar_g_campaign) return;
 void TeamBalance_RemoveExcessPlayers(entity ignore)
 {
        if(AVAILABLE_TEAMS != 2 || autocvar_g_campaign) return;
@@ -736,7 +766,7 @@ void TeamBalance_RemoveExcessPlayers(entity ignore)
        for(int tmi = 1; tmi <= AVAILABLE_TEAMS; ++tmi)
        {
                int cur = TeamBalance_GetTeamFromIndex(balance, tmi).m_num_players;
        for(int tmi = 1; tmi <= AVAILABLE_TEAMS; ++tmi)
        {
                int cur = TeamBalance_GetTeamFromIndex(balance, tmi).m_num_players;
-               if(cur > 0 && cur > min)
+               if(cur > 0 && cur > min) // If this team has excess players
                {
                        // Get newest player
                        int latest_join = 0;
                {
                        // Get newest player
                        int latest_join = 0;
@@ -753,8 +783,18 @@ void TeamBalance_RemoveExcessPlayers(entity ignore)
                        // Force player to spectate
                        if(latest_join_pl)
                        {
                        // Force player to spectate
                        if(latest_join_pl)
                        {
-                               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_MOVETOSPEC_REMOVE, latest_join_pl.netname);
-                               PutObserverInServer(latest_join_pl, true, true);
+                               // Send player to spectate
+                               remove_player = latest_join_pl;
+                               remove_time = 10;
+
+                               if (!remove_countdown)
+                               {
+                                       remove_countdown = new_pure(remove_countdown);
+                                       setthink(remove_countdown, Remove_Countdown);
+                                       remove_countdown.nextthink = time;
+                               }
+                               //Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_MOVETOSPEC_REMOVE, latest_join_pl.netname);
+                               //PutObserverInServer(latest_join_pl, true, true);
                        }
                }
        }
                        }
                }
        }