Fixed crash when starting challenges. @Joerg: please read the fixme I added in RaceManager. There is some confusing design to fix there =)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6085 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-09-20 17:09:25 +00:00
parent 77dfe17d39
commit 1c4e3f8492
2 changed files with 8 additions and 1 deletions

View File

@ -189,6 +189,11 @@ void RaceManager::computeRandomKartList()
/** Starts a new race or GP (or other mode). It sets up the list of player
* karts, AI karts, laps etc., and then uses startNextRace to actually start
* the race.
* \pre computeRandomKartList() must have been called first I think.
* FIXME: remove this silly precondition, the race manager should be able to
* do this automatically. If one forgets to call computeRandomKartList,
* like it sure happened to me, one gets weird and hard to debug crashes.
* The public interface of the RaceManager should NOT allow for this.
*/
void RaceManager::startNew()
{
@ -211,7 +216,8 @@ void RaceManager::startNew()
// First add the AI karts (randomly chosen)
// ----------------------------------------
int init_gp_rank = 0;
for(unsigned int i=0; i<m_random_kart_list.size(); i++)
const unsigned int ai_kart_count = m_random_kart_list.size();
for(unsigned int i=0; i<ai_kart_count; i++)
{
m_kart_status.push_back(KartStatus(m_random_kart_list[i], i, -1, -1,
init_gp_rank, KT_AI));

View File

@ -153,6 +153,7 @@ void ChallengesScreen::eventCallback(GUIEngine::Widget* widget, const std::strin
// Launch challenge
unlock_manager->getChallenge(selection)->setRace();
race_manager->computeRandomKartList();
race_manager->startNew();
}
}