# HG changeset patch
# User Wuzzy <almikes@aol.com>
# Date 1507164857 -7200
# Node ID 5e115ed19e27bffa353d415b36b005813c48182c
# Parent  eaf719616c7ba5de5e107841bf71bcd1d8f88a6b
Destroy rope when attempting to shoot it through wrap / bouncy world edge

This fixes a variety of graphical glitches

diff -r eaf719616c7b -r 5e115ed19e27 ChangeLog.txt
--- a/ChangeLog.txt	Thu Oct 05 02:02:28 2017 +0200
+++ b/ChangeLog.txt	Thu Oct 05 02:54:17 2017 +0200
@@ -35,6 +35,7 @@
  * Fixed screenshots being too bright if taken in quick succession
  * Video recording functionality is restored
  * Fixed bee not being affected by wrap world edge while still being thrown
+ * Rope is now destroyed when attempting to shoot it through wrap or bouncy world edge
  * Fixed turn not ending when sticky mine was trapped on rubberband
  * Fixed sniper rifle disabling laser sight utility after using
  * Fixed hedgehog-voices missing a response type (Justyouwait/"You're gonna pay for that") on some platforms (e.g. Linux)
diff -r eaf719616c7b -r 5e115ed19e27 hedgewars/uGearsHandlersRope.pas
--- a/hedgewars/uGearsHandlersRope.pas	Thu Oct 05 02:02:28 2017 +0200
+++ b/hedgewars/uGearsHandlersRope.pas	Thu Oct 05 02:54:17 2017 +0200
@@ -441,6 +441,17 @@
         end
     else if not CurrentTeam^.ExtDriven and (FollowGear <> nil) then FollowGear := HHGear;
 
+    // Destroy rope if it touched bouncy or world wrap world edge.
+    // TODO: Allow to shoot rope through the world wrap edge and rope normally.
+    if (WorldWrap(Gear) and (WorldEdge = weWrap)) or
+       ((WorldEdge = weBounce) and ((hwRound(Gear^.X) <= LeftX) or (hwRound(Gear^.X) >= RightX))) then
+        begin
+        HHGear^.State := HHGear^.State and (not (gstAttacking or gstHHJumping or gstHHHJump));
+        HHGear^.Message := HHGear^.Message and (not gmAttack);
+        DeleteGear(Gear);
+        exit()
+        end;
+
     DeleteCI(HHGear);
 
     if (HHGear^.State and gstMoving) <> 0 then