mirror of
https://github.com/osukey/osukey.git
synced 2025-05-02 20:27:27 +09:00
Merge pull request #15055 from peppy/fix-taiko-convert-woes
Fix `BeatmapConverter` not cloning deeply enough
This commit is contained in:
commit
f76b58e843
@ -32,6 +32,8 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
|
|
||||||
AddUntilStep("wait for editor load", () => editor != null);
|
AddUntilStep("wait for editor load", () => editor != null);
|
||||||
|
|
||||||
|
AddStep("Set overall difficulty", () => editorBeatmap.Difficulty.OverallDifficulty = 7);
|
||||||
|
|
||||||
AddStep("Add timing point", () => editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint()));
|
AddStep("Add timing point", () => editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint()));
|
||||||
|
|
||||||
AddStep("Enter compose mode", () => InputManager.Key(Key.F1));
|
AddStep("Enter compose mode", () => InputManager.Key(Key.F1));
|
||||||
@ -57,6 +59,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
|
|
||||||
AddUntilStep("Wait for editor load", () => editor != null);
|
AddUntilStep("Wait for editor load", () => editor != null);
|
||||||
AddAssert("Beatmap contains single hitcircle", () => editorBeatmap.HitObjects.Count == 1);
|
AddAssert("Beatmap contains single hitcircle", () => editorBeatmap.HitObjects.Count == 1);
|
||||||
|
AddAssert("Beatmap has correct overall difficulty", () => editorBeatmap.Difficulty.OverallDifficulty == 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,13 @@ namespace osu.Game.Beatmaps
|
|||||||
public IBeatmap Convert(CancellationToken cancellationToken = default)
|
public IBeatmap Convert(CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
// We always operate on a clone of the original beatmap, to not modify it game-wide
|
// We always operate on a clone of the original beatmap, to not modify it game-wide
|
||||||
return ConvertBeatmap(Beatmap.Clone(), cancellationToken);
|
var original = Beatmap.Clone();
|
||||||
|
|
||||||
|
// Shallow clone isn't enough to ensure we don't mutate beatmap info unexpectedly.
|
||||||
|
// Can potentially be removed after `Beatmap.Difficulty` doesn't save back to `Beatmap.BeatmapInfo`.
|
||||||
|
original.BeatmapInfo = original.BeatmapInfo.Clone();
|
||||||
|
|
||||||
|
return ConvertBeatmap(original, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -14,6 +14,7 @@ using osu.Framework.Graphics.Textures;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Formats;
|
using osu.Game.Beatmaps.Formats;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
|
using osu.Game.IO.Serialization;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
@ -109,6 +110,8 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
{
|
{
|
||||||
var beatmap = GetBeatmap(name);
|
var beatmap = GetBeatmap(name);
|
||||||
|
|
||||||
|
string beforeConversion = beatmap.Serialize();
|
||||||
|
|
||||||
var converterResult = new Dictionary<HitObject, IEnumerable<HitObject>>();
|
var converterResult = new Dictionary<HitObject, IEnumerable<HitObject>>();
|
||||||
|
|
||||||
var working = new ConversionWorkingBeatmap(beatmap)
|
var working = new ConversionWorkingBeatmap(beatmap)
|
||||||
@ -122,6 +125,10 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
|
|
||||||
working.GetPlayableBeatmap(CreateRuleset().RulesetInfo, mods);
|
working.GetPlayableBeatmap(CreateRuleset().RulesetInfo, mods);
|
||||||
|
|
||||||
|
string afterConversion = beatmap.Serialize();
|
||||||
|
|
||||||
|
Assert.AreEqual(beforeConversion, afterConversion, "Conversion altered original beatmap");
|
||||||
|
|
||||||
return new ConvertResult
|
return new ConvertResult
|
||||||
{
|
{
|
||||||
Mappings = converterResult.Select(r =>
|
Mappings = converterResult.Select(r =>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user