Modified my recent checks in highscores : on failure, ignore bogus entries instead of aborting

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5514 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-06-13 18:30:07 +00:00
parent 4afb71659f
commit c7ff68c1ab
2 changed files with 18 additions and 3 deletions

View File

@ -106,7 +106,16 @@ void HighscoreManager::loadHighscores()
for(unsigned int i=0; i<root->getNumNodes(); i++)
{
const XMLNode *node = root->getNode(i);
Highscores *highscores = new Highscores(*node);
Highscores *highscores;
try
{
highscores = new Highscores(*node);
}
catch (std::logic_error& e)
{
fprintf(stderr, "Invalid highscore entry will be skipped : %s\n", e.what());
continue;
}
m_all_scores.push_back(highscores);
} // next entry

View File

@ -83,8 +83,14 @@ void Highscores::readEntry(const XMLNode &node)
entry->get("kartname", &m_kart_name[i] );
// a non-empty entry needs a non-empty kart name.
assert(m_time[i] <= 0.0f || m_kart_name[i].size() > 0);
assert(m_time[i] <= 0.0f || m_name[i].size() > 0);
if (!(m_time[i] <= 0.0f || m_kart_name[i].size() > 0))
{
throw std::logic_error("Invalid highscore entry : empty kart name");
}
if (!(m_time[i] <= 0.0f || m_name[i].size() > 0))
{
throw std::logic_error("Invalid highscore entry : empty kart name");
}
}
} // readEntry