From d56accaef1ab193f33d214a16e53a56a8e22be49 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 5 Feb 2020 15:32:51 +0900 Subject: [PATCH] Disallow negative / zero repeat counts (and fix off-by-one) --- .../Components/Timeline/TimelineHitObjectBlueprint.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs index 2ac35534f4..b2da1577d0 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineHitObjectBlueprint.cs @@ -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: