hedgewars/uSound.pas
changeset 1669 b709e061577e
parent 1657 dde8f60d3e07
child 1712 f5b916de40f0
--- a/hedgewars/uSound.pas	Tue Jan 13 22:38:08 2009 +0000
+++ b/hedgewars/uSound.pas	Wed Jan 14 16:36:16 2009 +0000
@@ -30,13 +30,12 @@
 procedure InitSound;
 procedure ReleaseSound;
 procedure SoundLoad;
-procedure PlaySound(snd: TSound; infinite: boolean);
+procedure PlaySound(snd: TSound; infinite: boolean; voicepack: PVoicepack);
 procedure PlayMusic;
 procedure StopSound(snd: TSound);
 function  ChangeVolume(voldelta: LongInt): LongInt;
 
 function  AskForVoicepack(name: shortstring): Pointer;
-procedure SetVoicePack(vp: PVoicePack);
 
 var MusicFN: shortstring = '';
 
@@ -49,7 +48,6 @@
 	lastChan: array [TSound] of LongInt;
 	voicepacks: array[0..cMaxTeams] of TVoicepack;
 	defVoicepack: PVoicepack;
-	currentVP: PVoicepack;
 
 function  AskForVoicepack(name: shortstring): Pointer;
 var i: Longword;
@@ -65,11 +63,6 @@
 AskForVoicepack:= @voicepacks[i]
 end;
 
-procedure SetVoicePack(vp: PVoicePack);
-begin
-currentVP:= vp
-end;
-
 procedure InitSound;
 begin
 if not isSoundEnabled then exit;
@@ -109,7 +102,6 @@
 if not isSoundEnabled then exit;
 
 defVoicepack:= AskForVoicepack('Default');
-SetVoicePack(defVoicepack);
 
 for i:= Low(TSound) to High(TSound) do
 	if Soundz[i].Path <> ptVoices then
@@ -136,14 +128,14 @@
 				end;
 end;
 
-procedure PlaySound(snd: TSound; infinite: boolean);
+procedure PlaySound(snd: TSound; infinite: boolean; voicepack: PVoicepack);
 var loops: LongInt;
 begin
 if (not isSoundEnabled) or fastUntilLag then exit;
 if infinite then loops:= -1 else loops:= 0;
 
-if currentVP^.chunks[snd] <> nil then
-	lastChan[snd]:= Mix_PlayChannelTimed(-1, currentVP^.chunks[snd], loops, -1)
+if (voicepack <> nil) and (voicepack^.chunks[snd] <> nil) then
+	lastChan[snd]:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], loops, -1)
 else
 	lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], loops, -1)
 end;