Make flames collide with bounce world edge again, properly this time
authorWuzzy <Wuzzy2@mail.ru>
Thu, 11 Jul 2019 02:25:07 +0200
changeset 15225 ebbc2f04b863
parent 15224 f16376e9374f
child 15226 eb61cf77b365
Make flames collide with bounce world edge again, properly this time
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsList.pas
--- a/hedgewars/uGearsHandlersMess.pas	Thu Jul 11 00:53:29 2019 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Thu Jul 11 02:25:07 2019 +0200
@@ -2711,9 +2711,7 @@
     tdX,tdY, f: HWFloat;
     landPixel: Word;
 begin
-    // don't bounce
-    if WorldEdge <> weBounce then
-        WorldWrap(Gear);
+    WorldWrap(Gear);
     if Gear^.FlightTime > 0 then dec(Gear^.FlightTime);
     // There are 2 flame types: normal and sticky
     sticky:= (Gear^.State and gsttmpFlag) <> 0;
@@ -2773,7 +2771,18 @@
             if Gear^.dY.QWordValue > _0_2.QWordValue then
                 Gear^.dY := Gear^.dY * _0_995;
 
-            Gear^.X := Gear^.X + Gear^.dX + cWindSpeed * 640;
+            // Apply speed changes
+
+            tdX:= Gear^.dX + cWindSpeed * 640;
+            // Don't apply wind speed if moving against bounce world edge
+            if (WorldEdge = weBounce) and
+                (((hwRound(Gear^.X + tdX) - Gear^.Radius < leftX) and (hwSign(tdX) = -1)) or
+                ((hwRound(Gear^.X + tdX) + Gear^.Radius > rightX) and (hwSign(tdX) = 1))) then
+                    Gear^.X := Gear^.X + Gear^.dX
+            else
+                // Apply dX and wind speed
+                Gear^.X := Gear^.X + tdX;
+
             Gear^.Y := Gear^.Y + Gear^.dY;
         end;
 
--- a/hedgewars/uGearsList.pas	Thu Jul 11 00:53:29 2019 +0200
+++ b/hedgewars/uGearsList.pas	Thu Jul 11 02:25:07 2019 +0200
@@ -225,6 +225,7 @@
         case gear^.Kind of
             // list all gears here that could collide with the bounce world edge
             gtHedgehog,
+            gtFlame,
             gtMine,
             gtAirBomb,
             gtDrill,