Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 366ff28

Browse files
committed
Added some safety to not play sounds past the limit and removed the assert. Lowered sound per container limit down to 128.
1 parent 220a9ff commit 366ff28

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Entities/SoundContainer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ namespace RTE {
201201
/// Adds a channel index to the SoundContainer's collection of playing channels.
202202
/// </summary>
203203
/// <param name="channel">The channel index to add.</param>
204-
void AddPlayingChannel(unsigned short channel) { m_PlayingChannels.insert(channel); RTEAssert(m_PlayingChannels.size() <= c_MaxPlayingSoundsPerContainer, "Tried to play more than " + std::to_string(c_MaxPlayingSoundsPerContainer) + " sounds in SoundContainer " + GetPresetName()); }
204+
void AddPlayingChannel(unsigned short channel) { m_PlayingChannels.insert(channel); }
205205

206206
/// <summary>
207207
/// Removes a channel index from the SoundContainer's collection of playing channels.

Managers/AudioMan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ namespace RTE {
423423
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
424424

425425
bool AudioMan::PlaySound(SoundContainer *soundContainer, const Vector &position, int player, int priority, double pitch) {
426-
if (!m_AudioEnabled || !soundContainer) {
426+
if (!m_AudioEnabled || !soundContainer || soundContainer->GetPlayingChannels()->size() >= c_MaxPlayingSoundsPerContainer - 2) {
427427
return false;
428428
}
429429
FMOD_RESULT result = FMOD_OK;

System/Constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace RTE {
5757
#pragma region Audio Constants
5858
static constexpr unsigned short c_MaxSoftwareChannels = 128;
5959
static constexpr unsigned short c_MaxVirtualChannels = 1024;
60-
static constexpr unsigned short c_MaxPlayingSoundsPerContainer = 256;
60+
static constexpr unsigned short c_MaxPlayingSoundsPerContainer = 128;
6161
/* TODO These have been temporarily replaced with variables in settingsman to allow for easy tweaking. This needs to be undone once our soundscape is sorted out.
6262
static constexpr unsigned short c_ListenerZOffset = 50; //!< The Z offset for Audio listeners. Can be used to lessen harsh panning if panning effect strength is at max.
6363
static constexpr unsigned short c_MinimumDistanceForPanning = 50; //!< The minimum distance before which sound panning should not occur. Not relevant for immobile sounds or in splitscreen.

0 commit comments

Comments
 (0)