Engine:
authorsmxx
Sat, 20 Feb 2010 19:54:24 +0000
changeset 2832 8cb73c0e77a1
parent 2831 797207d0c500
child 2833 9c2accd92cc7
Engine: * Fix LoopSound returning an undefined value if sound isn't played/started
hedgewars/uSound.pas
--- a/hedgewars/uSound.pas	Sat Feb 20 18:58:51 2010 +0000
+++ b/hedgewars/uSound.pas	Sat Feb 20 19:54:24 2010 +0000
@@ -177,7 +177,11 @@
 
 function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt;
 begin
-if (not isSoundEnabled) or fastUntilLag then exit;
+if (not isSoundEnabled) or fastUntilLag then
+	begin
+	LoopSound:= -1;
+	exit
+	end;
 
 if (voicepack <> nil) and (voicepack^.chunks[snd] <> nil) then
 	LoopSound:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], -1, -1)
@@ -197,7 +201,8 @@
 
 procedure StopSound(chn: LongInt);
 begin
-	if (chn <> -1) and (Mix_Playing(chn) <> 0) then Mix_HaltChannel(chn);
+if not isSoundEnabled then exit;
+if (chn <> -1) and (Mix_Playing(chn) <> 0) then Mix_HaltChannel(chn);
 end;
 
 procedure PlayMusic;