mirror of https://github.com/ppy/osu
Handle no-duration single-object edge case
This commit is contained in:
parent
547b3d8bed
commit
a0de1cbfd0
|
@ -16,23 +16,11 @@ public class ModTimeRampTest
|
||||||
private const double duration = 9000;
|
private const double duration = 9000;
|
||||||
|
|
||||||
private TrackVirtual track;
|
private TrackVirtual track;
|
||||||
private IBeatmap beatmap;
|
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp()
|
public void SetUp()
|
||||||
{
|
{
|
||||||
track = new TrackVirtual(20_000);
|
track = new TrackVirtual(20_000);
|
||||||
beatmap = new Beatmap
|
|
||||||
{
|
|
||||||
HitObjects =
|
|
||||||
{
|
|
||||||
new Spinner
|
|
||||||
{
|
|
||||||
StartTime = start_time,
|
|
||||||
Duration = duration
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestCase(0, 1)]
|
[TestCase(0, 1)]
|
||||||
|
@ -43,6 +31,7 @@ public void SetUp()
|
||||||
[TestCase(15000, 1.5)]
|
[TestCase(15000, 1.5)]
|
||||||
public void TestModWindUp(double time, double expectedRate)
|
public void TestModWindUp(double time, double expectedRate)
|
||||||
{
|
{
|
||||||
|
var beatmap = createSingleSpinnerBeatmap();
|
||||||
var mod = new ModWindUp();
|
var mod = new ModWindUp();
|
||||||
mod.ApplyToBeatmap(beatmap);
|
mod.ApplyToBeatmap(beatmap);
|
||||||
mod.ApplyToTrack(track);
|
mod.ApplyToTrack(track);
|
||||||
|
@ -60,6 +49,7 @@ public void TestModWindUp(double time, double expectedRate)
|
||||||
[TestCase(15000, 0.5)]
|
[TestCase(15000, 0.5)]
|
||||||
public void TestModWindDown(double time, double expectedRate)
|
public void TestModWindDown(double time, double expectedRate)
|
||||||
{
|
{
|
||||||
|
var beatmap = createSingleSpinnerBeatmap();
|
||||||
var mod = new ModWindDown
|
var mod = new ModWindDown
|
||||||
{
|
{
|
||||||
FinalRate = { Value = 0.5 }
|
FinalRate = { Value = 0.5 }
|
||||||
|
@ -72,11 +62,52 @@ public void TestModWindDown(double time, double expectedRate)
|
||||||
Assert.That(mod.SpeedChange.Value, Is.EqualTo(expectedRate));
|
Assert.That(mod.SpeedChange.Value, Is.EqualTo(expectedRate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(0, 1)]
|
||||||
|
[TestCase(start_time, 1)]
|
||||||
|
[TestCase(2 * start_time, 1.5)]
|
||||||
|
public void TestZeroDurationMap(double time, double expectedRate)
|
||||||
|
{
|
||||||
|
var beatmap = createSingleObjectBeatmap();
|
||||||
|
var mod = new ModWindUp();
|
||||||
|
mod.ApplyToBeatmap(beatmap);
|
||||||
|
mod.ApplyToTrack(track);
|
||||||
|
|
||||||
|
seekTrackAndUpdateMod(mod, time);
|
||||||
|
|
||||||
|
Assert.That(mod.SpeedChange.Value, Is.EqualTo(expectedRate));
|
||||||
|
}
|
||||||
|
|
||||||
private void seekTrackAndUpdateMod(ModTimeRamp mod, double time)
|
private void seekTrackAndUpdateMod(ModTimeRamp mod, double time)
|
||||||
{
|
{
|
||||||
track.Seek(time);
|
track.Seek(time);
|
||||||
// update the mod via a fake playfield to re-calculate the current rate.
|
// update the mod via a fake playfield to re-calculate the current rate.
|
||||||
mod.Update(null);
|
mod.Update(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Beatmap createSingleSpinnerBeatmap()
|
||||||
|
{
|
||||||
|
return new Beatmap
|
||||||
|
{
|
||||||
|
HitObjects =
|
||||||
|
{
|
||||||
|
new Spinner
|
||||||
|
{
|
||||||
|
StartTime = start_time,
|
||||||
|
Duration = duration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Beatmap createSingleObjectBeatmap()
|
||||||
|
{
|
||||||
|
return new Beatmap
|
||||||
|
{
|
||||||
|
HitObjects =
|
||||||
|
{
|
||||||
|
new HitCircle { StartTime = start_time }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public virtual void ApplyToBeatmap(IBeatmap beatmap)
|
||||||
|
|
||||||
public virtual void Update(Playfield playfield)
|
public virtual void Update(Playfield playfield)
|
||||||
{
|
{
|
||||||
applyRateAdjustment((track.CurrentTime - beginRampTime) / (finalRateTime - beginRampTime));
|
applyRateAdjustment((track.CurrentTime - beginRampTime) / Math.Max(1, finalRateTime - beginRampTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue