From 6d07189474276bc242ae066f91030f98d3f036c0 Mon Sep 17 00:00:00 2001 From: Deve Date: Tue, 4 Nov 2014 20:27:01 +0100 Subject: [PATCH] Don't allow doubled tracks in random GP. Otherwise track number limit wouldn't have sense. --- src/race/grand_prix_data.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/race/grand_prix_data.cpp b/src/race/grand_prix_data.cpp index 92e999d64..cc91402b1 100644 --- a/src/race/grand_prix_data.cpp +++ b/src/race/grand_prix_data.cpp @@ -135,10 +135,24 @@ void GrandPrixData::changeTrackNumber(const unsigned int number_of_tracks, if (PlayerManager::getCurrentPlayer()->isLocked(track->getIdent())) continue; + + bool is_already_added = false; + for (unsigned int i = 0; i < m_tracks.size(); i++) + { + if (m_tracks[i] == id) + { + is_already_added = true; + break; + } + } + + if (!is_already_added) + { + m_tracks.push_back(id); + m_laps.push_back(track->getDefaultNumberOfLaps()); + m_reversed.push_back(false); // This will be changed later in the code + } - m_tracks.push_back(id); - m_laps.push_back(track->getDefaultNumberOfLaps()); - m_reversed.push_back(false); // This will be changed later in the code track_indices.erase(track_indices.begin()+index); } }