This really should have been a TPoint for consistency
authornemo
Sat, 20 Aug 2011 16:43:57 -0400
changeset 5612 2638dec1b323
parent 5610 f8bdc789ac60
child 5614 a281dce3fafc
This really should have been a TPoint for consistency
hedgewars/GSHandlers.inc
hedgewars/HHHandlers.inc
hedgewars/uGears.pas
hedgewars/uGearsRender.pas
hedgewars/uScript.pas
hedgewars/uTypes.pas
--- a/hedgewars/GSHandlers.inc	Sat Aug 20 16:31:20 2011 -0400
+++ b/hedgewars/GSHandlers.inc	Sat Aug 20 16:43:57 2011 -0400
@@ -795,8 +795,8 @@
     begin
         if (GameTicks and $30) = 0 then
             AddVisualGear(gX, gY, vgtBeeTrace);
-        Gear^.dX := Gear^.Elasticity * (Gear^.dX + _0_000064 * (Gear^.TargetX - gX));
-        Gear^.dY := Gear^.Elasticity * (Gear^.dY + _0_000064 * (Gear^.TargetY - gY));
+        Gear^.dX := Gear^.Elasticity * (Gear^.dX + _0_000064 * (Gear^.Target.X - gX));
+        Gear^.dY := Gear^.Elasticity * (Gear^.dY + _0_000064 * (Gear^.Target.Y - 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;
@@ -2373,7 +2373,7 @@
     Gear^.X := Gear^.X + cAirPlaneSpeed * Gear^.Tag;
 
     if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then
-    begin
+        begin
         dec(Gear^.Health);
         case Gear^.State of 
             0: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed *
@@ -2386,10 +2386,10 @@
                              Gear^.Tag, _0, Gear^.Timer + 1);
             //4: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtWaterMelon, 0, cBombsSpeed *
             //                 Gear^.Tag, _0, 5000);
-        end;
+            end;
         Gear^.dX := Gear^.dX + int2hwFloat(30 * Gear^.Tag);
         StopSound(Gear^.SoundChannel, 4000);
-    end;
+        end;
 
     if (GameTicks and $3F) = 0 then
         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
@@ -2418,14 +2418,14 @@
     end;
 
     Gear^.Y := int2hwFloat(topY-300);
-    Gear^.dX := int2hwFloat(Gear^.TargetX - 5 * Gear^.Tag * 15);
+    Gear^.dX := int2hwFloat(Gear^.Target.X - 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(Gear^.TargetY) - Gear^.Y > _0) then
-            Gear^.dX := Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(Gear^.TargetY) - Gear^.Y) * 2 /
+    else if (int2hwFloat(Gear^.Target.Y) - Gear^.Y > _0) then
+            Gear^.dX := Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(Gear^.Target.Y) - Gear^.Y) * 2 /
                 cGravity) * Gear^.Tag;
 
     Gear^.Health := 6;
@@ -2461,14 +2461,14 @@
     AllInactive := false;
 
     HHGear := Gear^.Hedgehog^.Gear;
-    tx := int2hwFloat(Gear^.TargetX);
-    ty := int2hwFloat(Gear^.TargetY);
+    tx := int2hwFloat(Gear^.Target.X);
+    ty := int2hwFloat(Gear^.Target.Y);
     x := HHGear^.X;
     y := HHGear^.Y;
 
     if (Distance(tx - x, ty - y) > _256) or
-       not TryPlaceOnLand(Gear^.TargetX - SpritesData[sprAmGirder].Width div 2,
-       Gear^.TargetY - SpritesData[sprAmGirder].Height div 2,
+       not TryPlaceOnLand(Gear^.Target.X - SpritesData[sprAmGirder].Width div 2,
+       Gear^.Target.Y - SpritesData[sprAmGirder].Height div 2,
        sprAmGirder, Gear^.State, true, false) then
     begin
         PlaySound(sndDenied);
@@ -2527,8 +2527,8 @@
     AllInactive := false;
 
     HHGear := Gear^.Hedgehog^.Gear;
-    if not TryPlaceOnLand(Gear^.TargetX - SpritesData[sprHHTelepMask].Width div 2,
-       Gear^.TargetY - SpritesData[sprHHTelepMask].Height div 2,
+    if not TryPlaceOnLand(Gear^.Target.X - SpritesData[sprHHTelepMask].Width div 2,
+       Gear^.Target.Y - SpritesData[sprHHTelepMask].Height div 2,
        sprHHTelepMask, 0, false, false) then
     begin
         HHGear^.Message := HHGear^.Message and not gmAttack;
@@ -2550,12 +2550,12 @@
         HHGear^.dX.isNegative := (Gear^.X.QWordValue <> 0);
         Gear^.X := HHGear^.X;
         Gear^.Y := HHGear^.Y;
-        HHGear^.X := int2hwFloat(Gear^.TargetX);
-        HHGear^.Y := int2hwFloat(Gear^.TargetY);
+        HHGear^.X := int2hwFloat(Gear^.Target.X);
+        HHGear^.Y := int2hwFloat(Gear^.Target.Y);
         HHGear^.State := HHGear^.State or gstMoving;
         playSound(sndWarp)
     end;
-    Gear^.TargetX:= NoPointX
+    Gear^.Target.X:= NoPointX
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
--- a/hedgewars/HHHandlers.inc	Sat Aug 20 16:31:20 2011 -0400
+++ b/hedgewars/HHHandlers.inc	Sat Aug 20 16:43:57 2011 -0400
@@ -376,8 +376,8 @@
                   end;
         if Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0 then
             begin
-            newGear^.TargetX:= TargetPoint.X;
-            newGear^.TargetY:= TargetPoint.Y
+            newGear^.Target.X:= TargetPoint.X;
+            newGear^.Target.Y:= TargetPoint.Y
             end;
 
         // Clear FollowGear if using on a rope/parachute/saucer etc so focus stays with the hog's movement
--- a/hedgewars/uGears.pas	Sat Aug 20 16:31:20 2011 -0400
+++ b/hedgewars/uGears.pas	Sat Aug 20 16:43:57 2011 -0400
@@ -209,7 +209,7 @@
 FillChar(gear^, sizeof(TGear), 0);
 gear^.X:= int2hwFloat(X);
 gear^.Y:= int2hwFloat(Y);
-gear^.TargetX:= NoPointX;
+gear^.Target.X:= NoPointX;
 gear^.Kind := Kind;
 gear^.State:= State;
 gear^.Active:= true;
--- a/hedgewars/uGearsRender.pas	Sat Aug 20 16:31:20 2011 -0400
+++ b/hedgewars/uGearsRender.pas	Sat Aug 20 16:43:57 2011 -0400
@@ -883,11 +883,11 @@
     i: Longword;
     startX, endX, startY, endY: LongInt;
 begin
-    if Gear^.TargetX <> NoPointX then
+    if Gear^.Target.X <> NoPointX then
         if Gear^.AmmoType = amBee then
-            DrawRotatedF(sprTargetBee, Gear^.TargetX + WorldDx, Gear^.TargetY + WorldDy, 0, 0, (RealTicks shr 3) mod 360)
+            DrawRotatedF(sprTargetBee, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360)
         else
-            DrawRotatedF(sprTargetP, Gear^.TargetX + WorldDx, Gear^.TargetY + WorldDy, 0, 0, (RealTicks shr 3) mod 360);
+            DrawRotatedF(sprTargetP, Gear^.Target.X + WorldDx, Gear^.Target.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360);
 
     case Gear^.Kind of
           gtGrenade: DrawRotated(sprBomb, x, y, 0, Gear^.DirAngle);
--- a/hedgewars/uScript.pas	Sat Aug 20 16:31:20 2011 -0400
+++ b/hedgewars/uScript.pas	Sat Aug 20 16:43:57 2011 -0400
@@ -1229,8 +1229,13 @@
         gear:= GearByUID(lua_tointeger(L, 1));
         if gear <> nil then
             begin
-            lua_pushinteger(L, gear^.TargetX);
-            lua_pushinteger(L, gear^.TargetY)
+            lua_pushinteger(L, gear^.Target.X);
+            lua_pushinteger(L, gear^.Target.Y)
+            end
+        else
+            begin
+            lua_pushnil(L);
+            lua_pushnil(L)
             end
         end;
     lc_getgeartarget:= 2;
@@ -1246,8 +1251,8 @@
         gear:= GearByUID(lua_tointeger(L, 1));
         if gear <> nil then
             begin
-            gear^.TargetX:= lua_tointeger(L, 2);
-            gear^.TargetY:= lua_tointeger(L, 3)
+            gear^.Target.X:= lua_tointeger(L, 2);
+            gear^.Target.Y:= lua_tointeger(L, 3)
             end
         end;
     lc_setgeartarget:= 0
--- a/hedgewars/uTypes.pas	Sat Aug 20 16:31:20 2011 -0400
+++ b/hedgewars/uTypes.pas	Sat Aug 20 16:43:57 2011 -0400
@@ -228,8 +228,7 @@
             Y : hwFloat;
             dX: hwFloat;
             dY: hwFloat;
-            TargetX : LongInt;
-            TargetY : LongInt;
+            Target : TPoint;
             Kind: TGearType;
             Pos: Longword;
             doStep: TGearStepProcedure;