]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/race.qc
Merge branch 'bones_was_here/subtlebloom' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / race.qc
index 715d00d46921df81756e1d6209d4b3a91bc5930c..4ecda0a9a09732b0411f164b1d4e3c175a729005 100644 (file)
@@ -8,6 +8,7 @@
 #include <common/mutators/mutator/waypoints/waypointsprites.qh>
 #include <common/net_linked.qh>
 #include <common/notifications/all.qh>
+#include <common/playerstats.qh>
 #include <common/state.qh>
 #include <common/stats.qh>
 #include <common/vehicles/sv_vehicles.qh>
@@ -474,8 +475,6 @@ void race_deleteTime(string map, float pos)
 
 void race_SendTime(entity e, float cp, float t, float tvalid)
 {
-       float snew, l;
-
        if(g_race_qualifying)
                t += e.race_penalty_accumulator;
 
@@ -485,23 +484,15 @@ void race_SendTime(entity e, float cp, float t, float tvalid)
        if(cp == race_timed_checkpoint) // finish line
        if (!CS(e).race_completed)
        {
-               float s;
-               if(g_race_qualifying)
-               {
-                       s = GameRules_scoring_add(e, RACE_FASTEST, 0);
-                       if(!s || t < s)
-                               GameRules_scoring_add(e, RACE_FASTEST, t - s);
-               }
-               else
+               int s = GameRules_scoring_add(e, RACE_FASTEST, 0);
+               if(!s || t < s)
+                       GameRules_scoring_add(e, RACE_FASTEST, t - s);
+               if(!g_race_qualifying)
                {
-                       s = GameRules_scoring_add(e, RACE_FASTEST, 0);
-                       if(!s || t < s)
-                               GameRules_scoring_add(e, RACE_FASTEST, t - s);
-
                        s = GameRules_scoring_add(e, RACE_TIME, 0);
-                       snew = TIME_ENCODE(time - game_starttime);
+                       int snew = TIME_ENCODE(time - game_starttime);
                        GameRules_scoring_add(e, RACE_TIME, snew - s);
-                       l = GameRules_scoring_add_team(e, RACE_LAPS, 1);
+                       int l = GameRules_scoring_add_team(e, RACE_LAPS, 1);
 
                        if(autocvar_fraglimit)
                                if(l >= autocvar_fraglimit)
@@ -841,26 +832,26 @@ bool race_waypointsprite_visible_for_player(entity this, entity player, entity v
 
 void defrag_waypointsprites(entity targeted, entity checkpoint)
 {
-       for(entity t = findchain(target, targeted.targetname); t; t = t.chain)
-       {
-               if(t.modelindex)
-               {
-                       entity s = WP_RaceStart;
-
-                       if(checkpoint.classname == "target_checkpoint")
-                               s = WP_RaceCheckpoint;
-                       else if(checkpoint.classname == "target_stopTimer")
-                               s = WP_RaceFinish;
+       // bones_was_here: spawn a waypoint for every entity with a bmodel
+       // that directly or indirectly targets this checkpoint
+       // (anything a player could touch or shoot to activate this cp)
 
-                       vector o = (t.absmin + t.absmax) * 0.5;
-
-                       WaypointSprite_SpawnFixed(s, o, t, sprite, RADARICON_NONE);
+       entity s = WP_RaceCheckpoint;
+       if (checkpoint.classname == "target_startTimer")
+               s = WP_RaceStart;
+       else if (checkpoint.classname == "target_stopTimer")
+               s = WP_RaceFinish;
 
+       for (entity t = findchain(target, targeted.targetname); t; t = t.chain)
+       {
+               if (t.modelindex)
+               {
+                       WaypointSprite_SpawnFixed(s, (t.absmin + t.absmax) * 0.5, t, sprite, RADARICON_NONE);
                        t.sprite.realowner = checkpoint;
                        t.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
                }
 
-               if(t.targetname)
+               if (t.targetname)
                        defrag_waypointsprites(t, checkpoint);
        }
 }
@@ -871,7 +862,7 @@ void trigger_race_checkpoint_verify(entity this)
        if (have_verified) return;
        have_verified = true;
 
-       bool qual = g_race_qualifying;
+       int qual = g_race_qualifying;
 
        int pl_race_checkpoint = 0;
        int pl_race_place = 0;
@@ -881,7 +872,7 @@ void trigger_race_checkpoint_verify(entity this)
                        pl_race_checkpoint = race_NextCheckpoint(i);
 
                        // race only (middle of the race)
-                       g_race_qualifying = false;
+                       g_race_qualifying = 0;
                        pl_race_place = 0;
                        if (!Spawn_FilterOutBadSpots(this, findchain(classname, "info_player_deathmatch"), 0, false, true)) {
                                error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(pl_race_place), " (used for respawning in race) - bailing out"));