Properly stop freezeray at bounce edge (instead of restarting the ray over and over again)
authorWuzzy <Wuzzy2@mail.ru>
Mon, 14 Jan 2019 02:48:36 +0100
changeset 14591 0da43a3d5500
parent 14590 0149d5ed5dc5
child 14592 1d3dc553829c
Properly stop freezeray at bounce edge (instead of restarting the ray over and over again)
hedgewars/uGearsHandlersMess.pas
--- a/hedgewars/uGearsHandlersMess.pas	Sun Jan 13 22:22:40 2019 +0100
+++ b/hedgewars/uGearsHandlersMess.pas	Mon Jan 14 02:48:36 2019 +0100
@@ -6449,9 +6449,10 @@
         exit
         end;
     updateFuel(Gear);
-    if WorldWrap(Gear) and (WorldEdge = weWrap) and (Gear^.Target.X = NoPointX) then
-        // Use FlightTime to count number of times the gear has world-wrapped
-        inc(Gear^.FlightTime);
+    if (WorldEdge <> weBounce) then
+        if WorldWrap(Gear) and (WorldEdge = weWrap) and (Gear^.Target.X = NoPointX) then
+            // Use FlightTime to count number of times the gear has world-wrapped
+            inc(Gear^.FlightTime);
 
     with Gear^ do
         begin
@@ -6461,7 +6462,8 @@
         if (ndX <> dX) or (ndY <> dY) or (Gear^.Message and (gmUp or gmDown) <> 0) or
            (((Target.X <> NoPointX) and (Target.X and LAND_WIDTH_MASK = 0) and
              (Target.Y and LAND_HEIGHT_MASK = 0) and ((Land[Target.Y, Target.X] = 0)) and
-             (not CheckCoordInWater(Target.X, Target.Y))) and (CheckGearNear(gtAirMine, int2hwFloat(Target.X),int2hwFloat(Target.Y), Gear^.Radius*3, Gear^.Radius*3) = nil)) then
+             (not CheckCoordInWater(Target.X, Target.Y))) and (CheckGearNear(gtAirMine, int2hwFloat(Target.X),int2hwFloat(Target.Y), Gear^.Radius*3, Gear^.Radius*3) = nil) and
+             (not ((WorldEdge = weBounce) and ((Target.X > rightX) or (Target.X < leftX))))) then
             begin
             updateTarget(Gear, ndX, ndY);
             Timer := iceWaitCollision;
@@ -6665,6 +6667,13 @@
                 X:= HHGear^.X;
                 Y:= HHGear^.Y
                 end
+            else if (WorldEdge = weBounce) and ((gX > rightX) or (gX < leftX)) then
+                begin
+                Target.X:= gX;
+                Target.Y:= gY;
+                X:= HHGear^.X;
+                Y:= HHGear^.Y
+                end
             else
                 begin
                 iter:= CheckGearNear(Gear, gtAirMine, Gear^.Radius*2, Gear^.Radius*2);