Clean up sv_pr_cmds.c, and sync up nq's copy.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2003-05-29 02:40:34 +00:00
parent 9e57425f4f
commit 1c1e6e17c4
2 changed files with 12 additions and 12 deletions

View file

@ -634,7 +634,7 @@ PF_findradius (progs_t *pr)
{ {
edict_t *ent, *chain; edict_t *ent, *chain;
float rad; float rad;
float *org; float *eorigin, *emins, *emaxs, *org;
int i, j; int i, j;
vec3_t eorg; vec3_t eorg;
@ -642,6 +642,7 @@ PF_findradius (progs_t *pr)
org = P_VECTOR (pr, 0); org = P_VECTOR (pr, 0);
rad = P_FLOAT (pr, 1); rad = P_FLOAT (pr, 1);
rad *= rad; // Square early, sqrt never
ent = NEXT_EDICT (pr, sv.edicts); ent = NEXT_EDICT (pr, sv.edicts);
for (i = 1; i < sv.num_edicts; i++, ent = NEXT_EDICT (pr, ent)) { for (i = 1; i < sv.num_edicts; i++, ent = NEXT_EDICT (pr, ent)) {
@ -649,11 +650,12 @@ PF_findradius (progs_t *pr)
continue; continue;
if (SVfloat (ent, solid) == SOLID_NOT) if (SVfloat (ent, solid) == SOLID_NOT)
continue; continue;
eorigin = SVvector (ent, origin);
emins = SVvector (ent, mins);
emaxs = SVvector (ent, maxs);
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
eorg[j] = org[j] - (SVvector (ent, origin)[j] eorg[j] = org[j] - eorigin[j] - 0.5 * (emins[j] - emaxs[j]);
+ (SVvector (ent, mins)[j] if (DotProduct (eorg, eorg) > rad)
+ SVvector (ent, maxs)[j]) * 0.5);
if (VectorLength (eorg) > rad)
continue; continue;
SVentity (ent, chain) = EDICT_TO_PROG (pr, chain); SVentity (ent, chain) = EDICT_TO_PROG (pr, chain);

View file

@ -628,16 +628,15 @@ PF_findradius (progs_t *pr)
{ {
edict_t *ent, *chain; edict_t *ent, *chain;
float rad; float rad;
float *eorigin, *emins, *emaxs; float *eorigin, *emins, *emaxs, *org;
int i, j; int i, j;
vec3_t eorg, org; vec3_t eorg;
chain = (edict_t *) sv.edicts; chain = (edict_t *) sv.edicts;
VectorScale (P_VECTOR (pr, 0), 2, org); org = P_VECTOR (pr, 0);
rad = P_FLOAT (pr, 1); rad = P_FLOAT (pr, 1);
// * 4 because the * 0.5 was removed from the emins-emaxs average rad *= rad; // Square early, sqrt never
rad *= 4 * rad; // Square early, sqrt never
ent = NEXT_EDICT (pr, sv.edicts); ent = NEXT_EDICT (pr, sv.edicts);
for (i = 1; i < sv.num_edicts; i++, ent = NEXT_EDICT (pr, ent)) { for (i = 1; i < sv.num_edicts; i++, ent = NEXT_EDICT (pr, ent)) {
@ -648,9 +647,8 @@ PF_findradius (progs_t *pr)
eorigin = SVvector (ent, origin); eorigin = SVvector (ent, origin);
emins = SVvector (ent, mins); emins = SVvector (ent, mins);
emaxs = SVvector (ent, maxs); emaxs = SVvector (ent, maxs);
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
eorg[j] = org[j] - 2 * eorigin[j] - emins[j] - emaxs[j]; eorg[j] = org[j] - eorigin[j] - 0.5 * (emins[j] - emaxs[j]);
if (DotProduct (eorg, eorg) > rad) if (DotProduct (eorg, eorg) > rad)
continue; continue;