# HG changeset patch
# User smxx
# Date 1266695664 0
# Node ID 8cb73c0e77a16377cb77ce9ad71d51add87dbeb3
# Parent  797207d0c5006e45cb132466aa47f15dd34bad98
Engine:
* Fix LoopSound returning an undefined value if sound isn't played/started

diff -r 797207d0c500 -r 8cb73c0e77a1 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;