hedgewars/uGearsHandlersRope.pas
changeset 9526 2fd51591b260
parent 9473 a51a69094c24
child 9571 273567816538
--- a/hedgewars/uGearsHandlersRope.pas	Fri Oct 11 13:06:04 2013 -0400
+++ b/hedgewars/uGearsHandlersRope.pas	Sun Oct 13 13:14:32 2013 -0400
@@ -31,9 +31,17 @@
 procedure doStepRopeAfterAttack(Gear: PGear);
 var 
     HHGear: PGear;
+    tX:     hwFloat;
 begin
     HHGear := Gear^.Hedgehog^.Gear;
-    WorldWrap(HHGear);
+    tX:= HHGear^.X;
+    if WorldWrap(HHGear) and (WorldEdge = weWrap) and 
+       (TestCollisionXwithGear(HHGear, 1) or TestCollisionXwithGear(HHGear, -1))  then
+        begin
+        HHGear^.X:= tX;
+        HHGear^.dX.isNegative:= (hwRound(tX) > leftX+HHGear^.Radius*2)
+        end;
+
     if (HHGear^.Hedgehog^.CurAmmoType = amParachute) and (HHGear^.dY > _0_39) then
         begin
         DeleteGear(Gear);
@@ -117,8 +125,20 @@
 
     HHGear := Gear^.Hedgehog^.Gear;
 
-    if ((HHGear^.State and gstHHDriven) = 0) or WorldWrap(HHGear)
-       or (CheckGearDrowning(HHGear)) or (Gear^.PortalCounter <> 0) then
+    tX:= HHGear^.X;
+    if WorldWrap(HHGear) and (WorldEdge = weWrap) and 
+       (TestCollisionXwithGear(HHGear, 1) or TestCollisionXwithGear(HHGear, -1))  then
+        begin
+        PlaySound(sndRopeRelease);
+        RopeDeleteMe(Gear, HHGear);
+        HHGear^.X:= tX;
+        HHGear^.dX.isNegative:= (hwRound(tX) > leftX+HHGear^.Radius*2);
+        exit
+        end;
+
+    tX:= HHGear^.X;
+    if ((HHGear^.State and gstHHDriven) = 0) or
+        (CheckGearDrowning(HHGear)) or (Gear^.PortalCounter <> 0) then
         begin
         PlaySound(sndRopeRelease);
         RopeDeleteMe(Gear, HHGear);