hedgewars/uGearsHandlersMess.pas
changeset 9505 56e0cca99e20
parent 9487 fbe203c1d11e
child 9521 8054d9d775fd
child 9526 2fd51591b260
--- 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);