Merge branch 'master' into martin-t/limit
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_world.qc
index fd8631f31a8657e82d664149f6ba16c83b729b7d..bf6fddf5cf3db2b75aa7b5be3baa1d05f9d22cb0 100644 (file)
@@ -1710,8 +1710,6 @@ float secondscore;
 int fragsleft_last;
 float WinningCondition_Scores(float limit, float leadlimit)
 {
 int fragsleft_last;
 float WinningCondition_Scores(float limit, float leadlimit)
 {
-       float limitreached;
-
        // TODO make everything use THIS winning condition (except LMS)
        WinningConditionHelper(NULL);
 
        // TODO make everything use THIS winning condition (except LMS)
        WinningConditionHelper(NULL);
 
@@ -1783,24 +1781,17 @@ float WinningCondition_Scores(float limit, float leadlimit)
                }
        }
 
                }
        }
 
-       limitreached = false;
-       if (limit && WinningConditionHelper_topscore >= limit)
-               limitreached = true;
-       if(leadlimit)
-       {
-               float leadlimitreached;
-               leadlimitreached = (WinningConditionHelper_topscore - WinningConditionHelper_secondscore >= leadlimit);
-               if(autocvar_leadlimit_and_fraglimit)
-                       limitreached = (limitreached && leadlimitreached);
-               else
-                       limitreached = (limitreached || leadlimitreached);
-       }
+       bool fraglimit_reached = (limit && WinningConditionHelper_topscore >= limit);
+       bool leadlimit_reached = (WinningConditionHelper_topscore - WinningConditionHelper_secondscore >= leadlimit);
 
 
-       if(limit)
-               game_completion_ratio = max(game_completion_ratio, bound(0, WinningConditionHelper_topscore / limit, 1));
+       bool limit_reached;
+       if(autocvar_leadlimit_and_fraglimit)
+               limit_reached = (fraglimit_reached && leadlimit_reached);
+       else
+               limit_reached = (fraglimit_reached || leadlimit_reached);
 
        return GetWinningCode(
 
        return GetWinningCode(
-               WinningConditionHelper_topscore && limitreached,
+               WinningConditionHelper_topscore && limit_reached,
                WinningConditionHelper_equality
        );
 }
                WinningConditionHelper_equality
        );
 }
@@ -1891,10 +1882,6 @@ Exit deathmatch games upon conditions
 */
 void CheckRules_World()
 {
 */
 void CheckRules_World()
 {
-       float timelimit;
-       float fraglimit;
-       float leadlimit;
-
        VoteThink();
        MapVote_Think();
 
        VoteThink();
        MapVote_Think();
 
@@ -1909,9 +1896,10 @@ void CheckRules_World()
                return;
        }
 
                return;
        }
 
-       timelimit = autocvar_timelimit * 60;
-       fraglimit = autocvar_fraglimit;
-       leadlimit = autocvar_leadlimit;
+       float timelimit = autocvar_timelimit * 60;
+       float fraglimit = autocvar_fraglimit;
+       float leadlimit = autocvar_leadlimit;
+       if (leadlimit < 0) leadlimit = 0;
 
        if(warmup_stage || time <= game_starttime) // NOTE: this is <= to prevent problems in the very tic where the game starts
        {
 
        if(warmup_stage || time <= game_starttime) // NOTE: this is <= to prevent problems in the very tic where the game starts
        {
@@ -1936,11 +1924,6 @@ void CheckRules_World()
        float wantovertime;
        wantovertime = 0;
 
        float wantovertime;
        wantovertime = 0;
 
-       if(timelimit > game_starttime)
-               game_completion_ratio = (time - game_starttime) / (timelimit - game_starttime);
-       else
-               game_completion_ratio = 0;
-
        if(checkrules_suddendeathend)
        {
                if(!checkrules_suddendeathwarning)
        if(checkrules_suddendeathend)
        {
                if(!checkrules_suddendeathwarning)