mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 09:22:54 +08:00
Disallow negative / zero repeat counts (and fix off-by-one)
This commit is contained in:
parent
09273d1da9
commit
d56accaef1
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user