fix Issue #724: Bee sound never stops (underwater when timer is 0)
authorsheepluva
Sun, 08 Dec 2013 17:58:45 +0100
changeset 9766 62c49992b049
parent 9765 6cad4393a315
child 9767 17df4c8201f6
fix issue #724: Bee sound never stops (underwater when timer is 0) also: instead of flowers add bubbles while underwater
hedgewars/uGearsHandlersMess.pas
--- a/hedgewars/uGearsHandlersMess.pas	Sun Dec 08 12:19:30 2013 +0100
+++ b/hedgewars/uGearsHandlersMess.pas	Sun Dec 08 17:58:45 2013 +0100
@@ -972,13 +972,24 @@
 
 
     if Gear^.Timer = 0 then
-        Gear^.RenderTimer:= false
+        begin
+        // no "fuel"? just fall
+        doStepFallingGear(Gear);
+        // if drowning, stop bee sound
+        if (Gear^.State and gstDrowning) <> 0 then
+            StopSoundChan(Gear^.SoundChannel);
+        end
     else
         begin
         if (GameTicks and $F) = 0 then
             begin
             if (GameTicks and $30) = 0 then
-                AddVisualGear(gX, gY, vgtBeeTrace);
+                begin
+                if nuw then
+                    AddVisualGear(gX, gY, vgtBubble)
+                else
+                    AddVisualGear(gX, gY, vgtBeeTrace);
+                end;
             Gear^.dX := Gear^.Elasticity * (Gear^.dX + _0_000064 * (Gear^.Target.X - gX));
             Gear^.dY := Gear^.Elasticity * (Gear^.dY + _0_000064 * (Gear^.Target.Y - gY));
             // make sure new speed isn't higher than original one (which we stored in Friction variable)
@@ -1019,17 +1030,15 @@
     end;
 
     if (Gear^.Timer > 0) then
-        dec(Gear^.Timer)
-    else
-        begin
-        Gear^.State:= Gear^.State and not gstSubmersible;
-        if nuw then
-           begin
-            StopSoundChan(Gear^.SoundChannel);
-            CheckGearDrowning(Gear);
-            end
-        else
-            doStepFallingGear(Gear);
+        begin
+        dec(Gear^.Timer);
+        if Gear^.Timer = 0 then
+            begin
+            // no need to display remaining time anymore
+            Gear^.RenderTimer:= false;
+            // bee can drown when timer reached 0
+            Gear^.State:= Gear^.State and not gstSubmersible;
+            end;
         end;
 end;