diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index d1db567b..db6917c7 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -213,6 +213,7 @@ void Game::init(void) tele_crewstats.resize(6); quick_crewstats.resize(6); besttimes.resize(6, -1); + ::memset(bestframes, -1, sizeof(bestframes) * sizeof(int)); besttrinkets.resize(6, -1); bestlives.resize(6, -1); bestrank.resize(6, -1); @@ -1447,9 +1448,12 @@ void Game::updatestate() if (trinkets() >= timetrialshinytarget) timetrialrank++; if (deathcounts == 0) timetrialrank++; - if (timetrialresulttime < besttimes[timetriallevel] || besttimes[timetriallevel]==-1) + if (timetrialresulttime < besttimes[timetriallevel] + || (timetrialresulttime == besttimes[timetriallevel] && timetrialresultframes < bestframes[timetriallevel]) + || besttimes[timetriallevel]==-1) { besttimes[timetriallevel] = timetrialresulttime; + bestframes[timetriallevel] = timetrialresultframes; } if (trinkets() > besttrinkets[timetriallevel] || besttrinkets[timetriallevel]==-1) { @@ -4549,6 +4553,7 @@ void Game::deletestats() for (int i = 0; i < 6; i++) { besttimes[i] = -1; + bestframes[i] = -1; besttrinkets[i] = -1; bestlives[i] = -1; bestrank[i] = -1; @@ -4648,6 +4653,19 @@ void Game::loadstats() } } + if (pKey == "bestframes") + { + std::string TextString = pText; + if (TextString.length()) + { + std::vector values = split(TextString, ','); + for (size_t i = 0; i < std::min(sizeof(bestframes), values.size()); i++) + { + bestframes[i] = atoi(values[i].c_str()); + } + } + } + if (pKey == "besttrinkets") { std::string TextString = (pText); @@ -4961,6 +4979,15 @@ void Game::savestats() msg->LinkEndChild( doc.NewText( s_besttimes.c_str() )); dataNode->LinkEndChild( msg ); + std::string s_bestframes; + for (size_t i = 0; i < sizeof(bestframes); i++) + { + s_bestframes += help.String(bestframes[i]) + ","; + } + msg = doc.NewElement( "bestframes" ); + msg->LinkEndChild( doc.NewText( s_bestframes.c_str() ) ); + dataNode->LinkEndChild( msg ); + std::string s_besttrinkets; for(size_t i = 0; i < besttrinkets.size(); i++ ) { diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 76207c9e..2ef0891d 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -297,6 +297,7 @@ public: std::vectorbesttimes; + int bestframes[6]; std::vectorbesttrinkets; std::vectorbestlives; std::vector bestrank;