Merge pull request #16979 from smoogipoo/fix-playlists-partial-mod

Fix playlists not allowing entry with partial mods
This commit is contained in:
Dean Herbert 2022-02-24 19:37:10 +09:00 committed by GitHub
commit d69446ff6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 4 deletions

View File

@ -121,6 +121,17 @@ namespace osu.Game.Tests.Online
Assert.That((deserialised?.Mods[0])?.Settings["speed_change"], Is.EqualTo(2));
}
[Test]
public void TestAPIModDetachedFromSource()
{
var mod = new OsuModDoubleTime { SpeedChange = { Value = 1.01 } };
var apiMod = new APIMod(mod);
mod.SpeedChange.Value = 1.5;
Assert.That(apiMod.Settings["speed_change"], Is.EqualTo(1.01d));
}
private class TestRuleset : Ruleset
{
public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[]

View File

@ -42,7 +42,7 @@ namespace osu.Game.Online.API
var bindable = (IBindable)property.GetValue(mod);
if (!bindable.IsDefault)
Settings.Add(property.Name.Underscore(), bindable);
Settings.Add(property.Name.Underscore(), ModUtils.GetSettingUnderlyingValue(bindable));
}
}

View File

@ -9,7 +9,6 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Screens;
using osu.Game.Extensions;
using osu.Game.Online.API;
using osu.Game.Online.Rooms;
using osu.Game.Rulesets;
using osu.Game.Scoring;
@ -40,8 +39,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
if (ruleset.Value.OnlineID != PlaylistItem.RulesetID)
throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset");
var localMods = Mods.Value.Select(m => new APIMod(m)).ToArray();
if (!PlaylistItem.RequiredMods.All(m => localMods.Any(m.Equals)))
var requiredLocalMods = PlaylistItem.RequiredMods.Select(m => m.ToMod(GameplayState.Ruleset));
if (!requiredLocalMods.All(m => Mods.Value.Any(m.Equals)))
throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods");
}