mirror of https://github.com/ppy/osu
Fix `GetMostCommonBeatLength` returning zero in case of not timing points
This commit is contained in:
parent
1b7dd32eb1
commit
d6ce56e6b1
|
@ -107,9 +107,12 @@ public double GetMostCommonBeatLength()
|
|||
// Aggregate durations into a set of (beatLength, duration) tuples for each beat length
|
||||
.GroupBy(t => Math.Round(t.beatLength * 1000) / 1000)
|
||||
.Select(g => (beatLength: g.Key, duration: g.Sum(t => t.duration)))
|
||||
// Get the most common one, or 0 as a suitable default
|
||||
// Get the most common one, or 0 as a suitable default (see handling below)
|
||||
.OrderByDescending(i => i.duration).FirstOrDefault();
|
||||
|
||||
if (mostCommon.beatLength == 0)
|
||||
return TimingControlPoint.DEFAULT_BEAT_LENGTH;
|
||||
|
||||
return mostCommon.beatLength;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue