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
This commit is contained in:
hikerstk 2010-12-18 12:58:09 +00:00
parent ca8ce904cc
commit 47661bf772
2 changed files with 13 additions and 2 deletions

View File

@ -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; }

View File

@ -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;