]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_subs.qc
Possibly fix compilation unit
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_subs.qc
index dba509b28b8d3e276aba89cac2346d196d1891b9..dbbd6d2b4dff76bdf68888a05847f851a759563a 100644 (file)
@@ -1,16 +1,13 @@
 #include "g_subs.qh"
 
+#include <server/defs.qh>
+#include <server/miscfunctions.qh>
 #include "antilag.qh"
 #include "command/common.qh"
 #include "../common/state.qh"
 #include "../lib/warpzone/common.qh"
-#include "../common/triggers/subs.qh"
+#include "../common/mapobjects/subs.qh"
 
-spawnfunc(info_null)
-{
-       remove(this);
-       // if anything breaks, tell the mapper to fix his map! info_null is meant to remove itself immediately.
-}
 
 /*
 ==================
@@ -48,14 +45,7 @@ void tracebox_antilag_force_wz (entity source, vector v1, vector mi, vector ma,
                source.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
 
        if (lag)
-       {
-               // take players back into the past
-               FOREACH_CLIENT(IS_PLAYER(it) && it != forent, antilag_takeback(it, CS(it), time - lag));
-               FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, {
-                       if(it != forent)
-                               antilag_takeback(it, it, time - lag);
-               });
-       }
+               antilag_takeback_all(forent, lag);
 
        // do the trace
        if(wz)
@@ -65,13 +55,7 @@ void tracebox_antilag_force_wz (entity source, vector v1, vector mi, vector ma,
 
        // restore players to current positions
        if (lag)
-       {
-               FOREACH_CLIENT(IS_PLAYER(it) && it != forent, antilag_restore(it, CS(it)));
-               FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, {
-                       if (it != forent)
-                               antilag_restore(it, it);
-               });
-       }
+               antilag_restore_all(forent);
 
        // restore shooter solid type
        if(source)
@@ -83,13 +67,15 @@ void traceline_antilag_force (entity source, vector v1, vector v2, float nomonst
 }
 void traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag)
 {
-       if (autocvar_g_antilag != 2 || source.cvar_cl_noantilag)
+       bool noantilag = ((IS_CLIENT(source)) ? CS(source).cvar_cl_noantilag : false);
+       if (autocvar_g_antilag != 2 || noantilag)
                lag = 0;
        traceline_antilag_force(source, v1, v2, nomonst, forent, lag);
 }
 void tracebox_antilag (entity source, vector v1, vector mi, vector ma, vector v2, float nomonst, entity forent, float lag)
 {
-       if (autocvar_g_antilag != 2 || source.cvar_cl_noantilag)
+       bool noantilag = ((IS_CLIENT(source)) ? CS(source).cvar_cl_noantilag : false);
+       if (autocvar_g_antilag != 2 || noantilag)
                lag = 0;
        tracebox_antilag_force_wz(source, v1, mi, ma, v2, nomonst, forent, lag, false);
 }
@@ -99,13 +85,15 @@ void WarpZone_traceline_antilag_force (entity source, vector v1, vector v2, floa
 }
 void WarpZone_traceline_antilag (entity source, vector v1, vector v2, float nomonst, entity forent, float lag)
 {
-       if (autocvar_g_antilag != 2 || source.cvar_cl_noantilag)
+       bool noantilag = ((IS_CLIENT(source)) ? CS(source).cvar_cl_noantilag : false);
+       if (autocvar_g_antilag != 2 || noantilag)
                lag = 0;
        WarpZone_traceline_antilag_force(source, v1, v2, nomonst, forent, lag);
 }
 void WarpZone_tracebox_antilag (entity source, vector v1, vector mi, vector ma, vector v2, float nomonst, entity forent, float lag)
 {
-       if (autocvar_g_antilag != 2 || source.cvar_cl_noantilag)
+       bool noantilag = ((IS_CLIENT(source)) ? CS(source).cvar_cl_noantilag : false);
+       if (autocvar_g_antilag != 2 || noantilag)
                lag = 0;
        tracebox_antilag_force_wz(source, v1, mi, ma, v2, nomonst, forent, lag, true);
 }
@@ -141,10 +129,10 @@ float tracebox_inverted (vector v1, vector mi, vector ma, vector v2, float nomon
 
                if(c == 50)
                {
-                       LOG_TRACE("HOLY SHIT! When tracing from ", vtos(v1), " to ", vtos(v2), "\n");
-                       LOG_TRACE("  Nudging gets us nowhere at ", vtos(pos), "\n");
-                       LOG_TRACE("  trace_endpos is ", vtos(trace_endpos), "\n");
-                       LOG_TRACE("  trace distance is ", ftos(vlen(pos - trace_endpos)), "\n");
+                       LOG_TRACE("HOLY SHIT! When tracing from ", vtos(v1), " to ", vtos(v2));
+                       LOG_TRACE("  Nudging gets us nowhere at ", vtos(pos));
+                       LOG_TRACE("  trace_endpos is ", vtos(trace_endpos));
+                       LOG_TRACE("  trace distance is ", ftos(vlen(pos - trace_endpos)));
                }
 
                stopentity = trace_ent;
@@ -204,26 +192,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;
@@ -281,7 +265,7 @@ void LODmodel_attach(entity this)
                if(e)
                {
                        this.lodmodel1 = e.model;
-                       remove(e);
+                       delete(e);
                }
        }
        if(this.lodtarget2 != "")
@@ -290,7 +274,7 @@ void LODmodel_attach(entity this)
                if(e)
                {
                        this.lodmodel2 = e.model;
-                       remove(e);
+                       delete(e);
                }
        }
 
@@ -324,127 +308,3 @@ void LODmodel_attach(entity this)
                if (!getSendEntity(this))
                        SetCustomizer(this, LOD_customize, LOD_uncustomize);
 }
-
-void ApplyMinMaxScaleAngles(entity e)
-{
-       if(e.angles.x != 0 || e.angles.z != 0 || e.avelocity.x != 0 || e.avelocity.z != 0) // "weird" rotation
-       {
-               e.maxs = '1 1 1' * vlen(
-                       '1 0 0' * max(-e.mins.x, e.maxs.x) +
-                       '0 1 0' * max(-e.mins.y, e.maxs.y) +
-                       '0 0 1' * max(-e.mins.z, e.maxs.z)
-               );
-               e.mins = -e.maxs;
-       }
-       else if(e.angles.y != 0 || e.avelocity.y != 0) // yaw only is a bit better
-       {
-               e.maxs_x = vlen(
-                       '1 0 0' * max(-e.mins.x, e.maxs.x) +
-                       '0 1 0' * max(-e.mins.y, e.maxs.y)
-               );
-               e.maxs_y = e.maxs.x;
-               e.mins_x = -e.maxs.x;
-               e.mins_y = -e.maxs.x;
-       }
-       if(e.scale)
-               setsize(e, e.mins * e.scale, e.maxs * e.scale);
-       else
-               setsize(e, e.mins, e.maxs);
-}
-
-void SetBrushEntityModel(entity this)
-{
-       if(this.model != "")
-       {
-               precache_model(this.model);
-               if(this.mins != '0 0 0' || this.maxs != '0 0 0')
-               {
-                       vector mi = this.mins;
-                       vector ma = this.maxs;
-                       _setmodel(this, this.model); // no precision needed
-                       setsize(this, mi, ma);
-               }
-               else
-                       _setmodel(this, this.model); // no precision needed
-               InitializeEntity(this, LODmodel_attach, INITPRIO_FINDTARGET);
-       }
-       setorigin(this, this.origin);
-       ApplyMinMaxScaleAngles(this);
-}
-
-void SetBrushEntityModelNoLOD(entity this)
-{
-       if(this.model != "")
-       {
-               precache_model(this.model);
-               if(this.mins != '0 0 0' || this.maxs != '0 0 0')
-               {
-                       vector mi = this.mins;
-                       vector ma = this.maxs;
-                       _setmodel(this, this.model); // no precision needed
-                       setsize(this, mi, ma);
-               }
-               else
-                       _setmodel(this, this.model); // no precision needed
-       }
-       setorigin(this, this.origin);
-       ApplyMinMaxScaleAngles(this);
-}
-
-/*
-================
-InitTrigger
-================
-*/
-
-void SetMovedir(entity this)
-{
-       if(this.movedir != '0 0 0')
-               this.movedir = normalize(this.movedir);
-       else
-       {
-               makevectors(this.angles);
-               this.movedir = v_forward;
-       }
-
-       this.angles = '0 0 0';
-}
-
-void InitTrigger(entity this)
-{
-// trigger angles are used for one-way touches.  An angle of 0 is assumed
-// to mean no restrictions, so use a yaw of 360 instead.
-       SetMovedir(this);
-       this.solid = SOLID_TRIGGER;
-       SetBrushEntityModel(this);
-       this.movetype = MOVETYPE_NONE;
-       this.modelindex = 0;
-       this.model = "";
-}
-
-void InitSolidBSPTrigger(entity this)
-{
-// trigger angles are used for one-way touches.  An angle of 0 is assumed
-// to mean no restrictions, so use a yaw of 360 instead.
-       SetMovedir(this);
-       this.solid = SOLID_BSP;
-       SetBrushEntityModel(this);
-       this.movetype = MOVETYPE_NONE; // why was this PUSH? -div0
-//     this.modelindex = 0;
-       this.model = "";
-}
-
-bool InitMovingBrushTrigger(entity this)
-{
-// trigger angles are used for one-way touches.  An angle of 0 is assumed
-// to mean no restrictions, so use a yaw of 360 instead.
-       this.solid = SOLID_BSP;
-       SetBrushEntityModel(this);
-       this.movetype = MOVETYPE_PUSH;
-       if(this.modelindex == 0)
-       {
-               objerror(this, "InitMovingBrushTrigger: no brushes found!");
-               return false;
-       }
-       return true;
-}