From 6c848a8bb927b7c5b29495fdff22f12e48ad339c Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 10 Sep 2021 19:35:29 -0700 Subject: [PATCH] Move `Mix_PausedMusic()` call into wrapper function This wrapper function is for (a) future-proofing (b) proactive prevention of future copy-pasting (c) to clarify that we never actually halt music in the SDL_mixer sense, we only pause it, so to check if the music is halted we actually check if the music is paused instead. This is important because Mix_PlayingMusic() does not check if the music is paused and Mix_PausedMusic() does not check if the music is halted. --- desktop_version/src/Music.cpp | 7 ++++++- desktop_version/src/Music.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index c991c168..3988b526 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -399,7 +399,7 @@ void musicclass::processmusic(void) } /* This needs to come after processing fades */ - if (nicefade && Mix_PausedMusic() == 1) + if (nicefade && halted()) { play(nicechange); nicechange = -1; @@ -525,3 +525,8 @@ void musicclass::resumeef(void) { Mix_Resume(-1); } + +bool musicclass::halted(void) +{ + return Mix_PausedMusic() == 1; +} diff --git a/desktop_version/src/Music.h b/desktop_version/src/Music.h index e987656c..ad330d60 100644 --- a/desktop_version/src/Music.h +++ b/desktop_version/src/Music.h @@ -44,6 +44,8 @@ public: void pauseef(void); void resumeef(void); + bool halted(void); + std::vector soundTracks; std::vector musicTracks; SoundSystem soundSystem;