:( bad revision.
authornemo
Wed, 10 Aug 2011 17:20:21 -0400
changeset 5539 7bb3d679e648
parent 5537 3d8b301a7054 (diff)
parent 5499 8fcb3831cf03 (current diff)
child 5541 ec3685a583a5
:( bad revision.
hedgewars/uVariables.pas
--- a/hedgewars/GSHandlers.inc	Wed Aug 10 16:07:34 2011 +0100
+++ b/hedgewars/GSHandlers.inc	Wed Aug 10 17:20:21 2011 -0400
@@ -794,8 +794,8 @@
     begin
         if (GameTicks and $30) = 0 then
             AddVisualGear(gX, gY, vgtBeeTrace);
-        Gear^.dX := Gear^.Elasticity * (Gear^.dX + _0_000064 * (TargetPoint.X - gX));
-        Gear^.dY := Gear^.Elasticity * (Gear^.dY + _0_000064 * (TargetPoint.Y - gY));
+        Gear^.dX := Gear^.Elasticity * (Gear^.dX + _0_000064 * (Gear^.TargetX - gX));
+        Gear^.dY := Gear^.Elasticity * (Gear^.dY + _0_000064 * (Gear^.TargetY - gY));
         // make sure new speed isn't higher than original one (which we stored in Friction variable)
         t := Gear^.Friction / Distance(Gear^.dX, Gear^.dY);
         Gear^.dX := Gear^.dX * t;
@@ -2417,14 +2417,14 @@
     end;
 
     Gear^.Y := int2hwFloat(topY-300);
-    Gear^.dX := int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15);
+    Gear^.dX := int2hwFloat(Gear^.TargetX - 5 * Gear^.Tag * 15);
 
     // calcs for Napalm Strike, so that it will hit the target (without wind at least :P)
     if (Gear^.State = 2) then
         Gear^.dX := Gear^.dX - cBombsSpeed * Gear^.Tag * 900 
     // calcs for regular falling gears
-    else if (int2hwFloat(TargetPoint.Y) - Gear^.Y > _0) then
-            Gear^.dX := Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(TargetPoint.Y) - Gear^.Y) * 2 /
+    else if (int2hwFloat(Gear^.TargetY) - Gear^.Y > _0) then
+            Gear^.dX := Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(Gear^.TargetY) - Gear^.Y) * 2 /
                 cGravity) * Gear^.Tag;
 
     Gear^.Health := 6;
@@ -2460,14 +2460,14 @@
     AllInactive := false;
 
     HHGear := Gear^.Hedgehog^.Gear;
-    tx := int2hwFloat(TargetPoint.X);
-    ty := int2hwFloat(TargetPoint.Y);
+    tx := int2hwFloat(Gear^.TargetX);
+    ty := int2hwFloat(Gear^.TargetY);
     x := HHGear^.X;
     y := HHGear^.Y;
 
     if (Distance(tx - x, ty - y) > _256) or
-       not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2,
-       TargetPoint.Y - SpritesData[sprAmGirder].Height div 2,
+       not TryPlaceOnLand(Gear^.TargetX - SpritesData[sprAmGirder].Width div 2,
+       Gear^.TargetY - SpritesData[sprAmGirder].Height div 2,
        sprAmGirder, Gear^.State, true, false) then
     begin
         PlaySound(sndDenied);
@@ -2486,7 +2486,6 @@
 
     HHGear^.State := HHGear^.State and not (gstAttacking or gstAttacked);
     HHGear^.Message := HHGear^.Message and not gmAttack;
-    TargetPoint.X := NoPointX
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -2527,8 +2526,8 @@
     AllInactive := false;
 
     HHGear := Gear^.Hedgehog^.Gear;
-    if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2,
-       TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2,
+    if not TryPlaceOnLand(Gear^.TargetX - SpritesData[sprHHTelepMask].Width div 2,
+       Gear^.TargetY - SpritesData[sprHHTelepMask].Height div 2,
        sprHHTelepMask, 0, false, false) then
     begin
         HHGear^.Message := HHGear^.Message and not gmAttack;
@@ -2550,12 +2549,12 @@
         HHGear^.dX.isNegative := (Gear^.X.QWordValue <> 0);
         Gear^.X := HHGear^.X;
         Gear^.Y := HHGear^.Y;
-        HHGear^.X := int2hwFloat(TargetPoint.X);
-        HHGear^.Y := int2hwFloat(TargetPoint.Y);
+        HHGear^.X := int2hwFloat(Gear^.TargetX);
+        HHGear^.Y := int2hwFloat(Gear^.TargetY);
         HHGear^.State := HHGear^.State or gstMoving;
         playSound(sndWarp)
     end;
-    TargetPoint.X := NoPointX;
+    Gear^.TargetX:= NoPointX
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -2943,10 +2942,29 @@
 ////////////////////////////////////////////////////////////////////////////////
 procedure doStepSeductionWork(Gear: PGear);
 var 
-    x, y: LongInt;
+    x, y, i: LongInt;
+    hogs: TPGearArray;
+    d: hwFloat;
 begin
     AllInactive := false;
-
+    hogs := GearsNear(Gear^.X, Gear^.Y, gtHedgehog, Gear^.Radius);
+    if Length(hogs) > 0 then
+        begin
+        for i:= 0 to High(hogs) do
+            begin
+            if hogs[i] <> CurrentHedgehog^.Gear then
+                begin
+                //d:= Distance(Gear^.X - hogs[i]^.X, Gear^.Y - hogs[i]^.Y);
+                hogs[i]^.dX:= _0_25 * (Gear^.X - hogs[i]^.X) / _250;
+                //if Gear^.X < hogs[i]^.X then hogs[i]^.dX.isNegative:= true;
+                hogs[i]^.dY:= -_0_25;
+                hogs[i]^.Active:= true;
+                end
+            end;
+        end ;
+        AfterAttack;
+        DeleteGear(Gear);
+(*
     Gear^.X := Gear^.X + Gear^.dX;
     Gear^.Y := Gear^.Y + Gear^.dY;
     x := hwRound(Gear^.X);
@@ -2968,7 +2986,7 @@
         begin
         AfterAttack;
         DeleteGear(Gear)
-        end
+        end*)
 end;
 
 procedure doStepSeductionWear(Gear: PGear);
@@ -2990,7 +3008,7 @@
 procedure doStepSeduction(Gear: PGear);
 begin
     AllInactive := false;
-    DeleteCI(Gear^.Hedgehog^.Gear);
+    //DeleteCI(Gear^.Hedgehog^.Gear);
     Gear^.doStep := @doStepSeductionWear
 end;
 
--- a/hedgewars/HHHandlers.inc	Wed Aug 10 16:07:34 2011 +0100
+++ b/hedgewars/HHHandlers.inc	Wed Aug 10 17:20:21 2011 -0400
@@ -182,6 +182,7 @@
      if ((State and gstHHDriven) <> 0)and
         ((State and (gstAttacked or gstHHChooseTarget)) = 0) and
         (((State and gstMoving) = 0) or
+            (CurAmmoType = amTeleport) or 
             // Allow attacks while moving on ammo with AltAttack
             ((CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)) or
             ((Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackInMove) <> 0)) and
@@ -301,7 +302,7 @@
                                  end;
                        amKamikaze: newGear:= AddGear(hwRound(lx), hwRound(ly), gtKamikaze, 0, xx * _0_5, yy * _0_5, 0);
                          amCake: newGear:= AddGear(hwRound(lx) + hwSign(dX) * 3, hwRound(ly), gtCake, 0, xx, _0, 0);
-                    amSeduction: newGear:= AddGear(hwRound(lx + xx * cHHRadius * 2), hwRound(ly + yy * cHHRadius * 2), gtSeduction, 0, xx * _0_4, yy * _0_4, 0);
+                    amSeduction: newGear:= AddGear(hwRound(lx), hwRound(ly), gtSeduction, 0, _0, _0, 0);
                    amWatermelon: newGear:= AddGear(hwRound(lx), hwRound(ly), gtWatermelon,  0, newDx, newDy, CurWeapon^.Timer);
                   amHellishBomb: newGear:= AddGear(hwRound(lx), hwRound(ly), gtHellishBomb,    0, newDx, newDy, 0);
                         amDrill: newGear:= AddGear(hwRound(lx), hwRound(ly), gtDrill, 0, newDx, newDy, 0);
@@ -373,6 +374,11 @@
                   amResurrector, amStructure,
                        amTardis: CurAmmoGear:= newGear;
                   end;
+        if Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then
+            begin
+            newGear^.TargetX:= TargetPoint.X;
+            newGear^.TargetY:= TargetPoint.Y
+            end;
 
         // Clear FollowGear if using on a rope/parachute/saucer etc so focus stays with the hog's movement
         if altUse then FollowGear:= nil;
@@ -416,7 +422,8 @@
            AfterAttack;
            end
         end else Message:= Message and not gmAttack;
-     end
+     end;
+     TargetPoint.X := NoPointX
 end;
 
 procedure AfterAttack;
--- a/hedgewars/SDLh.pas	Wed Aug 10 16:07:34 2011 +0100
+++ b/hedgewars/SDLh.pas	Wed Aug 10 17:20:21 2011 -0400
@@ -772,6 +772,7 @@
 function  SDL_GL_CreateContext(window: PSDL_Window): PSDL_GLContext; cdecl; external SDLLibName;
 procedure SDL_GL_DeleteContext(context: PSDL_GLContext); cdecl; external SDLLibName;
 function  SDL_GL_SwapWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
+function  SDL_GL_SetSwapInterval(interval: LongInt): LongInt; cdecl; external SDLLibName;
 
 procedure SDL_VideoQuit; cdecl; external SDLLibName;
 function  SDL_GetNumVideoDisplays: LongInt; cdecl; external SDLLibName;
--- a/hedgewars/hwengine.pas	Wed Aug 10 16:07:34 2011 +0100
+++ b/hedgewars/hwengine.pas	Wed Aug 10 17:20:21 2011 -0400
@@ -104,7 +104,7 @@
         end;
 
 {$IFDEF SDL13}
-    SDL_RenderPresent(SDLrender);
+    SDL_GL_SwapWindow(SDLwindow);
 {$ELSE}
     SDL_GL_SwapBuffers();
 {$ENDIF}
@@ -129,10 +129,9 @@
     CloseIPC();
     TTF_Quit();
 {$IFDEF SDL13}
-    SDL_RenderClear(SDLrender);
-    SDL_DestroyRenderer(SDLrender);
+    SDL_GL_DeleteContext(SDLGLcontext);
     SDL_DestroyWindow(SDLwindow);
-    SDLrender:= nil;
+    SDLGLcontext:= nil;
     SDLwindow:= nil;
 {$ENDIF}
     SDL_Quit();
@@ -146,6 +145,7 @@
 const event: TSDL_Event = ();
 {$WARNINGS ON}
 var PrevTime, CurrTime: Longword;
+    prevFocusState: boolean;
 begin
     PrevTime:= SDL_GetTicks;
     while isTerminated = false do
@@ -160,14 +160,22 @@
                     KeyPressChat(event.key.keysym.sym);
                 SDL_WINDOWEVENT:
                     if event.window.event = SDL_WINDOWEVENT_SHOWN then
+                        begin
                         cHasFocus:= true;
+                        onFocusStateChanged()
+                        end;
 {$ELSE}
                     KeyPressChat(event.key.keysym.unicode);
                 SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then wheelDown:= true;
                 SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELUP then wheelUp:= true;
                 SDL_ACTIVEEVENT:
                     if (event.active.state and SDL_APPINPUTFOCUS) <> 0 then
+                        begin
+                        prevFocusState:= cHasFocus;
                         cHasFocus:= event.active.gain = 1;
+                        if prevFocusState xor cHasFocus then
+                            onFocusStateChanged()
+                        end;
 {$ENDIF}
                 SDL_JOYAXISMOTION: ControllerAxisEvent(event.jaxis.which, event.jaxis.axis, event.jaxis.value);
                 SDL_JOYHATMOTION: ControllerHatEvent(event.jhat.which, event.jhat.hat, event.jhat.value);
--- a/hedgewars/uAmmos.pas	Wed Aug 10 16:07:34 2011 +0100
+++ b/hedgewars/uAmmos.pas	Wed Aug 10 17:20:21 2011 -0400
@@ -110,7 +110,8 @@
         if ((a = amLowGravity) and ((GameFlags and gfLowGravity) <> 0)) or
            ((a = amInvulnerable) and ((GameFlags and gfInvulnerable) <> 0)) or
            ((a = amLaserSight) and ((GameFlags and gfLaserSight) <> 0)) or
-           ((a = amVampiric) and ((GameFlags and gfVampiric) <> 0)) then
+           ((a = amVampiric) and ((GameFlags and gfVampiric) <> 0)) or
+           ((a = amExtraTime) and (cHedgehogTurnTime >= 1000000)) then
             begin
             cnt:= 0;
             Ammoz[a].Probability:= 0
--- a/hedgewars/uCommandHandlers.pas	Wed Aug 10 16:07:34 2011 +0100
+++ b/hedgewars/uCommandHandlers.pas	Wed Aug 10 17:20:21 2011 -0400
@@ -46,9 +46,13 @@
     if GameState <> gsConfirm then
     begin
         prevGState:= GameState;
-        GameState:= gsConfirm
+        GameState:= gsConfirm;
+        SDL_ShowCursor(1)
     end else
-    GameState:= prevGState
+    begin
+        GameState:= prevGState;
+        SDL_ShowCursor(ord(isPaused))
+    end
 end;
 
 procedure chForceQuit(var s: shortstring);
@@ -529,7 +533,11 @@
 s:= s; // avoid compiler hint
 if gameType <> gmtNet then
     isPaused:= not isPaused;
-SDL_ShowCursor(ord(isPaused))
+
+if isPaused then
+    SDL_ShowCursor(1)
+    else
+    SDL_ShowCursor(ord(GameState = gsConfirm))
 end;
 
 procedure chRotateMask(var s: shortstring);
--- a/hedgewars/uGears.pas	Wed Aug 10 16:07:34 2011 +0100
+++ b/hedgewars/uGears.pas	Wed Aug 10 17:20:21 2011 -0400
@@ -207,6 +207,7 @@
 FillChar(gear^, sizeof(TGear), 0);
 gear^.X:= int2hwFloat(X);
 gear^.Y:= int2hwFloat(Y);
+gear^.TargetX:= NoPointX;
 gear^.Kind := Kind;
 gear^.State:= State;
 gear^.Active:= true;
@@ -312,6 +313,9 @@
                 gear^.Elasticity:= _0_9;
                 gear^.Tag:= getRandom(32);
                 end;
+   gtSeduction: begin
+                gear^.Radius:= 250;
+                end;
  gtShotgunShot: begin
                 gear^.Timer:= 900;
                 gear^.Radius:= 2
@@ -332,7 +336,7 @@
         gtMine: begin
                 gear^.ImpactSound:= sndMineImpact;
                 gear^.nImpactSounds:= 1;
-		        gear^.Health:= 10;
+                gear^.Health:= 10;
                 gear^.State:= gear^.State or gstMoving;
                 gear^.Radius:= 2;
                 gear^.Elasticity:= _0_55;
@@ -914,8 +918,15 @@
         begin
         dec(delay2);
 
-        if ((delay2 mod cInactDelay) = 0) and (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) then 
+        if ((delay2 mod cInactDelay) = 0) and (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil) and not CurrentHedgehog^.Unplaced then
+            begin
+            if (CurrentHedgehog^.Gear^.State and gstAttacked <> 0) and (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0) then
+                begin
+                CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstHHChooseTarget;
+                isCursorVisible := true
+                end;
             CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State and not gstAttacked;
+            end;
         if delay2 = 0 then
             begin
             if (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.Gear^.State and gstAttacked = 0) then SweepDirty;
@@ -1214,7 +1225,6 @@
     vg: PVisualGear;
     i, cnt: LongInt;
 begin
-TargetPoint.X:= NoPointX;
 if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');
 if Radius > 25 then KickFlakes(Radius, X, Y);
 
@@ -1591,7 +1601,6 @@
 begin
     gear^.dX := _0;
     gear^.dY := _0;
-    gear^.State := gstWait;
     gear^.Damage := 0;
     gear^.Health := gear^.Hedgehog^.InitialHealth;
     gear^.Hedgehog^.Effects[hePoisoned] := false;
@@ -1608,6 +1617,7 @@
     if gear <> nil then begin
         RenderHealth(gear^.Hedgehog^);
         ScriptCall('onGearResurrect', gear^.uid);
+        gear^.State := gstWait;
     end;
     RecountTeamHealth(tempTeam);
 end;
--- a/hedgewars/uGearsRender.pas	Wed Aug 10 16:07:34 2011 +0100
+++ b/hedgewars/uGearsRender.pas	Wed Aug 10 17:20:21 2011 -0400
@@ -600,7 +600,10 @@
                 amGasBomb: DrawRotated(sprHandCheese, hx, hy, sign, aangle);
                 amMine: DrawRotated(sprHandMine, hx, hy, sign, aangle);
                 amSMine: DrawRotated(sprHandSMine, hx, hy, sign, aangle);
-                amSeduction: DrawRotated(sprHandSeduction, hx, hy, sign, aangle);
+                amSeduction: begin
+                             DrawRotated(sprHandSeduction, hx, hy, sign, aangle);
+                             DrawCircle(ox, oy, 248, 4, $FF, $00, $00, $AA); 
+                             end;
                 amVampiric: DrawRotatedF(sprHandVamp, hx, hy, (RealTicks div 125) mod 4, sign, aangle);
                 amRCPlane: begin
                     DrawRotated(sprHandPlane, hx, hy, sign, 0);
@@ -877,6 +880,12 @@
     i: Longword;
     startX, endX, startY, endY: LongInt;
 begin
+    if Gear^.TargetX <> NoPointX then
+        if Gear^.AmmoType = amBee then
+            DrawRotatedF(sprTargetBee, Gear^.TargetX + WorldDx, Gear^.TargetY + WorldDy, 0, 0, (RealTicks shr 3) mod 360)
+        else
+            DrawRotatedF(sprTargetP, Gear^.TargetX + WorldDx, Gear^.TargetY + WorldDy, 0, 0, (RealTicks shr 3) mod 360);
+
     case Gear^.Kind of
           gtGrenade: DrawRotated(sprBomb, x, y, 0, Gear^.DirAngle);
       gtSnowball: DrawRotated(sprSnowball, x, y, 0, Gear^.DirAngle);
@@ -1019,7 +1028,12 @@
                             end;
                         end
                     else
-                        DrawTextureF(SpritesData[sprBirdy].Texture, 1, x, y, ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
+                        begin
+                        if Gear^.Health < 250 then
+                            DrawTextureF(SpritesData[sprBirdy].Texture, 1, x, y, ((Gear^.Pos shr 6) or (RealTicks shr 7)) mod 2, Gear^.Tag, 75, 75)
+                        else
+                            DrawTextureF(SpritesData[sprBirdy].Texture, 1, x, y, ((Gear^.Pos shr 6) or (RealTicks shr 8)) mod 2, Gear^.Tag, 75, 75);
+                        end;
                     end;
              gtEgg: DrawRotatedTextureF(SpritesData[sprEgg].Texture, 1, 0, 0, x, y, 0, 1, 16, 16, Gear^.DirAngle);
            gtPiano: begin
@@ -1049,7 +1063,7 @@
                     Tint($FF, $FF, $FF, $FF);
                     end;
       gtNapalmBomb: DrawRotated(sprNapalmBomb, x, y, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
-           gtFlake: if (Gear^.State and gstTmpFlag) <> 0 then
+           gtFlake: if Gear^.State and (gstDrowning or gstTmpFlag) <> 0  then
                         begin
                         Tint((cExplosionBorderColor shr RShift) and $FF, 
                              (cExplosionBorderColor shr GShift) and $FF, 
--- a/hedgewars/uScript.pas	Wed Aug 10 16:07:34 2011 +0100
+++ b/hedgewars/uScript.pas	Wed Aug 10 17:20:21 2011 -0400
@@ -861,11 +861,13 @@
                vgear^.Hedgehog:= gear^.Hedgehog;
                vgear^.FrameTicks:= lua_tointeger(L, 3);
                if (vgear^.FrameTicks < 1) or (vgear^.FrameTicks > 3) then vgear^.FrameTicks:= 1;
-               end;
+               lua_pushinteger(L, vgear^.Uid)
+               end
             end
+            else lua_pushnil(L)
         end
     else LuaError('Lua: Wrong number of parameters passed to HogSay!');
-    lc_hogsay:= 0
+    lc_hogsay:= 1
 end;
 
 function lc_switchhog(L : Plua_State) : LongInt; Cdecl;
@@ -1214,6 +1216,44 @@
     lc_setgearposition:= 0
 end;
 
+function lc_getgeartarget(L : Plua_State) : LongInt; Cdecl;
+var gear: PGear;
+begin
+    if lua_gettop(L) <> 1 then
+        begin
+        LuaError('Lua: Wrong number of parameters passed to GetGearTarget!');
+        lua_pushnil(L);
+        lua_pushnil(L)
+        end
+    else
+        begin
+        gear:= GearByUID(lua_tointeger(L, 1));
+        if gear <> nil then
+            begin
+            lua_pushinteger(L, gear^.TargetX);
+            lua_pushinteger(L, gear^.TargetY)
+            end
+        end;
+    lc_getgeartarget:= 2;
+end;
+
+function lc_setgeartarget(L : Plua_State) : LongInt; Cdecl;
+var gear: PGear;
+begin
+    if lua_gettop(L) <> 3 then
+        LuaError('Lua: Wrong number of parameters passed to SetGearTarget!')
+    else
+        begin
+        gear:= GearByUID(lua_tointeger(L, 1));
+        if gear <> nil then
+            begin
+            gear^.TargetX:= lua_tointeger(L, 2);
+            gear^.TargetY:= lua_tointeger(L, 3)
+            end
+        end;
+    lc_setgeartarget:= 0
+end;
+
 function lc_getgearvelocity(L : Plua_State) : LongInt; Cdecl;
 var gear: PGear;
 begin
@@ -1819,6 +1859,27 @@
 for cg:= Low(TCapGroup) to High(TCapGroup) do
     ScriptSetInteger(EnumToStr(cg), ord(cg));
 
+ScriptSetInteger('gstDrowning'       ,$00000001);
+ScriptSetInteger('gstHHDriven'       ,$00000002);
+ScriptSetInteger('gstMoving'         ,$00000004);
+ScriptSetInteger('gstAttacked'       ,$00000008);
+ScriptSetInteger('gstAttacking'      ,$00000010);
+ScriptSetInteger('gstCollision'      ,$00000020);
+ScriptSetInteger('gstHHChooseTarget' ,$00000040);
+ScriptSetInteger('gstHHJumping'      ,$00000100);
+ScriptSetInteger('gsttmpFlag'        ,$00000200);
+ScriptSetInteger('gstHHThinking'     ,$00000800);
+ScriptSetInteger('gstNoDamage'       ,$00001000);
+ScriptSetInteger('gstHHHJump'        ,$00002000);
+ScriptSetInteger('gstAnimation'      ,$00004000);
+ScriptSetInteger('gstHHDeath'        ,$00008000);
+ScriptSetInteger('gstWinner'         ,$00010000);
+ScriptSetInteger('gstWait'           ,$00020000);
+ScriptSetInteger('gstNotKickable'    ,$00040000);
+ScriptSetInteger('gstLoser'          ,$00080000);
+ScriptSetInteger('gstHHGone'         ,$00100000);
+ScriptSetInteger('gstInvisible'      ,$00200000);
+
 // register functions
 lua_register(luaState, 'band', @lc_band);
 lua_register(luaState, 'bor', @lc_bor);
@@ -1843,6 +1904,8 @@
 lua_register(luaState, 'FindPlace', @lc_findplace);
 lua_register(luaState, 'SetGearPosition', @lc_setgearposition);
 lua_register(luaState, 'GetGearPosition', @lc_getgearposition);
+lua_register(luaState, 'SetGearTarget', @lc_setgeartarget);
+lua_register(luaState, 'GetGearTarget', @lc_getgeartarget);
 lua_register(luaState, 'SetGearVelocity', @lc_setgearvelocity);
 lua_register(luaState, 'GetGearVelocity', @lc_getgearvelocity);
 lua_register(luaState, 'ParseCommand', @lc_parsecommand);
--- a/hedgewars/uStore.pas	Wed Aug 10 16:07:34 2011 +0100
+++ b/hedgewars/uStore.pas	Wed Aug 10 17:20:21 2011 -0400
@@ -525,17 +525,24 @@
 end;
 
 procedure SetupOpenGL;
-{$IFNDEF IPHONEOS}
-var vendor: shortstring;
+var vendor: shortstring = '';
 {$IFDEF DARWIN}
 const one : LongInt = 1;
 {$ENDIF}
+begin
+{$IFDEF SDL13}
+    // this function creates an opengles1.1 context by default on mobile devices
+    // use SDL_GL_SetAttribute to change this behaviour
+    SDLGLcontext:=SDL_GL_CreateContext(SDLwindow);
+    SDLTry(SDLGLcontext <> nil, true);
+    SDL_GL_SetSwapInterval(1);
 {$ENDIF}
-begin
 
 {$IFDEF IPHONEOS}
     SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0);
     SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1);
+    vendor:= vendor; // avoid hint
+    one:= one; // avoid hint
 {$ELSE}
     SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
     vendor:= LowerCase(shortstring(pchar(glGetString(GL_VENDOR))));
@@ -709,7 +716,7 @@
     DrawFromRect( -squaresize div 2, (cScreenHeight - squaresize) shr 1, @r, ProgrTex);
 
 {$IFDEF SDL13}
-    SDL_RenderPresent(SDLrender);
+    SDL_GL_SwapWindow(SDLwindow);
 {$ELSE}
     SDL_GL_SwapBuffers();
 {$ENDIF}
@@ -814,7 +821,7 @@
         begin
         r:= WriteInRect(tmpsurf, FontBorder + 2, r.y + r.h, $ff707070, font, tmpline);
 
-        // render highlighted caption (if there's a ':')
+        // render highlighted caption (if there is a ':')
         tmpline2:= '';
         SplitByChar(tmpline, tmpline2, ':');
         if tmpline2 <> '' then
@@ -868,7 +875,7 @@
     extra:= trmsg[sidNotYetAvailable];
     extracolor:= LongInt($ffc77070);
     end
-else if (Ammoz[atype].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then // weapon or utility won't end your turn
+else if (Ammoz[atype].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then // weapon or utility will not end your turn
     begin
     extra:= trmsg[sidNoEndTurn];
     extracolor:= LongInt($ff70c770);
@@ -957,24 +964,11 @@
     x:= x or (SDL_GetNumVideoDisplays() - 1);
     y:= y or (SDL_GetNumVideoDisplays() - 1);
 
-    // hardcode the opengles driver as we do our own drawing
-    SDL_SetHint('SDL_RENDER_DRIVER','opengles');
-    flags:= flags or SDL_WINDOW_BORDERLESS;  // do not set SDL_WINDOW_RESIZABLE on iOS
+    flags:= flags or SDL_WINDOW_BORDERLESS; // do not use SDL_WINDOW_RESIZABLE on ios (yet)
 {$ENDIF}
 
     SDLwindow:= SDL_CreateWindow('Hedgewars', x, y, cScreenWidth, cScreenHeight, flags);
     SDLTry(SDLwindow <> nil, true);
-    SDLrender:= SDL_CreateRenderer(SDLwindow, -1, SDL_RENDERER_ACCELERATED or SDL_RENDERER_PRESENTVSYNC);
-    SDLTry(SDLrender <> nil, true);
-
-    // clean the renderer before using it
-    SDL_SetRenderDrawColor(SDLrender, 0, 0, 0, 255);
-    SDL_RenderClear(SDLrender);
-    SDL_RenderPresent(SDLrender);
-
-    // reset the gl context from the one created by SDL (as we have our own drawing system)
-    glMatrixMode(GL_PROJECTION);
-    glLoadIdentity();
 {$ELSE}
     if not cOnlyStats then
         begin
--- a/hedgewars/uTypes.pas	Wed Aug 10 16:07:34 2011 +0100
+++ b/hedgewars/uTypes.pas	Wed Aug 10 17:20:21 2011 -0400
@@ -228,6 +228,8 @@
             Y : hwFloat;
             dX: hwFloat;
             dY: hwFloat;
+            TargetX : LongInt;
+            TargetY : LongInt;
             Kind: TGearType;
             Pos: Longword;
             doStep: TGearStepProcedure;
--- a/hedgewars/uVariables.pas	Wed Aug 10 16:07:34 2011 +0100
+++ b/hedgewars/uVariables.pas	Wed Aug 10 17:20:21 2011 -0400
@@ -167,7 +167,7 @@
 
 {$IFDEF SDL13}
     SDLwindow       : PSDL_Window;
-    SDLrender       : PSDL_Renderer;
+    SDLGLcontext    : PSDL_GLContext;
 {$ENDIF}
 
     WorldDx: LongInt;
@@ -2492,7 +2492,7 @@
 
 {$IFDEF SDL13}
     SDLwindow       := nil;
-    SDLrender       := nil;
+    SDLGLcontext    := nil;
 {$ENDIF}
 
     // those values still are not perfect
--- a/hedgewars/uWorld.pas	Wed Aug 10 16:07:34 2011 +0100
+++ b/hedgewars/uWorld.pas	Wed Aug 10 17:20:21 2011 -0400
@@ -33,6 +33,7 @@
 procedure HideMission;
 procedure ShakeCamera(amount: LongWord);
 procedure MoveCamera;
+procedure onFocusStateChanged;
 
 implementation
 uses
@@ -51,7 +52,8 @@
     uTextures,
     uRender,
     uCaptions,
-    uCursor
+    uCursor,
+    uCommands
     ;
 
 var cWaveWidth, cWaveHeight: LongInt;
@@ -1175,7 +1177,7 @@
     PrevSentPointTime: LongWord = 0;
 begin
 {$IFNDEF IPHONEOS}
-if (not (CurrentTeam^.ExtDriven and isCursorVisible and not bShowAmmoMenu)) and cHasFocus then
+if (not (CurrentTeam^.ExtDriven and isCursorVisible and not bShowAmmoMenu)) and cHasFocus and (GameState <> gsConfirm) then
     uCursor.updatePosition();
 {$ENDIF}
 
@@ -1312,6 +1314,14 @@
     WorldDy:= WorldDy - amount + LongInt(getRandom(1 + amount * 2));
 end;
 
+
+procedure onFocusStateChanged;
+begin
+if (not cHasFocus) and (GameState <> gsConfirm) then
+    ParseCommand('quit', true);
+end;
+
+
 procedure initModule;
 begin
     fpsTexture:= nil;
--- a/misc/libfreetype/Xcode-iPhoneOS/Freetype.xcodeproj/project.pbxproj	Wed Aug 10 16:07:34 2011 +0100
+++ b/misc/libfreetype/Xcode-iPhoneOS/Freetype.xcodeproj/project.pbxproj	Wed Aug 10 17:20:21 2011 -0400
@@ -1115,7 +1115,8 @@
 			buildSettings = {
 				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				GCC_C_LANGUAGE_STANDARD = c99;
-				GCC_OPTIMIZATION_LEVEL = 2;
+				GCC_FAST_MATH = YES;
+				GCC_OPTIMIZATION_LEVEL = s;
 				GCC_PREPROCESSOR_DEFINITIONS = (
 					DARWIN_NO_CARBON,
 					FT2_BUILD_LIBRARY,
--- a/misc/liblua/Xcode/Lua.xcodeproj/project.pbxproj	Wed Aug 10 16:07:34 2011 +0100
+++ b/misc/liblua/Xcode/Lua.xcodeproj/project.pbxproj	Wed Aug 10 17:20:21 2011 -0400
@@ -405,6 +405,7 @@
 			buildSettings = {
 				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				GCC_C_LANGUAGE_STANDARD = c99;
+				GCC_FAST_MATH = YES;
 				GCC_THUMB_SUPPORT = NO;
 				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
--- a/misc/libtremor/Xcode/Tremor.xcodeproj/project.pbxproj	Wed Aug 10 16:07:34 2011 +0100
+++ b/misc/libtremor/Xcode/Tremor.xcodeproj/project.pbxproj	Wed Aug 10 17:20:21 2011 -0400
@@ -325,6 +325,7 @@
 			buildSettings = {
 				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
 				GCC_C_LANGUAGE_STANDARD = c99;
+				GCC_FAST_MATH = YES;
 				GCC_THUMB_SUPPORT = NO;
 				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
--- a/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m	Wed Aug 10 16:07:34 2011 +0100
+++ b/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m	Wed Aug 10 17:20:21 2011 -0400
@@ -144,10 +144,9 @@
 -(void) applicationWillResignActive:(UIApplication *)application {
     //[super applicationWillResignActive:application];
 
-    UIDevice* device = [UIDevice currentDevice];
+    UIDevice *device = [UIDevice currentDevice];
     if ([device respondsToSelector:@selector(isMultitaskingSupported)] &&
-         device.multitaskingSupported &&
-         self.isInGame) {
+         [device isMultitaskingSupported] && self.isInGame) {
         // let's try to be permissive with multitasking here...
         if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"multitasking"] boolValue])
             HW_suspend();
@@ -166,10 +165,9 @@
 -(void) applicationDidBecomeActive:(UIApplication *)application {
     //[super applicationDidBecomeActive:application];
 
-    UIDevice* device = [UIDevice currentDevice];
+    UIDevice *device = [UIDevice currentDevice];
     if ([device respondsToSelector:@selector(isMultitaskingSupported)] &&
-         device.multitaskingSupported &&
-         self.isInGame) {
+         [device isMultitaskingSupported] && self.isInGame) {
         HW_resume();
     }
 }
--- a/project_files/HedgewarsMobile/Classes/UIImageExtra.m	Wed Aug 10 16:07:34 2011 +0100
+++ b/project_files/HedgewarsMobile/Classes/UIImageExtra.m	Wed Aug 10 17:20:21 2011 -0400
@@ -25,17 +25,17 @@
 @implementation UIImage (extra)
 
 CGFloat getScreenScale(void) {
+    float scale = 1.0f;
     if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
-        return [UIScreen mainScreen].scale;
-    else
-        return 1.0f;
+        scale = [[UIScreen mainScreen] scale];
+    return scale;
 }
 
 -(UIImage *)scaleToSize:(CGSize) size {
     DLog(@"warning - this is a very expensive operation, you should avoid using it");
 
     // Create a bitmap graphics context; this will also set it as the current context
-    if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
+    if (UIGraphicsBeginImageContextWithOptions != NULL)
         UIGraphicsBeginImageContextWithOptions(size, NO, getScreenScale());
     else
         UIGraphicsBeginImageContext(size);
Binary file share/hedgewars/Data/Music/Golf.ogg has changed
--- a/share/hedgewars/Data/Themes/CMakeLists.txt	Wed Aug 10 16:07:34 2011 +0100
+++ b/share/hedgewars/Data/Themes/CMakeLists.txt	Wed Aug 10 17:20:21 2011 -0400
@@ -16,6 +16,7 @@
 	EarthRise
 	Eyes
 	Freeway
+	Golf
 	Halloween
 	Hell
 	Island
Binary file share/hedgewars/Data/Themes/Golf/Bag.png has changed
Binary file share/hedgewars/Data/Themes/Golf/Ball.png has changed
Binary file share/hedgewars/Data/Themes/Golf/Balldirt.png has changed
Binary file share/hedgewars/Data/Themes/Golf/Border.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Themes/Golf/CMakeLists.txt	Wed Aug 10 17:20:21 2011 -0400
@@ -0,0 +1,6 @@
+file(GLOB images *.png)
+
+install(FILES
+    theme.cfg
+    ${images}
+    DESTINATION ${SHAREPATH}Data/Themes/Golf)
Binary file share/hedgewars/Data/Themes/Golf/Car.png has changed
Binary file share/hedgewars/Data/Themes/Golf/Flag1.png has changed
Binary file share/hedgewars/Data/Themes/Golf/Flag2.png has changed
Binary file share/hedgewars/Data/Themes/Golf/Flag3.png has changed
Binary file share/hedgewars/Data/Themes/Golf/Flag4.png has changed
Binary file share/hedgewars/Data/Themes/Golf/Hole.png has changed
Binary file share/hedgewars/Data/Themes/Golf/LandTex.png has changed
Binary file share/hedgewars/Data/Themes/Golf/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Golf/SkyL.png has changed
Binary file share/hedgewars/Data/Themes/Golf/SkyR.png has changed
Binary file share/hedgewars/Data/Themes/Golf/Tee.png has changed
Binary file share/hedgewars/Data/Themes/Golf/horizont.png has changed
--- a/share/hedgewars/Data/Themes/Golf/theme.cfg	Wed Aug 10 16:07:34 2011 +0100
+++ b/share/hedgewars/Data/Themes/Golf/theme.cfg	Wed Aug 10 17:20:21 2011 -0400
@@ -1,15 +1,22 @@
-sky = 117, 141, 186
+sky = 34, 67, 135
 border = 38, 114, 35
 water-top = $54, $5C, $9D
 water-bottom = $34, $3C, $7D
 water-opacity = $80
-music = nature.ogg
+music = Golf.ogg
 clouds = 9
-object = Ball, 3, 0, 18, 24, 6, 1, 0, 0, 24, 13
-object = Tee, 1, 6, 22, 5, 4, 1, 0, 0, 16, 20
-object = Car, 1, 65, 258, 80, 2, 1, 0, 0, 240, 215
-object = Hole, 5, 0, 44, 100, 4, 1, 19, 0, 54, 41
-object = Flag1, 1, 65, 258, 80, 2, 1, 0, 0, 240, 215
-object = Flag2, 1, 65, 258, 80, 2, 1, 0, 0, 240, 215
-object = Club, 2, 162, 254, 21, 6, 1, 0, 0, 240, 245
-flakes = 100, 1, 1000, 50, 50
+object = Hole, 2, 0, 31, 123, 1, 1, 31, 0, 40, 27
+object = Car, 1, 78, 320, 80, 30, 1, 0, 0, 330, 220
+object = Club, 2, 180, 175, 5, 1, 2, 189, 155, 15, 20, 0, 0, 100, 100
+object = Flag1, 1, 0, 305, 15, 5, 1, 20, 0, 103, 260
+object = Flag2, 1, 40, 305, 10, 4, 1, 0, 0, 53, 270
+object = Flag3, 1, 0, 280, 12, 7, 1, 30, 0, 112, 260
+object = Flag4, 1, 275, 145, 8, 12, 1, 0, 0, 250, 158
+object = Tee, 2, 6, 20, 2, 2, 1, 0, 0, 12, 15
+object = Ball, 4, 8, 15, 2, 1, 1, 0, 0, 16, 8
+object = Ball, 3, 0, 0, 6, 16, 1, 10, 0, 6, 16
+object = Ball, 3, 10, 0, 6, 16, 1, 0, 0, 6, 16
+object = Bag, 1, 65, 0, 129, 44, 1, 0, 71, 234, 81
+spray = Balldirt, 5
+flakes = 55, 40, 99999999, 30, 200
+