diff --git a/src/challenges/challenge_status.cpp b/src/challenges/challenge_status.cpp index 423f0a14a..71ce2548c 100644 --- a/src/challenges/challenge_status.cpp +++ b/src/challenges/challenge_status.cpp @@ -43,35 +43,29 @@ void ChallengeStatus::load(const XMLNode* challenges_node) m_data->getId().c_str()); return; } - const XMLNode* easy = node->getNode("easy"); - const XMLNode* medium = node->getNode("medium"); - const XMLNode* hard = node->getNode("hard"); m_state[0] = CH_INACTIVE; m_state[1] = CH_INACTIVE; m_state[2] = CH_INACTIVE; - if (easy != NULL) + std::string solved; + if (node->get("solved", &solved)) { - bool finished = false; - easy->get("solved", &finished); + if (solved == "easy") + m_state[0] = CH_SOLVED; + else if (solved == "medium") + { + m_state[0] = CH_SOLVED; + m_state[1] = CH_SOLVED; + } + else if (solved == "hard") + { + m_state[0] = CH_SOLVED; + m_state[1] = CH_SOLVED; + m_state[2] = CH_SOLVED; + } + } // if has 'solved' attribute - if (finished) m_state[0] = CH_SOLVED; - } - if (medium != NULL) - { - bool finished = false; - medium->get("solved", &finished); - - if (finished) m_state[1] = CH_SOLVED; - } - if (hard != NULL) - { - bool finished = false; - hard->get("solved", &finished); - - if (finished) m_state[2] = CH_SOLVED; - } } // load //----------------------------------------------------------------------------- @@ -90,15 +84,13 @@ void ChallengeStatus::setSolved(RaceManager::Difficulty d) void ChallengeStatus::save(UTFWriter& writer) { - writer << L" <"<< m_data->getId() << L">\n" - << L" \n" - << L" \n" - << L" \n" - << L" getId() << L">\n"; + writer << L" <" << m_data->getId(); + if (isSolved(RaceManager::DIFFICULTY_HARD)) + writer << L" solved=\"hard\"/>\n"; + else if (isSolved(RaceManager::DIFFICULTY_MEDIUM)) + writer << L" solved=\"medium\"/>\n"; + else if (isSolved(RaceManager::DIFFICULTY_EASY)) + writer << L" solved=\"easy\"/>\n"; + else + writer << L" solved=\"none\"/>\n"; } // save