Made the story mode xml file format more compact by saving only the

highest level at which a challenge was solved (lower levels will
automatically be marked as solved).
This commit is contained in:
hiker 2014-02-22 11:44:21 +11:00
parent 90343ff276
commit b4099b5354

View File

@ -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" <easy solved=\""
<< isSolved(RaceManager::DIFFICULTY_EASY)
<< L"\"/>\n"
<< L" <medium solved=\""
<< isSolved(RaceManager::DIFFICULTY_MEDIUM)
<< L"\"/>\n"
<< L" <hard solved=\""
<< isSolved(RaceManager::DIFFICULTY_HARD)
<< L"\"/>\n"
<< L" </" << m_data->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