Fix entering garage in a cleaner way
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10817 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
38a626e921
commit
da25bc6105
@ -98,7 +98,7 @@ void OverWorld::update(float dt)
|
||||
|
||||
const unsigned int kart_amount = m_karts.size();
|
||||
|
||||
// isn't cool, on the overworld nitro is free!
|
||||
// isn't it cool, on the overworld nitro is free!
|
||||
for(unsigned int n=0; n<kart_amount; n++)
|
||||
{
|
||||
m_karts[n]->setEnergy(100.0f);
|
||||
@ -107,7 +107,8 @@ void OverWorld::update(float dt)
|
||||
if (m_return_to_garage)
|
||||
{
|
||||
m_return_to_garage = false;
|
||||
race_manager->exitRace();
|
||||
delayedSelfDestruct();
|
||||
race_manager->exitRace(false);
|
||||
KartSelectionScreen* s = KartSelectionScreen::getInstance();
|
||||
s->setMultiplayer(false);
|
||||
s->setFromOverworld(true);
|
||||
|
@ -89,6 +89,7 @@ World::World() : WorldStatus(), m_clear_color(255,100,101,140)
|
||||
m_clear_back_buffer = false;
|
||||
m_schedule_pause = false;
|
||||
m_schedule_unpause = false;
|
||||
m_self_destruct = false;
|
||||
|
||||
WorldStatus::setClockMode(CLOCK_CHRONO);
|
||||
} // World
|
||||
@ -589,6 +590,12 @@ void World::updateWorld(float dt)
|
||||
m_schedule_unpause = false;
|
||||
}
|
||||
|
||||
if (m_self_destruct)
|
||||
{
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't update world if a menu is shown or the race is over.
|
||||
if( m_phase == FINISH_PHASE ||
|
||||
m_phase == IN_GAME_MENU_PHASE )
|
||||
@ -946,4 +953,13 @@ void World::unpause()
|
||||
}
|
||||
} // pause
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Call when the world needs to be deleted but you can't do it immediately
|
||||
* because you are e.g. within World::update()
|
||||
*/
|
||||
void World::delayedSelfDestruct()
|
||||
{
|
||||
m_self_destruct = true;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
@ -146,6 +146,11 @@ protected:
|
||||
|
||||
Phase m_scheduled_pause_phase;
|
||||
|
||||
/** Set when the world needs to be deleted but you can't do it immediately
|
||||
* because you are e.g. within World::update()
|
||||
*/
|
||||
bool m_self_destruct;
|
||||
|
||||
public:
|
||||
World();
|
||||
virtual ~World();
|
||||
@ -276,10 +281,12 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Override if you want to know when a kart presses fire */
|
||||
virtual void onFirePressed(Controller* who) {}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Whether to compute checkline requirements for each world on the
|
||||
* quadgraph. Override to change value. */
|
||||
virtual bool computeChecklineRequirements() const { return false; }
|
||||
// ------------------------------------------------------------------------
|
||||
void delayedSelfDestruct();
|
||||
|
||||
}; // World
|
||||
|
||||
|
@ -489,7 +489,7 @@ void RaceManager::computeGPRanks()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void RaceManager::exitRace()
|
||||
void RaceManager::exitRace(bool delete_world)
|
||||
{
|
||||
// Only display the grand prix result screen if all tracks
|
||||
// were finished, and not when a race is aborted.
|
||||
@ -558,7 +558,8 @@ void RaceManager::exitRace()
|
||||
}
|
||||
}
|
||||
|
||||
World::deleteWorld();
|
||||
if (delete_world) World::deleteWorld();
|
||||
|
||||
m_track_number = 0;
|
||||
} // exitRace
|
||||
|
||||
|
@ -473,7 +473,7 @@ public:
|
||||
* \note In GP, displays the GP result screen first
|
||||
* \note Deletes the world.
|
||||
*/
|
||||
void exitRace();
|
||||
void exitRace(bool delete_world=true);
|
||||
|
||||
/**
|
||||
* \brief Higher-level method to start a GP without having to care about the exact startup sequence
|
||||
|
@ -313,7 +313,6 @@ void TrackObject::onTriggerItemApproached(Item* who)
|
||||
{
|
||||
if (m_action == "garage")
|
||||
{
|
||||
World::getWorld()->schedulePause(World::IN_GAME_MENU_PHASE);
|
||||
dynamic_cast<OverWorld*>(World::getWorld())->scheduleReturnToGarage();
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user