Fix some problems caught by C compiler
authorunC0Rr
Thu, 22 Oct 2020 12:50:24 +0200
changeset 15775 72f735c03fec
parent 15774 f09db263bc2a
child 15776 aa011799cb63
Fix some problems caught by C compiler
hedgewars/uAIMisc.pas
hedgewars/uFloat.pas
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsUtils.pas
hedgewars/uRenderUtils.pas
hedgewars/uStore.pas
--- a/hedgewars/uAIMisc.pas	Thu Oct 22 12:33:35 2020 +0200
+++ b/hedgewars/uAIMisc.pas	Thu Oct 22 12:50:24 2020 +0200
@@ -891,6 +891,7 @@
 meX:= Me^.X;
 meY:= Me^.Y;
 rate:= 0;
+hadSkips:= false;
 for i:= 0 to Targets.Count do
     if not Targets.ar[i].dead then
         with Targets.ar[i] do
@@ -975,6 +976,7 @@
 meX:= Me^.X;
 meY:= Me^.Y;
 rate:= 0;
+hadSkips:= false;
 for i:= 0 to Targets.Count do
     if (Targets.ar[i].Kind = gtGrave) and (not Targets.ar[i].dead) then
         with Targets.ar[i] do
--- a/hedgewars/uFloat.pas	Thu Oct 22 12:33:35 2020 +0200
+++ b/hedgewars/uFloat.pas	Thu Oct 22 12:50:24 2020 +0200
@@ -371,8 +371,8 @@
 
 function hwSqrt1(const t: hwFloat): hwFloat;
 const pwr = 8; // even value, feel free to adjust
-      rThreshold: QWord = 1 shl (pwr + 32);
-      lThreshold: QWord = 1 shl (pwr div 2 + 32);
+      rThreshold: QWord = QWord(1) shl (pwr + 32);
+      lThreshold: QWord = QWord(1) shl (pwr div 2 + 32);
 var l, r: QWord;
     c: hwFloat;
 begin
--- a/hedgewars/uGearsHandlersMess.pas	Thu Oct 22 12:33:35 2020 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Thu Oct 22 12:50:24 2020 +0200
@@ -3233,6 +3233,8 @@
 begin
     AllInactive := false;
 
+    HHGear:= nil;
+
     if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) then
         HHGear:= Gear^.Hedgehog^.Gear;
 
--- a/hedgewars/uGearsUtils.pas	Thu Oct 22 12:33:35 2020 +0200
+++ b/hedgewars/uGearsUtils.pas	Thu Oct 22 12:50:24 2020 +0200
@@ -1903,9 +1903,10 @@
 function HomingWrap(var Gear: PGear): boolean;
 var dist_center, dist_right, dist_left: hwFloat;
 begin
+    HomingWrap:= false;
+
     if WorldEdge = weWrap then
         begin
-        HomingWrap:= false;
         // We just check the same target 3 times:
         // 1) in current section (no change)
         // 2) clone in the right section
--- a/hedgewars/uRenderUtils.pas	Thu Oct 22 12:33:35 2020 +0200
+++ b/hedgewars/uRenderUtils.pas	Thu Oct 22 12:50:24 2020 +0200
@@ -115,7 +115,7 @@
     finalRect.x:= X + cFontBorder + cFontPadding;
     finalRect.y:= Y + cFontBorder;
     if SDLCheck(tmpsurf <> nil, 'TTF_RenderUTF8_Blended', true) then
-        exit;
+        exit(finalRect);
     SDL_UpperBlit(tmpsurf, @textRect, Surface, @finalRect);
     SDL_FreeSurface(tmpsurf);
     finalRect.x:= X;
--- a/hedgewars/uStore.pas	Thu Oct 22 12:33:35 2020 +0200
+++ b/hedgewars/uStore.pas	Thu Oct 22 12:50:24 2020 +0200
@@ -116,7 +116,7 @@
 clr.b:= Color and $FF;
 clr.a:= $FF;
 tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, s, clr);
-if tmpsurf = nil then exit;
+if tmpsurf = nil then exit(finalRect);
 tmpsurf:= doSurfaceConversion(tmpsurf);
 
 if tmpsurf <> nil then