Simplified function by removing duplicated code.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10105 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
3a6d1c16b5
commit
04087dd0b1
@ -241,33 +241,21 @@ void TrackManager::removeTrack(const std::string &ident)
|
|||||||
void TrackManager::updateGroups(const Track* track)
|
void TrackManager::updateGroups(const Track* track)
|
||||||
{
|
{
|
||||||
const std::vector<std::string>& new_groups = track->getGroups();
|
const std::vector<std::string>& new_groups = track->getGroups();
|
||||||
const bool isArena = track->isArena();
|
|
||||||
|
Group2Indices &group_2_indices = track->isArena() ? m_arena_groups
|
||||||
|
: m_track_groups;
|
||||||
|
std::vector<std::string> &group_names = track->isArena()
|
||||||
|
? m_arena_group_names
|
||||||
|
: m_track_group_names;
|
||||||
|
|
||||||
const unsigned int groups_amount = new_groups.size();
|
const unsigned int groups_amount = new_groups.size();
|
||||||
for(unsigned int i=0; i<groups_amount; i++)
|
for(unsigned int i=0; i<groups_amount; i++)
|
||||||
{
|
{
|
||||||
if (isArena)
|
bool group_exists = group_2_indices.find(new_groups[i])
|
||||||
{
|
!= group_2_indices.end();
|
||||||
// update the list of group names if necessary
|
if(!group_exists)
|
||||||
const bool isInArenaGroupsList =
|
group_names.push_back(new_groups[i]);
|
||||||
(m_arena_groups.find(new_groups[i]) != m_arena_groups.end());
|
group_2_indices[new_groups[i]].push_back(m_tracks.size()-1);
|
||||||
if (!isInArenaGroupsList)
|
|
||||||
m_arena_group_names.push_back(new_groups[i]);
|
|
||||||
|
|
||||||
// add this track to its group
|
|
||||||
m_arena_groups[new_groups[i]].push_back(m_tracks.size()-1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// update the list of group names if necessary
|
|
||||||
const bool isInTrackGroupsList =
|
|
||||||
(m_track_groups.find(new_groups[i]) != m_track_groups.end());
|
|
||||||
if (!isInTrackGroupsList)
|
|
||||||
m_track_group_names.push_back(new_groups[i]);
|
|
||||||
|
|
||||||
// add this track to its group
|
|
||||||
m_track_groups[new_groups[i]].push_back(m_tracks.size()-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} // updateGroups
|
} // updateGroups
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user