fixed bug where if the most recent run is a reset, the PB will be null

This commit is contained in:
Lexi Quinn 2022-06-13 18:33:00 +10:00
parent 89ce052dda
commit 16310e7c17

View File

@ -404,6 +404,9 @@ void resize(int i)
void calculatePB() void calculatePB()
{ {
bool valid = false; bool valid = false;
//TODO: come back to this value, this function should be redone a little
int PBsfound = 0;
int bestMS = INT_MAX; int bestMS = INT_MAX;
int bestAttempt = 0; int bestAttempt = 0;
@ -417,11 +420,12 @@ void calculatePB()
valid = false; valid = false;
} }
if (valid && pastRuns[run + segCount - 1].ms < bestMS) { if (valid && pastRuns[run + segCount - 1].ms < bestMS) {
PBsfound++;
bestAttempt = i; bestAttempt = i;
bestMS = pastRuns[run + segCount - 1].ms; bestMS = pastRuns[run + segCount - 1].ms;
} }
} }
if (valid) if (PBsfound > 0)
for (int i = 0; i < segCount; i++) for (int i = 0; i < segCount; i++)
pbrun[i].ms = pastRuns[(bestAttempt * segCount) + i].ms; pbrun[i].ms = pastRuns[(bestAttempt * segCount) + i].ms;
} }