From: Mario Date: Sun, 21 Aug 2016 14:32:17 +0000 (+1000) Subject: Some more intrusive lists X-Git-Tag: xonotic-v0.8.2~663^2~19 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=edeaa66721b27dd56891a09daa74fd8daadf345f;p=xonotic%2Fxonotic-data.pk3dir.git Some more intrusive lists --- diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index fb9acbd97..374e65e1e 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -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(); } diff --git a/qcsrc/server/mutators/mutator/gamemode_assault.qc b/qcsrc/server/mutators/mutator/gamemode_assault.qc index 5814e7cb7..3dfd5d1d3 100644 --- a/qcsrc/server/mutators/mutator/gamemode_assault.qc +++ b/qcsrc/server/mutators/mutator/gamemode_assault.qc @@ -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; diff --git a/qcsrc/server/mutators/mutator/gamemode_cts.qc b/qcsrc/server/mutators/mutator/gamemode_cts.qc index 33030f2f9..4cd8e8767 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qc +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qc @@ -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); diff --git a/qcsrc/server/mutators/mutator/gamemode_race.qc b/qcsrc/server/mutators/mutator/gamemode_race.qc index 756d975b1..b791a69dc 100644 --- a/qcsrc/server/mutators/mutator/gamemode_race.qc +++ b/qcsrc/server/mutators/mutator/gamemode_race.qc @@ -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); } diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index fc5ba4d61..8fc38aa2c 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -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 diff --git a/qcsrc/server/race.qh b/qcsrc/server/race.qh index 6360b0ae5..6419afb73 100644 --- a/qcsrc/server/race.qh +++ b/qcsrc/server/race.qh @@ -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);