fix a couple of loose ends
authorkoda
Sat, 26 Mar 2011 22:49:38 +0100
changeset 5052 74a81c276d67
parent 5051 7b5fa8d3c904
child 5053 a767954cfa03
fix a couple of loose ends
hedgewars/GSHandlers.inc
hedgewars/SDLh.pas
hedgewars/hwengine.pas
hedgewars/uMisc.pas
hedgewars/uScript.pas
hedgewars/uSound.pas
hedgewars/uStore.pas
hedgewars/uTeams.pas
--- a/hedgewars/GSHandlers.inc	Fri Mar 25 20:02:27 2011 -0400
+++ b/hedgewars/GSHandlers.inc	Sat Mar 26 22:49:38 2011 +0100
@@ -571,11 +571,10 @@
 end;
 
 procedure doStepSnowflake(Gear: PGear);
-var xx, yy, px, py, i: LongInt;
+var xx, yy, px, py: LongInt;
     move, draw, allpx, gun: Boolean;
     s: PSDL_Surface;
     p: PLongwordArray;
-    oAlpha, nAlpha: byte;
 begin
 gun:= (Gear^.State and gstTmpFlag) <> 0;
 move:= false;
@@ -4797,7 +4796,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepStructure(Gear: PGear);
 var 
-    i, x, y: LongInt;
+    x, y: LongInt;
     dX, dY: HWFloat;
     hog: PHedgehog;
 begin
--- a/hedgewars/SDLh.pas	Fri Mar 25 20:02:27 2011 -0400
+++ b/hedgewars/SDLh.pas	Sat Mar 26 22:49:38 2011 +0100
@@ -574,18 +574,18 @@
 {$IFDEF SDL13}
         case LongInt of
             SDL_FIRSTEVENT: (type_: LongInt);
-            SDL_WINDOWEVENT: (wevent: TSDL_WindowEvent);
+            SDL_WINDOWEVENT: (window: TSDL_WindowEvent);
             SDL_KEYDOWN,
             SDL_KEYUP: (key: TSDL_KeyboardEvent);
             SDL_TEXTEDITING,
-            SDL_TEXTINPUT: (txtin: byte);
+            SDL_TEXTINPUT: (edit: byte);
             SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent);
             SDL_MOUSEBUTTONDOWN,
             SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent);
             SDL_MOUSEWHEEL: (wheel: TSDL_MouseWheelEvent);
             SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent);
+            SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent);
             SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent);
-            SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent);
             SDL_JOYBUTTONDOWN,
             SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent);
             SDL_QUITEV: (quit: TSDL_QuitEvent);
@@ -780,19 +780,9 @@
 function  SDL_GetNumMice: LongInt; cdecl; external SDLLibName;
 function  SDL_PixelFormatEnumToMasks(format: TSDL_ArrayByteOrder; bpp: PLongInt; Rmask, Gmask, Bmask, Amask: PLongInt): boolean; cdecl; external SDLLibName;
 
-function  SDL_AllocFormat(format: Longword): PSDL_PixelFormat; cdecl; external SDLLibName;
-procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat); cdecl; external SDLLibName;
 procedure SDL_WarpMouseInWindow(window: PSDL_Window; x, y: LongInt); cdecl; external SDLLibName;
-
-procedure SDL_WarpMouse(x, y: Word);
-{$ELSE}
-procedure SDL_WarpMouse(x, y: Word); cdecl; external SDLLibName;
-
-function  SDL_AllocFormat(format: Longword): PSDL_PixelFormat;
-//procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat);
 {$ENDIF}
 
-function  SDL_GetKeyState(numkeys: PLongInt): PByteArray; cdecl; external SDLLibName {$IFDEF SDL13} name 'SDL_GetKeyboardState'{$ENDIF};
 function  SDL_GetMouseState(x, y: PLongInt): Byte; cdecl; external SDLLibName;
 function  SDL_GetKeyName(key: Longword): PChar; cdecl; external SDLLibName;
 
@@ -834,13 +824,19 @@
 function SDL_putenv(const text: PChar): LongInt; cdecl; external SDLLibName;
 function SDL_getenv(const text: PChar): PChar; cdecl; external SDLLibName;
 
+{* Compatibility between SDL-1.2 and SDL-1.3 *}
+procedure SDL_WarpMouse(x, y: Word); {$IFNDEF SDL13}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}
+
 {* OpenGL *}
 {$IFDEF DARWIN}
 function CGLGetCurrentContext(): Pointer; cdecl; external 'OpenGL';
 procedure CGLSetParameter(context: Pointer; option: LongInt; value: Pointer); cdecl; external 'OpenGL';
 {$ENDIF}
 
-(*  SDL_TTF  *)
+(*  SDL_ttf  *)
 function  TTF_Init: LongInt; cdecl; external SDL_TTFLibName;
 procedure TTF_Quit; cdecl; external SDL_TTFLibName;
 
@@ -919,6 +915,8 @@
 uses uVariables;
 
 {$IFDEF SDL13}
+// this needs to be reimplemented because in SDL_compat.c the window is the one created in the SDL_SetVideoMode
+// compatible function, but we use SDL_CreateWindow, so the window would be NULL
 procedure SDL_WarpMouse(x, y: Word);
 begin
     SDL_WarpMouseInWindow(SDLwindow, x, y);
@@ -936,9 +934,9 @@
     exit(@conversionFormat);
 end;
 
-procedure SDL_FreeFormat;
+procedure SDL_FreeFormat(pixelformat: PSDL_PixelFormat);
 begin
-    // yay free space
+    pixelformat:= pixelformat;
 end;
 {$ENDIF}
 
--- a/hedgewars/hwengine.pas	Fri Mar 25 20:02:27 2011 -0400
+++ b/hedgewars/hwengine.pas	Sat Mar 26 22:49:38 2011 +0100
@@ -154,7 +154,7 @@
                     // sdl on iphone supports only ashii keyboards and the unicode field is deprecated in sdl 1.3
                     KeyPressChat(event.key.keysym.sym);
                 SDL_WINDOWEVENT:
-                    if event.wevent.event = SDL_WINDOWEVENT_SHOWN then
+                    if event.window.event = SDL_WINDOWEVENT_SHOWN then
                         cHasFocus:= true;
 {$ELSE}
                     KeyPressChat(event.key.keysym.unicode);
--- a/hedgewars/uMisc.pas	Fri Mar 25 20:02:27 2011 -0400
+++ b/hedgewars/uMisc.pas	Sat Mar 26 22:49:38 2011 +0100
@@ -140,17 +140,15 @@
 end;
 
 procedure initModule;
+const SDL_PIXELFORMAT_ABGR8888 = ((1 shl 31) or (6 shl 24) or (7 shl 20) or (6 shl 16) or (32 shl 8) or 4);
 begin
-    // SDL_PIXELFORMAT_RGB8888
-    conversionFormat:= SDL_AllocFormat($86462004);
+    conversionFormat:= SDL_AllocFormat(SDL_PIXELFORMAT_ABGR8888);
 end;
 
 procedure freeModule;
 begin
     recordFileName:= '';
-{$IFDEF SDL13}
     SDL_FreeFormat(conversionFormat);
-{$ENDIF}
 end;
 
 end.
--- a/hedgewars/uScript.pas	Fri Mar 25 20:02:27 2011 -0400
+++ b/hedgewars/uScript.pas	Sat Mar 26 22:49:38 2011 +0100
@@ -1287,7 +1287,6 @@
 end;
 
 function lc_getcurammotype(L : Plua_State): LongInt; Cdecl;
-var gear : PGear;
 begin
     if lua_gettop(L) <> 0 then
         LuaError('Lua: Wrong number of parameters passed to GetCurAmmoType!')
--- a/hedgewars/uSound.pas	Fri Mar 25 20:02:27 2011 -0400
+++ b/hedgewars/uSound.pas	Sat Mar 26 22:49:38 2011 +0100
@@ -229,6 +229,7 @@
 
 function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt;
 begin
+    voicepack:= voicepack;    // avoid compiler hint
     LoopSound:= LoopSound(snd, nil, 0)
 end;
 
--- a/hedgewars/uStore.pas	Fri Mar 25 20:02:27 2011 -0400
+++ b/hedgewars/uStore.pas	Sat Mar 26 22:49:38 2011 +0100
@@ -882,7 +882,7 @@
 var flags: Longword = 0;
     ico: PSDL_Surface;
     buf: array[byte] of char;
-    x, y: LongInt;
+    {$IFDEF SDL13}x, y: LongInt;{$ENDIF}
 begin
     s:= s; // avoid compiler hint
     if Length(s) = 0 then cFullScreen:= not cFullScreen
@@ -928,8 +928,8 @@
     begin
         // the values in x and y make the window appear in the center
         // on ios, make the sdl window appear on the second monitor when present
-        x:= (SDL_WINDOWPOS_CENTERED_MASK or {$IFDEF IPHONEOS}SDL_GetNumVideoDisplays() - 1){$ELSE}0{$ENDIF});
-        y:= (SDL_WINDOWPOS_CENTERED_MASK or {$IFDEF IPHONEOS}SDL_GetNumVideoDisplays() - 1){$ELSE}0{$ENDIF});
+        x:= (SDL_WINDOWPOS_CENTERED_MASK or {$IFDEF IPHONEOS}(SDL_GetNumVideoDisplays() - 1){$ELSE}0{$ENDIF});
+        y:= (SDL_WINDOWPOS_CENTERED_MASK or {$IFDEF IPHONEOS}(SDL_GetNumVideoDisplays() - 1){$ELSE}0{$ENDIF});
         SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN
                         {$IFDEF IPHONEOS} or SDL_WINDOW_BORDERLESS {$ENDIF});
         SDLrender:= SDL_CreateRenderer(SDLwindow, -1, SDL_RENDERER_ACCELERATED or SDL_RENDERER_PRESENTVSYNC);
--- a/hedgewars/uTeams.pas	Fri Mar 25 20:02:27 2011 -0400
+++ b/hedgewars/uTeams.pas	Sat Mar 26 22:49:38 2011 +0100
@@ -96,7 +96,7 @@
 
 procedure SwitchHedgehog;
 var c: LongWord;
-    PrevHH, PrevTeam, PrevClan: LongWord;
+    PrevHH, PrevTeam : LongWord;
 begin
 TargetPoint.X:= NoPointX;
 TryDo(CurrentTeam <> nil, 'nil Team', true);