]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/warpzonelib/common.qc
ent_cs: cleanup
[xonotic/xonotic-data.pk3dir.git] / qcsrc / warpzonelib / common.qc
index 521cf343b3efa6b32dae20181218cce6a3224104..0eaaac980c69a3e70cf0ba8974994741776f8507 100644 (file)
@@ -1,5 +1,14 @@
-float trace_dphitcontents;
-.float dphitcontentsmask;
+#include "common.qh"
+
+#if defined(CSQC)
+       #include "../dpdefs/csprogsdefs.qh"
+    #include "../server/t_items.qh"
+#elif defined(MENUQC)
+#elif defined(SVQC)
+    #include "../common/weapons/all.qh"
+    #include "../dpdefs/dpextensions.qh"
+       #include "../dpdefs/progsdefs.qh"
+#endif
 
 void WarpZone_Accumulator_Clear(entity acc)
 {
@@ -32,9 +41,9 @@ void WarpZone_Accumulator_AddInverse(entity acc, entity wz)
 }
 
 .vector(vector, vector) camera_transform;
-var float autocvar_cl_warpzone_usetrace = 1;
+float autocvar_cl_warpzone_usetrace = 1;
 vector WarpZone_camera_transform(vector org, vector ang)
-{
+{SELFPARAM();
        vector vf, vr, vu;
        if(self.warpzone_fadestart)
                if(vlen(org - self.origin - 0.5 * (self.mins + self.maxs)) > self.warpzone_fadeend + 400)
@@ -72,7 +81,7 @@ void WarpZone_SetUp(entity e, vector my_org, vector my_ang, vector other_org, ve
 }
 
 vector WarpZone_Camera_camera_transform(vector org, vector ang)
-{
+{SELFPARAM();
        // a fixed camera view
        if(self.warpzone_fadestart)
                if(vlen(org - self.origin - 0.5 * (self.mins + self.maxs)) > self.warpzone_fadeend + 400)
@@ -107,7 +116,7 @@ float WarpZoneLib_BoxTouchesBrush_Recurse()
 #ifdef CSQC
        if (trace_networkentity)
        {
-               dprint("hit a network ent, cannot continue WarpZoneLib_BoxTouchesBrush\n");
+               LOG_TRACE("hit a network ent, cannot continue WarpZoneLib_BoxTouchesBrush\n");
                // we cannot continue, as a player blocks us...
                // so, abort
                return 0;
@@ -263,11 +272,11 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
        sol = -1;
        frac = 0;
        i = 16;
-       for(;;)
+       for (;;)
        {
                if(--i < 1)
                {
-                       dprint("Too many warpzones in sequence, aborting trace.\n");
+                       LOG_TRACE("Too many warpzones in sequence, aborting trace.\n");
                        trace_ent = world;
                        break;
                }
@@ -295,7 +304,7 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
                if(trace_ent == wz)
                {
                        // FIXME can this check be removed? Do we really need it?
-                       dprint("I transformed into the same zone again, wtf, aborting the trace\n");
+                       LOG_TRACE("I transformed into the same zone again, wtf, aborting the trace\n");
                        trace_ent = world;
                        break;
                }
@@ -386,11 +395,11 @@ void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZo
        }
        WarpZone_MakeAllSolid();
        i = 16;
-       for(;;)
+       for (;;)
        {
                if(--i < 1)
                {
-                       dprint("Too many warpzones in sequence, aborting trace.\n");
+                       LOG_TRACE("Too many warpzones in sequence, aborting trace.\n");
                        trace_ent = world;
                        break;
                }
@@ -408,7 +417,7 @@ void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZo
                if(trace_ent == wz)
                {
                        // FIXME can this check be removed? Do we really need it?
-                       dprint("I transformed into the same zone again, wtf, aborting the trace\n");
+                       LOG_TRACE("I transformed into the same zone again, wtf, aborting the trace\n");
                        trace_ent = world;
                        break;
                }
@@ -469,7 +478,7 @@ void WarpZone_TrailParticles_WithMultiplier_trace_callback(vector from, vector e
        boxparticles(WarpZone_TrailParticles_trace_callback_eff, WarpZone_TrailParticles_trace_callback_own, from, endpos, WarpZone_TrailParticles_trace_callback_own.velocity, WarpZone_TrailParticles_trace_callback_own.velocity, WarpZone_TrailParticles_trace_callback_f, WarpZone_TrailParticles_trace_callback_flags);
 }
 
-void WarpZone_TrailParticles_WithMultiplier(entity own, float eff, vector org, vector end, float f, float boxflags)
+void WarpZone_TrailParticles_WithMultiplier(entity own, float eff, vector org, vector end, float f, int boxflags)
 {
        WarpZone_TrailParticles_trace_callback_own = own;
        WarpZone_TrailParticles_trace_callback_eff = eff;
@@ -508,18 +517,18 @@ vector WarpZone_TransformVAngles(entity wz, vector ang)
 {
 #ifdef KEEP_ROLL
        float roll;
-       roll = ang_z;
-       ang_z = 0;
+       roll = ang.z;
+       ang.z = 0;
 #endif
 
        ang = AnglesTransform_ApplyToVAngles(wz.warpzone_transform, ang);
 
 #ifdef KEEP_ROLL
-       ang = AnglesTransform_Normalize(ang, TRUE);
+       ang = AnglesTransform_Normalize(ang, true);
        ang = AnglesTransform_CancelRoll(ang);
-       ang_z = roll;
+       ang.z = roll;
 #else
-       ang = AnglesTransform_Normalize(ang, FALSE);
+       ang = AnglesTransform_Normalize(ang, false);
 #endif
 
        return ang;
@@ -544,26 +553,63 @@ vector WarpZone_UnTransformVAngles(entity wz, vector ang)
 {
        float roll;
 
-       roll = ang_z;
-       ang_z = 0;
+       roll = ang.z;
+       ang.z = 0;
 
        ang = AnglesTransform_ApplyToVAngles(AnglesTransform_Invert(wz.warpzone_transform), ang);
-       ang = AnglesTransform_Normalize(ang, TRUE);
+       ang = AnglesTransform_Normalize(ang, true);
        ang = AnglesTransform_CancelRoll(ang);
 
-       ang_z = roll;
+       ang.z = roll;
        return ang;
 }
 
 vector WarpZoneLib_NearestPointOnBox(vector mi, vector ma, vector org)
 {
        vector nearest;
-       nearest_x = bound(mi_x, org_x, ma_x);
-       nearest_y = bound(mi_y, org_y, ma_y);
-       nearest_z = bound(mi_z, org_z, ma_z);
+       nearest.x = bound(mi.x, org.x, ma.x);
+       nearest.y = bound(mi.y, org.y, ma.y);
+       nearest.z = bound(mi.z, org.z, ma.z);
        return nearest;
 }
 
+bool WarpZoneLib_BadEntity(entity e)
+{
+       string myclassname = e.classname;
+       if (e.instanceOfObject) return true;
+       switch(myclassname)
+       {
+               case "deathtype":
+               case "weaponentity":
+               case "exteriorweaponentity":
+               case "csqc_score_team":
+               case "pingplreport":
+               case "ent_client_scoreinfo":
+               case "saved_cvar_value":
+               case "accuracy":
+               case "entcs_sender":
+               case "entcs_receiver":
+               case "clientinit":
+               case "sprite_waypoint":
+               case "waypoint":
+               case "gibsplash":
+               //case "net_linked": // actually some real entities are linked without classname, fail
+               case "":
+                       return true;
+       }
+
+       if(startsWith(myclassname, "msg_"))
+               return true;
+
+       if(startsWith(myclassname, "target_"))
+               return true;
+
+       if(startsWith(myclassname, "info_"))
+               return true;
+
+       return false;
+}
+
 .float WarpZone_findradius_hit;
 .entity WarpZone_findradius_next;
 void WarpZone_FindRadius_Recurse(vector org, float rad,        vector org0,               vector transform, vector shift, float needlineofsight)
@@ -582,6 +628,8 @@ void WarpZone_FindRadius_Recurse(vector org, float rad,        vector org0,
 
        for(e = e0; e; e = e.chain)
        {
+               if(WarpZoneLib_BadEntity(e))
+                       continue;
                p = WarpZoneLib_NearestPointOnBox(e.origin + e.mins, e.origin + e.maxs, org0);
                if(needlineofsight)
                {
@@ -617,6 +665,9 @@ void WarpZone_FindRadius_Recurse(vector org, float rad,        vector org0,
        }
        for(e = wz; e; e = e.WarpZone_findradius_next)
        {
+               if(WarpZoneLib_BadEntity(e))
+                       continue;
+
                org0_new = WarpZone_TransformOrigin(e, org);
                traceline(e.warpzone_targetorigin, org0_new, MOVE_NOMONSTERS, e);
                org_new = trace_endpos;
@@ -645,7 +696,7 @@ entity WarpZone_FindRadius(vector org, float rad, float needlineofsight)
 
 .entity WarpZone_refsys;
 void WarpZone_RefSys_GC()
-{
+{SELFPARAM();
        // garbage collect unused reference systems
        self.nextthink = time + 1;
        if(self.owner.WarpZone_refsys != self)
@@ -765,7 +816,7 @@ entity WarpZone_RefSys_SpawnSameRefSys(entity me)
 }
 
 float WarpZoneLib_ExactTrigger_Touch()
-{
+{SELFPARAM();
        return !WarpZoneLib_BoxTouchesBrush(other.absmin, other.absmax, self, other);
 }
 
@@ -791,11 +842,11 @@ float WarpZoneLib_MoveOutOfSolid(entity e)
        o = e.origin;
        traceline(o, o, MOVE_WORLDONLY, e);
        if (trace_startsolid)
-               return FALSE;
+               return false;
 
        tracebox(o, e.mins, e.maxs, o, MOVE_WORLDONLY, e);
        if (!trace_startsolid)
-               return TRUE;
+               return true;
 
        m0 = e.mins;
        m1 = e.maxs;
@@ -819,8 +870,8 @@ float WarpZoneLib_MoveOutOfSolid(entity e)
        if (trace_startsolid)
        {
                setorigin(e, o);
-               return FALSE;
+               return false;
        }
 
-       return TRUE;
+       return true;
 }