]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Some more intrusive lists
authorMario <mario@smbclan.net>
Sun, 21 Aug 2016 14:32:17 +0000 (00:32 +1000)
committerMario <mario@smbclan.net>
Sun, 21 Aug 2016 14:32:17 +0000 (00:32 +1000)
qcsrc/server/defs.qh
qcsrc/server/mutators/mutator/gamemode_assault.qc
qcsrc/server/mutators/mutator/gamemode_cts.qc
qcsrc/server/mutators/mutator/gamemode_race.qc
qcsrc/server/race.qc
qcsrc/server/race.qh

index fb9acbd97711ba829e45debb8215d376f1a951d8..374e65e1edeb9f7af23e7953638e4aad3f0ac977 100644 (file)
@@ -454,3 +454,9 @@ STATIC_INIT(g_initforplayer) { g_initforplayer = IL_NEW(); }
 
 IntrusiveList g_clones;
 STATIC_INIT(g_clones) { g_clones = IL_NEW(); }
+
+IntrusiveList g_assault_destructibles;
+STATIC_INIT(g_assault_destructibles) { g_assault_destructibles = IL_NEW(); }
+
+IntrusiveList g_assault_objectivedecreasers;
+STATIC_INIT(g_assault_objectivedecreasers) { g_assault_objectivedecreasers = IL_NEW(); }
index 5814e7cb744e2c56ea3a6b257fa2adc76410c117..3dfd5d1d3a80672e946fc2c57cba2e22aaa18449 100644 (file)
@@ -10,13 +10,10 @@ void assault_objective_use(entity this, entity actor, entity trigger)
        //print("^2Activated objective ", this.targetname, "=", etos(this), "\n");
        //print("Activator is ", actor.classname, "\n");
 
-       for (entity e = NULL; (e = find(e, target, this.targetname)); )
+       IL_EACH(g_assault_objectivedecreasers, it.target == this.targetname,
        {
-               if (e.classname == "target_objective_decrease")
-               {
-                       target_objective_decrease_activate(e);
-               }
-       }
+               target_objective_decrease_activate(it);
+       });
 }
 
 vector target_objective_spawn_evalfunc(entity this, entity player, entity spot, vector current)
@@ -297,6 +294,7 @@ spawnfunc(target_objective_decrease)
        if (!g_assault) { delete(this); return; }
 
        this.classname = "target_objective_decrease";
+       IL_PUSH(g_assault_objectivedecreasers, this);
 
        if(!this.dmg)
                this.dmg = 101;
@@ -317,6 +315,7 @@ spawnfunc(func_assault_destructible)
 
        this.spawnflags = 3;
        this.classname = "func_assault_destructible";
+       IL_PUSH(g_assault_destructibles, this);
 
        if(assault_attacker_team == NUM_TEAM_1)
                this.team = NUM_TEAM_2;
@@ -364,17 +363,15 @@ spawnfunc(target_assault_roundstart)
 // legacy bot code
 void havocbot_goalrating_ast_targets(entity this, float ratingscale)
 {
-       FOREACH_ENTITY_CLASS("func_assault_destructible", it.bot_attack,
+       IL_EACH(g_assault_destructibles, it.bot_attack,
        {
                if (it.target == "")
                        continue;
 
                bool found = false;
-               FOREACH_ENTITY_STRING(targetname, it.target,
+               entity destr = it;
+               IL_EACH(g_assault_objectivedecreasers, it.targetname == destr.target,
                {
-                       if(it.classname != "target_objective_decrease")
-                               continue;
-
                        if(it.enemy.health > 0 && it.enemy.health < ASSAULT_VALUE_INACTIVE)
                        {
                                found = true;
index 33030f2f9cce0057f094d1b173f6959f63f74ffe..4cd8e8767e5f163b58efd886f7e320c8dd66cd71 100644 (file)
@@ -18,7 +18,7 @@ void havocbot_role_cts(entity this)
                this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
 
-               FOREACH_ENTITY_CLASS("trigger_race_checkpoint", true,
+               IL_EACH(g_racecheckpoints, true,
                {
                        if(it.cnt == this.race_checkpoint)
                                navigation_routerating(this, it, 1000000, 5000);
index 756d975b156ad197febcbe333455f85d9eaf246f..b791a69dce9830cc42b45743501dce63bbc80ff1 100644 (file)
@@ -14,23 +14,22 @@ void havocbot_role_race(entity this)
        if(IS_DEAD(this))
                return;
 
-       entity e;
        if (this.bot_strategytime < time)
        {
                this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
 
-               for(e = NULL; (e = find(e, classname, "trigger_race_checkpoint")) != NULL; )
+               IL_EACH(g_racecheckpoints, true,
                {
-                       if(e.cnt == this.race_checkpoint)
+                       if(it.cnt == this.race_checkpoint)
                        {
-                               navigation_routerating(this, e, 1000000, 5000);
+                               navigation_routerating(this, it, 1000000, 5000);
                        }
                        else if(this.race_checkpoint == -1)
                        {
-                               navigation_routerating(this, e, 1000000, 5000);
+                               navigation_routerating(this, it, 1000000, 5000);
                        }
-               }
+               });
 
                navigation_goalrating_end(this);
        }
index fc5ba4d61b6dc50866360fb4e3a6cadb05cfe35e..8fc38aa2c5e028ed1d44f8cd5f3b7128454ddda9 100644 (file)
@@ -832,15 +832,14 @@ void trigger_race_checkpoint_verify(entity this)
                                race_timed_checkpoint = 255;
                        }
                } else {
-                       for (entity cp = NULL; (cp = find(cp, classname, "trigger_race_checkpoint")); ) {
-                               if (cp.sprite) {
-                                       if (cp.race_checkpoint == 0) {
-                                               WaypointSprite_UpdateSprites(cp.sprite, WP_RaceStart, WP_Null, WP_Null);
-                    } else if (cp.race_checkpoint == race_timed_checkpoint) {
-                                               WaypointSprite_UpdateSprites(cp.sprite, WP_RaceFinish, WP_Null, WP_Null);
-                    }
+                       IL_EACH(g_racecheckpoints, it.sprite,
+                       {
+                               if (it.race_checkpoint == 0) {
+                                       WaypointSprite_UpdateSprites(it.sprite, WP_RaceStart, WP_Null, WP_Null);
+                } else if (it.race_checkpoint == race_timed_checkpoint) {
+                                       WaypointSprite_UpdateSprites(it.sprite, WP_RaceFinish, WP_Null, WP_Null);
                                }
-            }
+            });
                }
        }
 
@@ -946,6 +945,8 @@ spawnfunc(trigger_race_checkpoint)
        this.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
        this.spawn_evalfunc = trigger_race_checkpoint_spawn_evalfunc;
 
+       IL_PUSH(g_racecheckpoints, this);
+
        InitializeEntity(this, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET);
 }
 
@@ -1142,7 +1143,7 @@ float race_GetFractionalLapCount(entity e)
 
        vector o0, o1;
        float bestfraction, fraction;
-       entity lastcp, cp0, cp1;
+       entity lastcp;
        float nextcpindex, lastcpindex;
 
        nextcpindex = max(e.race_checkpoint, 0);
@@ -1153,26 +1154,26 @@ float race_GetFractionalLapCount(entity e)
                return l; // finish
 
        bestfraction = 1;
-       for(cp0 = NULL; (cp0 = find(cp0, classname, "trigger_race_checkpoint")); )
+       IL_EACH(g_racecheckpoints, true,
        {
-               if(cp0.race_checkpoint != lastcpindex)
+               if(it.race_checkpoint != lastcpindex)
                        continue;
                if(lastcp)
-                       if(cp0 != lastcp)
+                       if(it != lastcp)
                                continue;
-               o0 = (cp0.absmin + cp0.absmax) * 0.5;
-               for(cp1 = NULL; (cp1 = find(cp1, classname, "trigger_race_checkpoint")); )
+               o0 = (it.absmin + it.absmax) * 0.5;
+               IL_EACH(g_racecheckpoints, true,
                {
-                       if(cp1.race_checkpoint != nextcpindex)
+                       if(it.race_checkpoint != nextcpindex)
                                continue;
-                       o1 = (cp1.absmin + cp1.absmax) * 0.5;
+                       o1 = (it.absmin + it.absmax) * 0.5;
                        if(o0 == o1)
                                continue;
                        fraction = bound(0.0001, vlen(e.origin - o1) / vlen(o0 - o1), 1);
                        if(fraction < bestfraction)
                                bestfraction = fraction;
-               }
-       }
+               });
+       });
 
        // we are at CP "nextcpindex - bestfraction"
        // race_timed_checkpoint == 4: then nextcp==4 means 0.9999x, nextcp==0 means 0.0000x
index 6360b0ae5aba535b3727c36110ac5a85e099cce1..6419afb737690604dace62c681cabe9da377f4e7 100644 (file)
@@ -29,6 +29,9 @@ float race_completing;
 .float race_respawn_checkpoint;
 .entity race_respawn_spotref; // try THIS spawn in case you respawn
 
+IntrusiveList g_racecheckpoints;
+STATIC_INIT(g_racecheckpoints) { g_racecheckpoints = IL_NEW(); }
+
 // definitions for functions used outside race.qc
 float race_PreviousCheckpoint(float f);
 float race_NextCheckpoint(float f);