From: Mario Date: Sat, 20 May 2017 10:16:36 +0000 (+1000) Subject: Add an intrusive list for seeker tags and fix seeker tracing to world origin when... X-Git-Tag: xonotic-v0.8.5~2766 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a69a356bfeb5ce22fb3899ccbcade2d43bcf969a;p=xonotic%2Fxonotic-data.pk3dir.git Add an intrusive list for seeker tags and fix seeker tracing to world origin when attacking --- diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index 0f4891837..4b5ccab4a 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -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) { diff --git a/qcsrc/common/weapons/weapon/seeker.qh b/qcsrc/common/weapons/weapon/seeker.qh index 6f70f09be..5a1a73f82 100644 --- a/qcsrc/common/weapons/weapon/seeker.qh +++ b/qcsrc/common/weapons/weapon/seeker.qh @@ -1 +1,6 @@ #pragma once + +#ifdef SVQC +IntrusiveList g_seeker_trackers; +STATIC_INIT(g_seeker_trackers) { g_seeker_trackers = IL_NEW(); } +#endif diff --git a/qcsrc/server/g_subs.qc b/qcsrc/server/g_subs.qc index e8e50c718..33f471eb4 100644 --- a/qcsrc/server/g_subs.qc +++ b/qcsrc/server/g_subs.qc @@ -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;