Fix sometimes missing overworld background music
This commit is contained in:
parent
ed6d7578a5
commit
0f2b3da37e
@ -124,10 +124,11 @@ void OverWorld::update(int ticks)
|
|||||||
setPhase(RACE_PHASE);
|
setPhase(RACE_PHASE);
|
||||||
// Normally done in WorldStatus::update(), during phase SET_PHASE,
|
// Normally done in WorldStatus::update(), during phase SET_PHASE,
|
||||||
// so we have to start music 'manually', since we skip all phases.
|
// so we have to start music 'manually', since we skip all phases.
|
||||||
|
MusicInformation* mi = Track::getCurrentTrack()->getTrackMusic();
|
||||||
Track::getCurrentTrack()->startMusic();
|
Track::getCurrentTrack()->startMusic();
|
||||||
|
|
||||||
if (UserConfigParams::m_music)
|
if (UserConfigParams::m_music)
|
||||||
music_manager->startMusic();
|
music_manager->startMusic(mi);
|
||||||
m_karts[0]->startEngineSFX();
|
m_karts[0]->startEngineSFX();
|
||||||
}
|
}
|
||||||
World::update(ticks);
|
World::update(ticks);
|
||||||
|
@ -176,6 +176,7 @@ Track::Track(const std::string &filename)
|
|||||||
m_minimap_y_scale = 1.0f;
|
m_minimap_y_scale = 1.0f;
|
||||||
m_force_disable_fog = false;
|
m_force_disable_fog = false;
|
||||||
m_startup_run = false;
|
m_startup_run = false;
|
||||||
|
m_music_idx = 0;
|
||||||
m_red_flag = m_blue_flag =
|
m_red_flag = m_blue_flag =
|
||||||
btTransform(btQuaternion(0.0f, 0.0f, 0.0f, 1.0f));
|
btTransform(btQuaternion(0.0f, 0.0f, 0.0f, 1.0f));
|
||||||
m_default_number_of_laps = 3;
|
m_default_number_of_laps = 3;
|
||||||
@ -709,6 +710,8 @@ void Track::getMusicInformation(std::vector<std::string>& filenames,
|
|||||||
"Music information for track '%s' replaced by default music.\n",
|
"Music information for track '%s' replaced by default music.\n",
|
||||||
m_name.c_str());
|
m_name.c_str());
|
||||||
}
|
}
|
||||||
|
if (!m_music.empty())
|
||||||
|
m_music_idx = rand() % m_music.size();
|
||||||
|
|
||||||
} // getMusicInformation
|
} // getMusicInformation
|
||||||
|
|
||||||
@ -719,7 +722,7 @@ void Track::startMusic() const
|
|||||||
{
|
{
|
||||||
// In case that the music wasn't found (a warning was already printed)
|
// In case that the music wasn't found (a warning was already printed)
|
||||||
if(m_music.size()>0)
|
if(m_music.size()>0)
|
||||||
music_manager->startMusic(m_music[rand()% m_music.size()], false);
|
music_manager->startMusic(m_music[m_music_idx], false);
|
||||||
else
|
else
|
||||||
music_manager->clearCurrentMusic();
|
music_manager->clearCurrentMusic();
|
||||||
} // startMusic
|
} // startMusic
|
||||||
|
@ -118,6 +118,7 @@ private:
|
|||||||
std::string m_screenshot;
|
std::string m_screenshot;
|
||||||
bool m_is_day;
|
bool m_is_day;
|
||||||
std::vector<MusicInformation*> m_music;
|
std::vector<MusicInformation*> m_music;
|
||||||
|
unsigned m_music_idx;
|
||||||
|
|
||||||
/** Will only be used on overworld */
|
/** Will only be used on overworld */
|
||||||
std::vector<OverworldChallenge> m_challenges;
|
std::vector<OverworldChallenge> m_challenges;
|
||||||
@ -732,6 +733,13 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
bool isOnGround(const Vec3& xyz, const Vec3& down, Vec3* hit_point,
|
bool isOnGround(const Vec3& xyz, const Vec3& down, Vec3* hit_point,
|
||||||
Vec3* normal, bool print_warning = true);
|
Vec3* normal, bool print_warning = true);
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
MusicInformation* getTrackMusic() const
|
||||||
|
{
|
||||||
|
if (m_music_idx < m_music.size())
|
||||||
|
return m_music[m_music_idx];
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}; // class Track
|
}; // class Track
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user