hedgewars/uGearsHandlersMess.pas
changeset 12748 f45ffb4cf1e1
parent 12742 d08afea02908
child 12749 058a5d373e4a
--- a/hedgewars/uGearsHandlersMess.pas	Mon Oct 23 14:49:01 2017 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Mon Oct 23 17:29:56 2017 +0200
@@ -3417,7 +3417,12 @@
             with hogs.ar^[i]^ do
                 if (hogs.ar^[i] <> CurrentHedgehog^.Gear) and (Hedgehog^.Effects[heFrozen] = 0)  then
                     begin
-                    dX:= _50 * cGravity * (Gear^.X - X) / _25;
+                    if (WorldEdge <> weWrap) or (not (hwAbs(Gear^.X - X) > int2hwFloat(Gear^.Radius))) then
+                        dX:= _50 * cGravity * (Gear^.X - X) / _25
+                    else if (not (hwAbs(Gear^.X + int2hwFloat(RightX-LeftX) - X) > int2hwFloat(Gear^.Radius))) then
+                        dX:= _50 * cGravity * ((Gear^.X + int2hwFloat(RightX-LeftX)) - X) / _25
+                    else
+                        dX:= _50 * cGravity * ((Gear^.X - int2hwFloat(RightX-LeftX)) - X) / _25;
                     dY:= -_450 * cGravity;
                     Active:= true;
                     end