A bit better formatting in world status

This commit is contained in:
Deve 2014-08-30 18:34:44 +02:00
parent 507d9566a0
commit 47b46558f2

View File

@ -44,7 +44,9 @@ WorldStatus::WorldStatus()
m_play_racestart_sounds = true; m_play_racestart_sounds = true;
IrrlichtDevice *device = irr_driver->getDevice(); IrrlichtDevice *device = irr_driver->getDevice();
if (device->getTimer()->isStopped()) device->getTimer()->start();
if (device->getTimer()->isStopped())
device->getTimer()->start();
} // WorldStatus } // WorldStatus
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -56,13 +58,15 @@ void WorldStatus::reset()
m_auxiliary_timer = 0.0f; m_auxiliary_timer = 0.0f;
// Using SETUP_PHASE will play the track into sfx first, and has no // Using SETUP_PHASE will play the track into sfx first, and has no
// other side effects. // other side effects.
m_phase = UserConfigParams::m_race_now ? RACE_PHASE : SETUP_PHASE; m_phase = UserConfigParams::m_race_now ? RACE_PHASE : SETUP_PHASE;
m_previous_phase = UNDEFINED_PHASE; m_previous_phase = UNDEFINED_PHASE;
// Just in case that the game is reset during the intro phase // Just in case that the game is reset during the intro phase
m_track_intro_sound->stop(); m_track_intro_sound->stop();
IrrlichtDevice *device = irr_driver->getDevice(); IrrlichtDevice *device = irr_driver->getDevice();
if (device->getTimer()->isStopped()) device->getTimer()->start();
if (device->getTimer()->isStopped())
device->getTimer()->start();
} // reset } // reset
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -74,7 +78,9 @@ WorldStatus::~WorldStatus()
sfx_manager->deleteSFX(m_start_sound); sfx_manager->deleteSFX(m_start_sound);
sfx_manager->deleteSFX(m_track_intro_sound); sfx_manager->deleteSFX(m_track_intro_sound);
IrrlichtDevice *device = irr_driver->getDevice(); IrrlichtDevice *device = irr_driver->getDevice();
if (device->getTimer()->isStopped()) device->getTimer()->start();
if (device->getTimer()->isStopped())
device->getTimer()->start();
} // ~WorldStatus } // ~WorldStatus
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -96,14 +102,12 @@ void WorldStatus::setClockMode(const ClockType mode, const float initial_time)
void WorldStatus::enterRaceOverState() void WorldStatus::enterRaceOverState()
{ {
// Don't enter race over if it's already race over // Don't enter race over if it's already race over
if( m_phase == DELAY_FINISH_PHASE if (m_phase == DELAY_FINISH_PHASE || m_phase == RESULT_DISPLAY_PHASE ||
|| m_phase == RESULT_DISPLAY_PHASE m_phase == FINISH_PHASE)
|| m_phase == FINISH_PHASE )
return; return;
m_phase = DELAY_FINISH_PHASE; m_phase = DELAY_FINISH_PHASE;
m_auxiliary_timer = 0.0f; m_auxiliary_timer = 0.0f;
} // enterRaceOverState } // enterRaceOverState
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -120,7 +124,7 @@ void WorldStatus::terminateRace()
*/ */
void WorldStatus::update(const float dt) void WorldStatus::update(const float dt)
{ {
switch(m_phase) switch (m_phase)
{ {
// Note: setup phase must be a separate phase, since the race_manager // Note: setup phase must be a separate phase, since the race_manager
// checks the phase when updating the camera: in the very first time // checks the phase when updating the camera: in the very first time
@ -148,7 +152,9 @@ void WorldStatus::update(const float dt)
if (UserConfigParams::m_artist_debug_mode && if (UserConfigParams::m_artist_debug_mode &&
race_manager->getNumberOfKarts() == 1 && race_manager->getNumberOfKarts() == 1 &&
race_manager->getTrackName() != "tutorial") race_manager->getTrackName() != "tutorial")
{
m_auxiliary_timer += dt * 6; m_auxiliary_timer += dt * 6;
}
// Work around a bug that occurred on linux once: // Work around a bug that occurred on linux once:
// the sfx_manager kept on reporting that it is playing, // the sfx_manager kept on reporting that it is playing,
@ -156,61 +162,86 @@ void WorldStatus::update(const float dt)
// ... phase. Since the sound effect is about 3 seconds // ... phase. Since the sound effect is about 3 seconds
// long, we use the aux timer to force the next phase // long, we use the aux timer to force the next phase
// after 3.5 seconds. // after 3.5 seconds.
if(m_track_intro_sound->getStatus()==SFXManager::SFX_PLAYING if (m_track_intro_sound->getStatus() == SFXManager::SFX_PLAYING &&
&& m_auxiliary_timer<3.5f) m_auxiliary_timer < 3.5f)
return; return;
// Wait before ready phase if sounds are disabled // Wait before ready phase if sounds are disabled
if(!UserConfigParams::m_sfx && m_auxiliary_timer<3.0f) if (!UserConfigParams::m_sfx && m_auxiliary_timer < 3.0f)
return; return;
m_auxiliary_timer = 0.0f; m_auxiliary_timer = 0.0f;
if (m_play_racestart_sounds) m_prestart_sound->play();
if (m_play_racestart_sounds)
m_prestart_sound->play();
m_phase = READY_PHASE; m_phase = READY_PHASE;
for(unsigned int i=0; i<World::getWorld()->getNumKarts(); i++)
for (unsigned int i = 0; i < World::getWorld()->getNumKarts(); i++)
{
World::getWorld()->getKart(i)->startEngineSFX(); World::getWorld()->getKart(i)->startEngineSFX();
}
break; break;
case READY_PHASE: case READY_PHASE:
if(m_auxiliary_timer>1.0) if (m_auxiliary_timer > 1.0)
{ {
if (m_play_racestart_sounds) m_prestart_sound->play(); if (m_play_racestart_sounds)
m_phase=SET_PHASE; {
m_prestart_sound->play();
}
m_phase = SET_PHASE;
} }
m_auxiliary_timer += dt; m_auxiliary_timer += dt;
// In artist debug mode, when without opponents, skip the ready/set/go counter faster // In artist debug mode, when without opponents, skip the ready/set/go counter faster
if (UserConfigParams::m_artist_debug_mode && if (UserConfigParams::m_artist_debug_mode &&
race_manager->getNumberOfKarts() == 1 && race_manager->getNumberOfKarts() == 1 &&
race_manager->getTrackName() != "tutorial") race_manager->getTrackName() != "tutorial")
{
m_auxiliary_timer += dt*6; m_auxiliary_timer += dt*6;
}
return; return;
case SET_PHASE : case SET_PHASE:
if(m_auxiliary_timer>2.0) if (m_auxiliary_timer > 2.0)
{ {
// set phase is over, go to the next one // set phase is over, go to the next one
m_phase=GO_PHASE; m_phase = GO_PHASE;
if (m_play_racestart_sounds) m_start_sound->play(); if (m_play_racestart_sounds)
{
m_start_sound->play();
}
World::getWorld()->getTrack()->startMusic(); World::getWorld()->getTrack()->startMusic();
// event // event
onGo(); onGo();
} }
m_auxiliary_timer += dt; m_auxiliary_timer += dt;
// In artist debug mode, when without opponents, skip the ready/set/go counter faster // In artist debug mode, when without opponents, skip the ready/set/go counter faster
if (UserConfigParams::m_artist_debug_mode && if (UserConfigParams::m_artist_debug_mode &&
race_manager->getNumberOfKarts() == 1 && race_manager->getNumberOfKarts() == 1 &&
race_manager->getTrackName() != "tutorial") race_manager->getTrackName() != "tutorial")
{
m_auxiliary_timer += dt*6; m_auxiliary_timer += dt*6;
}
return; return;
case GO_PHASE : case GO_PHASE :
if (m_auxiliary_timer>2.5f && music_manager->getCurrentMusic()) if (m_auxiliary_timer>2.5f && music_manager->getCurrentMusic())
music_manager->startMusic(music_manager->getCurrentMusic());
if(m_auxiliary_timer>3.0f) // how long to display the 'go' message
{ {
m_phase=MUSIC_PHASE; music_manager->startMusic(music_manager->getCurrentMusic());
}
if (m_auxiliary_timer > 3.0f) // how long to display the 'go' message
{
m_phase = MUSIC_PHASE;
} }
m_auxiliary_timer += dt; m_auxiliary_timer += dt;
@ -219,31 +250,38 @@ void WorldStatus::update(const float dt)
if (UserConfigParams::m_artist_debug_mode && if (UserConfigParams::m_artist_debug_mode &&
race_manager->getNumberOfKarts() == 1 && race_manager->getNumberOfKarts() == 1 &&
race_manager->getTrackName() != "tutorial") race_manager->getTrackName() != "tutorial")
{
m_auxiliary_timer += dt*6; m_auxiliary_timer += dt*6;
}
break; break;
case MUSIC_PHASE: case MUSIC_PHASE:
// how long to display the 'music' message // how long to display the 'music' message
if(m_auxiliary_timer>stk_config->m_music_credit_time) if (m_auxiliary_timer>stk_config->m_music_credit_time)
m_phase=RACE_PHASE; {
m_phase = RACE_PHASE;
}
m_auxiliary_timer += dt; m_auxiliary_timer += dt;
break; break;
case RACE_PHASE: case RACE_PHASE:
// Nothing to do for race phase, switch to delay finish phase // Nothing to do for race phase, switch to delay finish phase
// happens when // happens when
break; break;
case DELAY_FINISH_PHASE : case DELAY_FINISH_PHASE:
{ {
m_auxiliary_timer += dt; m_auxiliary_timer += dt;
// Change to next phase if delay is over // Change to next phase if delay is over
if(m_auxiliary_timer > stk_config->m_delay_finish_time) if (m_auxiliary_timer > stk_config->m_delay_finish_time)
{ {
m_phase = RESULT_DISPLAY_PHASE; m_phase = RESULT_DISPLAY_PHASE;
terminateRace(); terminateRace();
} }
break; break;
} }
case RESULT_DISPLAY_PHASE : case RESULT_DISPLAY_PHASE:
{ {
break; break;
} }
@ -256,7 +294,7 @@ void WorldStatus::update(const float dt)
default: break; default: break;
} }
switch(m_clock_mode) switch (m_clock_mode)
{ {
case CLOCK_CHRONO: case CLOCK_CHRONO:
m_time += dt; m_time += dt;
@ -297,11 +335,14 @@ void WorldStatus::setTime(const float time)
*/ */
void WorldStatus::pause(Phase phase) void WorldStatus::pause(Phase phase)
{ {
assert(m_previous_phase==UNDEFINED_PHASE); assert(m_previous_phase == UNDEFINED_PHASE);
m_previous_phase = m_phase; m_previous_phase = m_phase;
m_phase = phase; m_phase = phase;
IrrlichtDevice *device = irr_driver->getDevice(); IrrlichtDevice *device = irr_driver->getDevice();
if (!device->getTimer()->isStopped()) device->getTimer()->stop();
if (!device->getTimer()->isStopped())
device->getTimer()->stop();
} // pause } // pause
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -314,5 +355,7 @@ void WorldStatus::unpause()
// in pause to detect incorrect pause/unpause sequences. // in pause to detect incorrect pause/unpause sequences.
m_previous_phase = UNDEFINED_PHASE; m_previous_phase = UNDEFINED_PHASE;
IrrlichtDevice *device = irr_driver->getDevice(); IrrlichtDevice *device = irr_driver->getDevice();
if (device->getTimer()->isStopped()) device->getTimer()->start();
if (device->getTimer()->isStopped())
device->getTimer()->start();
} // unpause } // unpause