overall, using LongInt for leftX/rightX results in fewer casts, since most comparisons are against ints.
authornemo
Fri, 23 Nov 2018 15:54:23 -0500
changeset 14282 6015b74eea55
parent 14281 e754b516cc35
child 14283 9548edd9ebcf
overall, using LongInt for leftX/rightX results in fewer casts, since most comparisons are against ints.
hedgewars/uCollisions.pas
hedgewars/uGearsHandlers.pas
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsHandlersRope.pas
hedgewars/uGearsHedgehog.pas
hedgewars/uGearsRender.pas
hedgewars/uGearsUtils.pas
hedgewars/uLand.pas
hedgewars/uLandGenTemplateBased.pas
hedgewars/uLandGraphics.pas
hedgewars/uLandObjects.pas
hedgewars/uRender.pas
hedgewars/uVariables.pas
hedgewars/uWorld.pas
--- a/hedgewars/uCollisions.pas	Fri Nov 23 21:22:26 2018 +0100
+++ b/hedgewars/uCollisions.pas	Fri Nov 23 15:54:23 2018 -0500
@@ -145,7 +145,7 @@
 function CheckCoordInWater(X, Y: LongInt): boolean; inline;
 begin
     CheckCoordInWater:= (Y > cWaterLine)
-        or ((WorldEdge = weSea) and ((X < LongInt(leftX)) or (X > LongInt(rightX))));
+        or ((WorldEdge = weSea) and ((X < leftX) or (X > rightX)));
 end;
 
 function CheckGearsCollision(Gear: PGear): PGearArray;
--- a/hedgewars/uGearsHandlers.pas	Fri Nov 23 21:22:26 2018 +0100
+++ b/hedgewars/uGearsHandlers.pas	Fri Nov 23 15:54:23 2018 -0500
@@ -97,7 +97,7 @@
 
     // Handle world wrap and bounce edge manually
     if (WorldEdge = weWrap) and
-        ((hwRound(Gear^.X) < LongInt(leftX)) or (hwRound(Gear^.X) > LongInt(rightX))) then
+        ((hwRound(Gear^.X) < leftX) or (hwRound(Gear^.X) > rightX)) then
         begin
         LeftImpactTimer:= 150;
         RightImpactTimer:= 150;
@@ -105,9 +105,9 @@
         Gear^.Karma:= 1;
         end
     else if (WorldEdge = weBounce) and
-        (((hwRound(Gear^.X) - Gear^.Radius) < LongInt(leftX)) or ((hwRound(Gear^.X) + Gear^.Radius) > LongInt(rightX))) then
+        (((hwRound(Gear^.X) - Gear^.Radius) < leftX) or ((hwRound(Gear^.X) + Gear^.Radius) > rightX)) then
         begin
-        if (hwRound(Gear^.X) - Gear^.Radius < LongInt(leftX)) then
+        if (hwRound(Gear^.X) - Gear^.Radius < leftX) then
             LeftImpactTimer:= 333
         else
             RightImpactTimer:= 333;
--- a/hedgewars/uGearsHandlersMess.pas	Fri Nov 23 21:22:26 2018 +0100
+++ b/hedgewars/uGearsHandlersMess.pas	Fri Nov 23 15:54:23 2018 -0500
@@ -308,7 +308,7 @@
 
 if cWaterLine > hwRound(Gear^.Y) + Gear^.Radius then
     begin
-    if LongInt(leftX) + Gear^.Radius > hwRound(Gear^.X) then
+    if leftX + Gear^.Radius > hwRound(Gear^.X) then
         Gear^.X := Gear^.X - cDrownSpeed
     else
         Gear^.X := Gear^.X + cDrownSpeed;
@@ -375,7 +375,7 @@
         if (not Gear^.Sticky) then
             begin
             Gear^.X:= tX;
-            Gear^.dX.isNegative:= (gX > LongInt(leftX) + Gear^.Radius*2);
+            Gear^.dX.isNegative:= (gX > leftX + Gear^.Radius*2);
             Gear^.dX := Gear^.dX * Gear^.Friction;
             end;
         Gear^.State := Gear^.State or gstCollision;
@@ -842,9 +842,9 @@
         draw:= true;
     xx:= hwRound(Gear^.X);
     yy:= hwRound(Gear^.Y);
-    if draw and (WorldEdge = weWrap) and ((xx < LongInt(leftX) + 3) or (xx > LongInt(rightX) - 3)) then
-        begin
-        if xx < LongInt(leftX) + 3 then
+    if draw and (WorldEdge = weWrap) and ((xx < leftX + 3) or (xx > rightX - 3)) then
+        begin
+        if xx < leftX + 3 then
              xx:= rightX-3
         else xx:= leftX+3;
         Gear^.X:= int2hwFloat(xx)
@@ -3681,7 +3681,7 @@
         begin
         // Update coordinates
         tdx:=Gear^.X;
-        if (hwRound(Gear^.X) < LongInt(leftX)) then
+        if (hwRound(Gear^.X) < leftX) then
              Gear^.X:= Gear^.X + int2hwfloat(rightX - leftX)
         else Gear^.X:= Gear^.X - int2hwfloat(rightX - leftX);
 
@@ -5431,20 +5431,20 @@
 
         if WorldEdge = weWrap then
             begin
-            if x > LongInt(rightX) then
+            if x > rightX then
                 repeat
                     dec(x,  playWidth);
                     dec(rx, playWidth);
-                until x <= LongInt(rightX)
-            else if x < LongInt(leftX) then
+                until x <= rightX
+            else if x < leftX then
                 repeat
                     inc(x,  playWidth);
                     inc(rx, playWidth);
-                until x >= LongInt(leftX);
+                until x >= leftX;
             end
         else if (WorldEdge = weBounce) then
             begin
-            if (not justBounced) and ((x > LongInt(rightX)) or (x < LongInt(leftX))) then
+            if (not justBounced) and ((x > rightX) or (x < leftX)) then
                 begin
                 // reflect
                 lX:= lX - ldX + ((oX - lX) * 2);
@@ -6390,8 +6390,8 @@
                          (Land[Target.Y, Target.X] = lfIce) and
                          ((Target.Y+iceHeight+5 > cWaterLine) or
                           ((WorldEdge = weSea) and
-                           ((Target.X+iceHeight+5 > LongInt(rightX)) or
-                            (Target.X-iceHeight-5 < LongInt(leftX)))))
+                           ((Target.X+iceHeight+5 > rightX) or
+                            (Target.X-iceHeight-5 < leftX))))
                          ) then
                     begin
                     if Timer = iceWaitCollision then
@@ -6500,7 +6500,7 @@
                         DrawIceBreak(Target.X, Target.Y, iceRadius, iceHeight)
                     else if Target.Y+iceHeight+5 > cWaterLine then
                         DrawIceBreak(Target.X, Target.Y+iceHeight+5, iceRadius, iceHeight)
-                    else if Target.X+iceHeight+5 > LongInt(rightX) then
+                    else if Target.X+iceHeight+5 > rightX then
                         DrawIceBreak(Target.X+iceHeight+5, Target.Y, iceRadius, iceHeight)
                     else
                         DrawIceBreak(Target.X-iceHeight-5, Target.Y, iceRadius, iceHeight);
@@ -6613,7 +6613,7 @@
 if (Gear^.State and gstTmpFlag <> 0) or (GameTicks and $7 = 0) then
     begin
     doStepFallingGear(Gear);
-    if (Gear^.Tag = 1) and (GameTicks and $FF = 0) and (hwRound(Gear^.X) < LongInt(leftX)) or (hwRound(Gear^.X) > LongInt(rightX)) or (hwRound(Gear^.Y) < LongInt(topY)) then
+    if (Gear^.Tag = 1) and (GameTicks and $FF = 0) and (hwRound(Gear^.X) < leftX) or (hwRound(Gear^.X) > rightX) or (hwRound(Gear^.Y) < LongInt(topY)) then
         begin
         Gear^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX);
         Gear^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY);
--- a/hedgewars/uGearsHandlersRope.pas	Fri Nov 23 21:22:26 2018 +0100
+++ b/hedgewars/uGearsHandlersRope.pas	Fri Nov 23 15:54:23 2018 -0500
@@ -50,7 +50,7 @@
        ((TestCollisionXwithGear(HHGear, 1) <> 0) or (TestCollisionXwithGear(HHGear, -1) <> 0))  then
         begin
         HHGear^.X:= tX;
-        HHGear^.dX.isNegative:= hwRound(tX) > LongInt(leftX) + HHGear^.Radius * 2
+        HHGear^.dX.isNegative:= hwRound(tX) > leftX + HHGear^.Radius * 2
         end;
 
     if (HHGear^.Hedgehog^.CurAmmoType = amParachute) and (HHGear^.dY > _0_39) then
@@ -160,7 +160,7 @@
         PlaySound(sndRopeRelease);
         RopeDeleteMe(Gear, HHGear);
         HHGear^.X:= tX;
-        HHGear^.dX.isNegative:= hwRound(tX) > LongInt(leftX) + HHGear^.Radius * 2;
+        HHGear^.dX.isNegative:= hwRound(tX) > leftX + HHGear^.Radius * 2;
         exit
         end;
 
--- a/hedgewars/uGearsHedgehog.pas	Fri Nov 23 21:22:26 2018 +0100
+++ b/hedgewars/uGearsHedgehog.pas	Fri Nov 23 15:54:23 2018 -0500
@@ -1273,7 +1273,7 @@
 if (not isZero(Gear^.dY)) and (Gear^.FlightTime > 0) and ((GameFlags and gfLowGravity) = 0) then
     begin
     inc(Gear^.FlightTime);
-    if (Gear^.FlightTime > 1500) and ((hwRound(Gear^.X) < LongInt(leftX)-250) or (hwRound(Gear^.X) > LongInt(rightX)+250))  then
+    if (Gear^.FlightTime > 1500) and ((hwRound(Gear^.X) < leftX-250) or (hwRound(Gear^.X) > rightX+250))  then
         begin
         Gear^.FlightTime:= 0;
         s:= ansistring(CurrentHedgehog^.Name);
@@ -1580,7 +1580,7 @@
         // Stop hedgehog if it collides with land *just* behind other side of world wrap edge
         if ((Gear^.State and gstNotKickable) = 0) then
             begin
-            if (hwRound(tX) > LongInt(leftX) + Gear^.Radius * 2) then
+            if (hwRound(tX) > leftX + Gear^.Radius * 2) then
                 Gear^.X:= int2HwFloat(RightX)
             else
                 Gear^.X:= int2HwFloat(LeftX);
--- a/hedgewars/uGearsRender.pas	Fri Nov 23 21:22:26 2018 +0100
+++ b/hedgewars/uGearsRender.pas	Fri Nov 23 15:54:23 2018 -0500
@@ -816,30 +816,30 @@
                         begin
                         if WorldEdge = weWrap then
                             begin
-                            if hwRound(Gear^.X) < LongInt(leftX) + 256 then
+                            if hwRound(Gear^.X) < leftX + 256 then
                                 DrawSpriteClipped(sprGirder,
                                                 rightX+(ox-leftX)-256,
                                                 oy-256,
                                                 LongInt(topY)+WorldDy,
-                                                LongInt(rightX)+WorldDx,
+                                                rightX+WorldDx,
                                                 cWaterLine+WorldDy,
-                                                LongInt(leftX)+WorldDx);
-                            if hwRound(Gear^.X) > LongInt(rightX) - 256 then
+                                                leftX+WorldDx);
+                            if hwRound(Gear^.X) > rightX - 256 then
                                 DrawSpriteClipped(sprGirder,
                                                 leftX-(rightX-ox)-256,
                                                 oy-256,
                                                 LongInt(topY)+WorldDy,
-                                                LongInt(rightX)+WorldDx,
+                                                rightX+WorldDx,
                                                 cWaterLine+WorldDy,
-                                                LongInt(leftX)+WorldDx)
+                                                leftX+WorldDx)
                             end;
                         DrawSpriteClipped(sprGirder,
                                         ox-256,
                                         oy-256,
                                         LongInt(topY)+WorldDy,
-                                        LongInt(rightX)+WorldDx,
+                                        rightX+WorldDx,
                                         cWaterLine+WorldDy,
-                                        LongInt(leftX)+WorldDx)
+                                        leftX+WorldDx)
                         end
                     else if cBuildMaxDist > 0 then
                         begin
--- a/hedgewars/uGearsUtils.pas	Fri Nov 23 21:22:26 2018 +0100
+++ b/hedgewars/uGearsUtils.pas	Fri Nov 23 15:54:23 2018 -0500
@@ -238,12 +238,12 @@
         break;
 
     // Radius + 5 because that's the actual radius the explosion changes graphically
-    if X + (Radius + 5) > LongInt(rightX) then
+    if X + (Radius + 5) > rightX then
         begin
         dec(X, playWidth);
         wrap:= true;
         end
-    else if X - (Radius + 5) < LongInt(leftX) then
+    else if X - (Radius + 5) < leftX then
         begin
         inc(X, playWidth);
         wrap:= true;
@@ -664,7 +664,7 @@
     if WorldEdge = weSea then
         begin
         tmp:= dist2Water;
-        dist2Water:= min(dist2Water, min(X - Gear^.Radius - LongInt(leftX), LongInt(rightX) - (X + Gear^.Radius)));
+        dist2Water:= min(dist2Water, min(X - Gear^.Radius - leftX, rightX - (X + Gear^.Radius)));
         // if water on sides is closer than on bottom -> horizontal direction
         isDirH:= tmp <> dist2Water;
         end;
@@ -935,7 +935,7 @@
 tryAgain:= true;
 if WorldEdge <> weNone then
     begin
-    Left:= max(Left, LongInt(leftX) + Gear^.Radius);
+    Left:= max(Left, leftX + Gear^.Radius);
     Right:= min(Right,rightX-Gear^.Radius)
     end;
 while tryAgain do
@@ -1748,12 +1748,12 @@
 begin
 WorldWrap:= false;
 if WorldEdge = weNone then exit(false);
-if (hwRound(Gear^.X) < LongInt(leftX)) or
-   (hwRound(Gear^.X) > LongInt(rightX)) then
+if (hwRound(Gear^.X) < leftX) or
+   (hwRound(Gear^.X) > rightX) then
     begin
     if WorldEdge = weWrap then
         begin
-        if (hwRound(Gear^.X) < LongInt(leftX)) then
+        if (hwRound(Gear^.X) < leftX) then
              Gear^.X:= Gear^.X + int2hwfloat(rightX - leftX)
         else Gear^.X:= Gear^.X - int2hwfloat(rightX - leftX);
         LeftImpactTimer:= 150;
@@ -1761,11 +1761,11 @@
         end
     else if WorldEdge = weBounce then
         begin
-        if (hwRound(Gear^.X) - Gear^.Radius < LongInt(leftX)) then
+        if (hwRound(Gear^.X) - Gear^.Radius < leftX) then
             begin
             LeftImpactTimer:= 333;
             Gear^.dX.isNegative:= false;
-            Gear^.X:= int2hwfloat(LongInt(leftX) + Gear^.Radius)
+            Gear^.X:= int2hwfloat(leftX + Gear^.Radius)
             end
         else
             begin
--- a/hedgewars/uLand.pas	Fri Nov 23 21:22:26 2018 +0100
+++ b/hedgewars/uLand.pas	Fri Nov 23 15:54:23 2018 -0500
@@ -376,7 +376,7 @@
 
     if gameFlags and gfShoppaBorder <> 0 then DrawShoppaBorder;
 
-    for x:= leftX+2 to rightX-2 do
+    for x:= LongWord(leftX+2) to LongWord(rightX-2) do
         for y:= topY+2 to LAND_HEIGHT-3 do
             if (Land[y, x] = 0) and
                (((Land[y, x-1] = lfBasic) and ((Land[y+1,x] = lfBasic)) or (Land[y-1,x] = lfBasic)) or
@@ -692,7 +692,7 @@
 var x, w, c, y: Longword;
 begin
 for w:= 0 to 23 do
-    for x:= leftX to rightX do
+    for x:= LongWord(leftX) to LongWord(rightX) do
         begin
         y:= Longword(cWaterLine) - 1 - w;
         Land[y, x]:= lfIndestructible;
@@ -753,7 +753,7 @@
     hasBorder:= true
 else
     for y:= topY to topY + 5 do
-        for x:= leftX to rightX do
+        for x:= LongWord(leftX) to LongWord(rightX) do
             if Land[y, x] <> 0 then
                 begin
                 inc(c);
@@ -770,7 +770,7 @@
         begin
         for y:= 0 to LAND_HEIGHT - 1 do
             for x:= 0 to LAND_WIDTH - 1 do
-                if (y < topY) or (x < leftX) or (x > rightX) then
+                if (y < topY) or (x < LongWord(leftX)) or (x > LongWord(rightX)) then
                     Land[y, x]:= lfIndestructible;
         end
     else if topY > 0 then
@@ -809,7 +809,7 @@
                         end;
                     end;
 
-        for x:= leftX to rightX do
+        for x:= LongWord(leftX) to LongWord(rightX) do
             begin
             Land[topY + w, x]:= lfIndestructible;
             if (x + w) mod 32 < 16 then
@@ -844,7 +844,7 @@
 if GrayScale then
     begin
     if (cReducedQuality and rqBlurryLand) = 0 then
-        for x:= leftX to rightX do
+        for x:= LongWord(leftX) to LongWord(rightX) do
             for y:= topY to LAND_HEIGHT-1 do
                 begin
                 w:= LandPixels[y,x];
@@ -857,7 +857,7 @@
                 LandPixels[y,x]:= w or (LandPixels[y, x] and AMask)
                 end
     else
-        for x:= leftX div 2 to rightX div 2 do
+        for x:= LongWord(leftX div 2) to LongWord(rightX div 2) do
             for y:= topY div 2 to LAND_HEIGHT-1 div 2 do
                 begin
                 w:= LandPixels[y div 2,x div 2];
--- a/hedgewars/uLandGenTemplateBased.pas	Fri Nov 23 21:22:26 2018 +0100
+++ b/hedgewars/uLandGenTemplateBased.pas	Fri Nov 23 15:54:23 2018 -0500
@@ -114,8 +114,8 @@
     // don't process too short segments or those which are too close to map borders
     if (p1.x = NTPX)
             or (dab < minDistance * 3)
-            or (mp.x < LongInt(leftX) + mapBorderMargin)
-            or (mp.x > LongInt(rightX) - mapBorderMargin)
+            or (mp.x < leftX + mapBorderMargin)
+            or (mp.x > rightX - mapBorderMargin)
             or (mp.y < LongInt(topY) + mapBorderMargin)
             or (mp.y > LongInt(LAND_HEIGHT) - mapBorderMargin)
     then
@@ -128,13 +128,13 @@
     if a <> 0 then
     begin
         // left border
-        iy:= (LongInt(leftX) + mapBorderMargin - mp.x) * b div a + mp.y;
+        iy:= (leftX + mapBorderMargin - mp.x) * b div a + mp.y;
         d:= DistanceI(mp.x - leftX - mapBorderMargin, mp.y - iy).Round;
         t1:= a * (mp.x - mapBorderMargin) + b * (mp.y - iy);
         if t1 > 0 then distL:= d else distR:= d;
 
         // right border
-        iy:= (LongInt(rightX) - mapBorderMargin - mp.x) * b div a + mp.y;
+        iy:= (rightX - mapBorderMargin - mp.x) * b div a + mp.y;
         d:= DistanceI(mp.x - rightX + mapBorderMargin, mp.y - iy).Round;
         if t1 > 0 then distR:= d else distL:= d;
     end else
--- a/hedgewars/uLandGraphics.pas	Fri Nov 23 21:22:26 2018 +0100
+++ b/hedgewars/uLandGraphics.pas	Fri Nov 23 15:54:23 2018 -0500
@@ -422,7 +422,7 @@
     if x <= leftX then
         iceR:= min(leftX + iceHeight, iceR)
     else {if x >= rightX then}
-        iceL:= max(LongInt(rightX) - iceHeight, iceL);
+        iceL:= max(rightX - iceHeight, iceL);
     end;
 
 // don't continue if all ice is outside land array
@@ -754,7 +754,7 @@
 
                    (not outOfMap and
                        (((cpY + y) <= Longint(topY)) or ((cpY + y) >= LAND_HEIGHT) or
-                       ((cpX + x) <= Longint(leftX)) or ((cpX + x) >= Longint(rightX)) or
+                       ((cpX + x) <= leftX) or ((cpX + x) >= rightX) or
                        ((not force) and (Land[cpY + y, cpX + x] <> 0)))) then
                    begin
                    if SDL_MustLock(Image) then
@@ -874,7 +874,7 @@
         for x:= 0 to Pred(w) do
             if ((PLongword(@(p^[x * 4]))^) and AMask) <> 0 then
                 if ((cpY + y) <= Longint(topY)) or ((cpY + y) >= LAND_HEIGHT) or
-                   ((cpX + x) <= Longint(leftX)) or ((cpX + x) >= Longint(rightX)) then
+                   ((cpX + x) <= leftX) or ((cpX + x) >= rightX) then
                    begin
                    if SDL_MustLock(Image) then
                        SDL_UnlockSurface(Image);
@@ -977,7 +977,7 @@
     for x:= 0 to Pred(w) do
         if ((p^[x] and AMask) <> 0)
             and (((cpY + y) < Longint(topY)) or ((cpY + y) >= LAND_HEIGHT) or
-            ((cpX + x) < Longint(leftX)) or ((cpX + x) > Longint(rightX)) or (Land[cpY + y, cpX + x] <> 0)) then
+            ((cpX + x) < leftX) or ((cpX + x) > rightX) or (Land[cpY + y, cpX + x] <> 0)) then
                 pt^[x]:= cWhiteColor
         else
             (pt^[x]):= cWhiteColor and (not AMask);
@@ -1075,7 +1075,7 @@
 
 // check location
 if (Y <= LongInt(topY) + 1) or (Y >= LAND_HEIGHT-2)
-or (X <= LongInt(leftX) + 1) or (X >= LongInt(rightX) - 1) then
+or (X <= leftX + 1) or (X >= rightX - 1) then
     exit;
 
 // counter for neighbor pixels that are not known to be undamaged
@@ -1127,7 +1127,7 @@
 begin
 // a bit of AA for explosions
 if (Land[Y, X] = 0) and (Y > LongInt(topY) + 1) and
-    (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then
+    (Y < LAND_HEIGHT-2) and (X > leftX + 1) and (X < rightX - 1) then
     begin
     if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0))
     or (((Land[y, x+1] and lfDamaged) <> 0) and (((Land[y-1,x] and lfDamaged) <> 0) or ((Land[y+1,x] and lfDamaged) <> 0)))) then
@@ -1185,7 +1185,7 @@
     end
 else if ((cReducedQuality and rqBlurryLand) = 0) and ((LandPixels[Y, X] and AMask) = AMask)
 and (Land[Y, X] and (lfDamaged or lfBasic) = lfBasic)
-and (Y > LongInt(topY) + 1) and (Y < LAND_HEIGHT-2) and (X > LongInt(leftX) + 1) and (X < LongInt(rightX) - 1) then
+and (Y > LongInt(topY) + 1) and (Y < LAND_HEIGHT-2) and (X > leftX + 1) and (X < rightX - 1) then
     begin
     if ((((Land[y, x-1] and lfDamaged) <> 0) and (((Land[y+1,x] and lfDamaged) <> 0)) or ((Land[y-1,x] and lfDamaged) <> 0))
     or (((Land[y, x+1] and lfDamaged) <> 0) and (((Land[y-1,x] and lfDamaged) <> 0) or ((Land[y+1,x] and lfDamaged) <> 0)))) then
--- a/hedgewars/uLandObjects.pas	Fri Nov 23 21:22:26 2018 +0100
+++ b/hedgewars/uLandObjects.pas	Fri Nov 23 15:54:23 2018 -0500
@@ -363,27 +363,27 @@
     x1:= gX;
     x2:= gX;
 
-    while (x1 > Longint(leftX)+150) and (CountNonZeroz(x1, y, girderHeight) = 0) do
+    while (x1 > leftX+150) and (CountNonZeroz(x1, y, girderHeight) = 0) do
         dec(x1, 2);
 
     i:= x1 - 12;
     repeat
         k:= CountNonZeroz(x1, y, girderHeight);
         dec(x1, 2)
-    until (x1 < Longint(leftX) + 100) or (k = 0) or (k = girderHeight) or (x1 < i);
+    until (x1 < leftX + 100) or (k = 0) or (k = girderHeight) or (x1 < i);
 
     inc(x1, 2);
     if k = girderHeight then
         begin
-        while (x2 < (LongInt(rightX) - 100)) and (CountNonZeroz(x2, y, girderHeight) = 0) do
+        while (x2 < (rightX - 100)) and (CountNonZeroz(x2, y, girderHeight) = 0) do
             inc(x2, 2);
         i:= x2 + 12;
         repeat
         inc(x2, 2);
         k:= CountNonZeroz(x2, y, girderHeight)
-        until (x2 >= (LongInt(rightX)-150)) or (k = 0) or (k = girderHeight) or (x2 > i) or (x2 - x1 >= 900);
+        until (x2 >= (rightX-150)) or (k = 0) or (k = girderHeight) or (x2 > i) or (x2 - x1 >= 900);
 
-        if (x2 < (LongInt(rightX) - 100)) and (k = girderHeight) and (x2 - x1 > 200) and (x2 - x1 < 900)
+        if (x2 < (rightX - 100)) and (k = girderHeight) and (x2 - x1 > 200) and (x2 - x1 < 900)
         and (not CheckIntersect(x1 - 32, y - 64, x2 - x1 + 64, 144)) then
                 break;
         end;
--- a/hedgewars/uRender.pas	Fri Nov 23 21:22:26 2018 +0100
+++ b/hedgewars/uRender.pas	Fri Nov 23 15:54:23 2018 -0500
@@ -1845,8 +1845,8 @@
 else
     PrepareVbForWater(true,
         OffsetY + WorldDy + cWaterLine, ViewTopY,
-        LongInt(LeftX)  + WorldDx - OffsetX, ViewLeftX,
-        LongInt(RightX) + WorldDx + OffsetX, ViewRightX,
+        leftX  + WorldDx - OffsetX, ViewLeftX,
+        rightX + WorldDx + OffsetX, ViewRightX,
         ViewBottomY,
         first, count);
 
@@ -1936,8 +1936,8 @@
 dY:= -cWaveHeight + dy;
 ox:= -cWaveHeight + ox;
 
-lx:= LongInt(LeftX)  + WorldDx - ox;
-rx:= LongInt(RightX) + WorldDx + ox;
+lx:= leftX  + WorldDx - ox;
+rx:= rightX + WorldDx + ox;
 
 topy:= cWaterLine + WorldDy + dY;
 
--- a/hedgewars/uVariables.pas	Fri Nov 23 21:22:26 2018 +0100
+++ b/hedgewars/uVariables.pas	Fri Nov 23 15:54:23 2018 -0500
@@ -2461,7 +2461,8 @@
     LandDirty: TDirtyTag;
     hasBorder: boolean;
     hasGirders: boolean;
-    playHeight, playWidth, leftX, rightX, topY, MaxHedgehogs: Longword;  // idea is that a template can specify height/width.  Or, a map, a height/width by the dimensions of the image.  If the map has pixels near top of image, it triggers border.
+    playHeight, playWidth, leftX, rightX, topY: LongInt;  // idea is that a template can specify height/width.  Or, a map, a height/width by the dimensions of the image.  If the map has pixels near top of image, it triggers border.
+	MaxHedgehogs: LongWord;
     LandBackSurface: PSDL_Surface;
     CurAmmoGear: PGear;
     lastGearByUID: PGear;
--- a/hedgewars/uWorld.pas	Fri Nov 23 21:22:26 2018 +0100
+++ b/hedgewars/uWorld.pas	Fri Nov 23 15:54:23 2018 -0500
@@ -891,7 +891,7 @@
 
     rect.y:= ViewTopY;
     rect.h:= ViewHeight;
-    tmp:= LongInt(leftX) + WorldDx;
+    tmp:= leftX + WorldDx;
     w:= tmp - ViewLeftX;
 
     if w > 0 then
@@ -903,7 +903,7 @@
             DrawLineOnScreen(tmp - 1, ViewTopY, tmp - 1, ViewBottomY, 2, $54, $54, $FF, $FF);
         end;
 
-    tmp:= LongInt(rightX) + WorldDx;
+    tmp:= rightX + WorldDx;
     w:= ViewRightX - tmp;
 
     if w > 0 then
@@ -1210,8 +1210,8 @@
     end
 else
     begin
-    replicateToLeft := (LongInt(leftX)  + WorldDx > ViewLeftX);
-    replicateToRight:= (LongInt(rightX) + WorldDx < ViewRightX);
+    replicateToLeft := (leftX  + WorldDx > ViewLeftX);
+    replicateToRight:= (rightX + WorldDx < ViewRightX);
     end;
 
 ScreenBottom:= (WorldDy - trunc(cScreenHeight/cScaleFactor) - (cScreenHeight div 2) + cWaterLine);
@@ -1831,9 +1831,9 @@
 
             if (WorldEdge = weWrap) then
                 begin
-                    if dstX - prevPoint.X < (LongInt(leftX) - LongInt(rightX)) div 2 then
+                    if dstX - prevPoint.X < (leftX - rightX) div 2 then
                         CursorPoint.X:= (prevPoint.X * 7 + dstX - (leftX - rightX)) div 8
-                    else if dstX - prevPoint.X > (LongInt(rightX) - LongInt(leftX)) div 2 then
+                    else if dstX - prevPoint.X > (rightX - leftX) div 2 then
                         CursorPoint.X:= (prevPoint.X * 7 + dstX - (rightX - leftX)) div 8
                     else
                         CursorPoint.X:= (prevPoint.X * 7 + dstX) div 8;
@@ -1851,10 +1851,10 @@
 
 if (WorldEdge = weWrap) then
     begin
-        if -WorldDx < LongInt(leftX) then
-            WorldDx:= WorldDx - LongInt(rightX) + leftX
-        else if -WorldDx > LongInt(rightX) then
-            WorldDx:= WorldDx + LongInt(rightX) - leftX;
+        if -WorldDx < leftX then
+            WorldDx:= WorldDx - rightX + leftX
+        else if -WorldDx > rightX then
+            WorldDx:= WorldDx + rightX - leftX;
     end;
 
 wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - (cVisibleWater + trunc(CinematicBarH / (cScaleFactor / 2.0)));