]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Simplify / clean up WinningCondition_LMS
authorterencehill <piuntn@gmail.com>
Wed, 31 Jan 2018 15:10:15 +0000 (16:10 +0100)
committerterencehill <piuntn@gmail.com>
Wed, 31 Jan 2018 15:10:15 +0000 (16:10 +0100)
qcsrc/server/mutators/mutator/gamemode_lms.qc

index cd8fb390d4726744ee117bbad21fffe5a2fcaa62..c281424a076d5688ac6fac9a936ca22f9501ba27 100644 (file)
@@ -35,23 +35,17 @@ void ClearWinners();
 // limit.
 int WinningCondition_LMS()
 {
-       entity head, head2;
-       bool have_player = false;
-       bool have_players = false;
-
-       int l = LMS_NewPlayerLives();
-
-       head = find(NULL, classname, STR_PLAYER);
-       if(head)
-               have_player = true;
-       head2 = find(head, classname, STR_PLAYER);
-       if(head2)
-               have_players = true;
+       entity first_player = NULL;
+       int total_players = 0;
+       FOREACH_CLIENT(IS_PLAYER(it), {
+               if (!total_players)
+                       first_player = it;
+               ++total_players;
+       });
 
-       if(have_player)
+       if (total_players)
        {
-               // we have at least one player
-               if(have_players)
+               if (total_players > 1)
                {
                        // two or more active players - continue with the game
                }
@@ -62,7 +56,7 @@ int WinningCondition_LMS()
                        ClearWinners();
                        SetWinners(winning, 0); // NOTE: exactly one player is still "player", so this works out
 
-                       if(l)
+                       if (LMS_NewPlayerLives())
                        {
                                // game still running (that is, nobody got removed from the game by a frag yet)? then continue
                                return WINNING_NO;
@@ -71,7 +65,7 @@ int WinningCondition_LMS()
                        {
                                // a winner!
                                // and assign him his first place
-                               GameRules_scoring_add(head, LMS_RANK, 1);
+                               GameRules_scoring_add(first_player, LMS_RANK, 1);
                                if(warmup_stage)
                                        return WINNING_NO;
                                else
@@ -82,7 +76,7 @@ int WinningCondition_LMS()
        else
        {
                // nobody is playing at all...
-               if(l)
+               if (LMS_NewPlayerLives())
                {
                        // wait for players...
                }