Skip to content

Commit

Permalink
extra paranoia: fix 'abs()' warnings by leaving behavior unchanged
Browse files Browse the repository at this point in the history
- I don't have time for extensive testing of any actual game-behavior
  changes like 'abs()-->fabsf()' would introduce, so we'll leave this
  untouched and fix the warnings by explicit casting instead.
  (... this worked fine so far, so no reason to change it, unless done
  properly.)
- refs #31
  • Loading branch information
ReinhardPrix committed Aug 26, 2018
1 parent 7563f3e commit bb61143
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/enemy.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ CheckIfWayIsFreeOfDroids ( float x1 , float y1 , float x2 , float y2 , int OurLe
DebugPrintf( 2, "\nint CheckIfWayIsFreeOfDroids (...) : Checking from %d-%d to %d-%d.", (int) x1, (int) y1 , (int) x2, (int) y2 );
fflush(stdout);

if ( abs(x1-x2) > abs (y1-y2) ) LargerDistance=fabsf(x1-x2);
if ( abs((int)(x1-x2)) > abs ((int)(y1-y2)) ) LargerDistance=fabsf(x1-x2);
else LargerDistance=fabsf(y1-y2);

Steps=LargerDistance * 4 ; // We check four times on each map tile...
Expand Down
8 changes: 4 additions & 4 deletions src/influ.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ CheckInfluenceWallCollisions (void)
{
crashx = TRUE; /* In X wurde gecrasht */
sign = (SX < 0) ? -1 : 1;
SX = abs (SX);
SX = abs ((int)SX);
NumberOfShifts=0;
while (--SX
&& (DruidPassable (lastpos.x + sign * SX, lastpos.y) !=
Expand All @@ -518,7 +518,7 @@ CheckInfluenceWallCollisions (void)
{
crashy = TRUE; /* in Y wurde gecrasht */
sign = (SY < 0) ? -1 : 1;
SY = abs (SY);
SY = abs ((int)SY);
NumberOfShifts=0;
while (--SY
&& (DruidPassable (lastpos.x, lastpos.y + sign * SY) !=
Expand Down Expand Up @@ -727,9 +727,9 @@ CheckInfluenceEnemyCollision (void)
xdist = Me.pos.x - AllEnemys[i].pos.x;
ydist = Me.pos.y - AllEnemys[i].pos.y;

if (abs (xdist) > 1)
if (abs ((int)xdist) > 1)
continue;
if (abs (ydist) > 1)
if (abs ((int)ydist) > 1)
continue;

dist2 = sqrt( (xdist * xdist) + (ydist * ydist) );
Expand Down
4 changes: 2 additions & 2 deletions src/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -1315,10 +1315,10 @@ MoveLevelDoors (void)
AllEnemys[j].levelnum != CurLevel->levelnum)
continue;

xdist = abs (AllEnemys[j].pos.x - doorx);
xdist = abs ((int)(AllEnemys[j].pos.x - doorx));
if (xdist < Block_Rect.w)
{
ydist = abs (AllEnemys[j].pos.y - doory);
ydist = abs ((int)(AllEnemys[j].pos.y - doory));
if (ydist < Block_Rect.h)
{
dist2 = xdist * xdist + ydist * ydist;
Expand Down

0 comments on commit bb61143

Please sign in to comment.