Fix a bunch of warnings (also improves speed a bit in 32 bit code)
authorunC0Rr
Sat, 24 Sep 2011 22:16:49 +0400 (2011-09-24)
changeset 6011 519f8a58c021
parent 6010 10913a80cb50
child 6012 6bac93097da3
Fix a bunch of warnings (also improves speed a bit in 32 bit code)
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uAIMisc.pas
hedgewars/uLand.pas
hedgewars/uLandGraphics.pas
hedgewars/uWorld.pas
--- a/hedgewars/GSHandlers.inc	Sat Sep 24 17:12:46 2011 +0200
+++ b/hedgewars/GSHandlers.inc	Sat Sep 24 22:16:49 2011 +0400
@@ -509,6 +509,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepMolotov(Gear: PGear);
 var 
+	s: Longword;
     i, gX, gY: LongInt;
     dX, dY: hwFloat;
     Fire: PGear;
@@ -520,8 +521,8 @@
     CalcRotationDirAngle(Gear);
 
     // let's add some smoke depending on speed
-    i:= max(32,152 - hwRound(Distance(Gear^.dX,Gear^.dY)*120))+random(10);
-    if (GameTicks mod i) = 0 then
+    s:= max(32,152 - hwRound(Distance(Gear^.dX,Gear^.dY)*120))+random(10);
+    if (GameTicks mod s) = 0 then
         begin
         // adjust angle to match the texture
         if Gear^.dX.isNegative then i:= 130 else i:= 50;
@@ -4809,7 +4810,7 @@
         i := hwRound(Gear^.X) - HitGear^.Radius + 2;
         ei := hwRound(Gear^.X) + HitGear^.Radius - 2;
         for j := 1 to 4 do DrawExplosion(i - GetRandom(5), hwRound(Gear^.Y) + 6*j, 3);
-        for j := 1 to 4 do DrawExplosion(ei + GetRandom(5), hwRound(Gear^.Y) + 6*j, 3);
+        for j := 1 to 4 do DrawExplosion(ei + LongInt(GetRandom(5)), hwRound(Gear^.Y) + 6*j, 3);
         while i <= ei do
             begin
             for j := 1 to 11 do DrawExplosion(i, hwRound(Gear^.Y) + 3*j, 3);
--- a/hedgewars/HHHandlers.inc	Sat Sep 24 17:12:46 2011 +0200
+++ b/hedgewars/HHHandlers.inc	Sat Sep 24 22:16:49 2011 +0400
@@ -1017,7 +1017,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepHedgehogFree(Gear: PGear);
-var prevState, i: Longword;
+var prevState: Longword;
 begin
 prevState:= Gear^.State;
 
--- a/hedgewars/uAIMisc.pas	Sat Sep 24 17:12:46 2011 +0200
+++ b/hedgewars/uAIMisc.pas	Sat Sep 24 22:16:49 2011 +0400
@@ -80,7 +80,7 @@
 
 procedure FillTargets;
 var i, t: Longword;
-    f, e: Longword;
+    f, e: LongInt;
 begin
 Targets.Count:= 0;
 f:= 0;
@@ -233,7 +233,7 @@
     with Targets.ar[i] do
          begin
          dmg:= hwRound(_0_01 * cDamageModifier
-            * min((r + cHHRadius div 2 - DistanceI(Point.x - x, Point.y - y).Round) div 2, r) * cDamagePercent);
+            * min((r + cHHRadius div 2 - LongInt(DistanceI(Point.x - x, Point.y - y).Round)) div 2, r) * cDamagePercent);
 
          if dmg > 0 then
             begin
--- a/hedgewars/uLand.pas	Sat Sep 24 17:12:46 2011 +0200
+++ b/hedgewars/uLand.pas	Sat Sep 24 22:16:49 2011 +0400
@@ -1234,16 +1234,16 @@
 for w:= 0 to 23 do
     for x:= leftX to rightX do
         begin
-        Land[cWaterLine-1 - w, x]:= lfIndestructible;
+        Land[Longword(cWaterLine) - 1 - w, x]:= lfIndestructible;
         if (x + w) mod 32 < 16 then
             c:= AMask
         else
             c:= AMask or RMask or GMask; // FF00FFFF
 
         if (cReducedQuality and rqBlurryLand) = 0 then
-            LandPixels[cWaterLine-1 - w, x]:= c
+            LandPixels[Longword(cWaterLine) - 1 - w, x]:= c
         else
-            LandPixels[(cWaterLine-1 - w) div 2, x div 2]:= c
+            LandPixels[(Longword(cWaterLine) - 1 - w) div 2, x div 2]:= c
         end
 end;
 
--- a/hedgewars/uLandGraphics.pas	Sat Sep 24 17:12:46 2011 +0200
+++ b/hedgewars/uLandGraphics.pas	Sat Sep 24 22:16:49 2011 +0400
@@ -47,10 +47,10 @@
 function addBgColor(OldColor, NewColor: LongWord): LongWord;
 // Factor ranges from 0 to 100% NewColor
 var
-    oRed, oBlue, oGreen, oAlpha, nRed, nBlue, nGreen, nAlpha: LongWord;
+    oRed, oBlue, oGreen, oAlpha, nRed, nBlue, nGreen, nAlpha: byte;
 begin
-    oAlpha := (OldColor shr AShift) and $FF;
-    nAlpha := (NewColor shr AShift) and $FF;
+    oAlpha := (OldColor shr AShift);
+    nAlpha := (NewColor shr AShift);
     // shortcircuit
     if (oAlpha = 0) or (nAlpha = $FF) then
         begin
@@ -58,18 +58,18 @@
         exit
         end; 
     // Get colors
-    oRed   := (OldColor shr RShift) and $FF;
-    oGreen := (OldColor shr GShift) and $FF;
-    oBlue  := (OldColor shr BShift) and $FF;
+    oRed   := (OldColor shr RShift);
+    oGreen := (OldColor shr GShift);
+    oBlue  := (OldColor shr BShift);
 
-    nRed   := (NewColor shr RShift) and $FF;
-    nGreen := (NewColor shr GShift) and $FF;
-    nBlue  := (NewColor shr BShift) and $FF;
+    nRed   := (NewColor shr RShift);
+    nGreen := (NewColor shr GShift);
+    nBlue  := (NewColor shr BShift);
 
     // Mix colors
-    nRed   := min(255,((nRed*nAlpha) div 255) + ((oRed*oAlpha*(255-nAlpha)) div 65025));
-    nGreen := min(255,((nGreen*nAlpha) div 255) + ((oGreen*oAlpha*(255-nAlpha)) div 65025));
-    nBlue  := min(255,((nBlue*nAlpha) div 255) + ((oBlue*oAlpha*(255-nAlpha)) div 65025)); 
+    nRed   := min(255,((nRed*nAlpha) div 255) + ((oRed*oAlpha*byte(255-nAlpha)) div 65025));
+    nGreen := min(255,((nGreen*nAlpha) div 255) + ((oGreen*oAlpha*byte(255-nAlpha)) div 65025));
+    nBlue  := min(255,((nBlue*nAlpha) div 255) + ((oBlue*oAlpha*byte(255-nAlpha)) div 65025)); 
     nAlpha := min(255, oAlpha + nAlpha);
 
     addBgColor := (nAlpha shl AShift) or (nRed shl RShift) or (nGreen shl GShift) or (nBlue shl BShift);
@@ -780,8 +780,8 @@
 procedure Smooth(X, Y: LongInt);
 begin
 // a bit of AA for explosions
-if (Land[Y, X] = 0) and (Y > topY+1) and 
-   (Y < LAND_HEIGHT-2) and (X>leftX+1) and (X<rightX-1) then
+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
     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/uWorld.pas	Sat Sep 24 17:12:46 2011 +0200
+++ b/hedgewars/uWorld.pas	Sat Sep 24 22:16:49 2011 +0400
@@ -31,7 +31,7 @@
 procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode);
 procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt);
 procedure HideMission;
-procedure ShakeCamera(amount: LongWord);
+procedure ShakeCamera(amount: LongInt);
 procedure InitCameraBorders;
 procedure MoveCamera;
 procedure onFocusStateChanged;
@@ -914,11 +914,11 @@
 DrawCaptions;
 
 // Teams Healths
-if TeamsCount * 20 > cScreenHeight div 7 then  // take up less screen on small displays
+if TeamsCount * 20 > Longword(cScreenHeight) div 7 then  // take up less screen on small displays
     begin
     SetScale(1.5);
     smallScreenOffset:= cScreenHeight div 6;
-    if TeamsCount * 20 > cScreenHeight div 5 then Tint($FF,$FF,$FF,$80);
+    if TeamsCount * 20 > Longword(cScreenHeight) div 5 then Tint($FF,$FF,$FF,$80);
     end
 else smallScreenOffset:= 0;
 for t:= 0 to Pred(TeamsCount) do
@@ -957,7 +957,7 @@
       // this approach should be faster than drawing all borders one by one tinted or not
       if highlight then
          begin
-         if TeamsCount * 20 > cScreenHeight div 5 then Tint($FF,$FF,$FF,$80)
+         if TeamsCount * 20 > Longword(cScreenHeight) div 5 then Tint($FF,$FF,$FF,$80)
          else Tint($FF, $FF, $FF, $FF);
 
          // draw name
@@ -979,7 +979,7 @@
 if smallScreenOffset <> 0 then
     begin
     SetScale(cDefaultZoomLevel);
-    if TeamsCount * 20 > cScreenHeight div 5 then Tint($FF,$FF,$FF,$FF);
+    if TeamsCount * 20 > Longword(cScreenHeight) div 5 then Tint($FF,$FF,$FF,$FF);
     end;
 
 // Lag alert
@@ -1312,7 +1312,7 @@
     if missionTex <> nil then FreeTexture(missionTex);
 end;
 
-procedure ShakeCamera(amount: LongWord);
+procedure ShakeCamera(amount: LongInt);
 begin
     if isCursorVisible then exit;
     amount:= Max(1, round(amount*zoom/2));