From c7ff68c1ab20af3912e1d1ab3d8e98d4ce7e07a8 Mon Sep 17 00:00:00 2001 From: auria Date: Sun, 13 Jun 2010 18:30:07 +0000 Subject: [PATCH] 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 --- src/race/highscore_manager.cpp | 11 ++++++++++- src/race/highscores.cpp | 10 ++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/race/highscore_manager.cpp b/src/race/highscore_manager.cpp index 92c80c260..6748c8aa7 100644 --- a/src/race/highscore_manager.cpp +++ b/src/race/highscore_manager.cpp @@ -106,7 +106,16 @@ void HighscoreManager::loadHighscores() for(unsigned int i=0; igetNumNodes(); 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 diff --git a/src/race/highscores.cpp b/src/race/highscores.cpp index 5f3468179..80313ccdc 100644 --- a/src/race/highscores.cpp +++ b/src/race/highscores.cpp @@ -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