hedgewars/uSound.pas
changeset 5921 43cb3139cebe
parent 5673 85336f377479
child 5922 7e7774e7be8c
--- a/hedgewars/uSound.pas	Fri Sep 16 00:32:53 2011 +0200
+++ b/hedgewars/uSound.pas	Thu Sep 15 18:54:16 2011 -0400
@@ -290,10 +290,12 @@
 procedure AddVoice(snd: TSound; voicepack: PVoicepack);
 var i : LongInt;
 begin
-    if (not isSoundEnabled) or fastUntilLag then exit;
+    if (not isSoundEnabled) or fastUntilLag or ((LastSound.snd = snd) and  (LastSound.voicepack = voicepack)) then exit;
     i:= 0;
     while (i<8) and (VoiceList[i].snd <> sndNone) do inc(i);
 
+    // skip playing same sound for same hog twice
+    if (i>0) and (VoiceList[i-1].snd = snd) and (VoiceList[i-1].voicepack = voicepack) then exit;
     VoiceList[i].snd:= snd;
     VoiceList[i].voicepack:= voicepack;
 end;