diff --git a/source/core/sound/s_sound.cpp b/source/core/sound/s_sound.cpp index 091048572..b67900d8a 100644 --- a/source/core/sound/s_sound.cpp +++ b/source/core/sound/s_sound.cpp @@ -502,26 +502,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/source/core/sound/s_soundinternal.h b/source/core/sound/s_soundinternal.h index f2dfd909c..112fb8d31 100644 --- a/source/core/sound/s_soundinternal.h +++ b/source/core/sound/s_soundinternal.h @@ -184,6 +184,7 @@ struct FSoundChan : public FISoundChannel // CHAN_ITEM is for small things and item pickup // CHAN_BODY is for generic body sounds // CHAN_PICKUP can optionally be set as a local sound only for "compatibility" +// Channels below 0 are reserved for CHAN_AUTO. enum EChannel { diff --git a/source/sw/src/panel.cpp b/source/sw/src/panel.cpp index d9cacf00e..bfb77a860 100644 --- a/source/sw/src/panel.cpp +++ b/source/sw/src/panel.cpp @@ -982,11 +982,16 @@ int WeaponOperate(PLAYERp pp) } // Shut that computer chick up if weapon has changed! + // This really should be handled better, but since there's no usable tracking state for the sounds, the easiest way to handle them is to play on otherwise unused channels. if (pp->WpnRocketType != 2 || pp->CurWpn != pp->Wpn[WPN_MICRO]) { pp->InitingNuke = FALSE; soundEngine->StopSound(SOURCE_Player, pp, CHAN_WEAPON); } + if (pp->CurWpn != pp->Wpn[WPN_RAIL]) + { + soundEngine->StopSound(SOURCE_Player, pp, CHAN_ITEM); + } return 0; } @@ -3718,7 +3723,7 @@ InitWeaponRail(PLAYERp pp) pSetState(psp, psp->PresentState); PlaySound(DIGI_RAIL_UP, pp, v3df_follow); - PlaySound(DIGI_RAILREADY, pp, v3df_follow|v3df_dontpan); + PlaySound(DIGI_RAILREADY, pp, v3df_follow | v3df_dontpan, CHAN_ITEM); // this one needs to be on a dedicated channel to allow switching it off without too many checks. Set3DSoundOwner(psp->PlayerP->PlayerSprite); FLAG_KEY_RELEASE(psp->PlayerP, SK_SHOOT); diff --git a/source/sw/src/sounds.cpp b/source/sw/src/sounds.cpp index ae4795c4f..5bf6e71b3 100644 --- a/source/sw/src/sounds.cpp +++ b/source/sw/src/sounds.cpp @@ -945,7 +945,7 @@ SWBOOL PlaySong(const char* mapname, const char* song_file_name, int cdaudio_tra } if (!Mus_Play(mapname, song_file_name, true)) { - // try the CD track anyway if no MIDI could be found (the original game doesn't have any MIDI, it was CD Audio only, this avoids no music playing id mus_redbook is off.) + // try the CD track anyway if no MIDI could be found (the original game doesn't have any MIDI, it was CD Audio only, this avoids no music playing if mus_redbook is off.) FStringf trackname("track%02d.ogg", cdaudio_track); if (!Mus_Play(nullptr, trackname, true)) return false; }