]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Document and slightly refactor defrag_waypointsprites()
authorbones_was_here <bones_was_here@xa.org.au>
Wed, 21 Jul 2021 23:12:15 +0000 (09:12 +1000)
committerbones_was_here <bones_was_here@xa.org.au>
Sat, 24 Jul 2021 09:26:24 +0000 (19:26 +1000)
qcsrc/server/race.qc

index 715d00d46921df81756e1d6209d4b3a91bc5930c..5ccb607e926ce13362fc2d11e4c1e444b7bdeb01 100644 (file)
@@ -841,26 +841,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);
        }
 }