Merge pull request #195 from tkoeppe/intfix

Fix signedness and float/int issues with abs()
This commit is contained in:
Tim Angus 2016-07-25 21:08:07 +01:00 committed by GitHub
commit 2ef99c8528
5 changed files with 9 additions and 9 deletions

View File

@ -390,9 +390,9 @@ int AAS_NearestEntity(vec3_t origin, int modelindex)
ent = &aasworld.entities[i]; ent = &aasworld.entities[i];
if (ent->i.modelindex != modelindex) continue; if (ent->i.modelindex != modelindex) continue;
VectorSubtract(ent->i.origin, origin, dir); VectorSubtract(ent->i.origin, origin, dir);
if (abs(dir[0]) < 40) if (fabsf(dir[0]) < 40)
{ {
if (abs(dir[1]) < 40) if (fabsf(dir[1]) < 40)
{ {
dist = VectorLength(dir); dist = VectorLength(dir);
if (dist < bestdist) if (dist < bestdist)

View File

@ -168,7 +168,7 @@ int AAS_AgainstLadder(vec3_t origin)
//get the plane the face is in //get the plane the face is in
plane = &aasworld.planes[face->planenum ^ side]; plane = &aasworld.planes[face->planenum ^ side];
//if the origin is pretty close to the plane //if the origin is pretty close to the plane
if (abs(DotProduct(plane->normal, origin) - plane->dist) < 3) if (fabsf(DotProduct(plane->normal, origin) - plane->dist) < 3)
{ {
if (AAS_PointInsideFace(abs(facenum), origin, 0.1f)) return qtrue; if (AAS_PointInsideFace(abs(facenum), origin, 0.1f)) return qtrue;
} //end if } //end if

View File

@ -2465,8 +2465,8 @@ int AAS_Reachability_Ladder(int area1num, int area2num)
VectorMA(area1point, -32, dir, area1point); VectorMA(area1point, -32, dir, area1point);
VectorMA(area2point, 32, dir, area2point); VectorMA(area2point, 32, dir, area2point);
// //
ladderface1vertical = abs(DotProduct(plane1->normal, up)) < 0.1; ladderface1vertical = fabsf(DotProduct(plane1->normal, up)) < 0.1;
ladderface2vertical = abs(DotProduct(plane2->normal, up)) < 0.1; ladderface2vertical = fabsf(DotProduct(plane2->normal, up)) < 0.1;
//there's only reachability between vertical ladder faces //there's only reachability between vertical ladder faces
if (!ladderface1vertical && !ladderface2vertical) return qfalse; if (!ladderface1vertical && !ladderface2vertical) return qfalse;
//if both vertical ladder faces //if both vertical ladder faces
@ -2474,7 +2474,7 @@ int AAS_Reachability_Ladder(int area1num, int area2num)
//and the ladder faces do not make a sharp corner //and the ladder faces do not make a sharp corner
&& DotProduct(plane1->normal, plane2->normal) > 0.7 && DotProduct(plane1->normal, plane2->normal) > 0.7
//and the shared edge is not too vertical //and the shared edge is not too vertical
&& abs(DotProduct(sharededgevec, up)) < 0.7) && fabsf(DotProduct(sharededgevec, up)) < 0.7)
{ {
//create a new reachability link //create a new reachability link
lreach = AAS_AllocReachability(); lreach = AAS_AllocReachability();
@ -2599,7 +2599,7 @@ int AAS_Reachability_Ladder(int area1num, int area2num)
if (face2->faceflags & FACE_LADDER) if (face2->faceflags & FACE_LADDER)
{ {
plane2 = &aasworld.planes[face2->planenum]; plane2 = &aasworld.planes[face2->planenum];
if (abs(DotProduct(plane2->normal, up)) < 0.1) break; if (fabsf(DotProduct(plane2->normal, up)) < 0.1) break;
} //end if } //end if
} //end for } //end for
//if from another area without vertical ladder faces //if from another area without vertical ladder faces

View File

@ -2054,7 +2054,7 @@ bot_moveresult_t BotTravel_Elevator(bot_movestate_t *ms, aas_reachability_t *rea
botimport.Print(PRT_MESSAGE, "bot on elevator\n"); botimport.Print(PRT_MESSAGE, "bot on elevator\n");
#endif //DEBUG_ELEVATOR #endif //DEBUG_ELEVATOR
//if vertically not too far from the end point //if vertically not too far from the end point
if (abs(ms->origin[2] - reach->end[2]) < sv_maxbarrier->value) if (fabsf(ms->origin[2] - reach->end[2]) < sv_maxbarrier->value)
{ {
#ifdef DEBUG_ELEVATOR #ifdef DEBUG_ELEVATOR
botimport.Print(PRT_MESSAGE, "bot moving to end\n"); botimport.Print(PRT_MESSAGE, "bot moving to end\n");

View File

@ -477,7 +477,7 @@ static unsigned int HashString (const char *key)
acc = (acc << 2) | (acc >> 30); acc = (acc << 2) | (acc >> 30);
acc &= 0xffffffffU; acc &= 0xffffffffU;
} }
return abs(acc); return acc;
} }