Skip to content

Commit

Permalink
Silence looping sounds while the game is paused
Browse files Browse the repository at this point in the history
snd_pauselooping 0 to disable
  • Loading branch information
temx committed Feb 2, 2023
1 parent acf529d commit 9557033
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Quake/snd_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ cvar_t snd_mixspeed = {"snd_mixspeed", "44100", CVAR_NONE};

cvar_t snd_waterfx = {"snd_waterfx", "1", CVAR_ARCHIVE};

cvar_t snd_pauselooping = {"snd_pauselooping", "1", CVAR_ARCHIVE};

#if defined(_WIN32)
#define SND_FILTERQUALITY_DEFAULT "5"
#else
Expand Down Expand Up @@ -182,6 +184,7 @@ void S_Init (void)
Cvar_RegisterVariable (&snd_mixspeed);
Cvar_RegisterVariable (&snd_filterquality);
Cvar_RegisterVariable (&snd_waterfx);
Cvar_RegisterVariable (&snd_pauselooping);

if (safemode || COM_CheckParm ("-nosound"))
return;
Expand Down
5 changes: 5 additions & 0 deletions Quake/snd_mix.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,15 @@ CHANNEL MIXING
static void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int endtime, int paintbufferstart);
static void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime, int paintbufferstart);

extern cvar_t snd_pauselooping;

void S_PaintChannels (int endtime)
{
int i;
int end, ltime, count;
channel_t *ch;
sfxcache_t *sc;
qboolean pause_loops = snd_pauselooping.value && (cl.paused || (sv.active && svs.maxclients == 1 && key_dest != key_game));

snd_vol = sfxvolume.value * 256;

Expand All @@ -426,6 +429,8 @@ void S_PaintChannels (int endtime)
sc = S_LoadSound (ch->sfx);
if (!sc)
continue;
if (sc->loopstart >= 0 && pause_loops)
continue;

ltime = paintedtime;

Expand Down

0 comments on commit 9557033

Please sign in to comment.