]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - world.c
added protocol.o
[xonotic/darkplaces.git] / world.c
diff --git a/world.c b/world.c
index 5a8d033a468998570d536377a7415ee361a44bce..0409d61a1220e6ab0a492a7c20f1743a5b948e1f 100644 (file)
--- a/world.c
+++ b/world.c
@@ -124,7 +124,6 @@ Offset is filled in to contain the adjustment that must be added to the
 testing object's origin to get a point to use with the returned hull.
 ================
 */
-extern qboolean hlbsp;
 hull_t *SV_HullForEntity (edict_t *ent, vec3_t mins, vec3_t maxs, vec3_t offset)
 {
        model_t         *model;
@@ -325,7 +324,7 @@ loc0:
                pr_global_struct->self = EDICT_TO_PROG(touch);
                pr_global_struct->other = EDICT_TO_PROG(ent);
                pr_global_struct->time = sv.time;
-               PR_ExecuteProgram (touch->v.touch);
+               PR_ExecuteProgram (touch->v.touch, "");
 
                pr_global_struct->self = old_self;
                pr_global_struct->other = old_other;
@@ -378,7 +377,10 @@ loc0:
        if ( node->contents < 0)
        {
                if (ent->num_leafs == MAX_ENT_LEAFS)
+               {
+                       Con_DPrintf("FindTouchedLeafs overflow\n");
                        return;
+               }
 
                leaf = (mleaf_t *)node;
                leafnum = leaf - sv.worldmodel->leafs - 1;
@@ -435,21 +437,28 @@ void SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
 // set the abs box
 
 // LordHavoc: enabling rotating bmodels
-       if (ent->v.solid == SOLID_BSP && (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]) )
+       if (ent->v.solid == SOLID_BSP && (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]))
        {       // expand for rotation
                float           max, v;
                int                     i;
 
+               max = DotProduct(ent->v.mins, ent->v.mins);
+               v = DotProduct(ent->v.maxs, ent->v.maxs);
+               if (max < v)
+                       max = v;
+               max = sqrt(max);
+               /*
                max = 0;
                for (i=0 ; i<3 ; i++)
                {
-                       v =fabs( ent->v.mins[i]);
-                       if (v > max)
+                       v = fabs(ent->v.mins[i]);
+                       if (max < v)
                                max = v;
-                       v =fabs( ent->v.maxs[i]);
-                       if (v > max)
+                       v = fabs(ent->v.maxs[i]);
+                       if (max < v)
                                max = v;
                }
+               */
                for (i=0 ; i<3 ; i++)
                {
                        ent->v.absmin[i] = ent->v.origin[i] - max;
@@ -483,7 +492,7 @@ void SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
                ent->v.absmax[1] += 1;
                ent->v.absmax[2] += 1;
        }
-       
+
 // link to PVS leafs
        ent->num_leafs = 0;
        if (ent->v.modelindex)
@@ -505,7 +514,7 @@ void SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
                else
                        break;          // crosses the node
        }
-       
+
 // link it in  
 
        if (ent->v.solid == SOLID_TRIGGER)
@@ -528,7 +537,19 @@ POINT TESTING IN HULLS
 ===============================================================================
 */
 
-// SV_HullPointContents moved to cpu_noasm.c
+/*
+==================
+SV_HullPointContents
+
+==================
+*/
+int SV_HullPointContents (hull_t *hull, int num, vec3_t p)
+{
+       while (num >= 0)
+               num = hull->clipnodes[num].children[(hull->planes[hull->clipnodes[num].planenum].type < 3 ? p[hull->planes[hull->clipnodes[num].planenum].type] : DotProduct (hull->planes[hull->clipnodes[num].planenum].normal, p)) < hull->planes[hull->clipnodes[num].planenum].dist];
+       
+       return num;
+}
 
 /*
 ============
@@ -682,11 +703,7 @@ loc0:
        }
        else
        {
-               // LordHavoc: unrolled vector operation because the compiler can't be sure vec3_origin is 0
-//             VectorSubtract (vec3_origin, plane->normal, trace->plane.normal);
-               trace->plane.normal[0] = -plane->normal[0];
-               trace->plane.normal[1] = -plane->normal[1];
-               trace->plane.normal[2] = -plane->normal[2];
+               VectorNegate (plane->normal, trace->plane.normal);
                trace->plane.dist = -plane->dist;
        }
 
@@ -742,10 +759,6 @@ loc0:
                return true;            // empty
        }
 
-       // LordHavoc: this can be eliminated by validating in the loader...  but Mercury told me not to bother
-       if (num < hull->firstclipnode || num > hull->lastclipnode)
-               Sys_Error ("SV_RecursiveHullCheck: bad node number");
-
 // find the point distances
        node = hull->clipnodes + num;
        plane = hull->planes + node->planenum;
@@ -814,11 +827,7 @@ loc0:
        }
        else
        {
-               // LordHavoc: vec3_origin is evil; the compiler can not rely on it being '0 0 0'
-//             VectorSubtract (vec3_origin, plane->normal, trace->plane.normal);
-               trace->plane.normal[0] = -plane->normal[0];
-               trace->plane.normal[1] = -plane->normal[1];
-               trace->plane.normal[2] = -plane->normal[2];
+               VectorNegate (plane->normal, trace->plane.normal);
                trace->plane.dist = -plane->dist;
        }
 
@@ -933,8 +942,7 @@ trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t max
 
 // LordHavoc: enabling rotating bmodels
        // rotate start and end into the models frame of reference
-       if (ent->v.solid == SOLID_BSP && 
-       (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]) )
+       if (ent->v.solid == SOLID_BSP && (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]))
        {
                vec3_t  forward, right, up;
                vec3_t  temp;
@@ -957,8 +965,7 @@ trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t max
 
 // LordHavoc: enabling rotating bmodels
        // rotate endpos back to world frame of reference
-       if (ent->v.solid == SOLID_BSP && 
-       (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]) )
+       if (ent->v.solid == SOLID_BSP && (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]))
        {
                vec3_t  a;
                vec3_t  forward, right, up;
@@ -966,7 +973,7 @@ trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t max
 
                if (trace.fraction != 1)
                {
-                       VectorSubtract (vec3_origin, ent->v.angles, a);
+                       VectorNegate (ent->v.angles, a);
                        AngleVectors (a, forward, right, up);
 
                        VectorCopy (trace.endpos, temp);
@@ -1054,8 +1061,7 @@ loc0:
                        trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins2, clip->maxs2, clip->end);
                else
                        trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins, clip->maxs, clip->end);
-               if (trace.allsolid || trace.startsolid ||
-               trace.fraction < clip->trace.fraction)
+               if (trace.allsolid || trace.startsolid || trace.fraction < clip->trace.fraction)
                {
                        trace.ent = touch;
                        if (clip->trace.startsolid)