From da641d0102dc89846fe03cd765057e74d996d580 Mon Sep 17 00:00:00 2001 From: Tyrann Date: Sun, 10 Sep 2006 19:13:23 +0930 Subject: [PATCH] [PATCH] world.c cleanups Mostly whitespace cleanups in the world.c's, and a little one in pmovetst.c since it's largely copied from world.c. This is mainly to keep the differences between NQ/QW versions as small as possible. The only (minor) code changes are a little cleanup of SV_TestEntityPosition (should be semantically the same) and changing the "backup past 0" message to be developer only. Signed-off-by: Tyrann --- NQ/world.c | 41 ++++++++++++++++----------------- QW/common/pmovetst.c | 4 ++-- QW/server/world.c | 54 +++++++++++++++++++++----------------------- 3 files changed, 48 insertions(+), 51 deletions(-) diff --git a/NQ/world.c b/NQ/world.c index 02084a1..d3ca0b8 100644 --- a/NQ/world.c +++ b/NQ/world.c @@ -312,7 +312,6 @@ SV_TouchLinks(edict_t *ent, areanode_t *node) 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); /* the PR_ExecuteProgram above can alter the linked edicts */ @@ -401,22 +400,24 @@ SV_LinkEdict(edict_t *ent, qboolean touch_triggers) if (ent->free) return; - // set the abs box + /* set the abs box */ VectorAdd(ent->v.origin, ent->v.mins, ent->v.absmin); VectorAdd(ent->v.origin, ent->v.maxs, ent->v.absmax); - // - // to make items easier to pick up and allow them to be grabbed off - // of shelves, the abs sizes are expanded - // + /* + * To make items easier to pick up and allow them to be grabbed off of + * shelves, the abs sizes are expanded + */ if ((int)ent->v.flags & FL_ITEM) { ent->v.absmin[0] -= 15; ent->v.absmin[1] -= 15; ent->v.absmax[0] += 15; ent->v.absmax[1] += 15; } else { - // because movement is clipped an epsilon away from an actual edge, - // we must fully check even when bounding boxes don't quite touch + /* + * because movement is clipped an epsilon away from an actual edge, we + * must fully check even when bounding boxes don't quite touch + */ ent->v.absmin[0] -= 1; ent->v.absmin[1] -= 1; ent->v.absmin[2] -= 1; @@ -425,7 +426,7 @@ SV_LinkEdict(edict_t *ent, qboolean touch_triggers) ent->v.absmax[2] += 1; } - // link to PVS leafs + /* link to PVS leafs */ ent->num_leafs = 0; if (ent->v.modelindex) SV_FindTouchedLeafs(ent, sv.worldmodel->nodes); @@ -433,7 +434,7 @@ SV_LinkEdict(edict_t *ent, qboolean touch_triggers) if (ent->v.solid == SOLID_NOT) return; - // find the first node that the ent's box crosses + /* find the first node that the ent's box crosses */ node = sv_areanodes; while (1) { if (node->axis == -1) @@ -446,14 +447,14 @@ SV_LinkEdict(edict_t *ent, qboolean touch_triggers) break; // crosses the node } - // link it in + /* link it in */ if (ent->v.solid == SOLID_TRIGGER) InsertLinkBefore(&ent->area, &node->trigger_edicts); else InsertLinkBefore(&ent->area, &node->solid_edicts); - // if touch_triggers, touch all entities at this node and decend for more if (touch_triggers) + /* touch all entities at this node and decend for more */ SV_TouchLinks(ent, sv_areanodes); } @@ -545,18 +546,16 @@ edict_t * SV_TestEntityPosition(edict_t *ent) { trace_t trace; + entvars_t *v = &ent->v; + edict_t *ret = NULL; - trace = - SV_Move(ent->v.origin, ent->v.mins, ent->v.maxs, ent->v.origin, 0, - ent); - + trace = SV_Move(v->origin, v->mins, v->maxs, v->origin, 0, ent); if (trace.startsolid) - return sv.edicts; + ret = sv.edicts; - return NULL; + return ret; } - /* =============================================================================== @@ -684,8 +683,8 @@ SV_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, trace->plane.dist = -plane->dist; } - while (SV_HullPointContents(hull, hull->firstclipnode, mid) - == CONTENTS_SOLID) { // shouldn't really happen, but does occasionally + /* shouldn't really happen, but does occasionally */ + while (SV_HullPointContents(hull, hull->firstclipnode, mid) == CONTENTS_SOLID) { frac -= 0.1; if (frac < 0) { trace->fraction = midf; diff --git a/QW/common/pmovetst.c b/QW/common/pmovetst.c index 1339285..84470c2 100644 --- a/QW/common/pmovetst.c +++ b/QW/common/pmovetst.c @@ -308,8 +308,8 @@ PM_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, trace->plane.dist = -plane->dist; } - while (PM_HullPointContents(hull, hull->firstclipnode, mid) - == CONTENTS_SOLID) { // shouldn't really happen, but does occasionally + /* shouldn't really happen, but does occasionally */ + while (PM_HullPointContents(hull, hull->firstclipnode, mid) == CONTENTS_SOLID) { frac -= 0.1; if (frac < 0) { trace->fraction = midf; diff --git a/QW/server/world.c b/QW/server/world.c index 141daea..c156dd7 100644 --- a/QW/server/world.c +++ b/QW/server/world.c @@ -94,7 +94,6 @@ SV_InitBoxHull(void) box_planes[i].type = i >> 1; box_planes[i].normal[i >> 1] = 1; } - } @@ -160,8 +159,8 @@ SV_HullForEntity(edict_t *ent, vec3_t mins, vec3_t maxs, vec3_t offset) // 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 - + } 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); @@ -169,7 +168,6 @@ SV_HullForEntity(edict_t *ent, vec3_t mins, vec3_t maxs, vec3_t offset) VectorCopy(ent->v.origin, offset); } - return hull; } @@ -307,7 +305,6 @@ SV_TouchLinks(edict_t *ent, areanode_t *node) Con_DPrintf("Warning: fixed up link in %s\n", __func__); next = l->next; } - pr_global_struct->self = old_self; pr_global_struct->other = old_other; } @@ -386,21 +383,24 @@ SV_LinkEdict(edict_t *ent, qboolean touch_triggers) if (ent->free) return; -// set the abs box + /* set the abs box */ VectorAdd(ent->v.origin, ent->v.mins, ent->v.absmin); VectorAdd(ent->v.origin, ent->v.maxs, ent->v.absmax); -// -// to make items easier to pick up and allow them to be grabbed off -// of shelves, the abs sizes are expanded -// + /* + * To make items easier to pick up and allow them to be grabbed off of + * shelves, the abs sizes are expanded + */ if ((int)ent->v.flags & FL_ITEM) { ent->v.absmin[0] -= 15; ent->v.absmin[1] -= 15; ent->v.absmax[0] += 15; ent->v.absmax[1] += 15; - } else { // because movement is clipped an epsilon away from an actual edge, - // we must fully check even when bounding boxes don't quite touch + } else { + /* + * because movement is clipped an epsilon away from an actual edge, we + * must fully check even when bounding boxes don't quite touch + */ ent->v.absmin[0] -= 1; ent->v.absmin[1] -= 1; ent->v.absmin[2] -= 1; @@ -409,7 +409,7 @@ SV_LinkEdict(edict_t *ent, qboolean touch_triggers) ent->v.absmax[2] += 1; } -// link to PVS leafs + /* link to PVS leafs */ ent->num_leafs = 0; if (ent->v.modelindex) SV_FindTouchedLeafs(ent, sv.worldmodel->nodes); @@ -417,7 +417,7 @@ SV_LinkEdict(edict_t *ent, qboolean touch_triggers) if (ent->v.solid == SOLID_NOT) return; -// find the first node that the ent's box crosses + /* find the first node that the ent's box crosses */ node = sv_areanodes; while (1) { if (node->axis == -1) @@ -430,15 +430,14 @@ SV_LinkEdict(edict_t *ent, qboolean touch_triggers) break; // crosses the node } -// link it in - + /* link it in */ if (ent->v.solid == SOLID_TRIGGER) InsertLinkBefore(&ent->area, &node->trigger_edicts); else InsertLinkBefore(&ent->area, &node->solid_edicts); -// if touch_triggers, touch all entities at this node and decend for more if (touch_triggers) + /* touch all entities at this node and decend for more */ SV_TouchLinks(ent, sv_areanodes); } @@ -447,12 +446,12 @@ SV_LinkEdict(edict_t *ent, qboolean touch_triggers) /* =============================================================================== -POINT TESTING IN HULLS + POINT TESTING IN HULLS =============================================================================== */ -#if !id386 +#if !id386 /* ================== @@ -520,15 +519,14 @@ edict_t * SV_TestEntityPosition(edict_t *ent) { trace_t trace; + entvars_t *v = &ent->v; + edict_t *ret = NULL; - trace = - SV_Move(ent->v.origin, ent->v.mins, ent->v.maxs, ent->v.origin, 0, - ent); - + trace = SV_Move(v->origin, v->mins, v->maxs, v->origin, 0, ent); if (trace.startsolid) - return sv.edicts; + ret = sv.edicts; - return NULL; + return ret; } /* @@ -658,13 +656,13 @@ SV_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, trace->plane.dist = -plane->dist; } - while (SV_HullPointContents(hull, hull->firstclipnode, mid) - == CONTENTS_SOLID) { // shouldn't really happen, but does occasionally + /* shouldn't really happen, but does occasionally */ + while (SV_HullPointContents(hull, hull->firstclipnode, mid) == CONTENTS_SOLID) { frac -= 0.1; if (frac < 0) { trace->fraction = midf; VectorCopy(mid, trace->endpos); - Con_Printf("backup past 0\n"); + Con_DPrintf("backup past 0\n"); return false; } midf = p1f + (p2f - p1f) * frac;