Avoid hog repeating himself
authornemo
Thu, 15 Sep 2011 18:54:16 -0400
changeset 5921 43cb3139cebe
parent 5920 32c0c0d37b6a
child 5922 7e7774e7be8c
Avoid hog repeating himself
hedgewars/uSound.pas
--- 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;