merge hedgeroid
authorXeli
Tue, 09 Aug 2011 21:41:52 +0200
branchhedgeroid
changeset 5530 25d4118056e1
parent 5516 8710987d3484 (current diff)
parent 5528 c539e5c81870 (diff)
child 5532 3d7ac2b3b703
merge
hedgewars/SDLh.pas
hedgewars/hwengine.pas
hedgewars/uCommandHandlers.pas
hedgewars/uScript.pas
hedgewars/uStore.pas
hedgewars/uWorld.pas
--- a/hedgewars/GSHandlers.inc	Tue Aug 09 21:31:49 2011 +0200
+++ b/hedgewars/GSHandlers.inc	Tue Aug 09 21:41:52 2011 +0200
@@ -257,16 +257,14 @@
     AllInactive := false;
     Gear^.Y := Gear^.Y + cDrownSpeed;
     Gear^.X := Gear^.X + Gear^.dX * cDrownSpeed;
-    if (not SuddenDeathDmg and (cWaterOpacity > $FE)) or (SuddenDeathDmg and (cSDWaterOpacity > $FE)) or (hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater) then
-        DeleteGear(Gear);
     // Create some bubbles (0.5% might be better but causes too few bubbles sometimes)
     if ((not SuddenDeathDmg and (cWaterOpacity < $FF)) or (SuddenDeathDmg and (cSDWaterOpacity < $FF))) and ((GameTicks and $1F) = 0) then
         if (Gear^.Kind = gtHedgehog) and (Random(4) = 0) then
-            AddVisualGear(hwRound(Gear^.X) - Gear^.Radius, hwRound(Gear^.Y) - Gear^.Radius,
-            vgtBubble)
+            AddVisualGear(hwRound(Gear^.X) - Gear^.Radius, hwRound(Gear^.Y) - Gear^.Radius, vgtBubble)
     else if Random(12) = 0 then
-             AddVisualGear(hwRound(Gear^.X) - Gear^.Radius, hwRound(Gear^.Y) - Gear^.Radius,
-             vgtBubble)
+             AddVisualGear(hwRound(Gear^.X) - Gear^.Radius, hwRound(Gear^.Y) - Gear^.Radius, vgtBubble);
+    if (not SuddenDeathDmg and (cWaterOpacity > $FE)) or (SuddenDeathDmg and (cSDWaterOpacity > $FE)) or (hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater) then
+        DeleteGear(Gear);
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -796,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;
@@ -1368,7 +1366,7 @@
     DeleteGear(Gear)
 end;
 
-procedure WaitCollision;
+(*procedure WaitCollision;
 begin
     with HHGear^ do
     begin
@@ -1378,7 +1376,7 @@
     RopePoints.Count := 0;
     Gear^.Elasticity := _0;
     Gear^.doStep := @doStepRopeAfterAttack
-end;
+end;*)
 
 begin
     HHGear := Gear^.Hedgehog^.Gear;
@@ -1584,9 +1582,9 @@
             with Gear^.Hedgehog^ do
                 begin
                 PlaySound(sndRopeRelease);
-                if CurAmmoType <> amParachute then
-                    WaitCollision
-                else
+                //if CurAmmoType <> amParachute then
+                //    WaitCollision
+                //else
                     DeleteMe
                 end
         end
@@ -2419,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;
@@ -2462,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);
@@ -2488,7 +2486,6 @@
 
     HHGear^.State := HHGear^.State and not (gstAttacking or gstAttacked);
     HHGear^.Message := HHGear^.Message and not gmAttack;
-    TargetPoint.X := NoPointX
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -2529,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;
@@ -2552,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;
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -2945,10 +2942,26 @@
 ////////////////////////////////////////////////////////////////////////////////
 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
+            //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 ;
+        AfterAttack;
+        DeleteGear(Gear);
+(*
     Gear^.X := Gear^.X + Gear^.dX;
     Gear^.Y := Gear^.Y + Gear^.dY;
     x := hwRound(Gear^.X);
@@ -2970,7 +2983,7 @@
         begin
         AfterAttack;
         DeleteGear(Gear)
-        end
+        end*)
 end;
 
 procedure doStepSeductionWear(Gear: PGear);
@@ -2992,7 +3005,7 @@
 procedure doStepSeduction(Gear: PGear);
 begin
     AllInactive := false;
-    DeleteCI(Gear^.Hedgehog^.Gear);
+    //DeleteCI(Gear^.Hedgehog^.Gear);
     Gear^.doStep := @doStepSeductionWear
 end;
 
--- a/hedgewars/HHHandlers.inc	Tue Aug 09 21:31:49 2011 +0200
+++ b/hedgewars/HHHandlers.inc	Tue Aug 09 21:41:52 2011 +0200
@@ -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	Tue Aug 09 21:31:49 2011 +0200
+++ b/hedgewars/SDLh.pas	Tue Aug 09 21:41:52 2011 +0200
@@ -783,6 +783,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	Tue Aug 09 21:31:49 2011 +0200
+++ b/hedgewars/hwengine.pas	Tue Aug 09 21:41:52 2011 +0200
@@ -105,7 +105,7 @@
         end;
 
 {$IFDEF SDL13}
-    SDL_RenderPresent(SDLrender);
+    SDL_GL_SwapWindow(SDLwindow);
 {$ELSE}
     SDL_GL_SwapBuffers();
 {$ENDIF}
@@ -130,10 +130,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();
@@ -147,6 +146,7 @@
 const event: TSDL_Event = ();
 {$WARNINGS ON}
 var PrevTime, CurrTime: Longword;
+    prevFocusState: boolean;
 begin
     PrevTime:= SDL_GetTicks;
     while isTerminated = false do
@@ -165,14 +165,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	Tue Aug 09 21:31:49 2011 +0200
+++ b/hedgewars/uAmmos.pas	Tue Aug 09 21:41:52 2011 +0200
@@ -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	Tue Aug 09 21:31:49 2011 +0200
+++ b/hedgewars/uCommandHandlers.pas	Tue Aug 09 21:41:52 2011 +0200
@@ -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	Tue Aug 09 21:31:49 2011 +0200
+++ b/hedgewars/uGears.pas	Tue Aug 09 21:41:52 2011 +0200
@@ -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;
@@ -275,6 +276,8 @@
                 gear^.Density:= _1;
                 end;
        gtSnowball: begin
+                gear^.ImpactSound:= sndMudballImpact;
+                gear^.nImpactSounds:= 1;
                 gear^.Radius:= 4;
                 gear^.Elasticity:= _1;
                 gear^.Friction:= _1;
@@ -310,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
@@ -328,6 +334,8 @@
                 RopePoints.Count:= 0;
                 end;
         gtMine: begin
+                gear^.ImpactSound:= sndMineImpact;
+                gear^.nImpactSounds:= 1;
                 gear^.Health:= 10;
                 gear^.State:= gear^.State or gstMoving;
                 gear^.Radius:= 2;
@@ -910,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;
@@ -1210,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);
 
@@ -1587,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;
@@ -1604,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	Tue Aug 09 21:31:49 2011 +0200
+++ b/hedgewars/uGearsRender.pas	Tue Aug 09 21:41:52 2011 +0200
@@ -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	Tue Aug 09 21:31:49 2011 +0200
+++ b/hedgewars/uScript.pas	Tue Aug 09 21:41:52 2011 +0200
@@ -1214,6 +1214,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 +1857,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 +1902,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	Tue Aug 09 21:31:49 2011 +0200
+++ b/hedgewars/uStore.pas	Tue Aug 09 21:41:52 2011 +0200
@@ -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 MOBILE}
+{$IFDEF IHPONE}
     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	Tue Aug 09 21:31:49 2011 +0200
+++ b/hedgewars/uTypes.pas	Tue Aug 09 21:41:52 2011 +0200
@@ -117,7 +117,8 @@
     TSound = (sndNone,
             sndGrenadeImpact, sndExplosion, sndThrowPowerUp, sndThrowRelease,
             sndSplash, sndShotgunReload, sndShotgunFire, sndGraveImpact,
-            sndMineTick, sndPickhammer, sndGun, sndBee, sndJump1, sndJump2,
+            sndMineImpact, sndMineTick, sndMudballImpact,
+            sndPickhammer, sndGun, sndBee, sndJump1, sndJump2,
             sndJump3, sndYesSir, sndLaugh, sndIllGetYou, sndIncoming,
             sndMissed, sndStupid, sndFirstBlood, sndBoring, sndByeBye,
             sndSameTeam, sndNutter, sndReinforce, sndTraitor, sndRegret,
@@ -227,6 +228,8 @@
             Y : hwFloat;
             dX: hwFloat;
             dY: hwFloat;
+            TargetX : LongInt;
+            TargetY : LongInt;
             Kind: TGearType;
             Pos: Longword;
             doStep: TGearStepProcedure;
--- a/hedgewars/uVariables.pas	Tue Aug 09 21:31:49 2011 +0200
+++ b/hedgewars/uVariables.pas	Tue Aug 09 21:41:52 2011 +0200
@@ -167,7 +167,7 @@
 
 {$IFDEF SDL13}
     SDLwindow       : PSDL_Window;
-    SDLrender       : PSDL_Renderer;
+    SDLGLcontext    : PSDL_GLContext;
 {$ENDIF}
 
     WorldDx: LongInt;
@@ -633,7 +633,9 @@
             (FileName:        'shotgunreload.ogg'; Path: ptSounds),// sndShotgunReload
             (FileName:          'shotgunfire.ogg'; Path: ptSounds),// sndShotgunFire
             (FileName:          'graveimpact.ogg'; Path: ptSounds),// sndGraveImpact
+            (FileName:           'mineimpact.ogg'; Path: ptSounds),// sndMineImpact
             (FileName:             'minetick.ogg'; Path: ptSounds),// sndMineTicks
+            (FileName:             'Droplet1.ogg'; Path: ptSounds),// sndMudballImpact
             (FileName:           'pickhammer.ogg'; Path: ptSounds),// sndPickhammer
             (FileName:                  'gun.ogg'; Path: ptSounds),// sndGun
             (FileName:                  'bee.ogg'; Path: ptSounds),// sndBee
@@ -729,7 +731,7 @@
             (FileName:                'Ooff1.ogg'; Path: ptVoices),// sndOoff1
             (FileName:                'Ooff2.ogg'; Path: ptVoices),// sndOoff2
             (FileName:                'Ooff3.ogg'; Path: ptVoices),// sndOoff3
-            (FileName:            'whipcrack.ogg'; Path: ptSounds),// sndWhack
+            (FileName:               'hammer.ogg'; Path: ptSounds),// sndWhack
             (FileName:           'Comeonthen.ogg'; Path: ptVoices),// sndComeonthen
             (FileName:            'parachute.ogg'; Path: ptSounds),// sndParachute
             (FileName:                 'bump.ogg'; Path: ptSounds),// sndBump
@@ -2490,7 +2492,7 @@
 
 {$IFDEF SDL13}
     SDLwindow       := nil;
-    SDLrender       := nil;
+    SDLGLcontext    := nil;
 {$ENDIF}
 
     // those values still are not perfect
--- a/hedgewars/uWorld.pas	Tue Aug 09 21:31:49 2011 +0200
+++ b/hedgewars/uWorld.pas	Tue Aug 09 21:41:52 2011 +0200
@@ -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 MOBILE}
-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	Tue Aug 09 21:31:49 2011 +0200
+++ b/misc/libfreetype/Xcode-iPhoneOS/Freetype.xcodeproj/project.pbxproj	Tue Aug 09 21:41:52 2011 +0200
@@ -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	Tue Aug 09 21:31:49 2011 +0200
+++ b/misc/liblua/Xcode/Lua.xcodeproj/project.pbxproj	Tue Aug 09 21:41:52 2011 +0200
@@ -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	Tue Aug 09 21:31:49 2011 +0200
+++ b/misc/libtremor/Xcode/Tremor.xcodeproj/project.pbxproj	Tue Aug 09 21:41:52 2011 +0200
@@ -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	Tue Aug 09 21:31:49 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/HedgewarsAppDelegate.m	Tue Aug 09 21:41:52 2011 +0200
@@ -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	Tue Aug 09 21:31:49 2011 +0200
+++ b/project_files/HedgewarsMobile/Classes/UIImageExtra.m	Tue Aug 09 21:41:52 2011 +0200
@@ -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/Sounds/hammer.ogg has changed
Binary file share/hedgewars/Data/Sounds/mineimpact.ogg has changed