Bool to string fix for challenges. String to bool applied for

achievements.
This commit is contained in:
gl3nn 2014-02-02 15:50:10 +01:00
parent 9b2b6c1c78
commit 06b7ba09f5
3 changed files with 5 additions and 4 deletions

View File

@ -131,13 +131,14 @@ MapAchievement::MapAchievement(const AchievementInfo * info)
// ============================================================================ // ============================================================================
void MapAchievement::load(XMLNode * input) void MapAchievement::load(XMLNode * input)
{ {
std::string achieved(""); bool achieved = false;
input->get("achieved", &achieved); input->get("achieved", &achieved);
if(achieved == "true") if(achieved)
{ {
m_achieved = true; m_achieved = true;
return; return;
} }
std::vector<XMLNode*> xml_entries; std::vector<XMLNode*> xml_entries;
input->getNodes("entry", xml_entries); input->getNodes("entry", xml_entries);
for (unsigned int n=0; n < xml_entries.size(); n++) for (unsigned int n=0; n < xml_entries.size(); n++)

View File

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

View File

@ -72,7 +72,7 @@ namespace StringUtils
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Specialisiation for bools to return 'true' or 'false'*/ /** Specialisiation for bools to return 'true' or 'false'*/
inline std::string toString(bool &b) inline std::string toString(const bool& b)
{ {
return (b ? "true" : "false"); return (b ? "true" : "false");
} // toString(bool) } // toString(bool)