1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00

Read and write best time trial frames

This is basically just bolting on the "frames" part of a time trial
score. There's not enough space to properly show it on the time trial
select screen, maybe we can figure something out later. But I at least
want to implement the functionality now.
This commit is contained in:
Misa 2020-06-30 18:59:16 -07:00 committed by Ethan Lee
parent 42e6185b12
commit ee20067fc2
2 changed files with 29 additions and 1 deletions

View file

@ -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<std::string> 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++ )
{

View file

@ -297,6 +297,7 @@ public:
std::vector<int>besttimes;
int bestframes[6];
std::vector<int>besttrinkets;
std::vector<int>bestlives;
std::vector<int> bestrank;