From 8e02b90b76074d59eb819d9e570658e9c02d2ded 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 5e968e3c..361005c8 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -428,7 +428,7 @@ void musicclass::processmusic(void) } /* This needs to come after processing fades */ - if (nicefade && Mix_PausedMusic() == 1) + if (nicefade && halted()) { play(nicechange); nicechange = -1; @@ -554,3 +554,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 84975afd..87707170 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;