# HG changeset patch
# User Wuzzy <Wuzzy2@mail.ru>
# Date 1531776435 -7200
# Node ID 1c45ce3ff296bff76344551d9d0cafa0d05332f8
# Parent  9f05872969dcde1d5de635f9f09900659b08bd30
Add variable to make state of sound system clear

diff -r 9f05872969dc -r 1c45ce3ff296 hedgewars/uGame.pas
--- a/hedgewars/uGame.pas	Tue Jul 17 12:55:07 2018 +0200
+++ b/hedgewars/uGame.pas	Mon Jul 16 23:27:15 2018 +0200
@@ -86,7 +86,7 @@
         begin
         j:= Volume;
         i:= ChangeVolume(cVolumeDelta);
-        if isAudioMuted and (j<>i) then
+        if (not cIsSoundEnabled) or (isAudioMuted and (j<>i)) then
             AddCaption(trmsg[sidMute], cWhiteColor, capgrpVolume)
         else if not isAudioMuted then
             begin
diff -r 9f05872969dc -r 1c45ce3ff296 hedgewars/uSound.pas
--- a/hedgewars/uSound.pas	Tue Jul 17 12:55:07 2018 +0200
+++ b/hedgewars/uSound.pas	Mon Jul 16 23:27:15 2018 +0200
@@ -339,7 +339,11 @@
 var success: boolean;
 begin
     if not (isSoundEnabled or isMusicEnabled) then
+        begin
+        isAudioMuted:= true;
+        cInitVolume:= 0;
         exit;
+        end;
     WriteToConsole('Init sound...');
     success:= SDL_InitSubSystem(SDL_INIT_AUDIO) = 0;
 
@@ -357,12 +361,17 @@
         WriteLnToConsole(msgFailed);
         isSoundEnabled:= false;
         isMusicEnabled:= false;
+        isAudioMuted:= true;
+        cInitVolume:= 0;
     end;
 
     WriteToConsole('Init SDL_mixer... ');
     if SDLCheck(Mix_Init(MIX_INIT_OGG) <> 0, 'Mix_Init', true) then exit;
     WriteLnToConsole(msgOK);
 
+    // from uVariables to be used by other modules
+    cIsSoundEnabled:= true;
+
     Mix_AllocateChannels(Succ(chanTPU));
     previousVolume:= cInitVolume;
     ChangeVolume(cInitVolume);
diff -r 9f05872969dc -r 1c45ce3ff296 hedgewars/uVariables.pas
--- a/hedgewars/uVariables.pas	Tue Jul 17 12:55:07 2018 +0200
+++ b/hedgewars/uVariables.pas	Mon Jul 16 23:27:15 2018 +0200
@@ -166,6 +166,7 @@
     cScriptName     : shortstring;
     cScriptParam    : shortstring;
     cSeed           : shortstring;
+    cIsSoundEnabled : boolean; // If the sound system is enabled
     cVolumeDelta    : LongInt;
     cMuteToggle     : boolean; // Mute toggle requested
     cHasFocus       : boolean;
@@ -2845,6 +2846,7 @@
     fastScrolling   := false;
     autoCameraOn    := true;
     cSeed           := '';
+    cIsSoundEnabled := false;
     cVolumeDelta    := 0;
     cMuteToggle     := false;
     cHasFocus       := true;