challenges.xml no longer contain a player name, only a player ID, so it no more needs to be UTF-32. Back to good old ASCII :)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11152 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2012-04-25 19:41:23 +00:00
parent caf8083b62
commit ef750af24e
5 changed files with 17 additions and 17 deletions

View File

@ -91,16 +91,16 @@ void Challenge::setSolved(RaceManager::Difficulty d)
//-----------------------------------------------------------------------------
const wchar_t* boolstr(bool b)
const char* boolstr(bool b)
{
return (b ? L"true" : L"false");
return (b ? "true" : "false");
}
void Challenge::save(XMLWriter& writer)
void Challenge::save(std::ofstream& writer)
{
writer << L" <" << core::stringw(m_data->getId().c_str()) << L">\n"
<< L" <easy solved=\"" << boolstr(isSolved(RaceManager::RD_EASY)) << L"\"/>\n"
<< L" <medium solved=\"" << boolstr(isSolved(RaceManager::RD_MEDIUM)) << L"\"/>\n"
<< L" <hard solved=\"" << boolstr(isSolved(RaceManager::RD_HARD)) << L"\"/>\n"
<< L" </" << core::stringw(m_data->getId().c_str()) << L">\n";
writer << " <" << m_data->getId().c_str() << ">\n"
<< " <easy solved=\"" << boolstr(isSolved(RaceManager::RD_EASY)) << "\"/>\n"
<< " <medium solved=\"" << boolstr(isSolved(RaceManager::RD_MEDIUM)) << "\"/>\n"
<< " <hard solved=\"" << boolstr(isSolved(RaceManager::RD_HARD)) << "\"/>\n"
<< " </" << m_data->getId().c_str() << ">\n";
} // save

View File

@ -62,7 +62,7 @@ public:
}
virtual ~Challenge() {};
void load(const XMLNode* config);
void save(XMLWriter& writer);
void save(std::ofstream& writer);
// ------------------------------------------------------------------------
bool isSolved(RaceManager::Difficulty d) const {return m_state[d]==CH_SOLVED; }

View File

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

View File

@ -96,7 +96,7 @@ public:
void raceFinished ();
void grandPrixFinished ();
void save (XMLWriter& file);
void save (std::ofstream& file);
int getPoints () const { return m_points; }

View File

@ -255,9 +255,10 @@ void UnlockManager::load()
void UnlockManager::save()
{
std::string filename = file_manager->getChallengeFile("challenges.xml");
XMLWriter challenge_file(filename.c_str());
std::ofstream challenge_file(filename.c_str(), std::ios::out);
if(!challenge_file.is_open())
if (!challenge_file.is_open())
{
std::cerr << "Failed to open " << filename << " for writing, challenges won't be saved\n";
return;
@ -266,7 +267,6 @@ void UnlockManager::save()
challenge_file << "<?xml version=\"1.0\"?>\n";
challenge_file << "<challenges>\n";
std::map<std::string, GameSlot*>::iterator it;
for (it = m_game_slots.begin(); it != m_game_slots.end(); it++)
{