Fix spinner requirements being susceptible to FP precision

This commit is contained in:
Dan Balasescu 2023-10-04 13:53:33 +09:00
parent 72cbc3b9cf
commit 48209872bf
1 changed files with 5 additions and 2 deletions

View File

@ -70,8 +70,11 @@ protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, I
double secondsDuration = Duration / 1000;
SpinsRequired = (int)(minRps * secondsDuration);
MaximumBonusSpins = Math.Max(0, (int)(maxRps * secondsDuration) - SpinsRequired - bonus_spins_gap);
// Allow a 0.1ms floating point precision error in the calculation of the duration.
const double duration_error = 0.0001;
SpinsRequired = (int)(minRps * secondsDuration + duration_error);
MaximumBonusSpins = Math.Max(0, (int)(maxRps * secondsDuration + duration_error) - SpinsRequired - bonus_spins_gap);
}
protected override void CreateNestedHitObjects(CancellationToken cancellationToken)