hedgewars/GSHandlers.inc
changeset 4886 e3e5362a308e
parent 4881 35e6269227b6
child 4956 48e1f9a04c28
--- a/hedgewars/GSHandlers.inc	Sun Jan 30 06:56:12 2011 +0100
+++ b/hedgewars/GSHandlers.inc	Sun Jan 30 19:05:31 2011 +0100
@@ -2381,7 +2381,7 @@
     if (Distance(tx - x, ty - y) > _256) or
        not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2,
        TargetPoint.Y - SpritesData[sprAmGirder].Height div 2,
-       sprAmGirder, Gear^.State, true) then
+       sprAmGirder, Gear^.State, true, false) then
     begin
         PlaySound(sndDenied);
         HHGear^.Message := HHGear^.Message and not gmAttack;
@@ -2442,7 +2442,7 @@
     HHGear := Gear^.Hedgehog^.Gear;
     if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2,
        TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2,
-       sprHHTelepMask, 0, false) then
+       sprHHTelepMask, 0, false, false) then
     begin
         HHGear^.Message := HHGear^.Message and not gmAttack;
         HHGear^.State := HHGear^.State and not gstAttacking;
@@ -3115,6 +3115,8 @@
     HHGear := Gear^.Hedgehog^.Gear;
     FollowGear := Gear;
 
+    if Gear^.Timer > 0 then dec(Gear^.Timer);
+
     fChanged := false;
     if ((HHGear^.State and gstHHDriven) = 0) or (Gear^.Timer = 0) then
     begin
@@ -4591,6 +4593,43 @@
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
+procedure doStepPlaceStructure(Gear: PGear);
+var 
+    HHGear: PGear;
+    x, y, tx, ty: hwFloat;
+begin
+    AllInactive := false;
+
+    HHGear := Gear^.Hedgehog^.Gear;
+    tx := int2hwFloat(TargetPoint.X);
+    ty := int2hwFloat(TargetPoint.Y);
+    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,
+       sprAmGirder, Gear^.State, true, false) then
+    begin
+        PlaySound(sndDenied);
+        HHGear^.Message := HHGear^.Message and not gmAttack;
+        HHGear^.State := HHGear^.State and not gstAttacking;
+        HHGear^.State := HHGear^.State or gstHHChooseTarget;
+        isCursorVisible := true;
+        DeleteGear(Gear)
+    end
+    else 
+    begin
+        PlaySound(sndPlaced);
+        DeleteGear(Gear);
+        AfterAttack;
+    end;
+
+    HHGear^.State := HHGear^.State and not (gstAttacking or gstAttacked);
+    HHGear^.Message := HHGear^.Message and not gmAttack;
+    TargetPoint.X := NoPointX
+end;
+
 procedure doStepStructure(Gear: PGear);
 var 
     i, x, y: LongInt;