minor changes for warnings and a variables scope
authorkoda
Fri, 11 May 2012 00:05:47 +0200
changeset 7049 35d762458d66
parent 7048 0a4c88935902
child 7050 91199321e916
minor changes for warnings and a variables scope
hedgewars/SDLh.pas
hedgewars/hwengine.pas
hedgewars/uInputHandler.pas
hedgewars/uLocale.pas
hedgewars/uMisc.pas
hedgewars/uStore.pas
hedgewars/uVariables.pas
hedgewars/uWorld.pas
--- a/hedgewars/SDLh.pas	Thu May 10 23:21:56 2012 +0200
+++ b/hedgewars/SDLh.pas	Fri May 11 00:05:47 2012 +0200
@@ -969,7 +969,7 @@
 {$ENDIF}
 
 {* Compatibility between SDL-1.2 and SDL-1.3 *}
-procedure SDL_WarpMouse(x, y: Word); {$IFNDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
+procedure SDL_WarpMouse(x, y: Word); {$IFDEF SDL13}inline{$ELSE}cdecl; external SDLLibName{$ENDIF};
 function  SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL13} name 'SDL_GetKeyboardState'{$ENDIF};
 function  SDL_AllocFormat(format: LongWord): PSDL_PixelFormat; {$IFDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
 procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); {$IFDEF SDL13}cdecl; external SDLLibName;{$ENDIF}
@@ -1055,12 +1055,12 @@
 
 implementation
 {$IFDEF SDL13}
-uses strings, uVariables;
+uses strings, uVariables, uStore;
 
 // compatible functions
-procedure SDL_WarpMouse(x, y: Word);
+procedure SDL_WarpMouse(x, y: Word); inline;
 begin
-    SDL_WarpMouseInWindow(SDLwindow, x, y);
+    WarpMouse(x, y);
 end;
 
 function SDL_VideoDriverName(namebuf: PChar; maxlen: LongInt): PChar;
@@ -1077,6 +1077,7 @@
 
 function SDL_EnableUNICODE(enable: LongInt): LongInt;
 begin
+    enable:= enable; // avoid hint
     SDL_StartTextInput();
     SDL_EnableUNICODE:= 0;
 end;
--- a/hedgewars/hwengine.pas	Thu May 10 23:21:56 2012 +0200
+++ b/hedgewars/hwengine.pas	Fri May 11 00:05:47 2012 +0200
@@ -100,11 +100,7 @@
             exit;
             end;
 
-{$IFDEF SDL13}
-    SDL_GL_SwapWindow(SDLwindow);
-{$ELSE}
-    SDL_GL_SwapBuffers();
-{$ENDIF}
+    SwapBuffers;
 
     if flagMakeCapture then
         begin
--- a/hedgewars/uInputHandler.pas	Thu May 10 23:21:56 2012 +0200
+++ b/hedgewars/uInputHandler.pas	Fri May 11 00:05:47 2012 +0200
@@ -175,12 +175,12 @@
 end;
 
 procedure ResetKbd;
-var j, k, t: LongInt;
+var j, t: LongInt;
     i: LongInt;
     pkbd: PByteArray;
 begin
 
-k:= SDL_GetMouseState(nil, nil);
+//k:= SDL_GetMouseState(nil, nil);
 pkbd:=SDL_GetKeyState(@j);
 
 //TryDo(j < cKeyMaxIndex, 'SDL keys number is more than expected (' + IntToStr(j) + ')', true);
@@ -188,7 +188,8 @@
 for i:= 1 to pred(j) do
     tkbdn[i]:= pkbd^[i];
 
-{$IFNDEF MOBILE}
+(*
+// TODO: reimplement
 // Controller(s)
 k:= j; // should we test k for hitting the limit? sounds rather unlikely to ever reach it
 for j:= 0 to Pred(ControllerNumControllers) do
@@ -219,7 +220,7 @@
         inc(k, 1);
         end;
     end;
-{$ENDIF}
+*)
 
 // what is this final loop for?
 for t:= 0 to cKeyMaxIndex do
--- a/hedgewars/uLocale.pas	Thu May 10 23:21:56 2012 +0200
+++ b/hedgewars/uLocale.pas	Fri May 11 00:05:47 2012 +0200
@@ -34,7 +34,7 @@
 {$ENDIF}
 
 implementation
-uses uRandom, uUtils, uVariables, uDebug, uConsole;
+uses uRandom, uUtils, uVariables, uDebug;
 
 var trevt: array[TEventId] of array [0..Pred(MAX_EVENT_STRINGS)] of ansistring;
     trevt_n: array[TEventId] of integer;
@@ -100,7 +100,6 @@
            end;
        end;
    Close(f);
-   {$IFNDEF HWLIBRARY}WriteLnToConsole('Locale loaded "' + FileName + '"');{$ENDIF}
    end;
 {$I+}
 end;
--- a/hedgewars/uMisc.pas	Thu May 10 23:21:56 2012 +0200
+++ b/hedgewars/uMisc.pas	Fri May 11 00:05:47 2012 +0200
@@ -49,6 +49,8 @@
          size: QWord;
          end;
 
+var conversionFormat: PSDL_PixelFormat;
+
 procedure movecursor(dx, dy: LongInt);
 var x, y: LongInt;
 begin
@@ -242,11 +244,11 @@
     doSurfaceConversion:= tmpsurf;
     if ((tmpsurf^.format^.bitsperpixel = 32) and (tmpsurf^.format^.rshift > tmpsurf^.format^.bshift)) or
        (tmpsurf^.format^.bitsperpixel = 24) then
-        begin
+    begin
         convertedSurf:= SDL_ConvertSurface(tmpsurf, conversionFormat, SDL_SWSURFACE);
         SDL_FreeSurface(tmpsurf);
         doSurfaceConversion:= convertedSurf;
-        end;
+    end;
 end;
 
 {$IFDEF SDL13}
--- a/hedgewars/uStore.pas	Thu May 10 23:21:56 2012 +0200
+++ b/hedgewars/uStore.pas	Fri May 11 00:05:47 2012 +0200
@@ -41,16 +41,22 @@
 procedure FreeWeaponTooltip;
 procedure MakeCrossHairs;
 
+procedure WarpMouse(x, y: Word); inline;
+procedure SwapBuffers; inline;
+
 implementation
-uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands, uDebug, uWorld;
+uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uRender, uRenderUtils, uCommands,
+     uDebug{$IFDEF USE_CONTEXT_RESTORE}, uWorld{$ENDIF};
 
 //type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple);
 
 var MaxTextureSize: LongInt;
+{$IFDEF SDL13}
+    SDLwindow: PSDL_Window;
+    SDLGLcontext: PSDL_GLContext;
+{$ELSE}
     SDLPrimSurface: PSDL_Surface;
-{$IFDEF SDL13}SDLGLcontext: PSDL_GLContext;{$ENDIF}
-
-//    cGPUVendor: TGPUVendor;
+{$ENDIF}
 
 function WriteInRect(Surface: PSDL_Surface; X, Y: LongInt; Color: LongWord; Font: THWFont; s: ansistring): TSDL_Rect;
 var w, h: LongInt;
@@ -794,11 +800,7 @@
 
     DrawTextureFromRect( -squaresize div 2, (cScreenHeight - squaresize) shr 1, @r, ProgrTex);
 
-{$IFDEF SDL13}
-    SDL_GL_SwapWindow(SDLwindow);
-{$ELSE}
-    SDL_GL_SwapBuffers();
-{$ENDIF}
+    SwapBuffers;
     inc(Step);
 end;
 
@@ -1124,13 +1126,10 @@
 begin
     RegisterVariable('fullscr', @chFullScr, true);
 
-    SDLPrimSurface:= nil;
-
     cScaleFactor:= 2.0;
     Step:= 0;
     ProgrTex:= nil;
     SupportNPOTT:= false;
-//    cGPUVendor:= gvUnknown;
 
     // init all ammo name texture pointers
     for ai:= Low(TAmmoType) to High(TAmmoType) do
@@ -1141,7 +1140,10 @@
     for i:= Low(CountTexz) to High(CountTexz) do
         CountTexz[i] := nil;
 {$IFDEF SDL13}
-    SDLGLcontext    := nil;
+    SDLwindow:= nil;
+    SDLGLcontext:= nil;
+{$ELSE}
+    SDLPrimSurface:= nil;
 {$ENDIF}
 end;
 
@@ -1156,4 +1158,22 @@
     SDL_Quit();
 end;
 
+procedure WarpMouse(x, y: Word); inline;
+begin
+{$IFDEF SDL13}
+    SDL_WarpMouseInWindow(SDLwindow, x, y);
+{$ELSE}
+    x:= x; y:= y; // avoid hints
+{$ENDIF}
+end;
+
+procedure SwapBuffers; inline;
+begin
+{$IFDEF SDL13}
+    SDL_GL_SwapWindow(SDLwindow);
+{$ELSE}
+    SDL_GL_SwapBuffers();
+{$ENDIF}
+end;
+
 end.
--- a/hedgewars/uVariables.pas	Thu May 10 23:21:56 2012 +0200
+++ b/hedgewars/uVariables.pas	Fri May 11 00:05:47 2012 +0200
@@ -172,11 +172,6 @@
 
     Theme           : shortstring;
     disableLandBack : boolean;
-    conversionFormat: PSDL_PixelFormat;
-
-{$IFDEF SDL13}
-    SDLwindow       : PSDL_Window;
-{$ENDIF}
 
     WorldDx: LongInt;
     WorldDy: LongInt;
@@ -2593,10 +2588,6 @@
 
     ScreenFade      := sfNone;
 
-{$IFDEF SDL13}
-    SDLwindow       := nil;
-{$ENDIF}
-
     // those values still are not perfect
     cLeftScreenBorder:= round(-cMinZoomLevel * cScreenWidth);
     cRightScreenBorder:= round(cMinZoomLevel * cScreenWidth + LAND_WIDTH);
--- a/hedgewars/uWorld.pas	Thu May 10 23:21:56 2012 +0200
+++ b/hedgewars/uWorld.pas	Fri May 11 00:05:47 2012 +0200
@@ -384,7 +384,7 @@
     STurns: LongInt;
     amSurface: PSDL_Surface;
     AMRect: TSDL_Rect;
-    tmpsurf: PSDL_Surface;
+{$IFDEF USE_AM_NUMCOLUMN}tmpsurf: PSDL_Surface;{$ENDIF}
 begin
     SlotsNum:= 0;
     for i:= 0 to cMaxSlotIndex do