Fix tons of warnings
authormartin_bede
Thu, 10 Jan 2013 22:59:46 +0400
changeset 8370 0c79946e96f8
parent 8369 31033e521653
child 8371 0551b5c3de9a
Fix tons of warnings
hedgewars/ArgParsers.inc
hedgewars/GSHandlers.inc
hedgewars/hwengine.pas
hedgewars/uAIAmmoTests.pas
hedgewars/uCommandHandlers.pas
hedgewars/uGearsRender.pas
hedgewars/uInputHandler.pas
hedgewars/uLand.pas
hedgewars/uLocale.pas
hedgewars/uScript.pas
hedgewars/uSound.pas
hedgewars/uStore.pas
hedgewars/uTeams.pas
hedgewars/uUtils.pas
hedgewars/uVideoRec.pas
hedgewars/uVisualGears.pas
hedgewars/uWorld.pas
--- a/hedgewars/ArgParsers.inc	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/ArgParsers.inc	Thu Jan 10 22:59:46 2013 +0400
@@ -124,6 +124,8 @@
 
 procedure startVideoRecording(var paramIndex: LongInt);
 begin
+    // Silence the hint that appears when USE_VIDEO_RECORDING is not defined
+    paramIndex:= paramIndex;
 {$IFDEF USE_VIDEO_RECORDING}
     GameType:= gmtRecord;
     inc(paramIndex);
@@ -245,6 +247,7 @@
     tmpInt:= 1;
     while (index < size) do
         begin
+        newSyntax:= '';
         inc(paramIndex);
         cmd:= cmdArray[index];
         arg:= ParamStr(paramIndex);
--- a/hedgewars/GSHandlers.inc	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/GSHandlers.inc	Thu Jan 10 22:59:46 2013 +0400
@@ -5174,7 +5174,7 @@
 if (Gear^.State and gstTmpFlag <> 0) or (GameTicks and $7 = 0) then
     begin
     doStepFallingGear(Gear);
-    if (Gear^.State and gstInvisible <> 0) and (GameTicks and $FF = 0) and ((hwRound(Gear^.X) < leftX) or (hwRound(Gear^.X) > rightX) or (hwRound(Gear^.Y) < topY)) then
+    if (Gear^.State and gstInvisible <> 0) and (GameTicks and $FF = 0) and (hwRound(Gear^.X) < LongInt(leftX)) or (hwRound(Gear^.X) > LongInt(rightX)) or (hwRound(Gear^.Y) < LongInt(topY)) then
         begin
         Gear^.X:= int2hwFloat(GetRandom(rightX-leftX)+leftX);
         Gear^.Y:= int2hwFloat(GetRandom(LAND_HEIGHT-topY)+topY);
@@ -5267,9 +5267,9 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepKnife(Gear: PGear);
-var ox, oy: LongInt;
-    la: hwFloat;
-    a: real;
+//var ox, oy: LongInt;
+//    la: hwFloat;
+var   a: real;
 begin
     // Gear is shrunk so it can actually escape the hog without carving into the terrain
     if (Gear^.Radius = 6) and (Gear^.CollisionMask = $FFFF) then Gear^.Radius:= 16;
@@ -5291,14 +5291,14 @@
         end
     else if (Gear^.CollisionIndex = -1) and (Gear^.Timer = 0) then
         begin
-        ox:= 0; oy:= 0;
+        (*ox:= 0; oy:= 0;
         if TestCollisionYwithGear(Gear, -1) <> 0 then oy:= -1;
         if TestCollisionXwithGear(Gear, 1)       then ox:=  1;
         if TestCollisionXwithGear(Gear, -1)      then ox:= -1;
         if TestCollisionYwithGear(Gear, 1) <> 0  then oy:=  1;
         if Gear^.Health > 0 then
             PlaySound(sndRopeAttach);
-(*
+
         la:= _10000;
         if (ox <> 0) or (oy <> 0) then
             la:= CalcSlopeNearGear(Gear, ox, oy);
--- a/hedgewars/hwengine.pas	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/hwengine.pas	Thu Jan 10 22:59:46 2013 +0400
@@ -330,8 +330,8 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 procedure Game{$IFDEF HWLIBRARY}(argc: LongInt; argv: PPChar); cdecl; export{$ENDIF};
-var p: TPathType;
-    s: shortstring;
+//var p: TPathType;
+var s: shortstring;
     i: LongInt;
 begin
 {$IFDEF HWLIBRARY}
--- a/hedgewars/uAIAmmoTests.pas	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/uAIAmmoTests.pas	Thu Jan 10 22:59:46 2013 +0400
@@ -1140,7 +1140,7 @@
 var i: Longword;
     v: LongInt;
 begin
-while (not TestColl(hwRound(Gear^.X), hwRound(Gear^.Y), 6)) and (Gear^.Y.Round < LAND_HEIGHT) do
+while (not TestColl(hwRound(Gear^.X), hwRound(Gear^.Y), 6)) and (Gear^.Y.Round < LongWord(LAND_HEIGHT)) do
     Gear^.Y:= Gear^.Y + _1;
 
 for i:= 0 to 2040 do
--- a/hedgewars/uCommandHandlers.pas	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/uCommandHandlers.pas	Thu Jan 10 22:59:46 2013 +0400
@@ -89,11 +89,11 @@
 end;
 
 procedure chCheckProto(var s: shortstring);
-var i, c: LongInt;
+var i: LongInt;
 begin
     if isDeveloperMode then
         begin
-        val(s, i, c);
+        i:= StrToInt(s);
         TryDo(i <= cNetProtoVersion, 'Protocol version mismatch: engine is too old (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true);
         TryDo(i >= cNetProtoVersion, 'Protocol version mismatch: engine is too new (got '+intToStr(i)+', expecting '+intToStr(cNetProtoVersion)+')', true);
         end
--- a/hedgewars/uGearsRender.pas	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/uGearsRender.pas	Thu Jan 10 22:59:46 2013 +0400
@@ -41,7 +41,7 @@
 
 const
     // hog tag mask
-    htNone        = $00;
+    //htNone        = $00;
     htTeamName    = $01;
     htName        = $02;
     htHealth      = $04;
--- a/hedgewars/uInputHandler.pas	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/uInputHandler.pas	Thu Jan 10 22:59:46 2013 +0400
@@ -67,10 +67,10 @@
     //ControllerNumBalls: array[0..5] of Integer;
     ControllerNumHats: array[0..5] of Integer;
     ControllerNumButtons: array[0..5] of Integer;
-    ControllerAxes: array[0..5] of array[0..19] of Integer;
+    //ControllerAxes: array[0..5] of array[0..19] of Integer;
     //ControllerBalls: array[0..5] of array[0..19] of array[0..1] of Integer;
-    ControllerHats: array[0..5] of array[0..19] of Byte;
-    ControllerButtons: array[0..5] of array[0..19] of Byte;
+    //ControllerHats: array[0..5] of array[0..19] of Byte;
+    //ControllerButtons: array[0..5] of array[0..19] of Byte;
     usingDBinds: boolean;
 
 function  KeyNameToCode(name: shortstring): LongInt; inline;
@@ -355,7 +355,7 @@
 var Controller: array [0..5] of PSDL_Joystick;
 
 procedure ControllerInit;
-var i, j: Integer;
+var j: Integer;
 begin
 ControllerEnabled:= 0;
 {$IFDEF IPHONE}
@@ -400,18 +400,18 @@
             if ControllerNumButtons[j] > 20 then
                 ControllerNumButtons[j]:= 20;
 
-            // reset all buttons/axes
+            (*// reset all buttons/axes
             for i:= 0 to pred(ControllerNumAxes[j]) do
                 ControllerAxes[j][i]:= 0;
-            (*for i:= 0 to pred(ControllerNumBalls[j]) do
+            for i:= 0 to pred(ControllerNumBalls[j]) do
                 begin
                 ControllerBalls[j][i][0]:= 0;
                 ControllerBalls[j][i][1]:= 0;
-                end;*)
+                end;
             for i:= 0 to pred(ControllerNumHats[j]) do
                 ControllerHats[j][i]:= SDL_HAT_CENTERED;
             for i:= 0 to pred(ControllerNumButtons[j]) do
-                ControllerButtons[j][i]:= 0;
+                ControllerButtons[j][i]:= 0;*)
             end;
         end;
     // enable event generation/controller updating
--- a/hedgewars/uLand.pas	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/uLand.pas	Thu Jan 10 22:59:46 2013 +0400
@@ -523,7 +523,6 @@
 
 procedure LoadMap;
 var tmpsurf: PSDL_Surface;
-    s: shortstring;
     mapName: shortstring = '';
 begin
 WriteLnToConsole('Loading land from file...');
@@ -631,7 +630,7 @@
             if Land[y, x] <> 0 then
                 begin
                 inc(c);
-                if c > (LAND_WIDTH div 2) then // avoid accidental triggering
+                if c > LongWord((LAND_WIDTH div 2)) then // avoid accidental triggering
                     begin
                     hasBorder:= true;
                     break;
--- a/hedgewars/uLocale.pas	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/uLocale.pas	Thu Jan 10 22:59:46 2013 +0400
@@ -40,14 +40,12 @@
     trevt_n: array[TEventId] of integer;
 
 procedure LoadLocale(FileName: shortstring);
-var s: ansistring;
+var s: ansistring = '';
     f: pfsFile;
     a, b, c: LongInt;
     first: array[TEventId] of boolean;
     e: TEventId;
-    loaded: boolean;
 begin
-loaded:= false;
 for e:= Low(TEventId) to High(TEventId) do
     first[e]:= true;
 
--- a/hedgewars/uScript.pas	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/uScript.pas	Thu Jan 10 22:59:46 2013 +0400
@@ -230,8 +230,9 @@
 begin
     for i:= 1 to lua_gettop(L) do
         if (GameFlags and lua_tointeger(L, i)) = 0 then
-            GameFlags := GameFlags + lua_tointeger(L, i);
+            GameFlags := GameFlags + LongWord(lua_tointeger(L, i));
     ScriptSetInteger('GameFlags', GameFlags);
+    lc_enablegameflags:= 0;
 end;
 
 function lc_disablegameflags(L : Plua_State) : LongInt; Cdecl;
@@ -239,14 +240,18 @@
 begin
     for i:= 1 to lua_gettop(L) do
         if (GameFlags and lua_tointeger(L, i)) <> 0 then
-            GameFlags := GameFlags - lua_tointeger(L, i);
+            GameFlags := GameFlags - LongWord(lua_tointeger(L, i));
     ScriptSetInteger('GameFlags', GameFlags);
+    lc_disablegameflags:= 0;
 end;
 
 function lc_cleargameflags(L : Plua_State) : LongInt; Cdecl;
 begin
+    // Silence hint
+    L:= L;
     GameFlags:= 0;
     ScriptSetInteger('GameFlags', GameFlags);
+    lc_cleargameflags:= 0;
 end;
 
 function lc_addcaption(L : Plua_State) : LongInt; Cdecl;
@@ -1760,8 +1765,7 @@
 end;
 
 function lc_restorehog(L: Plua_State): LongInt; Cdecl;
-var hog: PHedgehog;
-    i, h: LongInt;
+var i, h: LongInt;
     uid: LongWord;
 begin
     if lua_gettop(L) <> 1 then
--- a/hedgewars/uSound.pas	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/uSound.pas	Thu Jan 10 22:59:46 2013 +0400
@@ -106,7 +106,7 @@
 
 
 implementation
-uses uVariables, uConsole, uUtils, uCommands, uDebug, uPhysFSLayer;
+uses uVariables, uConsole, uCommands, uDebug, uPhysFSLayer;
 
 const chanTPU = 32;
 var Volume: LongInt;
--- a/hedgewars/uStore.pas	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/uStore.pas	Thu Jan 10 22:59:46 2013 +0400
@@ -605,6 +605,8 @@
 begin
     // check for file in user dir (never critical)
     tmpsurf:= LoadImage(cPathz[path] + '/' + filename, imageFlags);
+    
+    LoadDataImage:= tmpsurf;
 end;
 
 
--- a/hedgewars/uTeams.pas	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/uTeams.pas	Thu Jan 10 22:59:46 2013 +0400
@@ -40,7 +40,7 @@
 procedure SwitchCurrentHedgehog(newHog: PHedgehog);
 
 implementation
-uses uLocale, uAmmos, uChat, uVariables, uUtils, uIO, uCaptions, uCommands, uDebug, uScript,
+uses uLocale, uAmmos, uChat, uVariables, uUtils, uIO, uCaptions, uCommands, uDebug,
     uGearsUtils, uGearsList
     {$IFDEF USE_TOUCH_INTERFACE}, uTouch{$ENDIF};
 
@@ -503,7 +503,6 @@
 procedure chAddHH(var id: shortstring);
 var s: shortstring;
     Gear: PGear;
-    c: LongInt;
 begin
 s:= '';
 if (not isDeveloperMode) or (CurrentTeam = nil) then
@@ -512,10 +511,10 @@
     begin
     SplitBySpace(id, s);
     SwitchCurrentHedgehog(@Hedgehogs[HedgehogsNumber]);
-    val(id, CurrentHedgehog^.BotLevel, c);
+    CurrentHedgehog^.BotLevel:= StrToInt(id);
     Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0);
     SplitBySpace(s, id);
-    val(s, Gear^.Health, c);
+    Gear^.Health:= StrToInt(s);
     TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true);
     Gear^.Hedgehog^.Team:= CurrentTeam;
     if (GameFlags and gfSharedAmmo) <> 0 then
@@ -536,7 +535,6 @@
 
 procedure chAddTeam(var s: shortstring);
 var Color: Longword;
-    c: LongInt;
     ts, cs: shortstring;
 begin
 cs:= '';
@@ -545,7 +543,7 @@
     begin
     SplitBySpace(s, cs);
     SplitBySpace(cs, ts);
-    val(cs, Color, c);
+    Color:= StrToInt(cs);
     TryDo(Color <> 0, 'Error: black team color', true);
 
     // color is always little endian so the mask must be constant also in big endian archs
@@ -562,16 +560,16 @@
 
 procedure chSetHHCoords(var x: shortstring);
 var y: shortstring;
-    t, c: Longint;
+    t: Longint;
 begin
-y:= '';
-if (not isDeveloperMode) or (CurrentHedgehog = nil) or (CurrentHedgehog^.Gear = nil) then
-    exit;
-SplitBySpace(x, y);
-val(x, t, c);
-CurrentHedgehog^.Gear^.X:= int2hwFloat(t);
-val(y, t, c);
-CurrentHedgehog^.Gear^.Y:= int2hwFloat(t)
+    y:= '';
+    if (not isDeveloperMode) or (CurrentHedgehog = nil) or (CurrentHedgehog^.Gear = nil) then
+        exit;
+    SplitBySpace(x, y);
+    t:= StrToInt(x);
+    CurrentHedgehog^.Gear^.X:= int2hwFloat(t);
+    t:= StrToInt(y);
+    CurrentHedgehog^.Gear^.Y:= int2hwFloat(t)
 end;
 
 procedure chBind(var id: shortstring);
--- a/hedgewars/uUtils.pas	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/uUtils.pas	Thu Jan 10 22:59:46 2013 +0400
@@ -188,7 +188,11 @@
 function  StrToInt(s: shortstring): LongInt;
 var c: LongInt;
 begin
-val(s, StrToInt, c)
+val(s, StrToInt, c);
+{$IFDEF DEBUGFILE}
+if c <> 0 then
+    writeln(f, 'Error at position ' + IntToStr(c) + ' : ' + s[c])
+{$ENDIF}
 end;
 
 function FloatToStr(n: hwFloat): shortstring;
--- a/hedgewars/uVideoRec.pas	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/uVideoRec.pas	Thu Jan 10 22:59:46 2013 +0400
@@ -196,7 +196,7 @@
 end;
 
 function LoadNextCameraPosition(out newRealTicks, newGameTicks: LongInt): Boolean;
-var frame: TFrame;
+var frame: TFrame = (realTicks: 0; gameTicks: 0; CamX: 0; CamY: 0; zoom: 0);
 begin
     // we need to skip or duplicate frames to match target framerate
     while Int64(curTime)*cVideoFramerateNum <= Int64(numFrames)*cVideoFramerateDen*1000 do
@@ -244,9 +244,12 @@
 var inF, outF: file;
     buffer: array[0..1023] of byte;
     result: LongInt;
+    i: integer;
 begin
 {$IOCHECKS OFF}
-    result:= 0; // avoid compiler hint
+    result:= 0; // avoid compiler hint and warning
+    for i:= 0 to 1023 do
+        buffer[i]:= 0;
 
     Assign(inF, src);
     Reset(inF, 1);
--- a/hedgewars/uVisualGears.pas	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/uVisualGears.pas	Thu Jan 10 22:59:46 2013 +0400
@@ -57,7 +57,7 @@
 
 const 
     cExplFrameTicks = 110;
-    cSmokeZ = 499;
+    //cSmokeZ = 499;
 var VGCounter: LongWord;
     VisualGearLayers: array[0..6] of PVisualGear;
 
--- a/hedgewars/uWorld.pas	Thu Jan 10 22:54:55 2013 +0400
+++ b/hedgewars/uWorld.pas	Thu Jan 10 22:59:46 2013 +0400
@@ -86,7 +86,6 @@
     AmmoMenuTex     : PTexture;
     HorizontOffset: LongInt;
     cOffsetY: LongInt;
-    AFRToggle: Boolean;
 
 const cStereo_Sky           = 0.0500;
       cStereo_Horizon       = 0.0250;
@@ -105,7 +104,7 @@
       AMTypeMaskX     = $00000001;
       AMTypeMaskY     = $00000002;
       AMTypeMaskAlpha = $00000004;
-      AMTypeMaskSlide = $00000008;
+      //AMTypeMaskSlide = $00000008;
 
 {$IFDEF MOBILE}
       AMSlotSize = 48;