From 17add7f47f518b79a48ee3d235b95b55d4dac106 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 26 May 2020 22:19:30 +0200 Subject: [PATCH] - don't let CHANF_AUTO hijack other channels. With CHANF_OVERLAP this isn't needed anymore - any sound started on CHAN_AUTO can actually play on this channel with overlap implicitly allowed. This has the added advantage that these sounds can be reliably accessed with other function by using CHAN_AUTO. # Conflicts: # src/v_2ddrawer.cpp --- src/sfmt/SFMT.h | 2 ++ src/sound/s_sound.cpp | 23 +++-------------------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/sfmt/SFMT.h b/src/sfmt/SFMT.h index ddaabf246..b7d3c42f3 100644 --- a/src/sfmt/SFMT.h +++ b/src/sfmt/SFMT.h @@ -28,6 +28,8 @@ * unsigned int and 64-bit unsigned int in hexadecimal format. */ +#include + #ifndef SFMT_H #define SFMT_H diff --git a/src/sound/s_sound.cpp b/src/sound/s_sound.cpp index b94b9c5eb..ee3e63027 100644 --- a/src/sound/s_sound.cpp +++ b/src/sound/s_sound.cpp @@ -501,26 +501,9 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source, int seen = 0; if (source != NULL && channel == CHAN_AUTO) { - // Select a channel that isn't already playing something. - // Try channel 0 first, then travel from channel 7 down. - if (!IsChannelUsed(type, source, 0, &seen)) - { - channel = 0; - } - else - { - for (channel = 7; channel > 0; --channel) - { - if (!IsChannelUsed(type, source, channel, &seen)) - { - break; - } - } - if (channel == 0) - { // Crap. No free channels. - return NULL; - } - } + // In the old sound system, 'AUTO' hijacked one of the other channels. + // Now, with CHANF_OVERLAP at our disposal that isn't needed anymore. Just set the flag and let all sounds play on channel 0. + chanflags |= CHANF_OVERLAP; } // If this actor is already playing something on the selected channel, stop it.