--- a/hedgewars/GSHandlers.inc Sun Jan 30 21:33:08 2011 +0300
+++ b/hedgewars/GSHandlers.inc Sun Jan 30 21:33:39 2011 +0300
@@ -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 21:33:08 2011 +0300
+++ b/hedgewars/uLandGraphics.pas Sun Jan 30 21:33:39 2011 +0300
@@ -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