]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
LMS: end the game if after 30s less than 2 players remain due to forfeits
authorterencehill <piuntn@gmail.com>
Sun, 20 Mar 2022 20:15:36 +0000 (20:15 +0000)
committerbones_was_here <bones_was_here@xa.org.au>
Sun, 20 Mar 2022 20:15:36 +0000 (20:15 +0000)
gamemodes-server.cfg
qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc

index 1d2a0d70a945168d319ccda9b4e1a08dcb8675a2..ba4812b57afd8bdc4c5da48d31320788f122acb2 100644 (file)
@@ -451,6 +451,7 @@ set g_lms_last_join 3       "if g_lms_join_anytime is 0, new players can only join if
 set g_lms_join_anytime 1       "1: new players can join, but get same amount of lives as the worst player; 0: new players can only join if the worst active player has (fraglimit - g_lms_last_join) or more lives"
 set g_lms_items 0 "enables items to spawn, weaponarena still disables weapons and ammo (to force all items to spawn, use g_pickup_items 1 instead)"
 set g_lms_weaponarena "most_available" "starting weapons - takes the same options as g_weaponarena"
+set g_lms_forfeit_min_match_time 30 "end the match early if at least this many seconds have elapsed and less than 2 players are playing due to forfeits"
 
 
 // =========
index ffc7768e24cecbbab341ad9f2cc59d8ed605bb0e..c965e7817dfbfab8fef417d38c3cdb41d73eb1e1 100644 (file)
@@ -7,6 +7,7 @@
 #include <server/items/items.qh>
 
 int autocvar_g_lms_extra_lives;
+float autocvar_g_lms_forfeit_min_match_time;
 bool autocvar_g_lms_join_anytime;
 int autocvar_g_lms_last_join;
 bool autocvar_g_lms_items;
@@ -43,10 +44,16 @@ int WinningCondition_LMS()
 
        entity first_player = NULL;
        int totalplayers = 0;
-       FOREACH_CLIENT(IS_PLAYER(it) && it.frags == FRAGS_PLAYER, {
-               if (!totalplayers)
-                       first_player = it;
-               ++totalplayers;
+       int totalplayed = 0;
+       FOREACH_CLIENT(true, {
+               if (IS_PLAYER(it) && it.frags == FRAGS_PLAYER)
+               {
+                       if (!totalplayers)
+                               first_player = it;
+                       ++totalplayers;
+               }
+               else if (GameRules_scoring_add(it, LMS_RANK, 0))
+                       ++totalplayed;
        });
 
        if (totalplayers)
@@ -74,6 +81,11 @@ int WinningCondition_LMS()
 
                        if (LMS_NewPlayerLives())
                        {
+                               if (totalplayed && game_starttime > 0 && time > game_starttime + autocvar_g_lms_forfeit_min_match_time) // give players time to join
+                               {
+                                       GameRules_scoring_add(first_player, LMS_RANK, 1);
+                                       return WINNING_YES;
+                               }
                                // game still running (that is, nobody got removed from the game by a frag yet)? then continue
                                return WINNING_NO;
                        }
@@ -91,6 +103,11 @@ int WinningCondition_LMS()
                // nobody is playing at all...
                if (LMS_NewPlayerLives())
                {
+                       if (totalplayed && game_starttime > 0 && time > game_starttime + autocvar_g_lms_forfeit_min_match_time) // give players time to join
+                       {
+                               ClearWinners();
+                               return WINNING_YES;
+                       }
                        // wait for players...
                }
                else