don't stack bye/teleport sounds of hogs (when a team is gone) 0.9.20
authorsheepluva
Wed, 05 Mar 2014 12:35:51 +0100
branch0.9.20
changeset 9930 c38cdb5dd37c
parent 9928 fe4b1ce9b6f8
child 9932 99572fea028e
don't stack bye/teleport sounds of hogs (when a team is gone)
hedgewars/uGearsHedgehog.pas
--- a/hedgewars/uGearsHedgehog.pas	Tue Jan 07 11:40:58 2014 +0100
+++ b/hedgewars/uGearsHedgehog.pas	Wed Mar 05 12:35:51 2014 +0100
@@ -607,6 +607,7 @@
 procedure doStepHedgehogGone(Gear: PGear);
 const frametime = 65;
       timertime = frametime * 11;
+var i: LongInt;
 begin
 if Gear^.Hedgehog^.Unplaced then
     exit;
@@ -629,8 +630,20 @@
     Gear^.Z:= cCurrHHZ;
     RemoveGearFromList(Gear);
     InsertGearToList(Gear);
-    PlaySoundV(sndByeBye, Gear^.Hedgehog^.Team^.voicepack);
-    PlaySound(sndWarp);
+    // only play sound for one alive hedgehog
+    with Gear^.Hedgehog^.Team^ do
+        for i:= 0 to cMaxHHIndex do
+            begin
+            if (Hedgehogs[i].Gear <> nil) then
+                begin
+                if (Hedgehogs[i].Gear = Gear) then
+                    begin
+                    PlaySoundV(sndByeBye, Gear^.Hedgehog^.Team^.voicepack);
+                    PlaySound(sndWarp);
+                    end;
+                break;
+                end;
+            end;
     Gear^.Pos:= 0;
     Gear^.Timer:= timertime
     end