-void InsertLinkAfter (link_t *l, link_t *after)
-{
- l->next = after->next;
- l->prev = after;
- l->prev->next = l;
- l->next->prev = l;
-}
-
-
-typedef struct
-{
- vec3_t boxmins, boxmaxs;// enclose the test object along entire move
- float *mins, *maxs; // size of the moving object
- vec3_t mins2, maxs2; // size when clipping against mosnters
- float *start, *end;
- trace_t trace;
- int type;
- edict_t *passedict;
-} moveclip_t;
-
-
-/*
-===============================================================================
-
-HULL BOXES
-
-===============================================================================
-*/
-
-
-static hull_t box_hull;
-static dclipnode_t box_clipnodes[6];
-static mplane_t box_planes[6];
-
-/*
-===================
-SV_InitBoxHull
-
-Set up the planes and clipnodes so that the six floats of a bounding box
-can just be stored out and get a proper hull_t structure.
-===================
-*/
-void SV_InitBoxHull (void)
-{
- int i;
- int side;
-
- box_hull.clipnodes = box_clipnodes;
- box_hull.planes = box_planes;
- box_hull.firstclipnode = 0;
- box_hull.lastclipnode = 5;
-
- for (i=0 ; i<6 ; i++)
- {
- box_clipnodes[i].planenum = i;
-
- side = i&1;
-
- box_clipnodes[i].children[side] = CONTENTS_EMPTY;
- if (i != 5)
- box_clipnodes[i].children[side^1] = i + 1;
- else
- box_clipnodes[i].children[side^1] = CONTENTS_SOLID;
-
- box_planes[i].type = i>>1;
- box_planes[i].normal[i>>1] = 1;
- }
-}
-
-
-/*
-===================
-SV_HullForBox
-
-To keep everything totally uniform, bounding boxes are turned into small
-BSP trees instead of being compared directly.
-===================
-*/
-hull_t *SV_HullForBox (vec3_t mins, vec3_t maxs)
-{
- box_planes[0].dist = maxs[0];
- box_planes[1].dist = mins[0];
- box_planes[2].dist = maxs[1];
- box_planes[3].dist = mins[1];
- box_planes[4].dist = maxs[2];
- box_planes[5].dist = mins[2];
-
- return &box_hull;
-}
-
-
-
-/*
-================
-SV_HullForEntity
-
-Returns a hull that can be used for testing or clipping an object of mins/maxs
-size.
-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.
-================
-*/
-hull_t *SV_HullForEntity (edict_t *ent, vec3_t mins, vec3_t maxs, vec3_t offset)
-{
- model_t *model;
- vec3_t size;
- vec3_t hullmins, hullmaxs;
- hull_t *hull;
-
-// decide which clipping hull to use, based on the size
- if (ent->v.solid == SOLID_BSP)
- { // explicit hulls in the BSP model
- if (ent->v.movetype != MOVETYPE_PUSH)
- Host_Error ("SOLID_BSP without MOVETYPE_PUSH");
-
- model = sv.models[ (int)ent->v.modelindex ];
- Mod_CheckLoaded(model);
-
- // LordHavoc: fixed SOLID_BSP error message
- if (!model || model->type != mod_brush)
- {
- Con_Printf ("SOLID_BSP with a non bsp model, entity dump:\n");
- ED_Print (ent);
- Host_Error ("SOLID_BSP with a non bsp model\n");
- }
-
- VectorSubtract (maxs, mins, size);
- // LordHavoc: FIXME!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- if (sv.worldmodel->ishlbsp)
- {
- if (size[0] < 3)
- hull = &model->hulls[0]; // 0x0x0
- else if (size[0] <= 32)
- {
- if (size[2] < 54) // pick the nearest of 36 or 72
- hull = &model->hulls[3]; // 32x32x36
- else
- hull = &model->hulls[1]; // 32x32x72
- }
- else
- hull = &model->hulls[2]; // 64x64x64
- }
- else
- {
- if (size[0] < 3)
- hull = &model->hulls[0]; // 0x0x0
- else if (size[0] <= 32)
- hull = &model->hulls[1]; // 32x32x56
- else
- hull = &model->hulls[2]; // 64x64x88
- }
-
-// calculate an offset value to center the origin
- VectorSubtract (hull->clip_mins, mins, offset);
- VectorAdd (offset, ent->v.origin, offset);
- }
- else
- { // create a temp hull from bounding box sizes
-
- VectorSubtract (ent->v.mins, maxs, hullmins);
- VectorSubtract (ent->v.maxs, mins, hullmaxs);
- hull = SV_HullForBox (hullmins, hullmaxs);
-
- VectorCopy (ent->v.origin, offset);
- }
-
-
- return hull;
-}