]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Add cvar snd_cdautopause: optional CD track pause during game pause
authorbones_was_here <bones_was_here@xa.org.au>
Fri, 18 Mar 2022 07:28:57 +0000 (17:28 +1000)
committerbones_was_here <bones_was_here@xa.org.au>
Mon, 21 Mar 2022 22:22:39 +0000 (08:22 +1000)
Previously it was mandatory and if not desired, had to be hacked around
with stuffcmd.

Also fixes:
- the CD track always being resumed when resuming from game pause,
even when muted, Ref: CDAudio_SetVolume()
- bgmvolume < 0 not pausing the CD track

Signed-off-by: bones_was_here <bones_was_here@xa.org.au>
cd_shared.c
cl_parse.c

index 0f2f6fd1bd513d70566d09f15f071ce4db11b7da..88551e0a43ee6fa7d16844dd7ae3e13f3d0c30ba 100644 (file)
@@ -417,12 +417,12 @@ static void CDAudio_SetVolume (float newvol)
                return;
 
        // If the CD has been muted
-       if (newvol == 0.0f)
+       if (newvol <= 0.0f)
                CDAudio_Pause ();
        else
        {
                // If the CD has been unmuted
-               if (cdvolume == 0.0f)
+               if (cdvolume <= 0.0f)
                        CDAudio_Resume ();
 
                if (faketrack != -1)
index ecd250fc56da0f21100b204b00e5ff74cc9a1232..1afbcbe7fd83cc51e0c8d12df82e71e91285cbb9 100644 (file)
@@ -184,6 +184,8 @@ cvar_t cl_readpicture_force = {CF_CLIENT, "cl_readpicture_force", "0", "when ena
 #define RIC_GUNSHOTQUAD        2
 cvar_t cl_sound_ric_gunshot = {CF_CLIENT, "cl_sound_ric_gunshot", "0", "specifies if and when the related cl_sound_ric and cl_sound_tink sounds apply to TE_GUNSHOT/TE_GUNSHOTQUAD, 0 = no sound, 1 = TE_GUNSHOT, 2 = TE_GUNSHOTQUAD, 3 = TE_GUNSHOT and TE_GUNSHOTQUAD"};
 cvar_t cl_sound_r_exp3 = {CF_CLIENT, "cl_sound_r_exp3", "weapons/r_exp3.wav", "sound to play during TE_EXPLOSION and related effects (empty cvar disables sound)"};
+cvar_t snd_cdautopause = {CF_CLIENT | CF_ARCHIVE, "snd_cdautopause", "1", "pause the CD track while the game is paused"};
+
 cvar_t cl_serverextension_download = {CF_CLIENT, "cl_serverextension_download", "0", "indicates whether the server supports the download command"};
 cvar_t cl_joinbeforedownloadsfinish = {CF_CLIENT | CF_ARCHIVE, "cl_joinbeforedownloadsfinish", "1", "if non-zero the game will begin after the map is loaded before other downloads finish"};
 cvar_t cl_nettimesyncfactor = {CF_CLIENT | CF_ARCHIVE, "cl_nettimesyncfactor", "0", "rate at which client time adapts to match server time, 1 = instantly, 0.125 = slowly, 0 = not at all (only applied in bound modes 0, 1, 2, 3)"};
@@ -3793,9 +3795,9 @@ void CL_ParseServerMessage(void)
 
                        case qw_svc_setpause:
                                cl.paused = MSG_ReadByte(&cl_message) != 0;
-                               if (cl.paused)
+                               if (cl.paused && snd_cdautopause.integer)
                                        CDAudio_Pause ();
-                               else
+                               else if (bgmvolume.value > 0.0f)
                                        CDAudio_Resume ();
                                S_PauseGameSounds (cl.paused);
                                break;
@@ -4120,9 +4122,9 @@ void CL_ParseServerMessage(void)
 
                        case svc_setpause:
                                cl.paused = MSG_ReadByte(&cl_message) != 0;
-                               if (cl.paused)
+                               if (cl.paused && snd_cdautopause.integer)
                                        CDAudio_Pause ();
-                               else
+                               else if (bgmvolume.value > 0.0f)
                                        CDAudio_Resume ();
                                S_PauseGameSounds (cl.paused);
                                break;
@@ -4324,6 +4326,7 @@ void CL_Parse_Init(void)
        Cvar_RegisterVariable(&cl_sound_ric3);
        Cvar_RegisterVariable(&cl_sound_ric_gunshot);
        Cvar_RegisterVariable(&cl_sound_r_exp3);
+       Cvar_RegisterVariable(&snd_cdautopause);
 
        Cvar_RegisterVariable(&cl_joinbeforedownloadsfinish);