X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=world.c;h=0dbcb29feee5e2646f8f9a3a07b79e0910aa1962;hb=6d8a43b977296dbaee1af8a032ad3fa8e41700dd;hp=1ce1b73ac8bfba1ad996bff41c405d4d4925b75c;hpb=ea7c24e1fb41f3b1df984ac0eed6881c9fde16f5;p=xonotic%2Fdarkplaces.git diff --git a/world.c b/world.c index 1ce1b73a..0dbcb29f 100644 --- a/world.c +++ b/world.c @@ -29,6 +29,14 @@ line of sight checks trace->crosscontent, but bullets don't */ +cvar_t sv_useareanodes = {CVAR_NOTIFY, "sv_useareanodes", "1"}; + +void SV_World_Init(void) +{ + Cvar_RegisterVariable(&sv_useareanodes); + Collision_Init (); +} + void ClearLink (link_t *l); void RemoveLink (link_t *l); @@ -172,8 +180,6 @@ SV_ClearWorld */ void SV_ClearWorld (void) { - Collision_Init (); - memset (sv_areanodes, 0, sizeof(sv_areanodes)); sv_numareanodes = 0; Mod_CheckLoaded(sv.worldmodel); @@ -283,12 +289,12 @@ void SV_LinkEdict (edict_t *ent, qboolean touch_triggers) if (ent->v.solid == SOLID_BSP) { if (ent->v.modelindex < 0 || ent->v.modelindex > MAX_MODELS) - PR_RunError("SOLID_BSP with invalid modelindex!\n"); + Host_Error("SOLID_BSP with invalid modelindex!\n"); model = sv.models[(int) ent->v.modelindex]; if (model != NULL) { if (model->type != mod_brush) - PR_RunError("SOLID_BSP with non-BSP model\n"); + Host_Error("SOLID_BSP with non-BSP model\n"); if (ent->v.angles[0] || ent->v.angles[2] || ent->v.avelocity[0] || ent->v.avelocity[2]) { @@ -383,20 +389,6 @@ POINT TESTING IN HULLS =============================================================================== */ -/* -================== -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; -} - /* ============ SV_TestEntityPosition @@ -404,16 +396,9 @@ SV_TestEntityPosition This could be a lot more efficient... ============ */ -edict_t *SV_TestEntityPosition (edict_t *ent) +int SV_TestEntityPosition (edict_t *ent) { - trace_t trace; - - trace = SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, ent->v.origin, MOVE_NORMAL, ent); - - if (trace.startsolid) - return sv.edicts; - - return NULL; + return SV_Move (ent->v.origin, ent->v.mins, ent->v.maxs, ent->v.origin, MOVE_NORMAL, ent).startsolid; } @@ -441,10 +426,10 @@ trace_t SV_ClipMoveToEntity (edict_t *ent, vec3_t start, vec3_t mins, vec3_t max i = ent->v.modelindex; if ((unsigned int) i >= MAX_MODELS) - PR_RunError("SV_ClipMoveToEntity: invalid modelindex\n"); + Host_Error("SV_ClipMoveToEntity: invalid modelindex\n"); model = sv.models[i]; if (i != 0 && model == NULL) - PR_RunError("SV_ClipMoveToEntity: invalid modelindex\n"); + Host_Error("SV_ClipMoveToEntity: invalid modelindex\n"); if ((int) ent->v.solid == SOLID_BSP) { @@ -492,7 +477,10 @@ loc0: if (touch == clip->passedict) continue; if (touch->v.solid == SOLID_TRIGGER) + { + ED_Print(touch); Host_Error ("Trigger in clipping list"); + } if (clip->type == MOVE_NOMONSTERS && touch->v.solid != SOLID_BSP) continue; @@ -521,10 +509,10 @@ loc0: } // might interact, so do an exact clip - if ((int)touch->v.flags & FL_MONSTER) - trace = SV_ClipMoveToEntity (touch, clip->start, clip->mins2, clip->maxs2, clip->end); - else if (touch->v.solid == SOLID_BSP) + if (touch->v.solid == SOLID_BSP) trace = SV_ClipMoveToEntity (touch, clip->start, clip->hullmins, clip->hullmaxs, clip->end); + else if ((int)touch->v.flags & FL_MONSTER) + 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); // LordHavoc: take the 'best' answers from the new trace and combine with existing data @@ -576,27 +564,30 @@ SV_MoveBounds */ void SV_MoveBounds (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, vec3_t boxmins, vec3_t boxmaxs) { -#if 0 -// debug to test against everything -boxmins[0] = boxmins[1] = boxmins[2] = -999999999; -boxmaxs[0] = boxmaxs[1] = boxmaxs[2] = 999999999; -#else - int i; - - for (i=0 ; i<3 ; i++) + if (sv_useareanodes.integer) { - if (end[i] > start[i]) - { - boxmins[i] = start[i] + mins[i] - 1; - boxmaxs[i] = end[i] + maxs[i] + 1; - } - else + int i; + + for (i=0 ; i<3 ; i++) { - boxmins[i] = end[i] + mins[i] - 1; - boxmaxs[i] = start[i] + maxs[i] + 1; + if (end[i] > start[i]) + { + boxmins[i] = start[i] + mins[i] - 1; + boxmaxs[i] = end[i] + maxs[i] + 1; + } + else + { + boxmins[i] = end[i] + mins[i] - 1; + boxmaxs[i] = start[i] + maxs[i] + 1; + } } } -#endif + else + { + // debug to test against everything + boxmins[0] = boxmins[1] = boxmins[2] = -999999999; + boxmaxs[0] = boxmaxs[1] = boxmaxs[2] = 999999999; + } } /*