Skip to content

Commit

Permalink
Merge pull request #172 from cortex-command-community/musicman-use-af…
Browse files Browse the repository at this point in the history
…ter-free

Null NextSongSection properly - fix Mac/Linux crash when playing DynamicSongs
  • Loading branch information
Causeless authored Dec 20, 2024
2 parents 8993e9d + 8cdb2cc commit 510c61a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Source/Entities/DynamicSong.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ SoundContainer& DynamicSongSection::SelectTransitionSoundContainer() {
}

SoundContainer& DynamicSongSection::SelectSoundContainer() {
RTEAssert(!m_SoundContainers.empty(), "Tried to get a SoundContainer from a DynamicSongSection with none to choose from!");

// Shuffle between our options if we have multiple
if (m_SoundContainers.size() > 1) {
if (m_ShuffleUnplayedIndices.empty()) {
Expand Down Expand Up @@ -199,8 +201,7 @@ SoundContainer& DynamicSongSection::SelectSoundContainer() {
}
}
}

RTEAssert(!m_SoundContainers.empty(), "Tried to get a SoundContainer from a DynamicSongSection with none to choose from!");

return m_SoundContainers[0];
}

Expand Down
1 change: 1 addition & 0 deletions Source/Managers/MusicMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ void MusicMan::ResetMusicState() {

bool MusicMan::PlayDynamicSong(const std::string& songName, const std::string& songSectionType, bool playImmediately, bool playTransition, bool smoothFade) {
if (const DynamicSong* dynamicSongToPlay = dynamic_cast<const DynamicSong*>(g_PresetMan.GetEntityPreset("DynamicSong", songName))) {
m_NextSongSection = nullptr;
m_CurrentSong = std::unique_ptr<DynamicSong>(dynamic_cast<DynamicSong*>(dynamicSongToPlay->Clone()));
SetNextSongSectionType(songSectionType);
SelectNextSongSection();
Expand Down

0 comments on commit 510c61a

Please sign in to comment.