1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 02:32:55 +08:00

Fix GetMostCommonBeatLength returning zero in case of not timing points

This commit is contained in:
Dean Herbert 2023-05-08 16:55:48 +09:00
parent 1b7dd32eb1
commit d6ce56e6b1

View File

@ -107,9 +107,12 @@ namespace osu.Game.Beatmaps
// Aggregate durations into a set of (beatLength, duration) tuples for each beat length // Aggregate durations into a set of (beatLength, duration) tuples for each beat length
.GroupBy(t => Math.Round(t.beatLength * 1000) / 1000) .GroupBy(t => Math.Round(t.beatLength * 1000) / 1000)
.Select(g => (beatLength: g.Key, duration: g.Sum(t => t.duration))) .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(); .OrderByDescending(i => i.duration).FirstOrDefault();
if (mostCommon.beatLength == 0)
return TimingControlPoint.DEFAULT_BEAT_LENGTH;
return mostCommon.beatLength; return mostCommon.beatLength;
} }