]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add an intrusive list for warpzones
authorMario <mario@smbclan.net>
Wed, 24 Aug 2016 09:56:13 +0000 (19:56 +1000)
committerMario <mario@smbclan.net>
Wed, 24 Aug 2016 09:56:13 +0000 (19:56 +1000)
qcsrc/lib/warpzone/client.qc
qcsrc/lib/warpzone/common.qc
qcsrc/lib/warpzone/common.qh
qcsrc/lib/warpzone/server.qc
qcsrc/lib/warpzone/server.qh
qcsrc/server/sv_main.qc

index bd0397f897330d876cdede80e284e1a2062ed0cf..15a3ca4c3ccc6e90870c72ab7bc74251777dd397 100644 (file)
@@ -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)
index 90e3cd76c983a803a552b32ed7af220aaccb6b6e..5a3929e1e92d58ecd6520f0bbb05d68499e61f73 100644 (file)
@@ -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()
index 4bbbb853b00bad0266f2482cd5ef7efcccd738d3..26c0e80fe4623526ee12cecc05842fb92c4f5dd0 100644 (file)
@@ -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;
 
index 34ea2610dedd7afa60e30ce6bab89f7df643940a..a3361a8d81e56296d2ac6834d7b524c8da8951d7 100644 (file)
@@ -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)
 {
index b0c583d2dc7bf31728f28e0d53de23219f689c22..4287ef60de798195e0e963d93736a7348a88d175 100644 (file)
@@ -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);
 
index 20299f61329053483fb8a1bbe91f1558bd04d025..06f55063f664ec6940590463101cc7f6f96187af 100644 (file)
@@ -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;