wrap sinegun
authorsheepluva
Thu, 11 Dec 2014 09:50:31 +0100
changeset 10652 4456836514ed
parent 10651 7a8e321be3bd
child 10653 ae9ad7735690
wrap sinegun
hedgewars/uGearsHandlersMess.pas
--- 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