From f421898ad39ed8a01249c8648ce8523692e91f44 Mon Sep 17 00:00:00 2001 From: Noah Metzger Date: Mon, 31 May 2021 16:54:23 -0500 Subject: [PATCH] cmod: Add experimental 's_noDuplicate' option to emulate original EF sound filtering --- code/client/snd_dma.c | 8 ++++++++ code/cmod/cmod_cvar.c | 1 + code/cmod/cmod_cvar_defs.h | 4 ++++ code/cmod/cmod_defs.h | 4 ++++ 4 files changed, 17 insertions(+) diff --git a/code/client/snd_dma.c b/code/client/snd_dma.c index a7b47d4a1..77eddbf37 100644 --- a/code/client/snd_dma.c +++ b/code/client/snd_dma.c @@ -598,6 +598,11 @@ static void S_Base_StartSoundEx( vec3_t origin, int entityNum, int entchannel, s return; } inplay++; +#ifdef CMOD_NO_DUPLICATE_SOUNDS + if ( s_noDuplicate->integer ) { + goto gotChannel; + } +#endif } } @@ -608,6 +613,9 @@ static void S_Base_StartSoundEx( vec3_t origin, int entityNum, int entchannel, s sfx->lastTimeUsed = time; ch = S_ChannelMalloc(); // entityNum, entchannel); +#ifdef CMOD_NO_DUPLICATE_SOUNDS + gotChannel: +#endif if (!ch) { ch = s_channels; diff --git a/code/cmod/cmod_cvar.c b/code/cmod/cmod_cvar.c index 29ff0714e..00e6fdfa9 100644 --- a/code/cmod/cmod_cvar.c +++ b/code/cmod/cmod_cvar.c @@ -1172,6 +1172,7 @@ special_cvar_t specials[] = { {"s_useOpenAL", "0", CVARTYPE_SOUND, 0}, {"s_volume", "0.6", CVARTYPE_SOUND, CVAR_ARCHIVE|CVAR_PROTECTED_ARCHIVABLE}, {"s_musicvolume", "0.6", CVARTYPE_SOUND, CVAR_ARCHIVE|CVAR_PROTECTED_ARCHIVABLE}, + {"s_noDuplicate", "0", CVARTYPE_SOUND, CVAR_ARCHIVE|CVAR_PROTECTED_ARCHIVABLE}, // UI Menu Settings {"ui_initialsetup", "1", CVARTYPE_MENU, CVAR_ARCHIVE|CVAR_PROTECTED_ARCHIVABLE|CVAR_IGNORE_VM_DEFAULT}, diff --git a/code/cmod/cmod_cvar_defs.h b/code/cmod/cmod_cvar_defs.h index 5077fb219..05f3972b8 100644 --- a/code/cmod/cmod_cvar_defs.h +++ b/code/cmod/cmod_cvar_defs.h @@ -43,6 +43,10 @@ CVAR_DEF(in_mouse_warping, "0", CVAR_ARCHIVE); CVAR_DEF(cmod_anti_burnin, "0", CVAR_ARCHIVE); #endif +#ifdef CMOD_NO_DUPLICATE_SOUNDS +CVAR_DEF(s_noDuplicate, "0", CVAR_ARCHIVE); +#endif + #ifdef CMOD_LOGGING_SYSTEM CVAR_DEF(cmod_log_flush, "1", 0) #endif diff --git a/code/cmod/cmod_defs.h b/code/cmod/cmod_defs.h index f60ee8fcd..5872eaed7 100644 --- a/code/cmod/cmod_defs.h +++ b/code/cmod/cmod_defs.h @@ -184,6 +184,10 @@ #define CMOD_CROSSHAIR #endif +// [FEATURE] Support "s_noDuplicate" option to emulate 1.20 behavior of only playing one copy +// of the same sound effect at the same time +#define CMOD_NO_DUPLICATE_SOUNDS + // [BUGFIX] Use traditional EF float casting behavior in VM, which fixes the physics behavior // in various mods #define CMOD_VMFLOATCAST