Added new 'UNDEFINED_PHASE' to catch incorrect pause/unpause

sequences (instead of re-using SETUP_PHASE as was done previously).



git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5477 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-06-07 03:31:41 +00:00
parent c6727bfc01
commit e0328642f1
2 changed files with 11 additions and 18 deletions

View File

@ -31,8 +31,7 @@ WorldStatus::WorldStatus()
m_time = 0.0f;
m_auxiliary_timer = 0.0f;
m_phase = SETUP_PHASE;
m_previous_phase = SETUP_PHASE; // initialise it just in case
m_phase = SETUP_PHASE;
m_previous_phase = UNDEFINED_PHASE; // initialise it just in case
// FIXME - is it a really good idea to reload and delete the sound every race??
m_prestart_sound = sfx_manager->createSoundSource("prestart");
@ -47,7 +46,7 @@ void WorldStatus::reset()
m_time = 0.0f;
m_auxiliary_timer = 0.0f;
m_phase = READY_PHASE; // FIXME - unsure
m_previous_phase = SETUP_PHASE;
m_previous_phase = UNDEFINED_PHASE;
} // reset
//-----------------------------------------------------------------------------
@ -218,7 +217,7 @@ void WorldStatus::setTime(const float time)
*/
void WorldStatus::pause(Phase phase)
{
assert(m_previous_phase==SETUP_PHASE);
assert(m_previous_phase==UNDEFINED_PHASE);
m_previous_phase = m_phase;
m_phase = phase;
} // pause
@ -231,5 +230,5 @@ void WorldStatus::unpause()
m_phase = m_previous_phase;
// Set m_previous_phase so that we can use an assert
// in pause to detect incorrect pause/unpause sequences.
m_previous_phase = SETUP_PHASE;
}
m_previous_phase = UNDEFINED_PHASE;
} // unpause

View File

@ -71,6 +71,8 @@ public:
// Display the in-game menu, but no update of world or anything
IN_GAME_MENU_PHASE,
// Undefined, used in asserts to catch incorrect states.
UNDEFINED_PHASE
};
protected:
SFXBase *m_prestart_sound;
@ -123,11 +125,7 @@ public:
/** Returns the current race time. */
float getTime() const { return m_time; }
/** Returns the value of the auxiliary timer. */
float getAuxiliaryTimer() const {return m_auxiliary_timer; }
/**
* Call each frame, with the elapsed time as argument.
*/
/** Call each frame, with the elapsed time as argument. */
void update(const float dt);
void setTime(const float time);
@ -137,15 +135,11 @@ public:
virtual void enterRaceOverState();
virtual void terminateRace();
/*
* Will be called to notify your derived class that the clock,
* which is in COUNTDOWN mode, has reached zero.
*/
/** Will be called to notify your derived class that the clock,
* which is in COUNTDOWN mode, has reached zero. */
virtual void countdownReachedZero() {};
/*
* Called when the race actually starts.
*/
/** Called when the race actually starts. */
virtual void onGo() {};