]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc
Properly implement checks to end the game right when a player dies (old hacky method...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / lms / sv_lms.qc
index b10cffb74998bb7c8e09d9fef3e449529db93086..58582d290d5c65c36523ad72110626c0b1dcc8f9 100644 (file)
@@ -37,7 +37,7 @@ int WinningCondition_LMS()
 {
        entity first_player = NULL;
        int totalplayers = 0;
-       FOREACH_CLIENT(IS_PLAYER(it), {
+       FOREACH_CLIENT(IS_PLAYER(it) && it.frags != FRAGS_LMS_LOSER, {
                if (!totalplayers)
                        first_player = it;
                ++totalplayers;
@@ -185,8 +185,10 @@ void lms_RemovePlayer(entity player)
        if (!player_rank)
        {
                int pl_cnt = 0;
-               FOREACH_CLIENT(IS_PLAYER(it), { pl_cnt++; });
-               if (player.lms_spectate_warning != 2)
+               FOREACH_CLIENT(IS_PLAYER(it) && it.frags != FRAGS_LMS_LOSER, {
+                       pl_cnt++;
+               });
+               if (player.lms_spectate_warning < 2)
                {
                        if(IS_BOT_CLIENT(player))
                                bot_clear(player);
@@ -220,12 +222,10 @@ void lms_RemovePlayer(entity player)
                        player.frags = FRAGS_LMS_LOSER;
                        TRANSMUTE(Observer, player);
                }
-               if (pl_cnt == 2 && !warmup_stage) // a player is forfeiting leaving only one player
-                       lms_lowest_lives = 0; // end the game now!
        }
 
-       if(CS(player).killcount != FRAGS_SPECTATOR)
-               if(GameRules_scoring_add(player, LMS_RANK, 0) > 0 && player.lms_spectate_warning != 2)
+       if (CS(player).killcount != FRAGS_SPECTATOR && player.lms_spectate_warning < 3)
+               if (GameRules_scoring_add(player, LMS_RANK, 0) > 0 && player.lms_spectate_warning < 2)
                        Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_LMS_NOLIVES, player.netname);
                else
                        Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_LMS_FORFEIT, player.netname);
@@ -235,6 +235,9 @@ MUTATOR_HOOKFUNCTION(lms, ClientDisconnect)
 {
        entity player = M_ARGV(0, entity);
 
+       // no further message other than the disconnect message
+       player.lms_spectate_warning = 3;
+
        lms_RemovePlayer(player);
 }
 
@@ -302,7 +305,9 @@ MUTATOR_HOOKFUNCTION(lms, GiveFragsForKill)
                if(tl <= 0)
                {
                        int pl_cnt = 0;
-                       FOREACH_CLIENT(IS_PLAYER(it), { pl_cnt++; });
+                       FOREACH_CLIENT(IS_PLAYER(it) && it.frags != FRAGS_LMS_LOSER, {
+                               pl_cnt++;
+                       });
                        if(IS_BOT_CLIENT(frag_target))
                                bot_clear(frag_target);
                        frag_target.frags = FRAGS_LMS_LOSER;