Air attack: Fix infintie sound when target is at extreme X pos
authorWuzzy <Wuzzy2@mail.ru>
Thu, 11 Jul 2019 20:23:42 +0200
changeset 15235 66dcb7728e01
parent 15234 186c3f272187
child 15236 afda6c9711cf
Air attack: Fix infintie sound when target is at extreme X pos
hedgewars/uGearsHandlersMess.pas
--- a/hedgewars/uGearsHandlersMess.pas	Thu Jul 11 19:58:35 2019 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Thu Jul 11 20:23:42 2019 +0200
@@ -3108,16 +3108,17 @@
 
         if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then
             FollowGear^.State:= FollowGear^.State or gstSubmersible;
-        if (Gear^.SoundChannel <> -1) and (WorldEdge <> weSea) then
-            begin
-            StopSoundChan(Gear^.SoundChannel, 4000);
-            Gear^.SoundChannel := -1;
-            end;
         end;
 
     if (Gear^.Health = 0) then
         inc(Gear^.FlightTime);
 
+    if (Gear^.SoundChannel <> -1) and (WorldEdge <> weSea) and (Gear^.FlightTime > 20) then
+        begin
+        StopSoundChan(Gear^.SoundChannel, 4000);
+        Gear^.SoundChannel := -1;
+        end;
+
     // Particles
     if (GameTicks and $3F) = 0 then
         if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then
@@ -3127,7 +3128,7 @@
 
     // Get rid of gear and cleanup
     if ((WorldEdge = weWrap) and (Gear^.FlightTime >= 4000)) or
-        ((WorldEdge <> weWrap) and (((hwRound(Gear^.X) - Gear^.Radius > (max(LAND_WIDTH,4096)+2048)) or (hwRound(Gear^.X) + Gear^.Radius < -2048) or ((Gear^.Message and gmDestroy) > 0))) then
+        ((WorldEdge <> weWrap) and (((hwRound(Gear^.X) - Gear^.Radius > (max(LAND_WIDTH,4096)+2048)) or (hwRound(Gear^.X) + Gear^.Radius < -2048) or ((Gear^.Message and gmDestroy) > 0)))) then
         begin
         // fail-safe: instanly stop sound if it wasn't disabled before
         if (Gear^.SoundChannel <> -1) then