From 2cddd16d403dd265ab0e13de1aebb016543f9c6f Mon Sep 17 00:00:00 2001 From: cosmosninja Date: Thu, 6 Dec 2007 20:57:42 +0000 Subject: [PATCH] Applied Paul's patch so the number of laps per track per grand prix can be specified in the *.cup files. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1322 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- data/all.cup | 4 +++- data/gotm.cup | 1 + data/island.cup | 4 +++- data/tuxkart.cup | 1 + data/volcano.cup | 4 +++- src/cup_data.cpp | 1 + src/cup_data.hpp | 4 ++++ src/race_manager.cpp | 2 +- 8 files changed, 17 insertions(+), 4 deletions(-) diff --git a/data/all.cup b/data/all.cup index b9d99631c..8ac2c9461 100644 --- a/data/all.cup +++ b/data/all.cup @@ -3,6 +3,8 @@ (supertuxkart-cup (name "All tracks") (description "All 13 tracks included in SuperTuxKart") - (tracks "beach" "startrack" "lighthouse" "volcano" "gownsbow" "islandtrack" "bsodcastle" "geekopeak" "littlevolcano" "olivermath" "race" "subseatrack" "tuxtrack")) + (tracks "beach" "startrack" "lighthouse" "volcano" "gownsbow" "islandtrack" "bsodcastle" "geekopeak" "littlevolcano" "olivermath" "race" "subseatrack" "tuxtrack") + (laps 2 3 4 3 2 2 3 3 3 4 5 3 2) +) ;; EOF ;; diff --git a/data/gotm.cup b/data/gotm.cup index 00e637e6b..748222d2e 100644 --- a/data/gotm.cup +++ b/data/gotm.cup @@ -5,6 +5,7 @@ (description "All seven tracks done by the Game of the month team") (herring "new") (tracks "beach" "lighthouse" "startrack" "volcano" "littlevolcano" "race" "subseatrack" ) + (laps 2 4 3 3 3 5 3) ) ;; EOF ;; diff --git a/data/island.cup b/data/island.cup index e72c9fae6..0abb73cd8 100644 --- a/data/island.cup +++ b/data/island.cup @@ -3,6 +3,8 @@ (supertuxkart-cup (name "All Island Tracks") (description "All three tracks on Islands") - (tracks "beach" "lighthouse" "islandtrack" )) + (tracks "beach" "lighthouse" "islandtrack" ) + (laps 2 4 2) +) ;; EOF ;; diff --git a/data/tuxkart.cup b/data/tuxkart.cup index adb223038..4af4ae194 100644 --- a/data/tuxkart.cup +++ b/data/tuxkart.cup @@ -5,6 +5,7 @@ (description "The original five tracks included in TuxKart") (herring "old") (tracks "olivermath" "gownsbow" "bsodcastle" "geekopeak" "tuxtrack") + (laps 4 2 3 3 2) ) ;; EOF ;; diff --git a/data/volcano.cup b/data/volcano.cup index b9934e2bc..ccb97ec79 100644 --- a/data/volcano.cup +++ b/data/volcano.cup @@ -3,6 +3,8 @@ (supertuxkart-cup (name "Volcano Tracks") (description "All four tracks with Volcanos") - (tracks "volcano" "bsodcastle" "geekopeak" "littlevolcano" )) + (tracks "volcano" "bsodcastle" "geekopeak" "littlevolcano" ) + (laps 3 3 3 3) +) ;; EOF ;; diff --git a/src/cup_data.cpp b/src/cup_data.cpp index d1a6ca59c..e5e7a5cbd 100644 --- a/src/cup_data.cpp +++ b/src/cup_data.cpp @@ -44,6 +44,7 @@ CupData::CupData(const std::string filename_) lisp->get ("description", m_description ); lisp->get ("herring", m_herring_style); lisp->getVector("tracks", m_tracks ); + lisp->getVector("laps", m_laps ); } catch(std::exception& err) { diff --git a/src/cup_data.hpp b/src/cup_data.hpp index 78300b1a7..544d65cf5 100644 --- a/src/cup_data.hpp +++ b/src/cup_data.hpp @@ -39,6 +39,9 @@ class CupData means the filename of the .track file without .track extension (ie. 'volcano') */ std::vector m_tracks; + /** The number of laps that each track should be raced, in the right + * order*/ + std::vector m_laps; public: @@ -51,6 +54,7 @@ public: const std::string& getFilename () const { return m_filename; } const std::string& getTrack(size_t track_index) const { assert(track_index < m_tracks.size()); return m_tracks[track_index]; } size_t getTrackCount() const { return m_tracks.size(); } + const int& getLaps(size_t lap_index) const { assert(lap_index < m_tracks.size()); return m_laps[lap_index]; } } ; // CupData diff --git a/src/race_manager.cpp b/src/race_manager.cpp index b9cfe36d6..2e80695d9 100644 --- a/src/race_manager.cpp +++ b/src/race_manager.cpp @@ -96,7 +96,7 @@ GrandPrixMode::start_race(int n) RaceSetup raceSetup; raceSetup.m_mode = RaceSetup::RM_GRAND_PRIX; raceSetup.m_difficulty = m_difficulty; - raceSetup.m_num_laps = 2; + raceSetup.m_num_laps = m_cup.getLaps(n); raceSetup.m_track = m_cup.getTrack(n); raceSetup.m_karts.resize(m_karts.size()); raceSetup.m_players.resize(m_players.size());