hedgewars/uGearsHandlersMess.pas
changeset 10652 4456836514ed
parent 10650 7f23971bd9db
child 10657 f2507005be87
--- a/hedgewars/uGearsHandlersMess.pas	Thu Dec 11 01:39:29 2014 +0100
+++ b/hedgewars/uGearsHandlersMess.pas	Thu Dec 11 09:50:31 2014 +0100
@@ -4618,6 +4618,20 @@
         x := hwRound(Gear^.X);
         y := hwRound(Gear^.Y);
 
+        if WorldEdge = weWrap then
+            begin
+            if x > LongInt(rightX) then
+                repeat;
+                dec(x,  playWidth);
+                dec(rx, playWidth);
+                until x <= LongInt(rightX)
+            else if x < LongInt(leftX) then
+                repeat;
+                inc(x,  playWidth);
+                inc(rx, playWidth);
+                until x >= LongInt(leftX);
+            end;
+
         // if borders are on, stop outside land array
         if hasBorder and (((x and LAND_WIDTH_MASK) <> 0) or ((y and LAND_HEIGHT_MASK) <> 0)) then
             begin