]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix match not ending when score limit reached
authorMario <mario@smbclan.net>
Sun, 25 Oct 2015 10:59:03 +0000 (20:59 +1000)
committerMario <mario@smbclan.net>
Sun, 25 Oct 2015 10:59:03 +0000 (20:59 +1000)
qcsrc/server/g_world.qc
qcsrc/server/mutators/mutator/gamemode_lms.qc

index c3932f3fb8062a3d254507537dfff60db4c30ff1..c706a1bdd5ad4288a89d81930af3ee97a743354b 100644 (file)
@@ -1709,85 +1709,6 @@ float WinningCondition_Assault()
        return status;
 }
 
-// LMS winning condition: game terminates if and only if there's at most one
-// one player who's living lives. Top two scores being equal cancels the time
-// limit.
-float WinningCondition_LMS()
-{
-       entity head, head2;
-       float have_player;
-       float have_players;
-       float l;
-
-       have_player = false;
-       have_players = false;
-       l = LMS_NewPlayerLives();
-
-       head = find(world, classname, "player");
-       if(head)
-               have_player = true;
-       head2 = find(head, classname, "player");
-       if(head2)
-               have_players = true;
-
-       if(have_player)
-       {
-               // we have at least one player
-               if(have_players)
-               {
-                       // two or more active players - continue with the game
-               }
-               else
-               {
-                       // exactly one player?
-
-                       ClearWinners();
-                       SetWinners(winning, 0); // NOTE: exactly one player is still "player", so this works out
-
-                       if(l)
-                       {
-                               // game still running (that is, nobody got removed from the game by a frag yet)? then continue
-                               return WINNING_NO;
-                       }
-                       else
-                       {
-                               // a winner!
-                               // and assign him his first place
-                               PlayerScore_Add(head, SP_LMS_RANK, 1);
-                               return WINNING_YES;
-                       }
-               }
-       }
-       else
-       {
-               // nobody is playing at all...
-               if(l)
-               {
-                       // wait for players...
-               }
-               else
-               {
-                       // SNAFU (maybe a draw game?)
-                       ClearWinners();
-                       LOG_TRACE("No players, ending game.\n");
-                       return WINNING_YES;
-               }
-       }
-
-       // When we get here, we have at least two players who are actually LIVING,
-       // now check if the top two players have equal score.
-       WinningConditionHelper();
-
-       ClearWinners();
-       if(WinningConditionHelper_winner)
-               WinningConditionHelper_winner.winning = true;
-       if(WinningConditionHelper_topscore == WinningConditionHelper_secondscore)
-               return WINNING_NEVER;
-
-       // Top two have different scores? Way to go for our beloved TIMELIMIT!
-       return WINNING_NO;
-}
-
 void ShuffleMaplist()
 {
        cvar_set("g_maplist", shufflewords(autocvar_g_maplist));
@@ -2092,11 +2013,11 @@ void CheckRules_World()
        int checkrules_status = WinningCondition_RanOutOfSpawns();
        if(checkrules_status == WINNING_YES)
                bprint("Hey! Someone ran out of spawns!\n");
-       else if(!MUTATOR_CALLHOOK(CheckRules_World, checkrules_status, timelimit, fraglimit))
+       else if(MUTATOR_CALLHOOK(CheckRules_World, checkrules_status, timelimit, fraglimit))
+               checkrules_status = ret_float;
+       else
                checkrules_status = WinningCondition_Scores(fraglimit, leadlimit);
 
-       checkrules_status = ret_float;
-
        if(checkrules_status == WINNING_STARTSUDDENDEATHOVERTIME)
        {
                checkrules_status = WINNING_NEVER;
index efab45e3fa817be6fbc02eb316167b47b7f8c34f..de11a6739e9b01415ffa34e9d532806641f152fe 100644 (file)
@@ -71,6 +71,85 @@ float LMS_NewPlayerLives()
        return bound(1, lms_lowest_lives, fl);
 }
 
+// LMS winning condition: game terminates if and only if there's at most one
+// one player who's living lives. Top two scores being equal cancels the time
+// limit.
+float WinningCondition_LMS()
+{
+       entity head, head2;
+       float have_player;
+       float have_players;
+       float l;
+
+       have_player = false;
+       have_players = false;
+       l = LMS_NewPlayerLives();
+
+       head = find(world, classname, "player");
+       if(head)
+               have_player = true;
+       head2 = find(head, classname, "player");
+       if(head2)
+               have_players = true;
+
+       if(have_player)
+       {
+               // we have at least one player
+               if(have_players)
+               {
+                       // two or more active players - continue with the game
+               }
+               else
+               {
+                       // exactly one player?
+
+                       ClearWinners();
+                       SetWinners(winning, 0); // NOTE: exactly one player is still "player", so this works out
+
+                       if(l)
+                       {
+                               // game still running (that is, nobody got removed from the game by a frag yet)? then continue
+                               return WINNING_NO;
+                       }
+                       else
+                       {
+                               // a winner!
+                               // and assign him his first place
+                               PlayerScore_Add(head, SP_LMS_RANK, 1);
+                               return WINNING_YES;
+                       }
+               }
+       }
+       else
+       {
+               // nobody is playing at all...
+               if(l)
+               {
+                       // wait for players...
+               }
+               else
+               {
+                       // SNAFU (maybe a draw game?)
+                       ClearWinners();
+                       LOG_TRACE("No players, ending game.\n");
+                       return WINNING_YES;
+               }
+       }
+
+       // When we get here, we have at least two players who are actually LIVING,
+       // now check if the top two players have equal score.
+       WinningConditionHelper();
+
+       ClearWinners();
+       if(WinningConditionHelper_winner)
+               WinningConditionHelper_winner.winning = true;
+       if(WinningConditionHelper_topscore == WinningConditionHelper_secondscore)
+               return WINNING_NEVER;
+
+       // Top two have different scores? Way to go for our beloved TIMELIMIT!
+       return WINNING_NO;
+}
+
 // mutator hooks
 MUTATOR_HOOKFUNCTION(lms, reset_map_global)
 {