diff --git a/src/event.cxx b/src/event.cxx index 9854f0c..e9fe135 100644 --- a/src/event.cxx +++ b/src/event.cxx @@ -3066,20 +3066,26 @@ CEvent::IsHelpHide () } std::string -CEvent::GetMusicLocation (Sint32 music) +CEvent::GetMusicLocation (Sint32 music, std::string & format) { static const std::string exts[] = {"ogg", "mid"}; static const Location locs[] = {LOCATION_USER, LOCATION_BASE}; std::string absolute; + format = ""; + // Look for music in the user directory, then in the game directory. for (size_t i = 0; i < countof (locs); ++i) { - auto filename = string_format ( - "music/music%.3d.%s", music - 1, exts[g_restoreMidi ? 1 : 0].c_str ()); + format = exts[g_restoreMidi ? 1 : 0]; + auto filename = + string_format ("music/music%.3d.%s", music - 1, format.c_str ()); if (!FileExists (filename, absolute, locs[i])) - filename = string_format ( - "music/music%.3d.%s", music - 1, exts[g_restoreMidi ? 0 : 1].c_str ()); + { + format = exts[g_restoreMidi ? 0 : 1]; + filename = + string_format ("music/music%.3d.%s", music - 1, format.c_str ()); + } if (FileExists (filename, absolute, locs[i])) break; @@ -3399,7 +3405,8 @@ CEvent::ChangePhase (Uint32 phase) music = m_pDecor->GetMusic (); if (music > 0) { - auto absolute = this->GetMusicLocation (music); + std::string format; + auto absolute = this->GetMusicLocation (music, format); m_pSound->StopMusic (); m_pSound->PlayMusic (absolute); diff --git a/src/event.h b/src/event.h index 73fe2d5..3ca7b03 100644 --- a/src/event.h +++ b/src/event.h @@ -100,7 +100,7 @@ public: Sint32 GetPhysicalWorld (); Sint32 GetImageWorld (); bool IsHelpHide (); - std::string GetMusicLocation (Sint32 music); + std::string GetMusicLocation (Sint32 music, std::string & format); bool ChangePhase (Uint32 phase); bool MovieToStart (); Uint32 GetPhase ();