diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index cf6b4e57..fa657b56 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -195,51 +195,51 @@ void musicclass::play(int t, const double position_sec /*= 0.0*/, const int fade currentsong = t; - if (t == -1) + if (t == -1) + { + return; + } + + if (!INBOUNDS_VEC(t, musicTracks)) + { + puts("play() out-of-bounds!"); + currentsong = -1; + return; + } + + if (currentsong == 0 || currentsong == 7 || (!map.custommode && (currentsong == 0+num_mmmmmm_tracks || currentsong == 7+num_mmmmmm_tracks))) + { + // Level Complete theme, no fade in or repeat + if (Mix_FadeInMusicPos(musicTracks[t].m_music, 0, 0, position_sec) == -1) { - return; + printf("Mix_FadeInMusicPos: %s\n", Mix_GetError()); } + } + else + { + if (Mix_FadingMusic() == MIX_FADING_OUT) + { + // We're already fading out + nicechange = t; + nicefade = true; + currentsong = -1; - if (!INBOUNDS_VEC(t, musicTracks)) + if (quick_fade) { - puts("play() out-of-bounds!"); - currentsong = -1; - return; - } - - if (currentsong == 0 || currentsong == 7 || (!map.custommode && (currentsong == 0+num_mmmmmm_tracks || currentsong == 7+num_mmmmmm_tracks))) - { - // Level Complete theme, no fade in or repeat - if (Mix_FadeInMusicPos(musicTracks[t].m_music, 0, 0, position_sec) == -1) - { - printf("Mix_FadeInMusicPos: %s\n", Mix_GetError()); - } + Mix_FadeOutMusic(500); // fade out quicker } else { - if (Mix_FadingMusic() == MIX_FADING_OUT) - { - // We're already fading out - nicechange = t; - nicefade = true; - currentsong = -1; - - if (quick_fade) - { - Mix_FadeOutMusic(500); // fade out quicker - } - else - { - quick_fade = true; - } - } - else if (Mix_FadeInMusicPos(musicTracks[t].m_music, -1, fadein_ms, position_sec) == -1) - { - printf("Mix_FadeInMusicPos: %s\n", Mix_GetError()); - } + quick_fade = true; } + } + else if (Mix_FadeInMusicPos(musicTracks[t].m_music, -1, fadein_ms, position_sec) == -1) + { + printf("Mix_FadeInMusicPos: %s\n", Mix_GetError()); + } + } - songStart = SDL_GetPerformanceCounter(); + songStart = SDL_GetPerformanceCounter(); } void musicclass::resume(const int fadein_ms /*= 0*/)