Fix "Mixing signed expressions and longwords gives a 64bit result" warnings
authorunc0rr
Wed, 27 Apr 2011 15:57:23 +0400
changeset 5179 8d64dcb566ea
parent 5178 f3cc6119f1fe
child 5182 7eb5e1268330
Fix "Mixing signed expressions and longwords gives a 64bit result" warnings
hedgewars/CMakeLists.txt
hedgewars/VGSHandlers.inc
hedgewars/uGears.pas
hedgewars/uGearsRender.pas
hedgewars/uLandGraphics.pas
hedgewars/uLandObjects.pas
hedgewars/uVariables.pas
hedgewars/uVisualGears.pas
--- a/hedgewars/CMakeLists.txt	Tue Apr 26 13:13:07 2011 +0200
+++ b/hedgewars/CMakeLists.txt	Wed Apr 27 15:57:23 2011 +0400
@@ -57,6 +57,7 @@
     uTextures.pas
     uTypes.pas
     uUtils.pas
+    uVariables.pas
     uVisualGears.pas
     uWorld.pas
     GSHandlers.inc
--- a/hedgewars/VGSHandlers.inc	Tue Apr 26 13:13:07 2011 +0200
+++ b/hedgewars/VGSHandlers.inc	Wed Apr 27 15:57:23 2011 +0400
@@ -684,7 +684,7 @@
                 if tmp > round(dY) then tdY:= -1;
                 if tmp > 255 then tmp := 255;
                 if tmp < 0 then tmp := 0;
-                Gear^.Tint:= (Gear^.Tint and $FFFFFF00) or tmp
+                Gear^.Tint:= (Gear^.Tint and $FFFFFF00) or Longword(tmp)
                 end
             end
 end;
--- a/hedgewars/uGears.pas	Tue Apr 26 13:13:07 2011 +0200
+++ b/hedgewars/uGears.pas	Wed Apr 27 15:57:23 2011 +0400
@@ -1081,7 +1081,6 @@
         end;
     end else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure
         begin
-        AddFileLog('Assigning hedgehog ' + inttostr(LongInt(AttackerHog)) + ' to gear ' + inttostr(Gear^.uid));
         Gear^.Hedgehog:= AttackerHog;
         end;
     inc(Gear^.Damage, Damage);
@@ -1141,7 +1140,7 @@
 end;
 
 procedure AddMiscGears;
-var i: LongInt;
+var i: Longword;
     Gear: PGear;
 begin
 AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000);
--- a/hedgewars/uGearsRender.pas	Tue Apr 26 13:13:07 2011 +0200
+++ b/hedgewars/uGearsRender.pas	Wed Apr 27 15:57:23 2011 +0400
@@ -576,7 +576,7 @@
                 amRope: DrawRotated(sprHandRope, hx, hy, sign, aangle);
                 amShotgun: DrawRotated(sprHandShotgun, hx, hy, sign, aangle);
                 amDEagle: DrawRotated(sprHandDEagle, hx, hy, sign, aangle);
-                amSineGun: DrawRotatedF(sprHandSinegun, hx, hy, 73+(sign * (RealTicks div 73)) mod 8, sign, aangle);
+                amSineGun: DrawRotatedF(sprHandSinegun, hx, hy, 73 + (sign * LongInt(RealTicks div 73)) mod 8, sign, aangle);
                 amPortalGun: if (CurWeapon^.Timer and 2) <> 0 then // Add a new Hedgehog value instead of abusing timer?
                                 DrawRotatedF(sprPortalGun, hx, hy, 0, sign, aangle)
                         else
@@ -996,7 +996,7 @@
                             else
                                 startX:= max(-LAND_WIDTH - 1024, endX - 2048);
                             startY:= endY - 256;
-                            DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + round((endX - startX) * (-power(2, -10 * LongInt(Gear^.Timer)/2000) + 1)), startY + WorldDy + round((endY - startY) * sqrt(1 - power((LongInt(Gear^.Timer)/2000)-1, 2))), ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
+                            DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + LongInt(round((endX - startX) * (-power(2, -10 * LongInt(Gear^.Timer)/2000) + 1))), startY + WorldDy + LongInt(round((endY - startY) * sqrt(1 - power((LongInt(Gear^.Timer)/2000)-1, 2)))), ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
                             end
                         else // Disappearing
                             begin
@@ -1007,7 +1007,7 @@
                             else
                                 endX:= max(-LAND_WIDTH - 1024, startX - 2048);
                             endY:= startY + 256;
-                            DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + round((endX - startX) * power(2, 10 * (LongInt(Gear^.Timer)/2000 - 1))) + hwRound(Gear^.dX * Gear^.Timer), startY + WorldDy + round((endY - startY) * cos(LongInt(Gear^.Timer)/2000 * (Pi/2)) - (endY - startY)) + hwRound(Gear^.dY * Gear^.Timer), ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
+                            DrawTextureF(SpritesData[sprBirdy].Texture, 1, startX + WorldDx + LongInt(round((endX - startX) * power(2, 10 * (LongInt(Gear^.Timer)/2000 - 1)))) + hwRound(Gear^.dX * Gear^.Timer), startY + WorldDy + LongInt(round((endY - startY) * cos(LongInt(Gear^.Timer)/2000 * (Pi/2)) - (endY - startY))) + hwRound(Gear^.dY * Gear^.Timer), ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
                             end;
                         end
                     else
--- a/hedgewars/uLandGraphics.pas	Tue Apr 26 13:13:07 2011 +0200
+++ b/hedgewars/uLandGraphics.pas	Wed Apr 27 15:57:23 2011 +0400
@@ -61,9 +61,9 @@
 
     // Mix colors
     nAlpha := min(255, oAlpha + nAlpha);
-    nRed   := ((oRed * oAlpha) + (nRed * (255-oAlpha))) div 255;
-    nGreen := ((oGreen * oAlpha) + (nGreen * (255-oAlpha))) div 255;
-    nBlue  := ((oBlue * oAlpha) + (nBlue * (255-oAlpha))) div 255;
+    nRed   := ((oRed * oAlpha) + (nRed * Byte(255-oAlpha))) div 255;
+    nGreen := ((oGreen * oAlpha) + (nGreen * Byte(255-oAlpha))) div 255;
+    nBlue  := ((oBlue * oAlpha) + (nBlue * Byte(255-oAlpha))) div 255;
 
     addBgColor := (nAlpha shl AShift) or (nRed shl RShift) or (nGreen shl GShift) or (nBlue shl BShift);
 end;
--- a/hedgewars/uLandObjects.pas	Tue Apr 26 13:13:07 2011 +0200
+++ b/hedgewars/uLandObjects.pas	Wed Apr 27 15:57:23 2011 +0400
@@ -368,7 +368,8 @@
 procedure ReadThemeInfo(var ThemeObjects: TThemeObjects; var SprayObjects: TSprayObjects);
 var s, key: shortstring;
     f: textfile;
-    i, ii: LongInt;
+    i: LongInt;
+    ii: Longword;
     c1, c2: TSDL_Color;
 
     procedure CheckRect(Width, Height, x, y, w, h: LongWord);
@@ -458,7 +459,7 @@
     else if key = 'music' then MusicFN:= Trim(s)
     else if key = 'clouds' then
         begin
-        cCloudsNumber:= StrToInt(Trim(s)) * cScreenSpace div LAND_WIDTH;
+        cCloudsNumber:= Word(StrToInt(Trim(s))) * cScreenSpace div LAND_WIDTH;
         cSDCloudsNumber:= cCloudsNumber
         end
     else if key = 'object' then
@@ -574,7 +575,7 @@
         SDWaterColorArray[3]:= SDWaterColorArray[2];
         end
     else if key = 'sd-water-opacity' then cSDWaterOpacity:= StrToInt(Trim(s))
-    else if key = 'sd-clouds' then cSDCloudsNumber:= StrToInt(Trim(s)) * cScreenSpace div LAND_WIDTH
+    else if key = 'sd-clouds' then cSDCloudsNumber:= Word(StrToInt(Trim(s))) * cScreenSpace div LAND_WIDTH
     else if key = 'sd-flakes' then
         begin
         i:= Pos(',', s);
--- a/hedgewars/uVariables.pas	Tue Apr 26 13:13:07 2011 +0200
+++ b/hedgewars/uVariables.pas	Wed Apr 27 15:57:23 2011 +0400
@@ -87,14 +87,14 @@
     cWaterRise       : LongInt;
     cHealthDecrease  : LongInt;
 
-    cCloudsNumber    : LongInt;
-    cSDCloudsNumber  : LongInt;
+    cCloudsNumber    : LongWord;
+    cSDCloudsNumber  : LongWord;
 
     cTagsMask        : byte;
     zoom             : GLfloat;
     ZoomValue        : GLfloat;
 
-    cWaterLine       : LongInt;
+    cWaterLine       : Word;
     cGearScrEdgesDist: LongInt;
 
     GameTicks   : LongWord;
@@ -102,15 +102,15 @@
     // originally from uConsts
     Pathz: array[TPathType] of shortstring;
     CountTexz: array[1..Pred(AMMO_INFINITE)] of PTexture;
-    LAND_WIDTH       : LongInt;
-    LAND_HEIGHT      : LongInt;
+    LAND_WIDTH       : Word;
+    LAND_HEIGHT      : Word;
     LAND_WIDTH_MASK  : LongWord;
     LAND_HEIGHT_MASK : LongWord;
     cMaxCaptions     : LongInt;
 
     cLeftScreenBorder     : LongInt;
     cRightScreenBorder    : LongInt;
-    cScreenSpace          : LongInt;
+    cScreenSpace          : Longword;
 
     cCaseFactor     : Longword;
     cLandMines      : Longword;
--- a/hedgewars/uVisualGears.pas	Tue Apr 26 13:13:07 2011 +0200
+++ b/hedgewars/uVisualGears.pas	Wed Apr 27 15:57:23 2011 +0400
@@ -597,7 +597,7 @@
 var i: LongInt;
 begin
 for i:= 0 to cCloudsNumber - 1 do
-    AddVisualGear(cLeftScreenBorder + i * cScreenSpace div (cCloudsNumber + 1), LAND_HEIGHT-1184, vgtCloud)
+    AddVisualGear(cLeftScreenBorder + i * LongInt(cScreenSpace div (cCloudsNumber + 1)), LAND_HEIGHT-1184, vgtCloud)
 end;
 
 procedure ChangeToSDClouds;
@@ -615,7 +615,7 @@
         end
     else vg:= vg^.NextGear;
 for i:= 0 to cSDCloudsNumber - 1 do
-    AddVisualGear(cLeftScreenBorder + i * cScreenSpace div (cSDCloudsNumber + 1), LAND_HEIGHT-1184, vgtCloud)
+    AddVisualGear(cLeftScreenBorder + i * LongInt(cScreenSpace div (cSDCloudsNumber + 1)), LAND_HEIGHT-1184, vgtCloud)
 end;
 
 procedure AddFlakes;