From 47661bf772663f5345ce7b0e53b5f8f12d0f77f1 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Sat, 18 Dec 2010 12:58:09 +0000 Subject: [PATCH] Fixed crashes in case of FTL GP (in 2nd races no number of laps was defined). Note that the ordering in FTL GP is still broken and can still result in crashes. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7073 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/race/race_manager.hpp | 11 ++++++++++- src/states_screens/race_gui.cpp | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/race/race_manager.hpp b/src/race/race_manager.hpp index 26155c883..c7d95e025 100644 --- a/src/race/race_manager.hpp +++ b/src/race/race_manager.hpp @@ -275,7 +275,16 @@ public: MinorRaceModeType getMinorMode() const { return m_minor_mode; } unsigned int getNumPlayers() const { return m_player_karts.size(); } - int getNumLaps() const { return m_num_laps[m_track_number];} + /** Returns the number lf laps. In case of FTL or battle mode always + * return 9999, since they don't have laps. This avoids problems in FTL GP, + * since in this case no laps would be set (otherwise we would need many + * more tests in calls to getNumLaps). */ + int getNumLaps() const + { + if(m_minor_mode==MINOR_MODE_3_STRIKES || m_minor_mode==MINOR_MODE_FOLLOW_LEADER) + return 9999; + return m_num_laps[m_track_number]; + } // getNumLaps Difficulty getDifficulty() const { return m_difficulty; } const std::string& getTrackName() const { return m_tracks[m_track_number]; } const GrandPrixData *getGrandPrix() const { return &m_grand_prix; } diff --git a/src/states_screens/race_gui.cpp b/src/states_screens/race_gui.cpp index f1f2333dd..7d6d97988 100644 --- a/src/states_screens/race_gui.cpp +++ b/src/states_screens/race_gui.cpp @@ -111,7 +111,9 @@ RaceGUI::RaceGUI() m_rank_lap_width = font->getDimension(m_string_lap.c_str()).Width; int w; - if (race_manager->getNumLaps() > 9) + if (race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER || + race_manager->getMinorMode()==RaceManager::MINOR_MODE_3_STRIKES || + race_manager->getNumLaps() > 9) w = font->getDimension(L"99/99").Width; else w = font->getDimension(L"9/9").Width;