Make music and sound work with fast starts, fixes #1291

This commit is contained in:
Flakebi 2015-02-09 01:15:48 +01:00
parent d5cbf4fc6b
commit 4abe3ce327
2 changed files with 25 additions and 4 deletions

View File

@ -1052,7 +1052,7 @@ void initRest()
Online::RequestManager::get()->startNetworkThread();
NewsManager::get(); // this will create the news manager
music_manager = new MusicManager();
music_manager = new MusicManager();
SFXManager::create();
// The order here can be important, e.g. KartPropertiesManager needs
// defaultKartProperties, which are defined in stk_config.
@ -1238,7 +1238,7 @@ int main(int argc, char *argv[] )
material_manager->addSharedMaterial(materials_file);
}
Referee::init();
powerup_manager -> loadAllPowerups ();
powerup_manager->loadAllPowerups();
ItemManager::loadDefaultItemMeshes();
GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI,

View File

@ -56,7 +56,22 @@ void WorldStatus::reset()
m_auxiliary_timer = 0.0f;
// Using SETUP_PHASE will play the track into sfx first, and has no
// other side effects.
m_phase = UserConfigParams::m_race_now ? RACE_PHASE : SETUP_PHASE;
m_phase = UserConfigParams::m_race_now ? MUSIC_PHASE : SETUP_PHASE;
if (UserConfigParams::m_race_now)
{
// Setup music and sound
if (World::getWorld()->getWeather() != NULL)
World::getWorld()->getWeather()->playSound();
// Starting the music here doesn't work so it's done in the MUSIC_PHASE
World::getWorld()->getTrack()->startMusic();
// Start engines
for (unsigned int i = 0; i < World::getWorld()->getNumKarts(); i++)
World::getWorld()->getKart(i)->startEngineSFX();
}
m_previous_phase = UNDEFINED_PHASE;
// Just in case that the game is reset during the intro phase
m_track_intro_sound->stop();
@ -140,7 +155,7 @@ void WorldStatus::update(const float dt)
if (World::getWorld()->getWeather() != NULL)
{
World::getWorld()->getWeather()->playSound();
World::getWorld()->getWeather()->playSound();
}
return;
@ -254,6 +269,12 @@ void WorldStatus::update(const float dt)
break;
case MUSIC_PHASE:
// Start the music here when starting fast
if (UserConfigParams::m_race_now)
{
music_manager->startMusic(music_manager->getCurrentMusic());
UserConfigParams::m_race_now = false;
}
// how long to display the 'music' message
if (m_auxiliary_timer>stk_config->m_music_credit_time)
{