Small improvement to challenge file, to add a textual player name next to the player ID, to make it easier to read

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12510 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2013-02-17 20:31:26 +00:00
parent c51b746097
commit d9af2f9706
3 changed files with 14 additions and 4 deletions

View File

@ -231,12 +231,12 @@ void GameSlot::grandPrixFinished()
//-----------------------------------------------------------------------------
void GameSlot::save(std::ofstream& out)
void GameSlot::save(std::ofstream& out, const std::string& name)
{
out << " <gameslot playerID=\"" << m_player_unique_id.c_str()
<< "\" kart=\"" << m_kart_ident.c_str()
<< "\" firstTime=\"" << (m_first_time ? "true" : "false")
<< "\">\n";
<< "\"> <!-- " << name.c_str() << " -->\n";
std::map<std::string, Challenge*>::const_iterator i;
for(i = m_challenges_state.begin();
i != m_challenges_state.end(); i++)

View File

@ -117,7 +117,7 @@ public:
void raceFinished ();
void grandPrixFinished ();
void save (std::ofstream& file);
void save (std::ofstream& file, const std::string& name);
void setCurrentChallenge(const std::string &challenge_id);
/** Returns the number of points accumulated. */

View File

@ -275,7 +275,17 @@ void UnlockManager::save()
std::map<std::string, GameSlot*>::iterator it;
for (it = m_game_slots.begin(); it != m_game_slots.end(); it++)
{
it->second->save(challenge_file);
std::string name = "unknown player";
for (int i = 0; i < UserConfigParams::m_all_players.size(); i++)
{
if (UserConfigParams::m_all_players[i].getUniqueID() == it->second->getPlayerID())
{
name = core::stringc(UserConfigParams::m_all_players[i].getName().c_str()).c_str();
break;
}
}
it->second->save(challenge_file, name);
}
challenge_file << "</challenges>\n\n";