fixed unlimeted fuel bug for rcplane
authorHenek
Sun, 30 Jan 2011 19:05:31 +0100
changeset 4886 e3e5362a308e
parent 4884 b2006a9f0fbc
child 4887 39f300fdbc64
fixed unlimeted fuel bug for rcplane also added solid flag for tryplaceonland function
hedgewars/GSHandlers.inc
hedgewars/uLandGraphics.pas
--- 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;
--- a/hedgewars/uLandGraphics.pas	Sun Jan 30 06:56:12 2011 +0100
+++ b/hedgewars/uLandGraphics.pas	Sun Jan 30 19:05:31 2011 +0100
@@ -38,7 +38,7 @@
 procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean);
 function  LandBackPixel(x, y: LongInt): LongWord;
 
-function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
+function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; indestructible: boolean): boolean;
 
 implementation
 uses SDLh, uLandTexture, uVariables, uUtils, uDebug;
@@ -619,7 +619,7 @@
 UpdateLandTexture(tx, ddx, ty, ddy)
 end;
 
-function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
+function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean; indestructible: boolean): boolean;
 var X, Y, bpp, h, w, row, col, numFramesFirstCol: LongInt;
     p: PByteArray;
     Image: PSDL_Surface;
@@ -675,7 +675,10 @@
             for x:= 0 to Pred(w) do
                 if PLongword(@(p^[x * 4]))^ <> 0 then
                    begin
-                   Land[cpY + y, cpX + x]:= lfObject;
+                   if indestructible then
+                       Land[cpY + y, cpX + x]:= lfIndestructible
+                   else
+                       Land[cpY + y, cpX + x]:= lfObject;
                    if (cReducedQuality and rqBlurryLand) = 0 then
                        LandPixels[cpY + y, cpX + x]:= PLongword(@(p^[x * 4]))^
                    else