Allow girder construction to wrap. Makes wrapping w/ large bodies of water a bit more interesting.
--- a/hedgewars/uGearsHandlersMess.pas Tue Oct 08 23:38:45 2013 +0400
+++ b/hedgewars/uGearsHandlersMess.pas Wed Oct 09 20:16:34 2013 -0400
@@ -2399,6 +2399,7 @@
var
HHGear: PGear;
x, y, tx, ty: hwFloat;
+ rx: LongInt;
begin
AllInactive := false;
@@ -2407,8 +2408,13 @@
ty := int2hwFloat(Gear^.Target.Y);
x := HHGear^.X;
y := HHGear^.Y;
-
- if (Distance(tx - x, ty - y) > _256)
+ rx:= hwRound(x);
+
+ if ((Distance(tx - x, ty - y) > _256) and ((WorldEdge <> weWrap) or
+ (
+ (Distance(tx - int2hwFloat(rightX+(rx-leftX)), ty - y) > _256) and
+ (Distance(tx - int2hwFloat(leftX-(rightX-rx)), ty - y) > _256)
+ )))
or (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);
--- a/hedgewars/uGearsRender.pas Tue Oct 08 23:38:45 2013 +0400
+++ b/hedgewars/uGearsRender.pas Wed Oct 09 20:16:34 2013 -0400
@@ -671,6 +671,25 @@
end;
amGirder: begin
DrawSpriteRotated(sprHandConstruction, hx, hy, sign, aangle);
+ if WorldEdge = weWrap then
+ begin
+ if hwRound(Gear^.X) < leftX+256 then
+ DrawSpriteClipped(sprGirder,
+ rightX+(ox-leftX)-256,
+ oy-256,
+ LongInt(topY)+WorldDy,
+ LongInt(rightX)+WorldDx,
+ cWaterLine+WorldDy,
+ LongInt(leftX)+WorldDx);
+ if hwRound(Gear^.X) > rightX-256 then
+ DrawSpriteClipped(sprGirder,
+ leftX-(rightX-ox)-256,
+ oy-256,
+ LongInt(topY)+WorldDy,
+ LongInt(rightX)+WorldDx,
+ cWaterLine+WorldDy,
+ LongInt(leftX)+WorldDx)
+ end;
DrawSpriteClipped(sprGirder,
ox-256,
oy-256,