From 87af9bba04ab29c3f0fa8bab2b96ba7d7f276c4e Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 6 Nov 2020 00:36:25 -0800 Subject: [PATCH] Merge fadeoutqueuesong into nicechange fadeoutqueuesong basically does the same thing as nicechange - they both queue a song to be played when the current track is done fading out. Except, for some reason, I decided to add fadeoutqueuesong instead of using the existing nicechange/nicefade system. This has consequences where fadeoutqueuesong would step on the toes of nicechange. In the case of #390, nicechange would say "let's play Potential for Anything" when entering the Super Gravitron, but fadeoutqueuesong had previously said "let's play Pipe Dream" because of the player having just exited the Super Gravitron. fadeoutqueuesong took priority because it came first in musicclass::processfade(), and when it called play(), the Mix_PlayingMusic() in the nicechange check afterwards would say music would already be playing at that point, so the nicechange wouldn't take effect. In the end, the solution is to just merge the new system into the already-existing system. Fixes #390. --- desktop_version/src/Music.cpp | 16 ++++++++-------- desktop_version/src/Music.h | 3 +-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index 5792271c..41556315 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -139,7 +139,6 @@ void musicclass::init() nicechange = -1; nicefade = false; resumesong = 0; - fadeoutqueuesong = -1; dontquickfade = false; songStart = 0; @@ -199,14 +198,20 @@ void musicclass::play(int t, const double position_sec /*= 0.0*/, const int fade } else { - if (Mix_FadingMusic() == MIX_FADING_OUT) { + if (Mix_FadingMusic() == MIX_FADING_OUT) + { // We're already fading out - fadeoutqueuesong = t; + nicechange = t; + nicefade = true; currentsong = -1; if (!dontquickfade) + { Mix_FadeOutMusic(500); // fade out quicker + } else + { dontquickfade = false; + } } else if(Mix_FadeInMusicPos(musicTracks[t].m_music, -1, fadein_ms, position_sec)==-1) { @@ -277,11 +282,6 @@ void musicclass::processmusic() return; } - if (fadeoutqueuesong != -1 && Mix_PlayingMusic() == 0) { - play(fadeoutqueuesong); - fadeoutqueuesong = -1; - } - if (nicefade && Mix_PlayingMusic() == 0) { play(nicechange); diff --git a/desktop_version/src/Music.h b/desktop_version/src/Music.h index 67f25677..edddf868 100644 --- a/desktop_version/src/Music.h +++ b/desktop_version/src/Music.h @@ -36,14 +36,13 @@ public: SoundSystem soundSystem; bool safeToProcessMusic; - int nicechange; + int nicechange; // -1 if no song queued bool nicefade; bool m_doFadeInVol; int FadeVolAmountPerFrame; int musicVolume; - int fadeoutqueuesong; // -1 if no song queued bool dontquickfade; // MMMMMM mod settings