]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc
LMS: don't show "X has no more lives left" message for a player that disconnects
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / lms / sv_lms.qc
index ffbecf1b3df6abcb68c558b4e1c9336713225328..338fb89dc2101756c3643b899d4b53a2a6ec4298 100644 (file)
@@ -36,16 +36,16 @@ void ClearWinners();
 int WinningCondition_LMS()
 {
        entity first_player = NULL;
-       int total_players = 0;
+       int totalplayers = 0;
        FOREACH_CLIENT(IS_PLAYER(it), {
-               if (!total_players)
+               if (!totalplayers)
                        first_player = it;
-               ++total_players;
+               ++totalplayers;
        });
 
-       if (total_players)
+       if (totalplayers)
        {
-               if (total_players > 1)
+               if (totalplayers > 1)
                {
                        // two or more active players - continue with the game
 
@@ -129,6 +129,14 @@ MUTATOR_HOOKFUNCTION(lms, reset_map_players)
        });
 }
 
+// FIXME add support for sv_ready_restart_after_countdown
+// that is find a way to respawn/reset players IN GAME without setting lives to 0
+MUTATOR_HOOKFUNCTION(lms, ReadLevelCvars)
+{
+       // incompatible
+       sv_ready_restart_after_countdown = 0;
+}
+
 MUTATOR_HOOKFUNCTION(lms, PutClientInServer)
 {
        entity player = M_ARGV(0, entity);
@@ -178,7 +186,7 @@ void lms_RemovePlayer(entity player)
        {
                int pl_cnt = 0;
                FOREACH_CLIENT(IS_PLAYER(it), { pl_cnt++; });
-               if (player.lms_spectate_warning != 2)
+               if (player.lms_spectate_warning < 2)
                {
                        if(IS_BOT_CLIENT(player))
                                bot_clear(player);
@@ -216,8 +224,8 @@ void lms_RemovePlayer(entity 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);
@@ -227,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);
 }
 
@@ -252,6 +263,7 @@ MUTATOR_HOOKFUNCTION(lms, ClientConnect)
        }
 }
 
+// FIXME LMS doesn't allow clients to spectate due to its particular implementation
 MUTATOR_HOOKFUNCTION(lms, AutoJoinOnConnection)
 {
        if(autocvar_g_campaign)