Fix a bunch of float vs int bugs

Just those made me glad I tried compiling with clang: running into those
bugs would have lead to some serious headaches, I imagine.
This commit is contained in:
Bill Currie 2022-03-31 00:28:26 +09:00
parent 38319d01b2
commit 0bb562f93f
7 changed files with 7 additions and 7 deletions

View file

@ -271,7 +271,7 @@ CL_RelinkEntities (void)
f = frac;
ent->old_origin = Transform_GetWorldPosition (ent->transform);
// If the delta is large, assume a teleport and don't lerp
if (fabs (delta[0]) > 100 || fabs (delta[1] > 100)
if (fabs (delta[0]) > 100 || fabs (delta[1]) > 100
|| fabs (delta[2]) > 100) {
// assume a teleportation, not a motion
CL_TransformEntity (ent, new->scale / 16.0, new->angles,

View file

@ -294,7 +294,7 @@ SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist)
return;
}
// try other directions
if (((rand () & 3) & 1) || abs (deltay) > abs (deltax)) {
if (((rand () & 3) & 1) || fabsf (deltay) > fabsf (deltax)) {
tdir = d[1];
d[1] = d[2];
d[2] = tdir;

View file

@ -240,7 +240,7 @@ CL_LinkPacketEntities (void)
vec4f_t delta = new->origin - old->origin;
f = frac;
// If the delta is large, assume a teleport and don't lerp
if (fabs (delta[0]) > 100 || fabs (delta[1] > 100)
if (fabs (delta[0]) > 100 || fabs (delta[1]) > 100
|| fabs (delta[2]) > 100) {
// assume a teleportation, not a motion
CL_TransformEntity (ent, new->scale / 16, new->angles,

View file

@ -293,7 +293,7 @@ SV_NewChaseDir (edict_t *actor, edict_t *enemy, float dist)
return;
}
// try other directions
if (((rand () & 3) & 1) || abs (deltay) > abs (deltax)) {
if (((rand () & 3) & 1) || fabsf (deltay) > fabsf (deltax)) {
tdir = d[1];
d[1] = d[2];
d[2] = tdir;

View file

@ -820,7 +820,7 @@ render_map (bsp_t *bsp)
vert1 = &vertexlist[edgelist[i].v[0]];
vert2 = &vertexlist[edgelist[i].v[1]];
SUB (*vert1, *vert2, vect);
if (abs (tempf) < options.flat_threshold
if (fabsf (tempf) < options.flat_threshold
&& usearea > options.area_threshold
&& sqrt (DOT (vect, vect)) > options.linelen_threshold) {
float offs0, offs1;

View file

@ -56,7 +56,7 @@ typedef struct entity_s {
const char *classname;
vec3_t origin;
vec_t angle;
int light;
vec_t light;
int sun_light[2];
vec3_t sun_color[2];

View file

@ -241,7 +241,7 @@ LoadEntities (void)
}
if (options.verbosity > 1 && entity->targetname)
printf ("%s %d %d\n", entity->targetname, entity->light,
printf ("%s %g %d\n", entity->targetname, entity->light,
entity->style);
// all fields have been parsed