Improved Follow-the-leader game ending. An assert failure might occur if one kart dies in front of the leader
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4964 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
0757764383
commit
9fb9278f31
@ -486,10 +486,17 @@ void Kart::finishedRace(float time)
|
||||
}
|
||||
else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER)
|
||||
{
|
||||
// start end animation
|
||||
setController(new EndController(this, m_controller->getPlayer()));
|
||||
m_kart_properties->getKartModel()->setEndAnimation(true);
|
||||
|
||||
// Not all karts have a camera
|
||||
if (m_camera) m_camera->setMode(Camera::CM_REVERSE);
|
||||
|
||||
RaceGUI* m = World::getWorld()->getRaceGUI();
|
||||
if(m)
|
||||
{
|
||||
m->addMessage((getPosition() == 1 ? _("You won the race!") : _("You finished the race!")) ,
|
||||
m->addMessage((getPosition() == 2 ? _("You won the race!") : _("You finished the race!")) ,
|
||||
this, 2.0f, 60);
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@
|
||||
#include "audio/sound_manager.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "states_screens/race_gui.hpp"
|
||||
#include "items/powerup_manager.hpp"
|
||||
#include "states_screens/race_gui.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
@ -86,7 +86,25 @@ void FollowTheLeaderRace::countdownReachedZero()
|
||||
sound_manager->switchToFastMusic();
|
||||
}
|
||||
|
||||
// End of race is also detected from the World::update(),
|
||||
if (isRaceOver())
|
||||
{
|
||||
// mark leader as finished
|
||||
m_karts[0]->finishedRace(getTime());
|
||||
|
||||
// mark last human player as finished
|
||||
for (unsigned int n=0; n<m_karts.size(); n++)
|
||||
{
|
||||
if (!m_karts[n]->isEliminated() &&
|
||||
m_karts[n]->getController()->getPlayer() != NULL) // if player kart
|
||||
{
|
||||
m_karts[n]->finishedRace(getTime());
|
||||
//irr::core::stringw message(_("You won the race!"));
|
||||
//getRaceGUI()->addMessage( message, m_karts[n], 2.0f, 60 );
|
||||
}
|
||||
}
|
||||
}
|
||||
// End of race is detected from World::updateWorld()
|
||||
|
||||
} // countdownReachedZero
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user