]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add an intrusive list for seeker tags and fix seeker tracing to world origin when...
authorMario <mario@smbclan.net>
Sat, 20 May 2017 10:16:36 +0000 (20:16 +1000)
committerMario <mario@smbclan.net>
Sat, 20 May 2017 10:16:36 +0000 (20:16 +1000)
qcsrc/common/weapons/weapon/seeker.qc
qcsrc/common/weapons/weapon/seeker.qh
qcsrc/server/g_subs.qc

index 0f4891837fb492b34f06a91f01142cd483c4bc51..4b5ccab4a55a5f371c8475ecf032c7321c834cab 100644 (file)
@@ -395,33 +395,36 @@ void W_Seeker_Fire_Flac(Weapon thiswep, entity actor, .entity weaponentity)
 // ============================
 entity W_Seeker_Tagged_Info(entity isowner, .entity weaponentity, entity istarget)
 {
-       entity tag;
-       for(tag = NULL; (tag = find(tag, classname, "tag_tracker")); )
-               if((tag.realowner == isowner) && (tag.tag_target == istarget) && (tag.weaponentity_fld == weaponentity))
-                       return tag;
+       IL_EACH(g_seeker_trackers, it.classname == "tag_tracker" && it.realowner == isowner,
+       {
+               if(it.tag_target == istarget && it.weaponentity_fld == weaponentity)
+                       return it;
+       });
 
        return NULL;
 }
 
 void W_Seeker_Attack(entity actor, .entity weaponentity)
 {
-       entity tracker, closest_target;
+       entity closest_target = NULL;
 
-       closest_target = NULL;
-       for(tracker = NULL; (tracker = find(tracker, classname, "tag_tracker")); ) if (tracker.realowner == actor)
+       IL_EACH(g_seeker_trackers, it.classname == "tag_tracker" && it.realowner == actor,
        {
                if(closest_target)
                {
-                       if(vlen2(actor.origin - tracker.tag_target.origin) < vlen2(actor.origin - closest_target.origin))
-                               closest_target = tracker.tag_target;
+                       if(vlen2(actor.origin - it.tag_target.origin) < vlen2(actor.origin - closest_target.origin))
+                               closest_target = it.tag_target;
                }
                else
-                       closest_target = tracker.tag_target;
-       }
+                       closest_target = it.tag_target;
+       });
 
-       traceline(actor.origin + actor.view_ofs, closest_target.origin, MOVE_NOMONSTERS, actor);
-       if((!closest_target) || ((trace_fraction < 1) && (trace_ent != closest_target)))
-               closest_target = NULL;
+       if(closest_target)
+       {
+               traceline(actor.origin + actor.view_ofs, closest_target.origin, MOVE_NOMONSTERS, actor);
+               if(!closest_target || (trace_fraction < 1 && trace_ent != closest_target))
+                       closest_target = NULL;
+       }
 
        W_Seeker_Fire_Missile(WEP_SEEKER, actor, weaponentity, '0 0 0', closest_target);
 }
@@ -545,6 +548,7 @@ void W_Seeker_Tag_Touch(entity this, entity toucher)
                        e.cnt         = WEP_CVAR(seeker, missile_count);
                        e.owner       = this.owner;
                        e.realowner   = this.realowner;
+                       IL_PUSH(g_seeker_trackers, e);
 
                        if(WEP_CVAR(seeker, type) == 1)
                        {
index 6f70f09beec2219624baeca92e2cd7deaa104fb4..5a1a73f824d5c60b2902f503bdef9dd30fb4740d 100644 (file)
@@ -1 +1,6 @@
 #pragma once
+
+#ifdef SVQC
+IntrusiveList g_seeker_trackers;
+STATIC_INIT(g_seeker_trackers) { g_seeker_trackers = IL_NEW(); }
+#endif
index e8e50c7184134148406c439b092c96e2b5161137..33f471eb488cf97cde02e41d86e6390c03e6a7c0 100644 (file)
@@ -204,26 +204,22 @@ Ripped from DPMod
 */
 vector findbetterlocation (vector org, float mindist)
 {
-       vector  loc;
-       vector vec;
-       float c, h;
-
-       vec = mindist * '1 0 0';
-       c = 0;
+       vector vec = mindist * '1 0 0';
+       int c = 0;
        while (c < 6)
        {
                traceline (org, org + vec, true, NULL);
                vec = vec * -1;
                if (trace_fraction < 1)
                {
-                       loc = trace_endpos;
+                       vector loc = trace_endpos;
                        traceline (loc, loc + vec, true, NULL);
                        if (trace_fraction >= 1)
                                org = loc + vec;
                }
                if (c & 1)
                {
-                       h = vec.y;
+                       float h = vec.y;
                        vec.y = vec.x;
                        vec.x = vec.z;
                        vec.z = h;