]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/warpzone/common.qc
Reorganise item code so that VM-specific code is in its correct directories and not...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / warpzone / common.qc
index 2c491cab9809d9b875ad739d3d92971280a3e01f..830c56de65f0cca4834131760898e93b9a148006 100644 (file)
@@ -1,7 +1,7 @@
 #include "common.qh"
 
 #if defined(CSQC)
-    #include <common/t_items.qh>
+    #include <client/items/items.qh>
 #elif defined(MENUQC)
 #elif defined(SVQC)
     #include <common/weapons/_all.qh>
@@ -71,7 +71,8 @@ void WarpZone_SetUp(entity e, vector my_org, vector my_ang, vector other_org, ve
        e.warpzone_targetorigin = other_org;
        e.warpzone_angles = my_ang;
        e.warpzone_targetangles = other_ang;
-       FIXED_MAKE_VECTORS_NEW(my_ang, forward, right, up);
+       vector forward, right, up;
+       FIXED_MAKE_VECTORS(my_ang, forward, right, up);
        e.warpzone_forward = forward;
        FIXED_MAKE_VECTORS(other_ang, forward, right, up);
        e.warpzone_targetforward = forward;
@@ -204,6 +205,7 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
        float frac, sol, i;
        float contentshack;
        entity wz;
+       vector vf, vr, vu;
 
        WarpZone_trace_forent = forent;
        WarpZone_trace_firstzone = NULL;
@@ -228,6 +230,10 @@ void WarpZone_TraceBox_ThroughZone(vector org, vector mi, vector ma, vector end,
                }
        }
 
+       vf = v_forward;
+       vr = v_right;
+       vu = v_up;
+
        switch(nomonsters)
        {
                case MOVE_WORLDONLY:
@@ -319,6 +325,9 @@ LABEL(fail)
        if(contentshack)
                BITCLR_ASSIGN(WarpZone_trace_forent.dphitcontentsmask, DPCONTENTS_SOLID);
        trace_startsolid = sol;
+       v_forward = vf;
+       v_right = vr;
+       v_up = vu;
 }
 
 void WarpZone_TraceBox(vector org, vector mi, vector ma, vector end, float nomonsters, entity forent)
@@ -334,7 +343,7 @@ void WarpZone_TraceLine(vector org, vector end, float nomonsters, entity forent)
 void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZone_trace_callback_t cb)
 {
        float g, dt, i;
-       vector v0, o0;
+       vector vf, vr, vu, v0, o0;
        entity wz;
 
        o0 = e.origin;
@@ -359,6 +368,10 @@ void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZo
                return;
        }
 
+       vf = v_forward;
+       vr = v_right;
+       vu = v_up;
+
        // if starting in warpzone, first transform
        wz = WarpZone_Find(e.origin + e.mins, e.origin + e.maxs);
        if(wz)
@@ -428,6 +441,9 @@ void WarpZone_TraceToss_ThroughZone(entity e, entity forent, entity zone, WarpZo
        WarpZone_MakeAllOther();
 LABEL(fail)
        WarpZone_tracetoss_velocity = e.velocity;
+       v_forward = vf;
+       v_right = vr;
+       v_up = vu;
        // restore old entity data (caller just uses trace_endpos, WarpZone_tracetoss_velocity and the transform)
        e.velocity = v0;
        e.origin = o0;
@@ -770,13 +786,18 @@ entity WarpZone_RefSys_SpawnSameRefSys(entity me)
 
 bool WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher)
 {
-       return !WarpZoneLib_BoxTouchesBrush(toucher.absmin, toucher.absmax, this, toucher);
+       vector emin = toucher.absmin, emax = toucher.absmax;
+       // the engine offsets absolute bounding boxes by a single quake unit
+       // we must undo that here to allow accurate touching
+       emin += '1 1 1';
+       emax -= '1 1 1';
+       return !WarpZoneLib_BoxTouchesBrush(emin, emax, this, toucher);
 }
 
 
 void WarpZoneLib_MoveOutOfSolid_Expand(entity e, vector by)
 {
-       float eps = 0.0625;
+       const float eps = 0.0625;
        tracebox(e.origin, e.mins - '1 1 1' * eps, e.maxs + '1 1 1' * eps, e.origin + by, MOVE_WORLDONLY, e);
        if (trace_startsolid)
                return;