]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move race winning conditions into race file
authorMario <mario@smbclan.net>
Tue, 24 Nov 2015 07:40:58 +0000 (17:40 +1000)
committerMario <mario@smbclan.net>
Tue, 24 Nov 2015 07:40:58 +0000 (17:40 +1000)
qcsrc/server/g_world.qc
qcsrc/server/mutators/mutator/gamemode_race.qc

index de20273b809a2b180c06afa77193df7e68467d34..1af638cf4e50f8ed43d70a9c469e6621a29da49d 100644 (file)
@@ -1770,46 +1770,6 @@ float WinningCondition_Scores(float limit, float leadlimit)
        );
 }
 
-float WinningCondition_Race(float fraglimit)
-{
-       float wc;
-       entity p;
-       float n, c;
-
-       n = 0;
-       c = 0;
-       FOR_EACH_PLAYER(p)
-       {
-               ++n;
-               if(p.race_completed)
-                       ++c;
-       }
-       if(n && (n == c))
-               return WINNING_YES;
-       wc = WinningCondition_Scores(fraglimit, 0);
-
-       // ALWAYS initiate overtime, unless EVERYONE has finished the race!
-       if(wc == WINNING_YES || wc == WINNING_STARTSUDDENDEATHOVERTIME)
-       // do NOT support equality when the laps are all raced!
-               return WINNING_STARTSUDDENDEATHOVERTIME;
-       else
-               return WINNING_NEVER;
-}
-
-float WinningCondition_QualifyingThenRace(float limit)
-{
-       float wc;
-       wc = WinningCondition_Scores(limit, 0);
-
-       // NEVER initiate overtime
-       if(wc == WINNING_YES || wc == WINNING_STARTSUDDENDEATHOVERTIME)
-       {
-               return WINNING_YES;
-       }
-
-       return wc;
-}
-
 float WinningCondition_RanOutOfSpawns()
 {
        entity head;
index 4fbafe03535a21da375d031d38aa3c8f37817021..4982a4a8f6a3bdffb635f25387b0ea7d3ba374de 100644 (file)
@@ -107,6 +107,46 @@ void race_EventLog(string mode, entity actor) // use an alias for easy changing
                GameLogEcho(strcat(":race:", mode, ":", ((actor != world) ? (strcat(":", ftos(actor.playerid))) : "")));
 }
 
+float WinningCondition_Race(float fraglimit)
+{
+       float wc;
+       entity p;
+       float n, c;
+
+       n = 0;
+       c = 0;
+       FOR_EACH_PLAYER(p)
+       {
+               ++n;
+               if(p.race_completed)
+                       ++c;
+       }
+       if(n && (n == c))
+               return WINNING_YES;
+       wc = WinningCondition_Scores(fraglimit, 0);
+
+       // ALWAYS initiate overtime, unless EVERYONE has finished the race!
+       if(wc == WINNING_YES || wc == WINNING_STARTSUDDENDEATHOVERTIME)
+       // do NOT support equality when the laps are all raced!
+               return WINNING_STARTSUDDENDEATHOVERTIME;
+       else
+               return WINNING_NEVER;
+}
+
+float WinningCondition_QualifyingThenRace(float limit)
+{
+       float wc;
+       wc = WinningCondition_Scores(limit, 0);
+
+       // NEVER initiate overtime
+       if(wc == WINNING_YES || wc == WINNING_STARTSUDDENDEATHOVERTIME)
+       {
+               return WINNING_YES;
+       }
+
+       return wc;
+}
+
 MUTATOR_HOOKFUNCTION(rc, PlayerPhysics)
 {SELFPARAM();
        self.race_movetime_frac += PHYS_INPUT_TIMELENGTH;
@@ -399,10 +439,18 @@ MUTATOR_HOOKFUNCTION(rc, FixClientCvars)
 
 MUTATOR_HOOKFUNCTION(rc, CheckRules_World)
 {
-       if(g_race_qualifying == 2 && checkrules_timelimit >= 0)
+       if(checkrules_timelimit >= 0)
        {
-               ret_float = WinningCondition_QualifyingThenRace(checkrules_fraglimit);
-               return true;
+               if(!g_race_qualifying)
+               {
+                       ret_float = WinningCondition_QualifyingThenRace(fraglimit);
+                       return true;
+               }
+               else if(g_race_qualifying == 2)
+               {
+                       ret_float = WinningCondition_QualifyingThenRace(checkrules_fraglimit);
+                       return true;
+               }
        }
 
        return false;