From 16310e7c172cfd3e66ca267c2002193ac2824f7a Mon Sep 17 00:00:00 2001 From: Lexi Quinn Date: Mon, 13 Jun 2022 18:33:00 +1000 Subject: [PATCH] fixed bug where if the most recent run is a reset, the PB will be null --- src/timer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/timer.c b/src/timer.c index eb40e55..e3c392d 100644 --- a/src/timer.c +++ b/src/timer.c @@ -404,6 +404,9 @@ void resize(int i) void calculatePB() { bool valid = false; + //TODO: come back to this value, this function should be redone a little + int PBsfound = 0; + int bestMS = INT_MAX; int bestAttempt = 0; @@ -417,11 +420,12 @@ void calculatePB() valid = false; } if (valid && pastRuns[run + segCount - 1].ms < bestMS) { + PBsfound++; bestAttempt = i; bestMS = pastRuns[run + segCount - 1].ms; } } - if (valid) + if (PBsfound > 0) for (int i = 0; i < segCount; i++) pbrun[i].ms = pastRuns[(bestAttempt * segCount) + i].ms; }