]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add cvar for remove warning wait
authorz411 <z411@omaera.org>
Mon, 5 Jun 2023 22:24:06 +0000 (18:24 -0400)
committerz411 <z411@omaera.org>
Mon, 5 Jun 2023 22:24:06 +0000 (18:24 -0400)
qcsrc/server/teamplay.qc
qcsrc/server/world.qc
xonotic-server.cfg

index 148c514618ed7441bb778332efba7adf4c6e9913..6e78c26be56caa63d1a1f2c65256e6f67a991830 100644 (file)
@@ -719,15 +719,15 @@ bool TeamBalance_AreEqual(entity ignore)
 
 entity remove_countdown;
 entity remove_player;
-int remove_time;
+int remove_timeleft;
 
 void Remove_Countdown(entity this)
 {
-       if(remove_time <= 0 || TeamBalance_AreEqual(NULL))
+       if(remove_timeleft <= 0 || TeamBalance_AreEqual(NULL))
        {
-               if(remove_time <= 0)
+               if(remove_timeleft <= 0)
                {
-                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_MOVETOSPEC_REMOVE, remove_player.netname);
+                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_MOVETOSPEC_REMOVE, playername(remove_player.netname, remove_player.team, true));
                        PutObserverInServer(remove_player, true, true);
                }
 
@@ -742,8 +742,8 @@ void Remove_Countdown(entity this)
                return;
        }
 
-       Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_MOVETOSPEC_REMOVE, remove_player.netname, remove_time);
-       --remove_time;
+       Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_MOVETOSPEC_REMOVE, remove_player.netname, remove_timeleft);
+       --remove_timeleft;
        this.nextthink = time + 1;
 }
 
@@ -784,17 +784,25 @@ void TeamBalance_RemoveExcessPlayers(entity ignore)
                        if(latest_join_pl)
                        {
                                // Send player to spectate
-                               remove_player = latest_join_pl;
-                               remove_time = 10;
-
-                               if (!remove_countdown)
+                               if(autocvar_g_balance_teams_remove_wait)
+                               {
+                                       // Give a warning before moving to spect
+                                       remove_player = latest_join_pl;
+                                       remove_timeleft = autocvar_g_balance_teams_remove_wait;
+
+                                       if (!remove_countdown)
+                                       {
+                                               remove_countdown = new_pure(remove_countdown);
+                                               setthink(remove_countdown, Remove_Countdown);
+                                               remove_countdown.nextthink = time;
+                                       }
+                               }
+                               else
                                {
-                                       remove_countdown = new_pure(remove_countdown);
-                                       setthink(remove_countdown, Remove_Countdown);
-                                       remove_countdown.nextthink = time;
+                                       // Move to spects immediately
+                                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_MOVETOSPEC_REMOVE, latest_join_pl.netname);
+                                       PutObserverInServer(latest_join_pl, true, true);
                                }
-                               //Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_MOVETOSPEC_REMOVE, latest_join_pl.netname);
-                               //PutObserverInServer(latest_join_pl, true, true);
                        }
                }
        }
index 21bd4139f670a22350d05944f8d4def2e53b8626..d416b6144186cd73c447ec5d1b23bf30c5cbba33 100644 (file)
@@ -452,6 +452,7 @@ void cvar_changes_init()
                BADCVAR("g_balance_teams");
                BADCVAR("g_balance_teams_queue");
                BADCVAR("g_balance_teams_remove");
+               BADCVAR("g_balance_teams_remove_wait");
                BADCVAR("g_balance_teams_prevent_imbalance");
                BADCVAR("g_balance_teams_scorefactor");
                BADCVAR("g_ban_sync_trusted_servers");
index bc81ec6ed6122d65682dae748827ab3b10894ab7..91103ec3324a3a8421dd02f3a9be87b1c5ffda8e 100644 (file)
@@ -279,6 +279,7 @@ set g_balance_teams 1 "automatically balance out players entering instead of ask
 set g_balance_teams_prevent_imbalance 1 "prevent players from changing to larger teams"
 set g_balance_teams_queue 0 "queue players before joining"
 set g_balance_teams_remove 0 "remove excess players from teams"
+set g_balance_teams_remove_wait 10 "seconds to warn everyone before removing an excess player (0 = immediately)"
 set g_changeteam_banned 0 "not allowed to change team"
 
 set sv_teamnagger 1 "enable a nag message when the teams are unbalanced"