Fixed restart race bug + other issues possibly introduced by my scheduling of pausing

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6280 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2010-10-12 22:32:33 +00:00
parent fa6ae21672
commit 5e482d9989
4 changed files with 27 additions and 15 deletions

View File

@@ -85,7 +85,7 @@ Screen::~Screen()
void Screen::init()
{
if(m_pause_race && World::getWorld())
World::getWorld()->pause(World::IN_GAME_MENU_PHASE);
World::getWorld()->schedulePause(World::IN_GAME_MENU_PHASE);
} // init
// -----------------------------------------------------------------------------
@@ -96,7 +96,7 @@ void Screen::init()
void Screen::tearDown()
{
if(m_pause_race && World::getWorld())
World::getWorld()->unpause();
World::getWorld()->scheduleUnpause();
} // tearDown
// -----------------------------------------------------------------------------

View File

@@ -295,6 +295,9 @@ void World::onGo()
*/
void World::terminateRace()
{
m_schedule_pause = false;
m_schedule_unpause = false;
// Update the estimated finishing time for all karts that haven't
// finished yet.
const unsigned int kart_amount = getNumKarts();
@@ -330,6 +333,9 @@ void World::terminateRace()
*/
void World::resetAllKarts()
{
m_schedule_pause = false;
m_schedule_unpause = false;
//Project karts onto track from above. This will lower each kart so
//that at least one of its wheel will be on the surface of the track
for ( KartList::iterator i=m_karts.begin(); i!=m_karts.end(); i++)
@@ -400,7 +406,7 @@ void World::resetAllKarts()
} // resetAllKarts
void World::pause(Phase phase)
void World::schedulePause(Phase phase)
{
if (m_schedule_unpause)
{
@@ -413,7 +419,7 @@ void World::pause(Phase phase)
}
}
void World::unpause()
void World::scheduleUnpause()
{
if (m_schedule_pause)
{
@@ -439,12 +445,12 @@ void World::updateWorld(float dt)
{
if (m_schedule_pause)
{
doPause(m_scheduled_pause_phase);
pause(m_scheduled_pause_phase);
m_schedule_pause = false;
}
else if (m_schedule_unpause)
{
doUnpause();
unpause();
m_schedule_unpause = false;
}
@@ -703,6 +709,9 @@ void World::restartRace()
m_race_gui->clearAllMessages();
m_schedule_pause = false;
m_schedule_unpause = false;
WorldStatus::reset();
m_faster_music_active = false;
m_eliminated_karts = 0;
@@ -729,19 +738,22 @@ void World::restartRace()
//-----------------------------------------------------------------------------
/** Pauses the music (and then pauses WorldStatus).
*/
void World::doPause(Phase phase)
void World::pause(Phase phase)
{
music_manager->pauseMusic();
sfx_manager->pauseAll();
WorldStatus::pause(phase);
} // pause
//-----------------------------------------------------------------------------
void World::doUnpause()
void World::unpause()
{
music_manager->resumeMusic() ;
sfx_manager->resumeAll();
WorldStatus::unpause();
for(unsigned int i=0; i<m_karts.size(); i++)
{
// Note that we can not test for isPlayerController here, since

View File

@@ -162,9 +162,6 @@ protected:
Phase m_scheduled_pause_phase;
void doPause(Phase phase);
void doUnpause();
public:
World();
virtual ~World();
@@ -233,6 +230,9 @@ public:
virtual void pause(Phase phase);
virtual void unpause();
void schedulePause(Phase phase);
void scheduleUnpause();
/**
* The code that draws the timer should call this first to know
* whether the game mode wants a timer drawn

View File

@@ -47,7 +47,7 @@ RacePausedDialog::RacePausedDialog(const float percentWidth,
{
loadFromFile("race_paused_dialog.stkgui");
World::getWorld()->pause(WorldStatus::IN_GAME_MENU_PHASE);
World::getWorld()->schedulePause(WorldStatus::IN_GAME_MENU_PHASE);
IconButtonWidget* back_btn = getWidget<IconButtonWidget>("backbtn");
back_btn->setFocusForPlayer( PLAYER_ID_GAME_MASTER );
@@ -56,7 +56,7 @@ RacePausedDialog::RacePausedDialog(const float percentWidth,
// ----------------------------------------------------------------------------
RacePausedDialog::~RacePausedDialog()
{
World::getWorld()->unpause();
World::getWorld()->scheduleUnpause();
} // ~RacePausedDialog
// ----------------------------------------------------------------------------
@@ -133,14 +133,14 @@ GUIEngine::EventPropagation
{
ModalDialog::dismiss();
network_manager->setState(NetworkManager::NS_MAIN_MENU);
World::getWorld()->unpause();
World::getWorld()->scheduleUnpause();
race_manager->rerunRace();
return GUIEngine::EVENT_BLOCK;
}
else if (selection == "newrace")
{
ModalDialog::dismiss();
World::getWorld()->unpause();
World::getWorld()->scheduleUnpause();
race_manager->exitRace();
Screen* newStack[] = {MainMenuScreen::getInstance(),
RaceSetupScreen::getInstance(), NULL};