2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2019-04-10 16:13:12 +08:00
|
|
|
|
using System;
|
2019-09-11 04:06:10 +08:00
|
|
|
|
using System.IO;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using System.Linq;
|
2021-08-30 13:12:30 +08:00
|
|
|
|
using NUnit.Framework;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Audio;
|
2018-10-23 13:38:27 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Beatmaps.Formats;
|
2021-08-30 13:12:30 +08:00
|
|
|
|
using osu.Game.Beatmaps.Legacy;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Beatmaps.Timing;
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using osu.Game.IO;
|
2021-07-20 19:15:43 +08:00
|
|
|
|
using osu.Game.Rulesets.Catch;
|
|
|
|
|
using osu.Game.Rulesets.Catch.Beatmaps;
|
2019-04-08 17:32:05 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2018-06-28 17:27:33 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2018-10-16 16:10:24 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Legacy;
|
2021-08-30 13:12:30 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2018-10-23 13:38:27 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu;
|
2018-08-17 09:04:00 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Skinning;
|
2021-08-30 13:12:30 +08:00
|
|
|
|
using osu.Game.Tests.Resources;
|
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Beatmaps.Formats
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class LegacyBeatmapDecoderTest
|
|
|
|
|
{
|
2018-10-23 13:38:27 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeBeatmapVersion()
|
|
|
|
|
{
|
2019-01-28 17:19:57 +08:00
|
|
|
|
using (var resStream = TestResources.OpenResource("beatmap-version.osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2018-10-23 13:38:27 +08:00
|
|
|
|
{
|
|
|
|
|
var decoder = Decoder.GetDecoder<Beatmap>(stream);
|
|
|
|
|
var working = new TestWorkingBeatmap(decoder.Decode(stream));
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(6, working.BeatmapInfo.BeatmapVersion);
|
|
|
|
|
Assert.AreEqual(6, working.Beatmap.BeatmapInfo.BeatmapVersion);
|
2019-04-10 16:13:12 +08:00
|
|
|
|
Assert.AreEqual(6, working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Array.Empty<Mod>()).BeatmapInfo.BeatmapVersion);
|
2018-10-23 13:38:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeBeatmapGeneral()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2019-01-28 17:19:57 +08:00
|
|
|
|
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
var beatmap = decoder.Decode(stream);
|
|
|
|
|
var beatmapInfo = beatmap.BeatmapInfo;
|
|
|
|
|
var metadata = beatmap.Metadata;
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", metadata.AudioFile);
|
|
|
|
|
Assert.AreEqual(0, beatmapInfo.AudioLeadIn);
|
|
|
|
|
Assert.AreEqual(164471, metadata.PreviewTime);
|
|
|
|
|
Assert.AreEqual(0.7f, beatmapInfo.StackLeniency);
|
2022-01-27 14:19:48 +08:00
|
|
|
|
Assert.IsTrue(beatmapInfo.Ruleset.OnlineID == 0);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Assert.IsFalse(beatmapInfo.LetterboxInBreaks);
|
|
|
|
|
Assert.IsFalse(beatmapInfo.SpecialStyle);
|
|
|
|
|
Assert.IsFalse(beatmapInfo.WidescreenStoryboard);
|
2021-09-12 22:45:27 +08:00
|
|
|
|
Assert.IsFalse(beatmapInfo.SamplesMatchPlaybackRate);
|
2021-08-25 02:53:27 +08:00
|
|
|
|
Assert.AreEqual(CountdownType.None, beatmapInfo.Countdown);
|
|
|
|
|
Assert.AreEqual(0, beatmapInfo.CountdownOffset);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeBeatmapEditor()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder();
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2019-01-28 17:19:57 +08:00
|
|
|
|
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
var beatmapInfo = decoder.Decode(stream).BeatmapInfo;
|
|
|
|
|
|
|
|
|
|
int[] expectedBookmarks =
|
|
|
|
|
{
|
|
|
|
|
11505, 22054, 32604, 43153, 53703, 64252, 74802, 85351,
|
|
|
|
|
95901, 106450, 116999, 119637, 130186, 140735, 151285,
|
|
|
|
|
161834, 164471, 175020, 185570, 196119, 206669, 209306
|
|
|
|
|
};
|
|
|
|
|
Assert.AreEqual(expectedBookmarks.Length, beatmapInfo.Bookmarks.Length);
|
|
|
|
|
for (int i = 0; i < expectedBookmarks.Length; i++)
|
|
|
|
|
Assert.AreEqual(expectedBookmarks[i], beatmapInfo.Bookmarks[i]);
|
|
|
|
|
Assert.AreEqual(1.8, beatmapInfo.DistanceSpacing);
|
|
|
|
|
Assert.AreEqual(4, beatmapInfo.BeatDivisor);
|
|
|
|
|
Assert.AreEqual(4, beatmapInfo.GridSize);
|
|
|
|
|
Assert.AreEqual(2, beatmapInfo.TimelineZoom);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeBeatmapMetadata()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder();
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2019-01-28 17:19:57 +08:00
|
|
|
|
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
var beatmap = decoder.Decode(stream);
|
|
|
|
|
var beatmapInfo = beatmap.BeatmapInfo;
|
|
|
|
|
var metadata = beatmap.Metadata;
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual("Renatus", metadata.Title);
|
|
|
|
|
Assert.AreEqual("Renatus", metadata.TitleUnicode);
|
|
|
|
|
Assert.AreEqual("Soleily", metadata.Artist);
|
|
|
|
|
Assert.AreEqual("Soleily", metadata.ArtistUnicode);
|
2021-11-04 17:46:26 +08:00
|
|
|
|
Assert.AreEqual("Gamu", metadata.Author.Username);
|
2021-11-11 16:19:53 +08:00
|
|
|
|
Assert.AreEqual("Insane", beatmapInfo.DifficultyName);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Assert.AreEqual(string.Empty, metadata.Source);
|
|
|
|
|
Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", metadata.Tags);
|
2021-11-12 16:45:05 +08:00
|
|
|
|
Assert.AreEqual(557821, beatmapInfo.OnlineID);
|
2022-01-12 22:42:12 +08:00
|
|
|
|
Assert.AreEqual(241526, beatmapInfo.BeatmapSet?.OnlineID);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeBeatmapDifficulty()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder();
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2019-01-28 17:19:57 +08:00
|
|
|
|
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-10-02 11:34:29 +08:00
|
|
|
|
var difficulty = decoder.Decode(stream).Difficulty;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
Assert.AreEqual(6.5f, difficulty.DrainRate);
|
|
|
|
|
Assert.AreEqual(4, difficulty.CircleSize);
|
|
|
|
|
Assert.AreEqual(8, difficulty.OverallDifficulty);
|
|
|
|
|
Assert.AreEqual(9, difficulty.ApproachRate);
|
|
|
|
|
Assert.AreEqual(1.8, difficulty.SliderMultiplier);
|
|
|
|
|
Assert.AreEqual(2, difficulty.SliderTickRate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeBeatmapEvents()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2019-01-28 17:19:57 +08:00
|
|
|
|
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
var beatmap = decoder.Decode(stream);
|
|
|
|
|
var metadata = beatmap.Metadata;
|
|
|
|
|
var breakPoint = beatmap.Breaks[0];
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual("machinetop_background.jpg", metadata.BackgroundFile);
|
|
|
|
|
Assert.AreEqual(122474, breakPoint.StartTime);
|
|
|
|
|
Assert.AreEqual(140135, breakPoint.EndTime);
|
|
|
|
|
Assert.IsTrue(breakPoint.HasEffect);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeBeatmapTimingPoints()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2019-01-28 17:19:57 +08:00
|
|
|
|
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
var beatmap = decoder.Decode(stream);
|
2021-08-25 17:00:57 +08:00
|
|
|
|
var controlPoints = (LegacyControlPointInfo)beatmap.ControlPointInfo;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
Assert.AreEqual(4, controlPoints.TimingPoints.Count);
|
2019-10-25 18:58:42 +08:00
|
|
|
|
Assert.AreEqual(5, controlPoints.DifficultyPoints.Count);
|
|
|
|
|
Assert.AreEqual(34, controlPoints.SamplePoints.Count);
|
2021-09-06 20:05:43 +08:00
|
|
|
|
Assert.AreEqual(8, controlPoints.EffectPoints.Count);
|
2019-05-21 13:27:41 +08:00
|
|
|
|
|
|
|
|
|
var timingPoint = controlPoints.TimingPointAt(0);
|
|
|
|
|
Assert.AreEqual(956, timingPoint.Time);
|
|
|
|
|
Assert.AreEqual(329.67032967033, timingPoint.BeatLength);
|
2022-01-23 00:27:27 +08:00
|
|
|
|
Assert.AreEqual(TimeSignature.SimpleQuadruple, timingPoint.TimeSignature);
|
2019-05-21 13:27:41 +08:00
|
|
|
|
|
|
|
|
|
timingPoint = controlPoints.TimingPointAt(48428);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Assert.AreEqual(956, timingPoint.Time);
|
|
|
|
|
Assert.AreEqual(329.67032967033d, timingPoint.BeatLength);
|
2022-01-23 00:27:27 +08:00
|
|
|
|
Assert.AreEqual(TimeSignature.SimpleQuadruple, timingPoint.TimeSignature);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-05-21 13:27:41 +08:00
|
|
|
|
timingPoint = controlPoints.TimingPointAt(119637);
|
|
|
|
|
Assert.AreEqual(119637, timingPoint.Time);
|
|
|
|
|
Assert.AreEqual(659.340659340659, timingPoint.BeatLength);
|
2022-01-23 00:27:27 +08:00
|
|
|
|
Assert.AreEqual(TimeSignature.SimpleQuadruple, timingPoint.TimeSignature);
|
2019-05-21 13:27:41 +08:00
|
|
|
|
|
|
|
|
|
var difficultyPoint = controlPoints.DifficultyPointAt(0);
|
|
|
|
|
Assert.AreEqual(0, difficultyPoint.Time);
|
2021-08-31 22:59:36 +08:00
|
|
|
|
Assert.AreEqual(1.0, difficultyPoint.SliderVelocity);
|
2019-05-21 13:27:41 +08:00
|
|
|
|
|
|
|
|
|
difficultyPoint = controlPoints.DifficultyPointAt(48428);
|
2019-10-25 18:58:42 +08:00
|
|
|
|
Assert.AreEqual(0, difficultyPoint.Time);
|
2021-08-31 22:59:36 +08:00
|
|
|
|
Assert.AreEqual(1.0, difficultyPoint.SliderVelocity);
|
2019-05-21 13:27:41 +08:00
|
|
|
|
|
|
|
|
|
difficultyPoint = controlPoints.DifficultyPointAt(116999);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Assert.AreEqual(116999, difficultyPoint.Time);
|
2021-08-31 22:59:36 +08:00
|
|
|
|
Assert.AreEqual(0.75, difficultyPoint.SliderVelocity, 0.1);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-05-21 13:27:41 +08:00
|
|
|
|
var soundPoint = controlPoints.SamplePointAt(0);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Assert.AreEqual(956, soundPoint.Time);
|
|
|
|
|
Assert.AreEqual("soft", soundPoint.SampleBank);
|
|
|
|
|
Assert.AreEqual(60, soundPoint.SampleVolume);
|
|
|
|
|
|
2019-05-21 13:27:41 +08:00
|
|
|
|
soundPoint = controlPoints.SamplePointAt(53373);
|
|
|
|
|
Assert.AreEqual(53373, soundPoint.Time);
|
|
|
|
|
Assert.AreEqual("soft", soundPoint.SampleBank);
|
|
|
|
|
Assert.AreEqual(60, soundPoint.SampleVolume);
|
|
|
|
|
|
|
|
|
|
soundPoint = controlPoints.SamplePointAt(119637);
|
|
|
|
|
Assert.AreEqual(119637, soundPoint.Time);
|
|
|
|
|
Assert.AreEqual("soft", soundPoint.SampleBank);
|
|
|
|
|
Assert.AreEqual(80, soundPoint.SampleVolume);
|
|
|
|
|
|
|
|
|
|
var effectPoint = controlPoints.EffectPointAt(0);
|
|
|
|
|
Assert.AreEqual(0, effectPoint.Time);
|
|
|
|
|
Assert.IsFalse(effectPoint.KiaiMode);
|
|
|
|
|
Assert.IsFalse(effectPoint.OmitFirstBarLine);
|
|
|
|
|
|
|
|
|
|
effectPoint = controlPoints.EffectPointAt(53703);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Assert.AreEqual(53703, effectPoint.Time);
|
|
|
|
|
Assert.IsTrue(effectPoint.KiaiMode);
|
|
|
|
|
Assert.IsFalse(effectPoint.OmitFirstBarLine);
|
2019-05-21 13:27:41 +08:00
|
|
|
|
|
2021-09-02 18:42:41 +08:00
|
|
|
|
effectPoint = controlPoints.EffectPointAt(116637);
|
2019-10-25 18:58:42 +08:00
|
|
|
|
Assert.AreEqual(95901, effectPoint.Time);
|
2019-05-21 13:27:41 +08:00
|
|
|
|
Assert.IsFalse(effectPoint.KiaiMode);
|
|
|
|
|
Assert.IsFalse(effectPoint.OmitFirstBarLine);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-14 08:46:42 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeOverlappingTimingPoints()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("overlapping-control-points.osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2019-05-14 08:46:42 +08:00
|
|
|
|
{
|
2021-08-25 17:00:57 +08:00
|
|
|
|
var controlPoints = (LegacyControlPointInfo)decoder.Decode(stream).ControlPointInfo;
|
2019-05-14 08:46:42 +08:00
|
|
|
|
|
2020-04-21 13:19:05 +08:00
|
|
|
|
Assert.That(controlPoints.TimingPoints.Count, Is.EqualTo(4));
|
|
|
|
|
Assert.That(controlPoints.DifficultyPoints.Count, Is.EqualTo(3));
|
|
|
|
|
Assert.That(controlPoints.EffectPoints.Count, Is.EqualTo(3));
|
|
|
|
|
Assert.That(controlPoints.SamplePoints.Count, Is.EqualTo(3));
|
|
|
|
|
|
2021-08-31 22:59:36 +08:00
|
|
|
|
Assert.That(controlPoints.DifficultyPointAt(500).SliderVelocity, Is.EqualTo(1.5).Within(0.1));
|
|
|
|
|
Assert.That(controlPoints.DifficultyPointAt(1500).SliderVelocity, Is.EqualTo(1.5).Within(0.1));
|
|
|
|
|
Assert.That(controlPoints.DifficultyPointAt(2500).SliderVelocity, Is.EqualTo(0.75).Within(0.1));
|
|
|
|
|
Assert.That(controlPoints.DifficultyPointAt(3500).SliderVelocity, Is.EqualTo(1.5).Within(0.1));
|
2019-05-14 09:13:42 +08:00
|
|
|
|
|
|
|
|
|
Assert.That(controlPoints.EffectPointAt(500).KiaiMode, Is.True);
|
|
|
|
|
Assert.That(controlPoints.EffectPointAt(1500).KiaiMode, Is.True);
|
|
|
|
|
Assert.That(controlPoints.EffectPointAt(2500).KiaiMode, Is.False);
|
|
|
|
|
Assert.That(controlPoints.EffectPointAt(3500).KiaiMode, Is.True);
|
|
|
|
|
|
|
|
|
|
Assert.That(controlPoints.SamplePointAt(500).SampleBank, Is.EqualTo("drum"));
|
|
|
|
|
Assert.That(controlPoints.SamplePointAt(1500).SampleBank, Is.EqualTo("drum"));
|
|
|
|
|
Assert.That(controlPoints.SamplePointAt(2500).SampleBank, Is.EqualTo("normal"));
|
|
|
|
|
Assert.That(controlPoints.SamplePointAt(3500).SampleBank, Is.EqualTo("drum"));
|
|
|
|
|
|
2019-05-21 13:01:41 +08:00
|
|
|
|
Assert.That(controlPoints.TimingPointAt(500).BeatLength, Is.EqualTo(500).Within(0.1));
|
|
|
|
|
Assert.That(controlPoints.TimingPointAt(1500).BeatLength, Is.EqualTo(500).Within(0.1));
|
|
|
|
|
Assert.That(controlPoints.TimingPointAt(2500).BeatLength, Is.EqualTo(250).Within(0.1));
|
|
|
|
|
Assert.That(controlPoints.TimingPointAt(3500).BeatLength, Is.EqualTo(500).Within(0.1));
|
2019-05-14 08:46:42 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-30 17:02:18 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestTimingPointResetsSpeedMultiplier()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("timingpoint-speedmultiplier-reset.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
2021-08-31 15:31:48 +08:00
|
|
|
|
var controlPoints = (LegacyControlPointInfo)decoder.Decode(stream).ControlPointInfo;
|
2019-10-30 17:02:18 +08:00
|
|
|
|
|
2021-09-06 20:30:57 +08:00
|
|
|
|
Assert.That(controlPoints.DifficultyPointAt(0).SliderVelocity, Is.EqualTo(0.5).Within(0.1));
|
|
|
|
|
Assert.That(controlPoints.DifficultyPointAt(2000).SliderVelocity, Is.EqualTo(1).Within(0.1));
|
2019-10-30 17:02:18 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[Test]
|
2018-10-05 10:19:01 +08:00
|
|
|
|
public void TestDecodeBeatmapColours()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacySkinDecoder();
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2019-01-28 17:19:57 +08:00
|
|
|
|
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
var comboColors = decoder.Decode(stream).ComboColours;
|
|
|
|
|
|
|
|
|
|
Color4[] expectedColors =
|
|
|
|
|
{
|
|
|
|
|
new Color4(142, 199, 255, 255),
|
|
|
|
|
new Color4(255, 128, 128, 255),
|
|
|
|
|
new Color4(128, 255, 255, 255),
|
|
|
|
|
new Color4(128, 255, 128, 255),
|
|
|
|
|
new Color4(255, 187, 255, 255),
|
|
|
|
|
new Color4(255, 177, 140, 255),
|
2022-09-21 15:04:32 +08:00
|
|
|
|
new Color4(100, 100, 100, 255), // alpha is specified as 100, but should be ignored.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
};
|
|
|
|
|
Assert.AreEqual(expectedColors.Length, comboColors.Count);
|
|
|
|
|
for (int i = 0; i < expectedColors.Length; i++)
|
|
|
|
|
Assert.AreEqual(expectedColors[i], comboColors[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-15 12:36:22 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
2021-07-20 19:15:43 +08:00
|
|
|
|
public void TestDecodeBeatmapComboOffsetsOsu()
|
2018-08-15 12:36:22 +08:00
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder();
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2019-01-28 17:19:57 +08:00
|
|
|
|
using (var resStream = TestResources.OpenResource("hitobject-combo-offset.osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2018-08-15 12:36:22 +08:00
|
|
|
|
{
|
|
|
|
|
var beatmap = decoder.Decode(stream);
|
2018-08-17 09:04:00 +08:00
|
|
|
|
|
2019-12-24 15:02:16 +08:00
|
|
|
|
var converted = new OsuBeatmapConverter(beatmap, new OsuRuleset()).Convert();
|
2018-08-17 09:04:00 +08:00
|
|
|
|
new OsuBeatmapProcessor(converted).PreProcess();
|
|
|
|
|
new OsuBeatmapProcessor(converted).PostProcess();
|
|
|
|
|
|
2021-07-21 16:32:56 +08:00
|
|
|
|
Assert.AreEqual(4, ((IHasComboInformation)converted.HitObjects.ElementAt(0)).ComboIndexWithOffsets);
|
|
|
|
|
Assert.AreEqual(5, ((IHasComboInformation)converted.HitObjects.ElementAt(2)).ComboIndexWithOffsets);
|
|
|
|
|
Assert.AreEqual(5, ((IHasComboInformation)converted.HitObjects.ElementAt(4)).ComboIndexWithOffsets);
|
|
|
|
|
Assert.AreEqual(6, ((IHasComboInformation)converted.HitObjects.ElementAt(6)).ComboIndexWithOffsets);
|
|
|
|
|
Assert.AreEqual(11, ((IHasComboInformation)converted.HitObjects.ElementAt(8)).ComboIndexWithOffsets);
|
|
|
|
|
Assert.AreEqual(14, ((IHasComboInformation)converted.HitObjects.ElementAt(11)).ComboIndexWithOffsets);
|
2021-07-20 19:15:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeBeatmapComboOffsetsCatch()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder();
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("hitobject-combo-offset.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
var beatmap = decoder.Decode(stream);
|
|
|
|
|
|
|
|
|
|
var converted = new CatchBeatmapConverter(beatmap, new CatchRuleset()).Convert();
|
|
|
|
|
new CatchBeatmapProcessor(converted).PreProcess();
|
|
|
|
|
new CatchBeatmapProcessor(converted).PostProcess();
|
|
|
|
|
|
2021-07-21 16:32:56 +08:00
|
|
|
|
Assert.AreEqual(4, ((IHasComboInformation)converted.HitObjects.ElementAt(0)).ComboIndexWithOffsets);
|
|
|
|
|
Assert.AreEqual(5, ((IHasComboInformation)converted.HitObjects.ElementAt(2)).ComboIndexWithOffsets);
|
|
|
|
|
Assert.AreEqual(5, ((IHasComboInformation)converted.HitObjects.ElementAt(4)).ComboIndexWithOffsets);
|
|
|
|
|
Assert.AreEqual(6, ((IHasComboInformation)converted.HitObjects.ElementAt(6)).ComboIndexWithOffsets);
|
|
|
|
|
Assert.AreEqual(11, ((IHasComboInformation)converted.HitObjects.ElementAt(8)).ComboIndexWithOffsets);
|
|
|
|
|
Assert.AreEqual(14, ((IHasComboInformation)converted.HitObjects.ElementAt(11)).ComboIndexWithOffsets);
|
2018-08-15 12:36:22 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeBeatmapHitObjects()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2019-01-28 17:19:57 +08:00
|
|
|
|
using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
var hitObjects = decoder.Decode(stream).HitObjects;
|
|
|
|
|
|
2020-05-26 16:44:47 +08:00
|
|
|
|
var curveData = hitObjects[0] as IHasPathWithRepeats;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
var positionData = hitObjects[0] as IHasPosition;
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(positionData);
|
|
|
|
|
Assert.IsNotNull(curveData);
|
|
|
|
|
Assert.AreEqual(new Vector2(192, 168), positionData.Position);
|
|
|
|
|
Assert.AreEqual(956, hitObjects[0].StartTime);
|
2019-06-30 20:58:30 +08:00
|
|
|
|
Assert.IsTrue(hitObjects[0].Samples.Any(s => s.Name == HitSampleInfo.HIT_NORMAL));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
positionData = hitObjects[1] as IHasPosition;
|
|
|
|
|
|
|
|
|
|
Assert.IsNotNull(positionData);
|
|
|
|
|
Assert.AreEqual(new Vector2(304, 56), positionData.Position);
|
|
|
|
|
Assert.AreEqual(1285, hitObjects[1].StartTime);
|
2019-06-30 20:58:30 +08:00
|
|
|
|
Assert.IsTrue(hitObjects[1].Samples.Any(s => s.Name == HitSampleInfo.HIT_CLAP));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-28 17:20:43 +08:00
|
|
|
|
|
2019-10-29 17:02:30 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeControlPointDifficultyChange()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("controlpoint-difficulty-multiplier.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
2021-08-31 15:31:48 +08:00
|
|
|
|
var controlPointInfo = (LegacyControlPointInfo)decoder.Decode(stream).ControlPointInfo;
|
2019-10-29 17:02:30 +08:00
|
|
|
|
|
2021-08-31 22:59:36 +08:00
|
|
|
|
Assert.That(controlPointInfo.DifficultyPointAt(5).SliderVelocity, Is.EqualTo(1));
|
|
|
|
|
Assert.That(controlPointInfo.DifficultyPointAt(1000).SliderVelocity, Is.EqualTo(10));
|
|
|
|
|
Assert.That(controlPointInfo.DifficultyPointAt(2000).SliderVelocity, Is.EqualTo(1.8518518518518519d));
|
|
|
|
|
Assert.That(controlPointInfo.DifficultyPointAt(3000).SliderVelocity, Is.EqualTo(0.5));
|
2019-10-29 17:02:30 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-28 17:20:43 +08:00
|
|
|
|
[Test]
|
2018-07-20 14:12:04 +08:00
|
|
|
|
public void TestDecodeControlPointCustomSampleBank()
|
2018-06-28 17:20:43 +08:00
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2019-01-28 17:19:57 +08:00
|
|
|
|
using (var resStream = TestResources.OpenResource("controlpoint-custom-samplebank.osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2018-06-28 17:20:43 +08:00
|
|
|
|
{
|
|
|
|
|
var hitObjects = decoder.Decode(stream).HitObjects;
|
|
|
|
|
|
2020-10-30 11:12:30 +08:00
|
|
|
|
Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First());
|
|
|
|
|
Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[1]).LookupNames.First());
|
|
|
|
|
Assert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
|
|
|
|
|
Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[3]).LookupNames.First());
|
2018-12-03 16:21:27 +08:00
|
|
|
|
|
|
|
|
|
// The control point at the end time of the slider should be applied
|
2020-10-30 11:12:30 +08:00
|
|
|
|
Assert.AreEqual("Gameplay/soft-hitnormal8", getTestableSampleInfo(hitObjects[4]).LookupNames.First());
|
2018-06-28 17:20:43 +08:00
|
|
|
|
}
|
2018-06-28 17:27:33 +08:00
|
|
|
|
|
2019-11-12 18:37:20 +08:00
|
|
|
|
static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
|
2018-06-28 17:20:43 +08:00
|
|
|
|
}
|
2018-07-02 13:40:43 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
2018-07-20 14:12:04 +08:00
|
|
|
|
public void TestDecodeHitObjectCustomSampleBank()
|
2018-07-02 13:40:43 +08:00
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2019-01-28 17:19:57 +08:00
|
|
|
|
using (var resStream = TestResources.OpenResource("hitobject-custom-samplebank.osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2018-07-02 13:40:43 +08:00
|
|
|
|
{
|
|
|
|
|
var hitObjects = decoder.Decode(stream).HitObjects;
|
|
|
|
|
|
2020-10-30 11:12:30 +08:00
|
|
|
|
Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First());
|
|
|
|
|
Assert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[1]).LookupNames.First());
|
|
|
|
|
Assert.AreEqual("Gameplay/normal-hitnormal3", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
|
2018-07-20 14:12:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-12 18:37:20 +08:00
|
|
|
|
static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
|
2018-07-20 14:12:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeHitObjectFileSamples()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2019-01-28 17:19:57 +08:00
|
|
|
|
using (var resStream = TestResources.OpenResource("hitobject-file-samples.osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2018-07-20 14:12:44 +08:00
|
|
|
|
{
|
|
|
|
|
var hitObjects = decoder.Decode(stream).HitObjects;
|
|
|
|
|
|
2018-07-20 14:12:04 +08:00
|
|
|
|
Assert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[0]).LookupNames.First());
|
|
|
|
|
Assert.AreEqual("hit_2.wav", getTestableSampleInfo(hitObjects[1]).LookupNames.First());
|
2020-10-30 11:12:30 +08:00
|
|
|
|
Assert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
|
2018-07-20 14:12:04 +08:00
|
|
|
|
Assert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[3]).LookupNames.First());
|
2019-03-05 17:21:29 +08:00
|
|
|
|
Assert.AreEqual(70, getTestableSampleInfo(hitObjects[3]).Volume);
|
2018-07-02 13:40:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-12 18:37:20 +08:00
|
|
|
|
static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
|
2018-07-02 13:40:43 +08:00
|
|
|
|
}
|
2018-10-16 16:10:24 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeSliderSamples()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2019-01-28 17:19:57 +08:00
|
|
|
|
using (var resStream = TestResources.OpenResource("slider-samples.osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2018-10-16 16:10:24 +08:00
|
|
|
|
{
|
|
|
|
|
var hitObjects = decoder.Decode(stream).HitObjects;
|
|
|
|
|
|
|
|
|
|
var slider1 = (ConvertSlider)hitObjects[0];
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(1, slider1.NodeSamples[0].Count);
|
2019-06-30 20:58:30 +08:00
|
|
|
|
Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider1.NodeSamples[0][0].Name);
|
2018-10-16 16:10:24 +08:00
|
|
|
|
Assert.AreEqual(1, slider1.NodeSamples[1].Count);
|
2019-06-30 20:58:30 +08:00
|
|
|
|
Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider1.NodeSamples[1][0].Name);
|
2018-10-16 16:10:24 +08:00
|
|
|
|
Assert.AreEqual(1, slider1.NodeSamples[2].Count);
|
2019-06-30 20:58:30 +08:00
|
|
|
|
Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider1.NodeSamples[2][0].Name);
|
2018-10-16 16:10:24 +08:00
|
|
|
|
|
|
|
|
|
var slider2 = (ConvertSlider)hitObjects[1];
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(2, slider2.NodeSamples[0].Count);
|
2019-06-30 20:58:30 +08:00
|
|
|
|
Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider2.NodeSamples[0][0].Name);
|
|
|
|
|
Assert.AreEqual(HitSampleInfo.HIT_CLAP, slider2.NodeSamples[0][1].Name);
|
2018-10-16 16:10:24 +08:00
|
|
|
|
Assert.AreEqual(2, slider2.NodeSamples[1].Count);
|
2019-06-30 20:58:30 +08:00
|
|
|
|
Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider2.NodeSamples[1][0].Name);
|
|
|
|
|
Assert.AreEqual(HitSampleInfo.HIT_CLAP, slider2.NodeSamples[1][1].Name);
|
2018-10-16 16:10:24 +08:00
|
|
|
|
Assert.AreEqual(2, slider2.NodeSamples[2].Count);
|
2019-06-30 20:58:30 +08:00
|
|
|
|
Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider2.NodeSamples[2][0].Name);
|
|
|
|
|
Assert.AreEqual(HitSampleInfo.HIT_CLAP, slider2.NodeSamples[2][1].Name);
|
2018-10-16 16:10:24 +08:00
|
|
|
|
|
|
|
|
|
var slider3 = (ConvertSlider)hitObjects[2];
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(2, slider3.NodeSamples[0].Count);
|
2019-06-30 20:58:30 +08:00
|
|
|
|
Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider3.NodeSamples[0][0].Name);
|
|
|
|
|
Assert.AreEqual(HitSampleInfo.HIT_WHISTLE, slider3.NodeSamples[0][1].Name);
|
2018-10-16 16:10:24 +08:00
|
|
|
|
Assert.AreEqual(1, slider3.NodeSamples[1].Count);
|
2019-06-30 20:58:30 +08:00
|
|
|
|
Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider3.NodeSamples[1][0].Name);
|
2018-10-16 16:10:24 +08:00
|
|
|
|
Assert.AreEqual(2, slider3.NodeSamples[2].Count);
|
2019-06-30 20:58:30 +08:00
|
|
|
|
Assert.AreEqual(HitSampleInfo.HIT_NORMAL, slider3.NodeSamples[2][0].Name);
|
|
|
|
|
Assert.AreEqual(HitSampleInfo.HIT_CLAP, slider3.NodeSamples[2][1].Name);
|
2018-10-16 16:10:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-11-05 17:10:22 +08:00
|
|
|
|
|
2018-11-05 16:35:24 +08:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeHitObjectNullAdditionBank()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2019-01-28 17:19:57 +08:00
|
|
|
|
using (var resStream = TestResources.OpenResource("hitobject-no-addition-bank.osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2018-11-05 16:35:24 +08:00
|
|
|
|
{
|
|
|
|
|
var hitObjects = decoder.Decode(stream).HitObjects;
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(hitObjects[0].Samples[0].Bank, hitObjects[0].Samples[1].Bank);
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-08-05 18:56:35 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
2019-08-07 18:25:40 +08:00
|
|
|
|
public void TestInvalidEventStillPasses()
|
2019-08-05 18:56:35 +08:00
|
|
|
|
{
|
2019-08-06 09:14:36 +08:00
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
|
|
|
|
|
2019-08-06 11:35:18 +08:00
|
|
|
|
using (var badResStream = TestResources.OpenResource("invalid-events.osu"))
|
2019-09-10 06:43:30 +08:00
|
|
|
|
using (var badStream = new LineBufferedReader(badResStream))
|
2019-08-05 18:56:35 +08:00
|
|
|
|
{
|
2019-08-07 18:25:40 +08:00
|
|
|
|
Assert.DoesNotThrow(() => decoder.Decode(badStream));
|
2019-08-05 18:56:35 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-11 04:06:10 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestFallbackDecoderForCorruptedHeader()
|
|
|
|
|
{
|
|
|
|
|
Decoder<Beatmap> decoder = null;
|
|
|
|
|
Beatmap beatmap = null;
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("corrupted-header.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
|
|
|
|
|
Assert.IsInstanceOf<LegacyBeatmapDecoder>(decoder);
|
|
|
|
|
Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream));
|
|
|
|
|
Assert.IsNotNull(beatmap);
|
|
|
|
|
Assert.AreEqual("Beatmap with corrupted header", beatmap.Metadata.Title);
|
2021-11-04 17:46:26 +08:00
|
|
|
|
Assert.AreEqual("Evil Hacker", beatmap.Metadata.Author.Username);
|
2019-09-11 04:06:10 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestFallbackDecoderForMissingHeader()
|
|
|
|
|
{
|
|
|
|
|
Decoder<Beatmap> decoder = null;
|
|
|
|
|
Beatmap beatmap = null;
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("missing-header.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
|
|
|
|
|
Assert.IsInstanceOf<LegacyBeatmapDecoder>(decoder);
|
|
|
|
|
Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream));
|
|
|
|
|
Assert.IsNotNull(beatmap);
|
|
|
|
|
Assert.AreEqual("Beatmap with no header", beatmap.Metadata.Title);
|
2021-11-04 17:46:26 +08:00
|
|
|
|
Assert.AreEqual("Incredibly Evil Hacker", beatmap.Metadata.Author.Username);
|
2019-09-11 04:06:10 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeFileWithEmptyLinesAtStart()
|
|
|
|
|
{
|
|
|
|
|
Decoder<Beatmap> decoder = null;
|
|
|
|
|
Beatmap beatmap = null;
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("empty-lines-at-start.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
|
|
|
|
|
Assert.IsInstanceOf<LegacyBeatmapDecoder>(decoder);
|
|
|
|
|
Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream));
|
|
|
|
|
Assert.IsNotNull(beatmap);
|
|
|
|
|
Assert.AreEqual("Empty lines at start", beatmap.Metadata.Title);
|
2021-11-04 17:46:26 +08:00
|
|
|
|
Assert.AreEqual("Edge Case Hunter", beatmap.Metadata.Author.Username);
|
2019-09-11 04:06:10 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeFileWithEmptyLinesAndNoHeader()
|
|
|
|
|
{
|
|
|
|
|
Decoder<Beatmap> decoder = null;
|
|
|
|
|
Beatmap beatmap = null;
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("empty-line-instead-of-header.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
|
|
|
|
|
Assert.IsInstanceOf<LegacyBeatmapDecoder>(decoder);
|
|
|
|
|
Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream));
|
|
|
|
|
Assert.IsNotNull(beatmap);
|
|
|
|
|
Assert.AreEqual("The dog ate the file header", beatmap.Metadata.Title);
|
2021-11-04 17:46:26 +08:00
|
|
|
|
Assert.AreEqual("Why does this keep happening", beatmap.Metadata.Author.Username);
|
2019-09-11 04:06:10 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeFileWithContentImmediatelyAfterHeader()
|
|
|
|
|
{
|
|
|
|
|
Decoder<Beatmap> decoder = null;
|
|
|
|
|
Beatmap beatmap = null;
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("no-empty-line-after-header.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
|
|
|
|
|
Assert.IsInstanceOf<LegacyBeatmapDecoder>(decoder);
|
|
|
|
|
Assert.DoesNotThrow(() => beatmap = decoder.Decode(stream));
|
|
|
|
|
Assert.IsNotNull(beatmap);
|
|
|
|
|
Assert.AreEqual("No empty line delimiting header from contents", beatmap.Metadata.Title);
|
2021-11-04 17:46:26 +08:00
|
|
|
|
Assert.AreEqual("Edge Case Hunter", beatmap.Metadata.Author.Username);
|
2019-09-11 04:06:10 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestDecodeEmptyFile()
|
|
|
|
|
{
|
|
|
|
|
using (var resStream = new MemoryStream())
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
Assert.Throws<IOException>(() => Decoder.GetDecoder<Beatmap>(stream));
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-04 23:00:51 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestAllowFallbackDecoderOverwrite()
|
|
|
|
|
{
|
|
|
|
|
Decoder<Beatmap> decoder = null;
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("corrupted-header.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
|
|
|
|
|
Assert.IsInstanceOf<LegacyBeatmapDecoder>(decoder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.DoesNotThrow(LegacyDifficultyCalculatorBeatmapDecoder.Register);
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("corrupted-header.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
Assert.DoesNotThrow(() => decoder = Decoder.GetDecoder<Beatmap>(stream));
|
|
|
|
|
Assert.IsInstanceOf<LegacyDifficultyCalculatorBeatmapDecoder>(decoder);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-12 17:03:41 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestMultiSegmentSliders()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("multi-segment-slider.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
var decoded = decoder.Decode(stream);
|
|
|
|
|
|
|
|
|
|
// Multi-segment
|
|
|
|
|
var first = ((IHasPath)decoded.HitObjects[0]).Path;
|
|
|
|
|
|
2021-08-26 00:42:57 +08:00
|
|
|
|
Assert.That(first.ControlPoints[0].Position, Is.EqualTo(Vector2.Zero));
|
|
|
|
|
Assert.That(first.ControlPoints[0].Type, Is.EqualTo(PathType.PerfectCurve));
|
|
|
|
|
Assert.That(first.ControlPoints[1].Position, Is.EqualTo(new Vector2(161, -244)));
|
|
|
|
|
Assert.That(first.ControlPoints[1].Type, Is.EqualTo(null));
|
|
|
|
|
|
2021-11-04 14:09:04 +08:00
|
|
|
|
// ReSharper disable once HeuristicUnreachableCode
|
|
|
|
|
// weird one, see https://youtrack.jetbrains.com/issue/RIDER-70159.
|
2021-08-26 00:42:57 +08:00
|
|
|
|
Assert.That(first.ControlPoints[2].Position, Is.EqualTo(new Vector2(376, -3)));
|
|
|
|
|
Assert.That(first.ControlPoints[2].Type, Is.EqualTo(PathType.Bezier));
|
|
|
|
|
Assert.That(first.ControlPoints[3].Position, Is.EqualTo(new Vector2(68, 15)));
|
|
|
|
|
Assert.That(first.ControlPoints[3].Type, Is.EqualTo(null));
|
|
|
|
|
Assert.That(first.ControlPoints[4].Position, Is.EqualTo(new Vector2(259, -132)));
|
|
|
|
|
Assert.That(first.ControlPoints[4].Type, Is.EqualTo(null));
|
|
|
|
|
Assert.That(first.ControlPoints[5].Position, Is.EqualTo(new Vector2(92, -107)));
|
|
|
|
|
Assert.That(first.ControlPoints[5].Type, Is.EqualTo(null));
|
2020-10-12 17:03:41 +08:00
|
|
|
|
|
|
|
|
|
// Single-segment
|
|
|
|
|
var second = ((IHasPath)decoded.HitObjects[1]).Path;
|
|
|
|
|
|
2021-08-26 00:42:57 +08:00
|
|
|
|
Assert.That(second.ControlPoints[0].Position, Is.EqualTo(Vector2.Zero));
|
|
|
|
|
Assert.That(second.ControlPoints[0].Type, Is.EqualTo(PathType.PerfectCurve));
|
|
|
|
|
Assert.That(second.ControlPoints[1].Position, Is.EqualTo(new Vector2(161, -244)));
|
|
|
|
|
Assert.That(second.ControlPoints[1].Type, Is.EqualTo(null));
|
|
|
|
|
Assert.That(second.ControlPoints[2].Position, Is.EqualTo(new Vector2(376, -3)));
|
|
|
|
|
Assert.That(second.ControlPoints[2].Type, Is.EqualTo(null));
|
2020-10-12 17:58:07 +08:00
|
|
|
|
|
|
|
|
|
// Implicit multi-segment
|
|
|
|
|
var third = ((IHasPath)decoded.HitObjects[2]).Path;
|
|
|
|
|
|
2021-08-26 00:42:57 +08:00
|
|
|
|
Assert.That(third.ControlPoints[0].Position, Is.EqualTo(Vector2.Zero));
|
|
|
|
|
Assert.That(third.ControlPoints[0].Type, Is.EqualTo(PathType.Bezier));
|
|
|
|
|
Assert.That(third.ControlPoints[1].Position, Is.EqualTo(new Vector2(0, 192)));
|
|
|
|
|
Assert.That(third.ControlPoints[1].Type, Is.EqualTo(null));
|
|
|
|
|
Assert.That(third.ControlPoints[2].Position, Is.EqualTo(new Vector2(224, 192)));
|
|
|
|
|
Assert.That(third.ControlPoints[2].Type, Is.EqualTo(null));
|
|
|
|
|
|
|
|
|
|
Assert.That(third.ControlPoints[3].Position, Is.EqualTo(new Vector2(224, 0)));
|
|
|
|
|
Assert.That(third.ControlPoints[3].Type, Is.EqualTo(PathType.Bezier));
|
|
|
|
|
Assert.That(third.ControlPoints[4].Position, Is.EqualTo(new Vector2(224, -192)));
|
|
|
|
|
Assert.That(third.ControlPoints[4].Type, Is.EqualTo(null));
|
|
|
|
|
Assert.That(third.ControlPoints[5].Position, Is.EqualTo(new Vector2(480, -192)));
|
|
|
|
|
Assert.That(third.ControlPoints[5].Type, Is.EqualTo(null));
|
|
|
|
|
Assert.That(third.ControlPoints[6].Position, Is.EqualTo(new Vector2(480, 0)));
|
|
|
|
|
Assert.That(third.ControlPoints[6].Type, Is.EqualTo(null));
|
2021-04-05 16:47:12 +08:00
|
|
|
|
|
|
|
|
|
// Last control point duplicated
|
|
|
|
|
var fourth = ((IHasPath)decoded.HitObjects[3]).Path;
|
|
|
|
|
|
2021-08-26 00:42:57 +08:00
|
|
|
|
Assert.That(fourth.ControlPoints[0].Position, Is.EqualTo(Vector2.Zero));
|
|
|
|
|
Assert.That(fourth.ControlPoints[0].Type, Is.EqualTo(PathType.Bezier));
|
|
|
|
|
Assert.That(fourth.ControlPoints[1].Position, Is.EqualTo(new Vector2(1, 1)));
|
|
|
|
|
Assert.That(fourth.ControlPoints[1].Type, Is.EqualTo(null));
|
|
|
|
|
Assert.That(fourth.ControlPoints[2].Position, Is.EqualTo(new Vector2(2, 2)));
|
|
|
|
|
Assert.That(fourth.ControlPoints[2].Type, Is.EqualTo(null));
|
|
|
|
|
Assert.That(fourth.ControlPoints[3].Position, Is.EqualTo(new Vector2(3, 3)));
|
|
|
|
|
Assert.That(fourth.ControlPoints[3].Type, Is.EqualTo(null));
|
|
|
|
|
Assert.That(fourth.ControlPoints[4].Position, Is.EqualTo(new Vector2(3, 3)));
|
|
|
|
|
Assert.That(fourth.ControlPoints[4].Type, Is.EqualTo(null));
|
2021-04-05 16:47:12 +08:00
|
|
|
|
|
|
|
|
|
// Last control point in segment duplicated
|
|
|
|
|
var fifth = ((IHasPath)decoded.HitObjects[4]).Path;
|
|
|
|
|
|
2021-08-26 00:42:57 +08:00
|
|
|
|
Assert.That(fifth.ControlPoints[0].Position, Is.EqualTo(Vector2.Zero));
|
|
|
|
|
Assert.That(fifth.ControlPoints[0].Type, Is.EqualTo(PathType.Bezier));
|
|
|
|
|
Assert.That(fifth.ControlPoints[1].Position, Is.EqualTo(new Vector2(1, 1)));
|
|
|
|
|
Assert.That(fifth.ControlPoints[1].Type, Is.EqualTo(null));
|
|
|
|
|
Assert.That(fifth.ControlPoints[2].Position, Is.EqualTo(new Vector2(2, 2)));
|
|
|
|
|
Assert.That(fifth.ControlPoints[2].Type, Is.EqualTo(null));
|
|
|
|
|
Assert.That(fifth.ControlPoints[3].Position, Is.EqualTo(new Vector2(3, 3)));
|
|
|
|
|
Assert.That(fifth.ControlPoints[3].Type, Is.EqualTo(null));
|
|
|
|
|
Assert.That(fifth.ControlPoints[4].Position, Is.EqualTo(new Vector2(3, 3)));
|
|
|
|
|
Assert.That(fifth.ControlPoints[4].Type, Is.EqualTo(null));
|
|
|
|
|
|
|
|
|
|
Assert.That(fifth.ControlPoints[5].Position, Is.EqualTo(new Vector2(4, 4)));
|
|
|
|
|
Assert.That(fifth.ControlPoints[5].Type, Is.EqualTo(PathType.Bezier));
|
|
|
|
|
Assert.That(fifth.ControlPoints[6].Position, Is.EqualTo(new Vector2(5, 5)));
|
|
|
|
|
Assert.That(fifth.ControlPoints[6].Type, Is.EqualTo(null));
|
2021-04-05 23:21:45 +08:00
|
|
|
|
|
|
|
|
|
// Implicit perfect-curve multi-segment(Should convert to bezier to match stable)
|
|
|
|
|
var sixth = ((IHasPath)decoded.HitObjects[5]).Path;
|
|
|
|
|
|
2021-08-26 00:42:57 +08:00
|
|
|
|
Assert.That(sixth.ControlPoints[0].Position, Is.EqualTo(Vector2.Zero));
|
|
|
|
|
Assert.That(sixth.ControlPoints[0].Type == PathType.Bezier);
|
|
|
|
|
Assert.That(sixth.ControlPoints[1].Position, Is.EqualTo(new Vector2(75, 145)));
|
|
|
|
|
Assert.That(sixth.ControlPoints[1].Type == null);
|
|
|
|
|
Assert.That(sixth.ControlPoints[2].Position, Is.EqualTo(new Vector2(170, 75)));
|
2021-04-05 23:21:45 +08:00
|
|
|
|
|
2021-08-26 00:42:57 +08:00
|
|
|
|
Assert.That(sixth.ControlPoints[2].Type == PathType.Bezier);
|
|
|
|
|
Assert.That(sixth.ControlPoints[3].Position, Is.EqualTo(new Vector2(300, 145)));
|
|
|
|
|
Assert.That(sixth.ControlPoints[3].Type == null);
|
|
|
|
|
Assert.That(sixth.ControlPoints[4].Position, Is.EqualTo(new Vector2(410, 20)));
|
|
|
|
|
Assert.That(sixth.ControlPoints[4].Type == null);
|
2021-04-05 23:21:45 +08:00
|
|
|
|
|
|
|
|
|
// Explicit perfect-curve multi-segment(Should not convert to bezier)
|
|
|
|
|
var seventh = ((IHasPath)decoded.HitObjects[6]).Path;
|
|
|
|
|
|
2021-08-26 00:42:57 +08:00
|
|
|
|
Assert.That(seventh.ControlPoints[0].Position, Is.EqualTo(Vector2.Zero));
|
|
|
|
|
Assert.That(seventh.ControlPoints[0].Type == PathType.PerfectCurve);
|
|
|
|
|
Assert.That(seventh.ControlPoints[1].Position, Is.EqualTo(new Vector2(75, 145)));
|
|
|
|
|
Assert.That(seventh.ControlPoints[1].Type == null);
|
|
|
|
|
Assert.That(seventh.ControlPoints[2].Position, Is.EqualTo(new Vector2(170, 75)));
|
|
|
|
|
|
|
|
|
|
Assert.That(seventh.ControlPoints[2].Type == PathType.PerfectCurve);
|
|
|
|
|
Assert.That(seventh.ControlPoints[3].Position, Is.EqualTo(new Vector2(300, 145)));
|
|
|
|
|
Assert.That(seventh.ControlPoints[3].Type == null);
|
|
|
|
|
Assert.That(seventh.ControlPoints[4].Position, Is.EqualTo(new Vector2(410, 20)));
|
|
|
|
|
Assert.That(seventh.ControlPoints[4].Type == null);
|
2020-10-12 17:03:41 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-26 16:35:03 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestSliderLengthExtensionEdgeCase()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("duplicate-last-position-slider.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
var decoded = decoder.Decode(stream);
|
|
|
|
|
|
|
|
|
|
var path = ((IHasPath)decoded.HitObjects[0]).Path;
|
|
|
|
|
|
|
|
|
|
Assert.That(path.ExpectedDistance.Value, Is.EqualTo(2));
|
|
|
|
|
Assert.That(path.Distance, Is.EqualTo(1));
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-28 04:41:09 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestLegacyDefaultsPreserved()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
|
|
|
|
|
|
|
|
|
using (var memoryStream = new MemoryStream())
|
|
|
|
|
using (var stream = new LineBufferedReader(memoryStream))
|
|
|
|
|
{
|
|
|
|
|
var decoded = decoder.Decode(stream);
|
|
|
|
|
|
|
|
|
|
Assert.Multiple(() =>
|
|
|
|
|
{
|
|
|
|
|
Assert.That(decoded.BeatmapInfo.AudioLeadIn, Is.EqualTo(0));
|
|
|
|
|
Assert.That(decoded.BeatmapInfo.StackLeniency, Is.EqualTo(0.7f));
|
|
|
|
|
Assert.That(decoded.BeatmapInfo.SpecialStyle, Is.False);
|
|
|
|
|
Assert.That(decoded.BeatmapInfo.LetterboxInBreaks, Is.False);
|
|
|
|
|
Assert.That(decoded.BeatmapInfo.WidescreenStoryboard, Is.False);
|
|
|
|
|
Assert.That(decoded.BeatmapInfo.EpilepsyWarning, Is.False);
|
|
|
|
|
Assert.That(decoded.BeatmapInfo.SamplesMatchPlaybackRate, Is.False);
|
|
|
|
|
Assert.That(decoded.BeatmapInfo.Countdown, Is.EqualTo(CountdownType.Normal));
|
|
|
|
|
Assert.That(decoded.BeatmapInfo.CountdownOffset, Is.EqualTo(0));
|
|
|
|
|
Assert.That(decoded.BeatmapInfo.Metadata.PreviewTime, Is.EqualTo(-1));
|
|
|
|
|
Assert.That(decoded.BeatmapInfo.Ruleset.OnlineID, Is.EqualTo(0));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-28 18:28:42 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestUndefinedApproachRateInheritsOverallDifficulty()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("undefined-approach-rate.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
var decoded = decoder.Decode(stream);
|
|
|
|
|
Assert.That(decoded.Difficulty.ApproachRate, Is.EqualTo(1));
|
|
|
|
|
Assert.That(decoded.Difficulty.OverallDifficulty, Is.EqualTo(1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestApproachRateDefinedBeforeOverallDifficulty()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("approach-rate-before-overall-difficulty.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
var decoded = decoder.Decode(stream);
|
|
|
|
|
Assert.That(decoded.Difficulty.ApproachRate, Is.EqualTo(9));
|
|
|
|
|
Assert.That(decoded.Difficulty.OverallDifficulty, Is.EqualTo(1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestApproachRateDefinedAfterOverallDifficulty()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("approach-rate-after-overall-difficulty.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
var decoded = decoder.Decode(stream);
|
|
|
|
|
Assert.That(decoded.Difficulty.ApproachRate, Is.EqualTo(9));
|
|
|
|
|
Assert.That(decoded.Difficulty.OverallDifficulty, Is.EqualTo(1));
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-18 16:10:19 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestLegacyAdjacentImplicitCatmullSegmentsAreMerged()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("adjacent-catmull-segments.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
var decoded = decoder.Decode(stream);
|
|
|
|
|
var controlPoints = ((IHasPath)decoded.HitObjects[0]).Path.ControlPoints;
|
|
|
|
|
|
|
|
|
|
Assert.That(controlPoints.Count, Is.EqualTo(6));
|
|
|
|
|
Assert.That(controlPoints.Single(c => c.Type != null).Type, Is.EqualTo(PathType.Catmull));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestNonLegacyAdjacentImplicitCatmullSegmentsAreNotMerged()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder(LegacyBeatmapEncoder.FIRST_LAZER_VERSION) { ApplyOffsets = false };
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("adjacent-catmull-segments.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
var decoded = decoder.Decode(stream);
|
|
|
|
|
var controlPoints = ((IHasPath)decoded.HitObjects[0]).Path.ControlPoints;
|
|
|
|
|
|
|
|
|
|
Assert.That(controlPoints.Count, Is.EqualTo(4));
|
|
|
|
|
Assert.That(controlPoints[0].Type, Is.EqualTo(PathType.Catmull));
|
|
|
|
|
Assert.That(controlPoints[1].Type, Is.EqualTo(PathType.Catmull));
|
|
|
|
|
Assert.That(controlPoints[2].Type, Is.EqualTo(PathType.Catmull));
|
|
|
|
|
Assert.That(controlPoints[3].Type, Is.Null);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-24 10:47:42 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestLegacyDuplicateInitialCatmullPointIsMerged()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("catmull-duplicate-initial-controlpoint.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
var decoded = decoder.Decode(stream);
|
|
|
|
|
var controlPoints = ((IHasPath)decoded.HitObjects[0]).Path.ControlPoints;
|
|
|
|
|
|
|
|
|
|
Assert.That(controlPoints.Count, Is.EqualTo(4));
|
|
|
|
|
Assert.That(controlPoints[0].Type, Is.EqualTo(PathType.Catmull));
|
|
|
|
|
Assert.That(controlPoints[0].Position, Is.EqualTo(Vector2.Zero));
|
|
|
|
|
Assert.That(controlPoints[1].Type, Is.Null);
|
|
|
|
|
Assert.That(controlPoints[1].Position, Is.Not.EqualTo(Vector2.Zero));
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-24 14:53:55 +08:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestNaNControlPoints()
|
|
|
|
|
{
|
|
|
|
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
|
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("nan-control-points.osu"))
|
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
|
{
|
|
|
|
|
var controlPoints = (LegacyControlPointInfo)decoder.Decode(stream).ControlPointInfo;
|
|
|
|
|
|
|
|
|
|
Assert.That(controlPoints.TimingPoints.Count, Is.EqualTo(1));
|
2022-08-24 15:37:33 +08:00
|
|
|
|
Assert.That(controlPoints.DifficultyPoints.Count, Is.EqualTo(2));
|
2022-08-24 14:53:55 +08:00
|
|
|
|
|
|
|
|
|
Assert.That(controlPoints.TimingPointAt(1000).BeatLength, Is.EqualTo(500));
|
|
|
|
|
|
|
|
|
|
Assert.That(controlPoints.DifficultyPointAt(2000).SliderVelocity, Is.EqualTo(1));
|
|
|
|
|
Assert.That(controlPoints.DifficultyPointAt(3000).SliderVelocity, Is.EqualTo(1));
|
|
|
|
|
|
|
|
|
|
#pragma warning disable 618
|
|
|
|
|
Assert.That(((LegacyBeatmapDecoder.LegacyDifficultyControlPoint)controlPoints.DifficultyPointAt(2000)).GenerateTicks, Is.False);
|
|
|
|
|
Assert.That(((LegacyBeatmapDecoder.LegacyDifficultyControlPoint)controlPoints.DifficultyPointAt(3000)).GenerateTicks, Is.True);
|
|
|
|
|
#pragma warning restore 618
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|