From: Mario Date: Wed, 24 Aug 2016 09:56:13 +0000 (+1000) Subject: Add an intrusive list for warpzones X-Git-Tag: xonotic-v0.8.2~474^2~6 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=21fdd7bdfc222142ffd047a200cb2bd214c5d511;p=xonotic%2Fxonotic-data.pk3dir.git Add an intrusive list for warpzones --- diff --git a/qcsrc/lib/warpzone/client.qc b/qcsrc/lib/warpzone/client.qc index bd0397f89..15a3ca4c3 100644 --- a/qcsrc/lib/warpzone/client.qc +++ b/qcsrc/lib/warpzone/client.qc @@ -35,6 +35,9 @@ NET_HANDLE(ENT_CLIENT_WARPZONE, bool isnew) } this.classname = "trigger_warpzone"; + if(isnew) + IL_PUSH(g_warpzones, this); + int f = ReadByte(); this.warpzone_isboxy = (f & 1); if(f & 4) diff --git a/qcsrc/lib/warpzone/common.qc b/qcsrc/lib/warpzone/common.qc index 90e3cd76c..5a3929e1e 100644 --- a/qcsrc/lib/warpzone/common.qc +++ b/qcsrc/lib/warpzone/common.qc @@ -154,31 +154,33 @@ float WarpZoneLib_BoxTouchesBrush(vector mi, vector ma, entity e, entity ig) entity WarpZone_Find(vector mi, vector ma) { // if we are near any warpzone planes - MOVE AWAY (work around nearclip) - entity e; if(!warpzone_warpzones_exist) return NULL; - for(e = NULL; (e = find(e, classname, "trigger_warpzone")); ) - if(WarpZoneLib_BoxTouchesBrush(mi, ma, e, NULL)) - return e; + IL_EACH(g_warpzones, WarpZoneLib_BoxTouchesBrush(mi, ma, it, NULL), + { + return it; + }); return NULL; } void WarpZone_MakeAllSolid() { - entity e; if(!warpzone_warpzones_exist) return; - for(e = NULL; (e = find(e, classname, "trigger_warpzone")); ) - e.solid = SOLID_BSP; + IL_EACH(g_warpzones, true, + { + it.solid = SOLID_BSP; + }); } void WarpZone_MakeAllOther() { - entity e; if(!warpzone_warpzones_exist) return; - for(e = NULL; (e = find(e, classname, "trigger_warpzone")); ) - e.solid = SOLID_TRIGGER; + IL_EACH(g_warpzones, true, + { + it.solid = SOLID_TRIGGER; + }); } void WarpZone_Trace_InitTransform() diff --git a/qcsrc/lib/warpzone/common.qh b/qcsrc/lib/warpzone/common.qh index 4bbbb853b..26c0e80fe 100644 --- a/qcsrc/lib/warpzone/common.qh +++ b/qcsrc/lib/warpzone/common.qh @@ -3,6 +3,9 @@ // uncomment this if your mod uses the roll angle in fixangle // #define KEEP_ROLL +IntrusiveList g_warpzones; +STATIC_INIT(g_warpzones) { g_warpzones = IL_NEW(); } + float warpzone_warpzones_exist; float warpzone_cameras_exist; diff --git a/qcsrc/lib/warpzone/server.qc b/qcsrc/lib/warpzone/server.qc index 34ea2610d..a3361a8d8 100644 --- a/qcsrc/lib/warpzone/server.qc +++ b/qcsrc/lib/warpzone/server.qc @@ -631,7 +631,6 @@ void WarpZone_InitStep_ClearTarget(entity this) this.enemy = NULL; } -entity warpzone_first; .entity warpzone_next; void WarpZone_InitStep_FindTarget(entity this) { float i; @@ -731,6 +730,8 @@ spawnfunc(trigger_warpzone) BITSET_ASSIGN(this.effects, EF_NODEPTHTEST); this.warpzone_next = warpzone_first; warpzone_first = this; + + IL_PUSH(g_warpzones, this); } spawnfunc(func_camera) { diff --git a/qcsrc/lib/warpzone/server.qh b/qcsrc/lib/warpzone/server.qh index b0c583d2d..4287ef60d 100644 --- a/qcsrc/lib/warpzone/server.qh +++ b/qcsrc/lib/warpzone/server.qh @@ -1,6 +1,8 @@ #pragma once #ifdef SVQC +entity warpzone_first; .entity warpzone_next; + void WarpZone_StartFrame(); float WarpZone_Projectile_Touch(entity this, entity toucher); diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index 20299f613..06f55063f 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -403,8 +403,8 @@ LABEL(cvar_fail) void WarpZone_PostInitialize_Callback() { // create waypoint links for warpzones - entity e; - for(e = NULL; (e = find(e, classname, "trigger_warpzone")); ) + for(entity e = warpzone_first; e; e = e.warpzone_next) + //for(entity e = NULL; (e = find(e, classname, "trigger_warpzone")); ) { vector src, dst; src = (e.absmin + e.absmax) * 0.5;