Fix warnings given by 32-bit fpc
authorunC0Rr
Fri, 14 Nov 2014 17:00:47 +0300
changeset 10494 0eb97cf4c78e
parent 10493 bcbf029e6b08
child 10495 6d61b44a5652
Fix warnings given by 32-bit fpc
hedgewars/uCollisions.pas
hedgewars/uGears.pas
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsList.pas
hedgewars/uGearsUtils.pas
hedgewars/uLandGenMaze.pas
hedgewars/uLandGenPerlin.pas
hedgewars/uLandGenTemplateBased.pas
hedgewars/uLandTexture.pas
hedgewars/uRender.pas
hedgewars/uRenderUtils.pas
hedgewars/uWorld.pas
--- a/hedgewars/uCollisions.pas	Wed Nov 12 22:47:43 2014 +0900
+++ b/hedgewars/uCollisions.pas	Fri Nov 14 17:00:47 2014 +0300
@@ -117,7 +117,7 @@
 function CheckCoordInWater(X, Y: LongInt): boolean; inline;
 begin
     CheckCoordInWater:= (Y > cWaterLine)
-        or ((WorldEdge = weSea) and ((X < leftX) or (X > rightX)));
+        or ((WorldEdge = weSea) and ((X < LongInt(leftX)) or (X > LongInt(rightX))));
 end;
 
 function CheckGearsCollision(Gear: PGear): PGearArray;
--- a/hedgewars/uGears.pas	Wed Nov 12 22:47:43 2014 +0900
+++ b/hedgewars/uGears.pas	Fri Nov 14 17:00:47 2014 +0300
@@ -567,7 +567,8 @@
 end;
 
 procedure AddMiscGears;
-var p,i,j,rx, ry, unplaced: Longword;
+var p,i,j, unplaced: Longword;
+    rx, ry: LongInt;
     rdx, rdy: hwFloat;
     Gear: PGear;
 begin
@@ -644,7 +645,7 @@
         begin
         rx:=GetRandom(snowRight - snowLeft);
         ry:=GetRandom(750);
-        AddGear(rx + snowLeft, LAND_HEIGHT + ry - 1300, gtFlake, 0, _0, _0, 0)
+        AddGear(rx + snowLeft, LongInt(LAND_HEIGHT) + ry - 1300, gtFlake, 0, _0, _0, 0)
         end
 end;
 
--- a/hedgewars/uGearsHandlersMess.pas	Wed Nov 12 22:47:43 2014 +0900
+++ b/hedgewars/uGearsHandlersMess.pas	Fri Nov 14 17:00:47 2014 +0300
@@ -281,7 +281,7 @@
 
 if cWaterLine > hwRound(Gear^.Y) + Gear^.Radius then
     begin
-    if leftX > hwRound(Gear^.X) - Gear^.Radius then
+    if LongInt(leftX) + Gear^.Radius > hwRound(Gear^.X) then
         Gear^.X := Gear^.X - cDrownSpeed
     else
         Gear^.X := Gear^.X + cDrownSpeed;
@@ -2671,7 +2671,7 @@
     HHGear: PGear;
     hedgehog: PHedgehog;
     State: Longword;
-    switchDir: LongInt;
+    switchDir: Longword;
 begin
     AllInactive := false;
 
@@ -2712,7 +2712,7 @@
         PlaySound(sndSwitchHog);
 
         repeat
-            CurrentTeam^.CurrHedgehog := (CurrentTeam^.CurrHedgehog + switchDir) mod (CurrentTeam^.HedgehogsNumber);
+            CurrentTeam^.CurrHedgehog := (CurrentTeam^.CurrHedgehog + switchDir) mod CurrentTeam^.HedgehogsNumber;
         until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) and
               (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear^.Damage = 0) and
               (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Effects[heFrozen]=0);
--- a/hedgewars/uGearsList.pas	Wed Nov 12 22:47:43 2014 +0900
+++ b/hedgewars/uGearsList.pas	Fri Nov 14 17:00:47 2014 +0300
@@ -247,9 +247,9 @@
                 //gear^.Tint:= (($e0+random(32)) shl 24) or
                 //             ((random(80)+128) shl 16) or
                 //             (($d5+random(32)) shl 8) or $ff
-                c:= random(32);
+                c:= GetRandom(32);
                 gear^.Tint:= (($e0+c) shl 24) or
-                             ((random(90)+128) shl 16) or
+                             ((GetRandom(90)+128) shl 16) or
                              (($d5+c) shl 8) or $ff
                 end;
        gtShell: begin
--- a/hedgewars/uGearsUtils.pas	Wed Nov 12 22:47:43 2014 +0900
+++ b/hedgewars/uGearsUtils.pas	Fri Nov 14 17:00:47 2014 +0300
@@ -523,7 +523,7 @@
     if WorldEdge = weSea then
         begin
         tmp:= dist2Water;
-        dist2Water:= min(dist2Water, min(X - Gear^.Radius - leftX, rightX - (X + Gear^.Radius)));
+        dist2Water:= min(dist2Water, min(X - Gear^.Radius - LongInt(leftX), LongInt(rightX) - (X + Gear^.Radius)));
         // if water on sides is closer than on bottom -> horizontal direction
         isDirH:= tmp <> dist2Water;
         end;
--- a/hedgewars/uLandGenMaze.pas	Wed Nov 12 22:47:43 2014 +0900
+++ b/hedgewars/uLandGenMaze.pas	Fri Nov 14 17:00:47 2014 +0300
@@ -311,7 +311,7 @@
 end;
 
 procedure GenMaze;
-var i: LongInt;
+var i: Longword;
 begin
 case cTemplateFilter of
     0: begin
--- a/hedgewars/uLandGenPerlin.pas	Wed Nov 12 22:47:43 2014 +0900
+++ b/hedgewars/uLandGenPerlin.pas	Fri Nov 14 17:00:47 2014 +0300
@@ -55,7 +55,7 @@
 
 function lerp(t, a, b: LongInt) : LongInt; inline;
 begin
-    lerp:= a + (Int64(b - a) * t shr 12)
+    lerp:= a + ((Int64(b) - a) * t shr 12)
 end;
 
 
@@ -103,7 +103,7 @@
 end;
 
 procedure inoise_setup();
-var i, ii, t: LongInt;
+var i, ii, t: Longword;
 begin
     for i:= 0 to 254 do
         p[i]:= i + 1;
--- a/hedgewars/uLandGenTemplateBased.pas	Wed Nov 12 22:47:43 2014 +0900
+++ b/hedgewars/uLandGenTemplateBased.pas	Fri Nov 14 17:00:47 2014 +0300
@@ -196,7 +196,7 @@
                 if (aqpb <> 0) then
                 begin
                     // (ix; iy) is intersection point
-                    iy:= ((Int64(pa.ar[i].x - mp.x) * b + Int64(mp.y) * a) * q - Int64(pa.ar[i].y) * p * b) div aqpb;
+                    iy:= (((Int64(pa.ar[i].x) - mp.x) * b + Int64(mp.y) * a) * q - Int64(pa.ar[i].y) * p * b) div aqpb;
                     if abs(b) > abs(q) then
                         ix:= (iy - mp.y) * a div b + mp.x
                     else
@@ -227,7 +227,7 @@
                 if (aqpb <> 0) then
                 begin
                     // (ix; iy) is intersection point
-                    iy:= ((Int64(p1.x - mp.x) * b + Int64(mp.y) * a) * q - Int64(p1.y) * p * b) div aqpb;
+                    iy:= (((Int64(p1.x) - mp.x) * b + Int64(mp.y) * a) * q - Int64(p1.y) * p * b) div aqpb;
                     if abs(b) > abs(q) then
                         ix:= (iy - mp.y) * a div b + mp.x
                     else
@@ -246,7 +246,7 @@
                 if (aqpb <> 0) then
                 begin
                     // (ix; iy) is intersection point
-                    iy:= ((Int64(p2.x - mp.x) * b + Int64(mp.y) * a) * q - Int64(p2.y) * p * b) div aqpb;
+                    iy:= (((Int64(p2.x) - mp.x) * b + Int64(mp.y) * a) * q - Int64(p2.y) * p * b) div aqpb;
                     if abs(b) > abs(q) then
                         ix:= (iy - mp.y) * a div b + mp.x
                     else
--- a/hedgewars/uLandTexture.pas	Wed Nov 12 22:47:43 2014 +0900
+++ b/hedgewars/uLandTexture.pas	Fri Nov 14 17:00:47 2014 +0300
@@ -129,13 +129,13 @@
                     while isEmpty and (ty < TEXSIZE) do
                         begin
                         isEmpty:= LandPixels[ly + ty, lx] and AMask = 0;
-                        if isEmpty then isEmpty:= LandPixels[ly + ty, lx + TEXSIZE-1] and AMask = 0;
+                        if isEmpty then isEmpty:= LandPixels[ly + ty, Pred(lx + TEXSIZE)] and AMask = 0;
                         inc(ty)
                         end;
                     while isEmpty and (tx < TEXSIZE-1) do
                         begin
                         isEmpty:= LandPixels[ly, lx + tx] and AMask = 0;
-                        if isEmpty then isEmpty:= LandPixels[ly + TEXSIZE-1, lx + tx] and AMask = 0;
+                        if isEmpty then isEmpty:= LandPixels[Pred(ly + TEXSIZE), lx + tx] and AMask = 0;
                         inc(tx)
                         end;
                     // then search every other remaining. does this sort of stuff defeat compiler opts?
--- a/hedgewars/uRender.pas	Wed Nov 12 22:47:43 2014 +0900
+++ b/hedgewars/uRender.pas	Fri Nov 14 17:00:47 2014 +0300
@@ -1482,8 +1482,8 @@
 else
     PrepareVbForWater(true,
         OffsetY + WorldDy + cWaterLine, ViewTopY,
-        LeftX  + WorldDx - OffsetX, ViewLeftX,
-        RightX + WorldDx + OffsetX, ViewRightX,
+        LongInt(LeftX)  + WorldDx - OffsetX, ViewLeftX,
+        LongInt(RightX) + WorldDx + OffsetX, ViewRightX,
         ViewBottomY,
         first, count);
 
@@ -1561,8 +1561,8 @@
 dY:= -cWaveHeight + dy;
 ox:= -cWaveHeight + ox;
 
-lx:= LeftX  + WorldDx - ox;
-rx:= RightX + WorldDx + ox;
+lx:= LongInt(LeftX)  + WorldDx - ox;
+rx:= LongInt(RightX) + WorldDx + ox;
 
 topy:= cWaterLine + WorldDy + dY;
 
--- a/hedgewars/uRenderUtils.pas	Wed Nov 12 22:47:43 2014 +0900
+++ b/hedgewars/uRenderUtils.pas	Fri Nov 14 17:00:47 2014 +0300
@@ -77,13 +77,13 @@
 end;*)
 
 function WriteInRoundRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring; maxLength: LongWord): TSDL_Rect;
-var w, h: LongInt;
+var w, h: Longword;
     tmpsurf: PSDL_Surface;
     clr: TSDL_Color;
     finalRect, textRect: TSDL_Rect;
 begin
     TTF_SizeUTF8(Fontz[Font].Handle, PChar(s), @w, @h);
-    if (maxLength <> 0) and (w > maxLength) then w := maxLength;
+    if (maxLength > 0) and (w > maxLength) then w := maxLength;
     finalRect.x:= X;
     finalRect.y:= Y;
     finalRect.w:= w + cFontBorder * 2 + 4;
@@ -274,7 +274,7 @@
 end;
 
 function RenderStringTexLim(s: ansistring; Color: Longword; font: THWFont; maxLength: LongWord): PTexture;
-var w, h: LongInt;
+var w, h: Longword;
     finalSurface: PSDL_Surface;
 begin
     if cOnlyStats then
@@ -287,7 +287,7 @@
         font:= CheckCJKFont(s, font);
         w:= 0; h:= 0; // avoid compiler hints
         TTF_SizeUTF8(Fontz[font].Handle, PChar(s), @w, @h);
-        if (maxLength <> 0) and (w > maxLength) then w := maxLength;
+        if (maxLength > 0) and (w > maxLength) then w := maxLength;
 
         finalSurface:= SDL_CreateRGBSurface(SDL_SWSURFACE, w + cFontBorder * 2 + 4, h + cFontBorder * 2,
                 32, RMask, GMask, BMask, AMask);
--- a/hedgewars/uWorld.pas	Wed Nov 12 22:47:43 2014 +0900
+++ b/hedgewars/uWorld.pas	Fri Nov 14 17:00:47 2014 +0300
@@ -1002,7 +1002,7 @@
 {$ENDIF}
 end;
 
-procedure RenderWorldEdge(Lag: Longword);
+procedure RenderWorldEdge;
 var
     //VertexBuffer: array [0..3] of TVertex2f;
     tmp, w: LongInt;
@@ -1015,7 +1015,7 @@
 
     rect.y:= ViewTopY;
     rect.h:= ViewHeight;
-    tmp:= leftX + WorldDx;
+    tmp:= LongInt(leftX) + WorldDx;
     w:= tmp - ViewLeftX;
 
     if w > 0 then
@@ -1027,7 +1027,7 @@
             DrawLineOnScreen(tmp - 1, ViewTopY, tmp - 1, ViewBottomY, 2, $54, $54, $FF, $FF);
         end;
 
-    tmp:= rightX + WorldDx;
+    tmp:= LongInt(rightX) + WorldDx;
     w:= ViewRightX - tmp;
 
     if w > 0 then
@@ -1271,12 +1271,12 @@
 
     if Flip then
         begin
-        WorldDx:= -WorldDx - playWidth - Dir * playWidth;
+        WorldDx:= -WorldDx - LongInt(playWidth) - Dir * LongInt(playWidth);
         openglPushMatrix();
         openglScalef(-1, 1, 1);
         end
     else
-        WorldDx:= WorldDx + Dir * playWidth;
+        WorldDx:= WorldDx + Dir * LongInt(playWidth);
 
 end;
 
@@ -1306,8 +1306,8 @@
     end
 else
     begin
-    replicateToLeft := (leftX  + WorldDx > ViewLeftX);
-    replicateToRight:= (rightX + WorldDx < ViewRightX);
+    replicateToLeft := (LongInt(leftX)  + WorldDx > ViewLeftX);
+    replicateToRight:= (LongInt(rightX) + WorldDx < ViewRightX);
     flip:= (WorldEdge = weBounce);
     end;
 
@@ -1511,7 +1511,7 @@
     end;
 {$WARNINGS ON}
 
-RenderWorldEdge(Lag);
+RenderWorldEdge();
 
 // this scale is used to keep the various widgets at the same dimension at all zoom levels
 SetScale(cDefaultZoomLevel);
@@ -1835,7 +1835,7 @@
                     end;
                 end;
         //DrawSprite(sprArrow, TargetCursorPoint.X, cScreenHeight - TargetCursorPoint.Y, (RealTicks shr 6) mod 8)
-        DrawTextureF(SpritesData[sprArrow].Texture, cDefaultZoomLevel / cScaleFactor, TargetCursorPoint.X + round(SpritesData[sprArrow].Width / cScaleFactor), cScreenHeight - TargetCursorPoint.Y + round(SpritesData[sprArrow].Height / cScaleFactor), (RealTicks shr 6) mod 8, 1, SpritesData[sprArrow].Width, SpritesData[sprArrow].Height);
+        DrawTextureF(SpritesData[sprArrow].Texture, cDefaultZoomLevel / cScaleFactor, TargetCursorPoint.X + round(SpritesData[sprArrow].Width / cScaleFactor), cScreenHeight + round(SpritesData[sprArrow].Height / cScaleFactor) - TargetCursorPoint.Y, (RealTicks shr 6) mod 8, 1, SpritesData[sprArrow].Width, SpritesData[sprArrow].Height);
         end
     end;
 
@@ -1875,7 +1875,7 @@
         begin
         if abs(prevPoint.X - WorldDx - hwRound(FollowGear^.X)) > rightX - leftX - 100 then
             begin
-            if (prevPoint.X - WorldDx) * 2 < rightX + leftX then
+            if (prevPoint.X - WorldDx) * 2 < LongInt(rightX + leftX) then
                 cameraJump:= rightX - leftX
                 else
                 cameraJump:= leftX - rightX;