From 4881ec257a8a4cc3f6b5513c8e051757cf1f9a5d 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. --- src/common/2d/v_2ddrawer.cpp | 1 + src/common/audio/sound/s_sound.cpp | 23 +++-------------------- src/common/thirdparty/sfmt/SFMT.h | 2 ++ 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/common/2d/v_2ddrawer.cpp b/src/common/2d/v_2ddrawer.cpp index 9d89d3e66..98c0ba711 100644 --- a/src/common/2d/v_2ddrawer.cpp +++ b/src/common/2d/v_2ddrawer.cpp @@ -397,6 +397,7 @@ void F2DDrawer::SetColorOverlay(PalEntry color, float alpha, PalEntry &vertexcol void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms) { if (parms.style.BlendOp == STYLEOP_None) return; // not supposed to be drawn. + assert(img && img->isValid()); double xscale = parms.destwidth / parms.texwidth; double yscale = parms.destheight / parms.texheight; diff --git a/src/common/audio/sound/s_sound.cpp b/src/common/audio/sound/s_sound.cpp index b274a5754..b6d6bb242 100644 --- a/src/common/audio/sound/s_sound.cpp +++ b/src/common/audio/sound/s_sound.cpp @@ -494,26 +494,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. diff --git a/src/common/thirdparty/sfmt/SFMT.h b/src/common/thirdparty/sfmt/SFMT.h index ddaabf246..b7d3c42f3 100644 --- a/src/common/thirdparty/sfmt/SFMT.h +++ b/src/common/thirdparty/sfmt/SFMT.h @@ -28,6 +28,8 @@ * unsigned int and 64-bit unsigned int in hexadecimal format. */ +#include + #ifndef SFMT_H #define SFMT_H