1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 15:12:57 +08:00

Disallow negative / zero repeat counts (and fix off-by-one)

This commit is contained in:
Dean Herbert 2020-02-05 15:32:51 +09:00
parent 09273d1da9
commit d56accaef1

View File

@ -119,7 +119,14 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
switch (hitObject)
{
case IHasRepeats repeatHitObject:
repeatHitObject.RepeatCount = (int)((time - hitObject.StartTime) / (repeatHitObject.Duration / repeatHitObject.RepeatCount));
// find the number of repeats which can fit in the requested time.
var lengthOfOneRepeat = repeatHitObject.Duration / (repeatHitObject.RepeatCount + 1);
var proposedCount = (int)((time - hitObject.StartTime) / lengthOfOneRepeat) - 1;
if (proposedCount == repeatHitObject.RepeatCount || proposedCount < 0)
return;
repeatHitObject.RepeatCount = proposedCount;
break;
case IHasEndTime endTimeHitObject: