I think I fixed a logic error in the bestsegs run calculator

This commit is contained in:
Lexi Quinn 2022-01-16 03:15:20 +11:00
parent aab5682965
commit f0dc3bde84
2 changed files with 13 additions and 9 deletions

View File

@ -37,10 +37,10 @@ yet and may not ever be
### [Splits.io](https://splits.io/) ### [Splits.io](https://splits.io/)
[X] Import game, category and segment names from generic format - [X] Import game, category and segment names from generic format
[] Import all information the generic format support i.e. run histories - [ ] Import all information the generic format support i.e. run histories
[] Export runs in the generic format - [ ] Export runs in the generic format
### [Speedrun.com](https://www.speedrun.com/) ### [Speedrun.com](https://www.speedrun.com/)
[] Submit runs - [ ] Submit runs

View File

@ -436,13 +436,17 @@ void calculateBestSegs()
if (attempts == 0) if (attempts == 0)
return; return;
for (int i = 0; i < segCount; i++) { for (int i = 0; i < segCount; i++) {
int bms = INT_MAX; int bestDuration = INT_MAX;
for (int j = 0; j < attempts; j++) { for (int j = 0; j < attempts; j++) {
int cms = pastRuns[(j * segCount) + i].ms; int duration = pastRuns[(j * segCount) + i].ms;
if (cms != 0 && cms < bms) if (i != 0)
bms = cms; duration -= bestsegs[i-1].ms;
if (duration != 0 && duration < bestDuration)
bestDuration = duration;
} }
bestsegs[i].ms = bms; bestsegs[i].ms = bestDuration;
if (i != 0)
bestsegs[i].ms += bestsegs[i-1].ms;
} }
} }