]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/warpzone/common.qc
Remove legacy Quake bbox expansion: bmodel entities
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / warpzone / common.qc
index 429f6a1175a37f792c62155c02f1b5e39b56e7c2..3fe4d038486324b1f9e1b29d4e48a3eb04103c62 100644 (file)
@@ -124,8 +124,10 @@ float WarpZoneLib_BoxTouchesBrush_Recurse(vector mi, vector ma, entity e, entity
        se = trace_ent;
        s = se.solid;
        se.solid = SOLID_NOT;
+       setorigin(se, se.origin); // unlink
        f = WarpZoneLib_BoxTouchesBrush_Recurse(mi, ma, e, ig);
        se.solid = s;
+       setorigin(se, se.origin); // relink
 
        return f;
 }
@@ -140,10 +142,26 @@ float WarpZoneLib_BoxTouchesBrush(vector mi, vector ma, entity e, entity ig)
        if(!e.modelindex || e.warpzone_isboxy)
                return 1;
 
+       // work around trigger_hurt on geit3ctf1 not being detected by tracebox
+       // bones_was_here: FIXME: WHY do these triggers only have supercontents == 128 ?!
+       if (Q3COMPAT_COMMON && ig != world)
+               ig.dphitcontentsmask |= 128;
+
        s = e.solid;
-       e.solid = SOLID_BSP;
+       if (e.solid != SOLID_BSP)
+       {
+               e.solid = SOLID_BSP;
+               setorigin(e, e.origin); // update linking
+       }
        f = WarpZoneLib_BoxTouchesBrush_Recurse(mi, ma, e, ig);
-       e.solid = s;
+       if (e.solid != s) // if we needed to change .solid temporarily
+       {
+               e.solid = s; // restore it
+               setorigin(e, e.origin); // update linking
+       }
+
+       if (Q3COMPAT_COMMON && ig != world)
+               ig.dphitcontentsmask &= ~128;
 
        return f;
 }
@@ -790,17 +808,22 @@ entity WarpZone_RefSys_SpawnSameRefSys(entity me)
        return e;
 }
 
-bool WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher)
+bool WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher, bool touchfunc)
 {
        vector emin = toucher.absmin, emax = toucher.absmax;
-       if(STAT(Q3COMPAT))
+       if (!Q3COMPAT_COMMON)
        {
-               // DP's tracebox enlarges 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';
+               // Xonotic and Nexuiz maps assume triggers will be activated by adjacent players
+               // prior to sv_legacy_bbox_expand 0 DP always did this for SVQC and never for CSQC
+               emin -= '1 1 1';
+               emax += '1 1 1';
        }
-       return !WarpZoneLib_BoxTouchesBrush(emin, emax, this, toucher);
+
+       // if called from a touch func, we can assume the boxes do overlap
+       if (!touchfunc && !boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
+               return false;
+
+       return WarpZoneLib_BoxTouchesBrush(emin, emax, this, toucher); // accurate
 }