]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator/gamemode_race.qc
Use IS_DEAD everywhere
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_race.qc
index 4982a4a8f6a3bdffb635f25387b0ea7d3ba374de..9d2dcbf4aa22b0ad62217dd059d62981f06eda68 100644 (file)
@@ -10,9 +10,9 @@ REGISTER_MUTATOR(rc, false)
        {
                if (time > 1) // game loads at time 1
                        error("This is a game type and it cannot be added at runtime.");
-               race_Initialize();
 
                rc_SetLimits();
+               race_Initialize();
        }
 
        MUTATOR_ONROLLBACK_OR_REMOVE
@@ -42,7 +42,7 @@ const float SP_RACE_FASTEST = 6;
 
 #ifdef IMPLEMENTATION
 
-#include "../../race.qh"
+#include <server/race.qh>
 
 #define autocvar_g_race_laps_limit cvar("g_race_laps_limit")
 float autocvar_g_race_qualifying_timelimit;
@@ -53,7 +53,7 @@ int autocvar_g_race_teams;
 .float race_checkpoint;
 void havocbot_role_race()
 {SELFPARAM();
-       if(self.deadflag != DEAD_NO)
+       if(IS_DEAD(self))
                return;
 
        entity e;
@@ -110,17 +110,15 @@ void race_EventLog(string mode, entity actor) // use an alias for easy changing
 float WinningCondition_Race(float fraglimit)
 {
        float wc;
-       entity p;
        float n, c;
 
        n = 0;
        c = 0;
-       FOR_EACH_PLAYER(p)
-       {
+       FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
                ++n;
-               if(p.race_completed)
+               if(it.race_completed)
                        ++c;
-       }
+       ));
        if(n && (n == c))
                return WINNING_YES;
        wc = WinningCondition_Scores(fraglimit, 0);
@@ -228,17 +226,15 @@ MUTATOR_HOOKFUNCTION(rc, reset_map_global)
        race_ClearRecords();
        PlayerScore_Sort(race_place, 0, 1, 0);
 
-       entity e;
-       FOR_EACH_CLIENT(e)
-       {
-               if(e.race_place)
+       FOREACH_CLIENT(true, LAMBDA(
+               if(it.race_place)
                {
-                       s = PlayerScore_Add(e, SP_RACE_FASTEST, 0);
+                       s = PlayerScore_Add(it, SP_RACE_FASTEST, 0);
                        if(!s)
-                               e.race_place = 0;
+                               it.race_place = 0;
                }
-               race_EventLog(ftos(e.race_place), e);
-       }
+               race_EventLog(ftos(it.race_place), it);
+       ));
 
        if(g_race_qualifying == 2)
        {
@@ -253,16 +249,6 @@ MUTATOR_HOOKFUNCTION(rc, reset_map_global)
        return false;
 }
 
-MUTATOR_HOOKFUNCTION(rc, PlayerPreThink)
-{SELFPARAM();
-       if(IS_SPEC(self) || IS_OBSERVER(self))
-       if(g_race_qualifying)
-       if(msg_entity.enemy.race_laptime)
-               race_SendNextCheckpoint(msg_entity.enemy, 1);
-
-       return false;
-}
-
 MUTATOR_HOOKFUNCTION(rc, ClientConnect)
 {SELFPARAM();
        race_PreparePlayer();
@@ -443,7 +429,7 @@ MUTATOR_HOOKFUNCTION(rc, CheckRules_World)
        {
                if(!g_race_qualifying)
                {
-                       ret_float = WinningCondition_QualifyingThenRace(fraglimit);
+                       ret_float = WinningCondition_QualifyingThenRace(checkrules_fraglimit);
                        return true;
                }
                else if(g_race_qualifying == 2)