From 9a17eb9ac3e6c8c7e1ac86eab8f7963493e5882f Mon Sep 17 00:00:00 2001 From: Yamagi Date: Sat, 30 Jan 2021 13:51:02 +0100 Subject: [PATCH] Make limiting power screen sounds to 16 optional. This was added in e3e5bd1 as a work around for some openal-soft bug. When too many audio samples got played at the same time, the global volume dropped. This was fixed in openal-soft 0.19.0, released more than two years ago. We're keeping the work around, because some distros may still ship with buggy openal-soft versions and some players may like the changed behavior. It's disabled by default. --- doc/040_cvarlist.md | 6 ++++++ src/client/cl_main.c | 2 ++ src/client/cl_tempentities.c | 39 +++++++++++++++++++++++------------- src/client/header/client.h | 1 + 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/doc/040_cvarlist.md b/doc/040_cvarlist.md index e5b44b47..d84a1c6d 100644 --- a/doc/040_cvarlist.md +++ b/doc/040_cvarlist.md @@ -75,6 +75,12 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable` If *cl_async* is set to `0` *vid_maxfps* is the same as *cl_maxfps*, use *cl_maxfps* to set the framerate. +* **cl_limitsparksounds**: If set to `1` the number of sound generated + when shooting into power screen and power shields is limited to 16. + This works around global volume drops in some OpenAL implementations + if too many sounds are played at the same time. This was the default + behavior between Yamagi Quake II 7.10 and 7.45. Defaults to `0`. + * **cl_loadpaused**: If set to `1` (the default) the client is put into pause mode during single player savegame load. This prevents monsters and the environment from hurting the player while the client is still diff --git a/src/client/cl_main.c b/src/client/cl_main.c index 78cd8ad8..0a53009b 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -59,6 +59,7 @@ cvar_t *cl_loadpaused; cvar_t *cl_lightlevel; cvar_t *cl_r1q2_lightstyle; +cvar_t *cl_limitsparksounds; /* userinfo */ cvar_t *name; @@ -526,6 +527,7 @@ CL_InitLocal(void) cl_lightlevel = Cvar_Get("r_lightlevel", "0", 0); cl_r1q2_lightstyle = Cvar_Get("cl_r1q2_lightstyle", "1", CVAR_ARCHIVE); + cl_limitsparksounds = Cvar_Get("cl_limitsparksounds", "0", CVAR_ARCHIVE); /* userinfo */ name = Cvar_Get("name", "unnamed", CVAR_USERINFO | CVAR_ARCHIVE); diff --git a/src/client/cl_tempentities.c b/src/client/cl_tempentities.c index 50680801..5dc8961d 100644 --- a/src/client/cl_tempentities.c +++ b/src/client/cl_tempentities.c @@ -714,21 +714,32 @@ CL_ParseTEnt(void) CL_ParticleEffect(pos, dir, 0xb0, 40); } - num_power_sounds++; - - /* If too many of these sounds are started in one frame (for - * example if the player shoots with the super shotgun into - * the power screen of a Brain) things get too loud and OpenAL - * is forced to scale the volume of several other sounds and - * the background music down. That leads to a noticable and - * annoying drop in the overall volume. - * - * Work around that by limiting the number of sounds started. - * 16 was choosen by empirical testing. - */ - if (sound_started == SS_OAL && num_power_sounds < 16) + if (cl_limitsparksounds->value) { - S_StartSound(pos, 0, 0, cl_sfx_lashit, 1, ATTN_NORM, 0); + num_power_sounds++; + + /* If too many of these sounds are started in one frame + * (for example if the player shoots with the super + * shotgun into the power screen of a Brain) things get + * too loud and OpenAL is forced to scale the volume of + * several other sounds and the background music down. + * That leads to a noticable and annoying drop in the + * overall volume. + * + * Work around that by limiting the number of sounds + * started. + * 16 was choosen by empirical testing. + * + * This was fixed in openal-soft 0.19.0. We're keeping + * the work around hidden behind a cvar and no longer + * limited to OpenAL because a) some Linux distros may + * still ship older openal-soft versions and b) some + * player may like the changed behavior. + */ + if (num_power_sounds < 16) + { + S_StartSound(pos, 0, 0, cl_sfx_lashit, 1, ATTN_NORM, 0); + } } break; diff --git a/src/client/header/client.h b/src/client/header/client.h index 91fbbf0b..04471802 100644 --- a/src/client/header/client.h +++ b/src/client/header/client.h @@ -316,6 +316,7 @@ extern cvar_t *cin_force43; extern cvar_t *vid_fullscreen; extern cvar_t *cl_kickangles; extern cvar_t *cl_r1q2_lightstyle; +extern cvar_t *cl_limitsparksounds; typedef struct {