-
-//===========================================================================
-
-/*
-==================
-SV_Move
-==================
-*/
-#if COLLISIONPARANOID >= 1
-trace_t SV_Move_(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, prvm_edict_t *passedict)
-#else
-trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, prvm_edict_t *passedict)
-#endif
-{
- vec3_t hullmins, hullmaxs;
- int i;
- int hitsupercontentsmask;
- int passedictprog;
- qboolean pointtrace;
- prvm_edict_t *traceowner, *touch;
- trace_t trace;
- // bounding box of entire move area
- vec3_t clipboxmins, clipboxmaxs;
- // size of the moving object
- vec3_t clipmins, clipmaxs;
- // size when clipping against monsters
- vec3_t clipmins2, clipmaxs2;
- // start and end origin of move
- vec3_t clipstart, clipend;
- // trace results
- trace_t cliptrace;
- int numtouchedicts;
- prvm_edict_t *touchedicts[MAX_EDICTS];
-
- VectorCopy(start, clipstart);
- VectorCopy(end, clipend);
- VectorCopy(mins, clipmins);
- VectorCopy(maxs, clipmaxs);
- VectorCopy(mins, clipmins2);
- VectorCopy(maxs, clipmaxs2);
-#if COLLISIONPARANOID >= 3
- Con_Printf("move(%f %f %f,%f %f %f)", clipstart[0], clipstart[1], clipstart[2], clipend[0], clipend[1], clipend[2]);
-#endif
-
- hitsupercontentsmask = SUPERCONTENTS_SOLID;
- if (passedict)
- {
- if (passedict->fields.server->solid == SOLID_SLIDEBOX)
- hitsupercontentsmask |= SUPERCONTENTS_PLAYERCLIP;
- if ((int)passedict->fields.server->flags & FL_MONSTER)
- hitsupercontentsmask |= SUPERCONTENTS_MONSTERCLIP;
- }
-
- // clip to world
- cliptrace = SV_ClipMoveToEntity(prog->edicts, clipstart, clipmins, clipmaxs, clipend, type, hitsupercontentsmask);
- if (cliptrace.startsolid || cliptrace.fraction < 1)
- cliptrace.ent = prog->edicts;
- if (type == MOVE_WORLDONLY)
- return cliptrace;
-
- if (type == MOVE_MISSILE)
- {
- // LordHavoc: modified this, was = -15, now -= 15
- for (i = 0;i < 3;i++)
- {
- clipmins2[i] -= 15;
- clipmaxs2[i] += 15;
- }
- }
-
- // get adjusted box for bmodel collisions if the world is q1bsp or hlbsp
- if (sv.worldmodel && sv.worldmodel->brush.RoundUpToHullSize)
- sv.worldmodel->brush.RoundUpToHullSize(sv.worldmodel, clipmins, clipmaxs, hullmins, hullmaxs);
- else
- {
- VectorCopy(clipmins, hullmins);
- VectorCopy(clipmaxs, hullmaxs);
- }
-
- // create the bounding box of the entire move
- for (i = 0;i < 3;i++)
- {
- clipboxmins[i] = min(clipstart[i], cliptrace.endpos[i]) + min(hullmins[i], clipmins2[i]) - 1;
- clipboxmaxs[i] = max(clipstart[i], cliptrace.endpos[i]) + max(hullmaxs[i], clipmaxs2[i]) + 1;
- }
-
- // debug override to test against everything
- if (sv_debugmove.integer)
- {
- clipboxmins[0] = clipboxmins[1] = clipboxmins[2] = -999999999;
- clipboxmaxs[0] = clipboxmaxs[1] = clipboxmaxs[2] = 999999999;
- }
-
- // if the passedict is world, make it NULL (to avoid two checks each time)
- if (passedict == prog->edicts)
- passedict = NULL;
- // precalculate prog value for passedict for comparisons
- passedictprog = PRVM_EDICT_TO_PROG(passedict);
- // figure out whether this is a point trace for comparisons
- pointtrace = VectorCompare(clipmins, clipmaxs);
- // precalculate passedict's owner edict pointer for comparisons
- traceowner = passedict ? PRVM_PROG_TO_EDICT(passedict->fields.server->owner) : 0;
-
- // clip to enttiies
- numtouchedicts = SV_EntitiesInBox(clipboxmins, clipboxmaxs, MAX_EDICTS, touchedicts);
- if (numtouchedicts > MAX_EDICTS)
- {
- // this never happens
- Con_Printf("SV_EntitiesInBox returned %i edicts, max was %i\n", numtouchedicts, MAX_EDICTS);
- numtouchedicts = MAX_EDICTS;
- }
- for (i = 0;i < numtouchedicts;i++)
- {
- touch = touchedicts[i];
-
- if (touch->fields.server->solid < SOLID_BBOX)
- continue;
- if (type == MOVE_NOMONSTERS && touch->fields.server->solid != SOLID_BSP)
- continue;
-
- if (passedict)
- {
- // don't clip against self
- if (passedict == touch)
- continue;
- // don't clip owned entities against owner
- if (traceowner == touch)
- continue;
- // don't clip owner against owned entities
- if (passedictprog == touch->fields.server->owner)
- continue;
- // don't clip points against points (they can't collide)
- if (pointtrace && VectorCompare(touch->fields.server->mins, touch->fields.server->maxs) && (type != MOVE_MISSILE || !((int)touch->fields.server->flags & FL_MONSTER)))
- continue;
- // don't clip corpse against character
- if (passedict->fields.server->solid == SOLID_CORPSE && (touch->fields.server->solid == SOLID_SLIDEBOX || touch->fields.server->solid == SOLID_CORPSE))
- continue;
- // don't clip character against corpse
- if (passedict->fields.server->solid == SOLID_SLIDEBOX && touch->fields.server->solid == SOLID_CORPSE)
- continue;
- }
-
- // might interact, so do an exact clip
- if ((int)touch->fields.server->flags & FL_MONSTER)
- trace = SV_ClipMoveToEntity(touch, clipstart, clipmins2, clipmaxs2, clipend, type, hitsupercontentsmask);
- else
- trace = SV_ClipMoveToEntity(touch, clipstart, clipmins, clipmaxs, clipend, type, hitsupercontentsmask);
- // LordHavoc: take the 'best' answers from the new trace and combine with existing data
- if (trace.allsolid)
- cliptrace.allsolid = true;
- if (trace.startsolid)
- {
- cliptrace.startsolid = true;
- if (cliptrace.realfraction == 1)
- cliptrace.ent = touch;
- }
- // don't set this except on the world, because it can easily confuse
- // monsters underwater if there's a bmodel involved in the trace
- // (inopen && inwater is how they check water visibility)
- //if (trace.inopen)
- // cliptrace.inopen = true;
- if (trace.inwater)
- cliptrace.inwater = true;
- if (trace.realfraction < cliptrace.realfraction)
- {
- cliptrace.fraction = trace.fraction;
- cliptrace.realfraction = trace.realfraction;
- VectorCopy(trace.endpos, cliptrace.endpos);
- cliptrace.plane = trace.plane;
- cliptrace.ent = touch;
- }
- cliptrace.startsupercontents |= trace.startsupercontents;
- }
-
- return cliptrace;
-}
-
-#if COLLISIONPARANOID >= 1
-trace_t SV_Move(const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int type, prvm_edict_t *passedict)
-{
- int endstuck;
- trace_t trace;
- vec3_t temp;
- trace = SV_Move_(start, mins, maxs, end, type, passedict);
- if (passedict)
- {
- VectorCopy(trace.endpos, temp);
- endstuck = SV_Move_(temp, mins, maxs, temp, type, passedict).startsolid;
-#if COLLISIONPARANOID < 3
- if (trace.startsolid || endstuck)
-#endif
- Con_Printf("%s{e%i:%f %f %f:%f %f %f:%f:%f %f %f%s%s}\n", (trace.startsolid || endstuck) ? "\002" : "", passedict ? passedict - prog->edicts : -1, passedict->fields.server->origin[0], passedict->fields.server->origin[1], passedict->fields.server->origin[2], end[0] - passedict->fields.server->origin[0], end[1] - passedict->fields.server->origin[1], end[2] - passedict->fields.server->origin[2], trace.fraction, trace.endpos[0] - passedict->fields.server->origin[0], trace.endpos[1] - passedict->fields.server->origin[1], trace.endpos[2] - passedict->fields.server->origin[2], trace.startsolid ? " startstuck" : "", endstuck ? " endstuck" : "");
- }
- return trace;
-}
-#endif
-
-int SV_PointSuperContents(const vec3_t point)
-{
- return SV_Move(point, vec3_origin, vec3_origin, point, sv_gameplayfix_swiminbmodels.integer ? MOVE_NOMONSTERS : MOVE_WORLDONLY, NULL).startsupercontents;
-}
-
-int SV_PointQ1Contents(const vec3_t point)
-{
- return Mod_Q1BSP_NativeContentsFromSuperContents(NULL, SV_PointSuperContents(point));
-}
-
-