Don't save random GPs (which can not be continued anyway), and allow only

one saved data set (for each GP and difficulty). Previously saved 'random'
GPs (which can't be continued anyway) are deleted now, cleaning up the
config.xml file.
This commit is contained in:
hiker 2015-08-03 15:10:36 +10:00
parent 085627364c
commit a852cf94fb

View File

@ -546,7 +546,7 @@ void RaceManager::saveGP()
m_saved_gp->setKarts(m_kart_status);
m_saved_gp->setNextTrack(m_track_number);
}
else
else if (m_grand_prix.getId() != "random")
{
m_saved_gp = new SavedGrandPrix(
StateManager::get()->getActivePlayerProfile(0)->getUniqueID(),
@ -556,12 +556,30 @@ void RaceManager::saveGP()
m_track_number,
m_grand_prix.getReverseType(),
m_kart_status);
// If a new GP is saved, delete any other saved data for this
// GP at the same difficulty (even if #karts is different, otherwise
// the user has to remember the number of AI karts, with no indication
// on which ones are saved).
for (unsigned int i = 0;
i < UserConfigParams::m_saved_grand_prix_list.size();)
{
// Delete other save files (and random GP, which should never
// have been saved in the first place)
const SavedGrandPrix &sgp = UserConfigParams::m_saved_grand_prix_list[i];
if (sgp.getGPID() == "random" ||
(sgp.getGPID() == m_saved_gp->getGPID() &&
sgp.getDifficulty() == m_saved_gp->getDifficulty()) )
{
UserConfigParams::m_saved_grand_prix_list.erase(i);
}
else i++;
}
UserConfigParams::m_saved_grand_prix_list.push_back(m_saved_gp);
}
user_config->saveConfig();
}
} // saveGP
//-----------------------------------------------------------------------------