Skip to content

Commit

Permalink
cmod: Add experimental 's_noDuplicate' option to emulate original EF …
Browse files Browse the repository at this point in the history
…sound filtering
  • Loading branch information
Chomenor committed May 31, 2021
1 parent a6942b5 commit f421898
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions code/client/snd_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -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;

Expand Down
1 change: 1 addition & 0 deletions code/cmod/cmod_cvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
4 changes: 4 additions & 0 deletions code/cmod/cmod_cvar_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions code/cmod/cmod_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f421898

Please sign in to comment.