Add cvar to control sorting of play sounds

This commit is contained in:
Boris I. Bendovsky 2020-05-04 18:44:58 +03:00
parent 1887072cc9
commit 93a0473244
No known key found for this signature in database
GPG key ID: 48CD539C0518594B
2 changed files with 18 additions and 5 deletions

View file

@ -168,6 +168,7 @@ extern cvar_t *s_ambient;
extern cvar_t* s_underwater; extern cvar_t* s_underwater;
extern cvar_t* s_underwater_gain_hf; extern cvar_t* s_underwater_gain_hf;
extern cvar_t* s_doppler; extern cvar_t* s_doppler;
extern cvar_t* s_ps_sorting;
/* /*
* Globals * Globals

View file

@ -72,6 +72,7 @@ cvar_t *s_ambient;
cvar_t* s_underwater; cvar_t* s_underwater;
cvar_t* s_underwater_gain_hf; cvar_t* s_underwater_gain_hf;
cvar_t* s_doppler; cvar_t* s_doppler;
cvar_t* s_ps_sorting;
channel_t channels[MAX_CHANNELS]; channel_t channels[MAX_CHANNELS];
int num_sfx; int num_sfx;
@ -685,7 +686,7 @@ S_IssuePlaysound(playsound_t *ps)
Com_Printf("Issue %i\n", ps->begin); Com_Printf("Issue %i\n", ps->begin);
} }
if (ps->sfx->is_silenced_muzzle_flash) if (s_ps_sorting->value == 3 && ps->sfx->is_silenced_muzzle_flash)
{ {
S_FreePlaysound(ps); S_FreePlaysound(ps);
return; return;
@ -864,9 +865,14 @@ S_StartSound(vec3_t origin, int entnum, int entchannel, sfx_t *sfx,
cvar_t *game = Cvar_Get("game", "", CVAR_LATCH | CVAR_SERVERINFO); cvar_t *game = Cvar_Get("game", "", CVAR_LATCH | CVAR_SERVERINFO);
if ((strcmp(game->string, "") == 0) || const qboolean is_mission_pack =
(strcmp(game->string, "rogue") == 0) || (strcmp(game->string, "") == 0) ||
(strcmp(game->string, "xatrix") == 0)) (strcmp(game->string, "rogue") == 0) ||
(strcmp(game->string, "xatrix") == 0);
if ((s_ps_sorting->value == 1 && is_mission_pack) ||
s_ps_sorting->value == 2 ||
s_ps_sorting->value == 3)
{ {
for (sort = s_pendingplays.next; for (sort = s_pendingplays.next;
sort != &s_pendingplays && sort->begin <= ps->begin; sort != &s_pendingplays && sort->begin <= ps->begin;
@ -874,7 +880,7 @@ S_StartSound(vec3_t origin, int entnum, int entchannel, sfx_t *sfx,
{ {
} }
} }
else else if (!is_mission_pack && s_ps_sorting->value == 1)
{ {
for (sort = s_pendingplays.next; for (sort = s_pendingplays.next;
sort != &s_pendingplays && sort->begin < ps->begin; sort != &s_pendingplays && sort->begin < ps->begin;
@ -882,6 +888,11 @@ S_StartSound(vec3_t origin, int entnum, int entchannel, sfx_t *sfx,
{ {
} }
} }
else
{
/* No sorting. Just append at the end. */
sort = s_pendingplays.prev;
}
ps->next = sort; ps->next = sort;
ps->prev = sort->prev; ps->prev = sort->prev;
@ -1208,6 +1219,7 @@ S_Init(void)
s_underwater = Cvar_Get("s_underwater", "1", CVAR_ARCHIVE); s_underwater = Cvar_Get("s_underwater", "1", CVAR_ARCHIVE);
s_underwater_gain_hf = Cvar_Get("s_underwater_gain_hf", "0.25", CVAR_ARCHIVE); s_underwater_gain_hf = Cvar_Get("s_underwater_gain_hf", "0.25", CVAR_ARCHIVE);
s_doppler = Cvar_Get("s_doppler", "0", CVAR_ARCHIVE); s_doppler = Cvar_Get("s_doppler", "0", CVAR_ARCHIVE);
s_ps_sorting = Cvar_Get("s_ps_sorting", "1", CVAR_ARCHIVE);
Cmd_AddCommand("play", S_Play); Cmd_AddCommand("play", S_Play);
Cmd_AddCommand("stopsound", S_StopAllSounds); Cmd_AddCommand("stopsound", S_StopAllSounds);