mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 00:42:55 +08:00
Fix playlist items sharing mod instances
This commit is contained in:
parent
3cb22fad82
commit
0500d82b5b
@ -16,7 +16,9 @@ using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Screens.Multi.Components;
|
||||
using osu.Game.Screens.Select;
|
||||
|
||||
@ -145,6 +147,21 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddAssert("new item has id 2", () => Room.Playlist.Last().ID == 2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests that the same <see cref="Mod"/> instances are not shared between two playlist items.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestNewItemHasNewModInstances()
|
||||
{
|
||||
AddStep("set dt mod", () => SelectedMods.Value = new[] { new OsuModDoubleTime() });
|
||||
AddStep("create item", () => songSelect.BeatmapDetails.CreateNewItem());
|
||||
AddStep("change mod rate", () => ((OsuModDoubleTime)SelectedMods.Value[0]).SpeedChange.Value = 2);
|
||||
AddStep("create item", () => songSelect.BeatmapDetails.CreateNewItem());
|
||||
|
||||
AddAssert("item 1 has rate 1.5", () => Precision.AlmostEquals(1.5, ((OsuModDoubleTime)Room.Playlist.First().RequiredMods[0]).SpeedChange.Value));
|
||||
AddAssert("item 2 has rate 2", () => Precision.AlmostEquals(2, ((OsuModDoubleTime)Room.Playlist.Last().RequiredMods[0]).SpeedChange.Value));
|
||||
}
|
||||
|
||||
private class TestMatchSongSelect : MatchSongSelect
|
||||
{
|
||||
public new MatchBeatmapDetailArea BeatmapDetails => (MatchBeatmapDetailArea)base.BeatmapDetails;
|
||||
|
@ -77,6 +77,8 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
item.RequiredMods.Clear();
|
||||
item.RequiredMods.AddRange(Mods.Value);
|
||||
|
||||
Mods.Value = Mods.Value.Select(m => m.CreateCopy()).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user