Changed uSound.pas so that music will still play if music is enabled and sound is disabled. Effectively, isSoundEnabled represents only sound effects and does not include music (and I have replaced the places where both are concerned with a logical combination of the two). flibqtfrontend
authorMitchell Kember <mk12360@gmail.com>
Tue, 04 Dec 2012 17:57:18 -0500
branchflibqtfrontend
changeset 8251 81789b027dd7
parent 8248 34d1aceb31aa
child 8253 14c046a81e2b
Changed uSound.pas so that music will still play if music is enabled and sound is disabled. Effectively, isSoundEnabled represents only sound effects and does not include music (and I have replaced the places where both are concerned with a logical combination of the two). Still need to figure out why isSEBackup is used and if my changes affect it.
hedgewars/uSound.pas
--- a/hedgewars/uSound.pas	Tue Dec 04 16:53:47 2012 -0500
+++ b/hedgewars/uSound.pas	Tue Dec 04 17:57:18 2012 -0500
@@ -21,7 +21,7 @@
 unit uSound;
 (*
  * This unit controls the sounds and music of the game.
- * Doesn't really do anything if isSoundEnabled = false.
+ * Doesn't really do anything if isSoundEnabled = false and isMusicEnabled = false
  *
  * There are three basic types of sound controls:
  *    Music        - The background music of the game:
@@ -287,19 +287,24 @@
 
 procedure InitSound;
 const channels: LongInt = {$IFDEF MOBILE}1{$ELSE}2{$ENDIF};
+var success: boolean;
 begin
-    if not isSoundEnabled then
+    if not (isSoundEnabled or isMusicEnabled) then
         exit;
     WriteToConsole('Init sound...');
-    isSoundEnabled:= SDL_InitSubSystem(SDL_INIT_AUDIO) >= 0;
+    success:= SDL_InitSubSystem(SDL_INIT_AUDIO) >= 0;
 
-    if isSoundEnabled then
-        isSoundEnabled:= Mix_OpenAudio(44100, $8010, channels, 1024) = 0;
+    if success then
+        success:= Mix_OpenAudio(44100, $8010, channels, 1024) = 0;
 
-    if isSoundEnabled then
+    if success then
         WriteLnToConsole(msgOK)
     else
+    begin
         WriteLnToConsole(msgFailed);
+        isSoundEnabled:= false;
+        isMusicEnabled:= false;
+    end;
 
     WriteToConsole('Init SDL_mixer... ');
     SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true);
@@ -543,7 +548,7 @@
 procedure PlayMusic;
 var s: shortstring;
 begin
-    if (not isSoundEnabled) or (MusicFN = '') or (not isMusicEnabled) then
+    if (MusicFN = '') or (not isMusicEnabled) then
         exit;
 
     s:= '/Music/' + MusicFN;
@@ -564,7 +569,7 @@
 function ChangeVolume(voldelta: LongInt): LongInt;
 begin
     ChangeVolume:= 0;
-    if (not isSoundEnabled) or ((voldelta = 0) and (not (cInitVolume = 0))) then
+    if not (isSoundEnabled or isMusicEnabled) or ((voldelta = 0) and (not (cInitVolume = 0))) then
         exit;
 
     inc(Volume, voldelta);
@@ -604,7 +609,7 @@
 
 procedure MuteAudio;
 begin
-    if not isSoundEnabled then
+    if not (isSoundEnabled or isMusicEnabled) then
         exit;
 
     if (isAudioMuted) then
@@ -727,7 +732,7 @@
 
 procedure freeModule;
 begin
-    if isSoundEnabled then
+    if isSoundEnabled or isMusicEnabled then
         ReleaseSound(true);
 end;