Add reverse track functionality for GPs.
Fixes part of #503 (and #599 completely). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11019 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a5028ddd4f
commit
cb890d4f32
@ -1,25 +1,25 @@
|
||||
|
||||
<supertuxkart_grand_prix name="All Tracks">
|
||||
|
||||
<track id="hacienda" laps="3" />
|
||||
<track id="scotland" laps="3" />
|
||||
<track id="startrack" laps="3" />
|
||||
<track id="lighthouse" laps="4" />
|
||||
<track id="jungle" laps="3" />
|
||||
<track id="mines" laps="3" />
|
||||
<track id="islandtrack" laps="2" />
|
||||
<track id="sandtrack" laps="3" />
|
||||
<track id="fortmagma" laps="3" />
|
||||
<track id="snowtuxpeak" laps="3" />
|
||||
<track id="crescentcrossing" laps="2" />
|
||||
<track id="olivermath" laps="4" />
|
||||
<track id="farm" laps="3" />
|
||||
<track id="zengarden" laps="4" />
|
||||
<track id="city" laps="3" />
|
||||
<track id="xr591" laps="3" />
|
||||
<track id="minigolf" laps="3" />
|
||||
<track id="snowmountain" laps="3" />
|
||||
<track id="tuxtollway" laps="2" />
|
||||
<track id="subsea" laps="2" />
|
||||
<track id="hacienda" laps="3" reverse="false" />
|
||||
<track id="scotland" laps="3" reverse="false" />
|
||||
<track id="startrack" laps="3" reverse="false" />
|
||||
<track id="lighthouse" laps="4" reverse="false" />
|
||||
<track id="jungle" laps="3" reverse="false" />
|
||||
<track id="mines" laps="3" reverse="false" />
|
||||
<track id="islandtrack" laps="2" reverse="false" />
|
||||
<track id="sandtrack" laps="3" reverse="false" />
|
||||
<track id="fortmagma" laps="3" reverse="false" />
|
||||
<track id="snowtuxpeak" laps="3" reverse="false" />
|
||||
<track id="crescentcrossing" laps="2" reverse="false" />
|
||||
<track id="olivermath" laps="4" reverse="false" />
|
||||
<track id="farm" laps="3" reverse="false" />
|
||||
<track id="zengarden" laps="4" reverse="false" />
|
||||
<track id="city" laps="3" reverse="false" />
|
||||
<track id="xr591" laps="3" reverse="false" />
|
||||
<track id="minigolf" laps="3" reverse="false" />
|
||||
<track id="snowmountain" laps="3" reverse="false" />
|
||||
<track id="tuxtollway" laps="2" reverse="false" />
|
||||
<track id="subsea" laps="2" reverse="false" />
|
||||
|
||||
</supertuxkart_grand_prix>
|
||||
|
@ -1,11 +1,11 @@
|
||||
|
||||
<supertuxkart_grand_prix name="At World's End">
|
||||
|
||||
<track id="fortmagma" laps="3" />
|
||||
<track id="minigolf" laps="3" />
|
||||
<track id="xr591" laps="3" />
|
||||
<track id="mines" laps="3" />
|
||||
<track id="city" laps="3" />
|
||||
<track id="fortmagma" laps="3" reverse="false" />
|
||||
<track id="minigolf" laps="3" reverse="false" />
|
||||
<track id="xr591" laps="3" reverse="false" />
|
||||
<track id="mines" laps="3" reverse="false" />
|
||||
<track id="city" laps="3" reverse="false" />
|
||||
|
||||
</supertuxkart_grand_prix>
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
<supertuxkart_grand_prix name="Penguin Playground">
|
||||
|
||||
<track id="sandtrack" laps="3" />
|
||||
<track id="snowmountain" laps="3" />
|
||||
<track id="olivermath" laps="4" />
|
||||
<track id="scotland" laps="3" />
|
||||
<track id="jungle" laps="2" />
|
||||
<track id="sandtrack" laps="3" reverse="false" />
|
||||
<track id="snowmountain" laps="3" reverse="false" />
|
||||
<track id="olivermath" laps="4" reverse="false" />
|
||||
<track id="scotland" laps="3" reverse="false" />
|
||||
<track id="jungle" laps="2" reverse="false" />
|
||||
|
||||
</supertuxkart_grand_prix>
|
||||
|
@ -1,11 +1,11 @@
|
||||
|
||||
<supertuxkart_grand_prix name="Snag Drive">
|
||||
|
||||
<track id="islandtrack" laps="2" />
|
||||
<track id="tuxtollway" laps="2" />
|
||||
<track id="crescentcrossing" laps="2" />
|
||||
<track id="snowtuxpeak" laps="3" />
|
||||
<track id="subsea" laps="2" />
|
||||
<track id="islandtrack" laps="2" reverse="false" />
|
||||
<track id="tuxtollway" laps="2" reverse="false" />
|
||||
<track id="crescentcrossing" laps="2" reverse="false" />
|
||||
<track id="snowtuxpeak" laps="3" reverse="false" />
|
||||
<track id="subsea" laps="2" reverse="false" />
|
||||
|
||||
</supertuxkart_grand_prix>
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
|
||||
<supertuxkart_grand_prix name="To the Moon and Back">
|
||||
|
||||
<track id="lighthouse" laps="4" />
|
||||
<track id="startrack" laps="3" />
|
||||
<track id="hacienda" laps="3" />
|
||||
<track id="zengarden" laps="4" />
|
||||
<track id="farm" laps="3" />
|
||||
<track id="lighthouse" laps="4" reverse="false" />
|
||||
<track id="startrack" laps="3" reverse="false" />
|
||||
<track id="hacienda" laps="3" reverse="false" />
|
||||
<track id="zengarden" laps="4" reverse="false" />
|
||||
<track id="farm" laps="3" reverse="false" />
|
||||
|
||||
</supertuxkart_grand_prix>
|
||||
|
@ -73,22 +73,27 @@ GrandPrixData::GrandPrixData(const std::string filename) throw(std::logic_error)
|
||||
{
|
||||
std::string trackID;
|
||||
int numLaps;
|
||||
bool reversed;
|
||||
|
||||
const int idFound = node->get("id", &trackID );
|
||||
const int lapFound = node->get("laps", &numLaps );
|
||||
const int idFound = node->get("id", &trackID );
|
||||
const int lapFound = node->get("laps", &numLaps );
|
||||
const int reverseFound = node->get("reverse", &reversed );
|
||||
|
||||
if (!idFound || !lapFound)
|
||||
if (!idFound || !lapFound || !reverseFound)
|
||||
{
|
||||
fprintf(stderr, "/!\\ Error while trying to read grandprix file '%s' : "
|
||||
"<track> tag does not have id and laps attributes. \n", filename.c_str());
|
||||
"<track> tag does not have id, laps and reverse attributes. \n",
|
||||
filename.c_str());
|
||||
delete root;
|
||||
throw std::logic_error("File contents are incomplete or corrupt");
|
||||
}
|
||||
|
||||
m_tracks.push_back(trackID);
|
||||
m_laps.push_back(numLaps);
|
||||
m_reversed.push_back(reversed);
|
||||
|
||||
assert(m_tracks.size() == m_laps.size());
|
||||
assert(m_tracks.size() == m_laps.size() );
|
||||
assert(m_laps.size() == m_reversed.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -48,6 +48,9 @@ class GrandPrixData
|
||||
/** The number of laps that each track should be raced, in the right order */
|
||||
std::vector<int> m_laps;
|
||||
|
||||
/** Whether the track in question should be done in reverse mode */
|
||||
std::vector<bool> m_reversed;
|
||||
|
||||
public:
|
||||
|
||||
/** Load the GrandPrixData from the given filename */
|
||||
@ -63,7 +66,7 @@ public:
|
||||
/** @return the (potentially translated) user-visible description of the Grand Prix */
|
||||
//const irr::core::stringw& getDescription () const { return m_description; }
|
||||
|
||||
/** @return the internale name identifier of the Grand Prix (not translated) */
|
||||
/** @return the internal name identifier of the Grand Prix (not translated) */
|
||||
const std::string& getId () const { return m_id; }
|
||||
|
||||
const std::string& getFilename () const { return m_filename; }
|
||||
@ -71,6 +74,7 @@ public:
|
||||
return m_tracks[track_index]; }
|
||||
const std::vector<std::string>& getTracks() const {return m_tracks; }
|
||||
const std::vector<int>& getLaps() const {return m_laps; }
|
||||
const std::vector<bool>& getReverse() const {return m_reversed; }
|
||||
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];}
|
||||
|
@ -244,10 +244,12 @@ void RaceManager::computeRandomKartList()
|
||||
|
||||
void RaceManager::startNew()
|
||||
{
|
||||
if(m_major_mode==MAJOR_MODE_GRAND_PRIX) // GP: get tracks and laps from grand prix
|
||||
if(m_major_mode==MAJOR_MODE_GRAND_PRIX)
|
||||
{
|
||||
m_tracks = m_grand_prix.getTracks();
|
||||
m_num_laps = m_grand_prix.getLaps();
|
||||
// GP: get tracks, laps and reverse info from grand prix
|
||||
m_tracks = m_grand_prix.getTracks();
|
||||
m_num_laps = m_grand_prix.getLaps();
|
||||
m_reverse_track = m_grand_prix.getReverse();
|
||||
}
|
||||
assert(m_player_karts.size() > 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user