# HG changeset patch # User Wuzzy # Date 1562816683 -7200 # Node ID b9686895651436962848dbe74f34cdcd5985571c # Parent 1dd99fc2a0e8ca2424a495904834d0fc397f7db5 Air attack: Fix some issues with sound channel diff -r 1dd99fc2a0e8 -r b96868956514 hedgewars/uGearsHandlersMess.pas --- a/hedgewars/uGearsHandlersMess.pas Thu Jul 11 05:07:55 2019 +0200 +++ b/hedgewars/uGearsHandlersMess.pas Thu Jul 11 05:44:43 2019 +0200 @@ -3095,19 +3095,29 @@ Gear^.dX := Gear^.dX + int2hwFloat(Gear^.Damage * Gear^.Tag); if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then FollowGear^.State:= FollowGear^.State or gstSubmersible; - StopSoundChan(Gear^.SoundChannel, 4000); - end; - + if (Gear^.SoundChannel <> -1) then + begin + StopSoundChan(Gear^.SoundChannel, 4000); + Gear^.SoundChannel := -1; + end; + end; + + // Particles if (GameTicks and $3F) = 0 then if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtBubble) else AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace); + // Get rid of gear and cleanup if (hwRound(Gear^.X) > (max(LAND_WIDTH,4096)+2048)) or (hwRound(Gear^.X) < -2048) or ((Gear^.Message and gmDestroy) > 0) then begin - // avoid to play forever (is this necessary?) - StopSoundChan(Gear^.SoundChannel); + // fail-safe: instanly stop sound if it wasn't disabled before + if (Gear^.SoundChannel <> -1) then + begin + StopSoundChan(Gear^.SoundChannel); + Gear^.SoundChannel := -1; + end; DeleteGear(Gear) end end;