1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 09:27:34 +08:00

Ensure gameplay can't start when an UnknownMod is present

This commit is contained in:
Dean Herbert 2022-03-09 17:38:56 +09:00
parent 0267aed846
commit 1ee0be5e39
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,26 @@
// 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.
using NUnit.Framework;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu;
namespace osu.Game.Tests.Visual.Gameplay
{
public class TestSceneUnknownMod : ModTestScene
{
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
[Test]
public void TestUnknownModDoesntEnterGameplay()
{
CreateModTest(new ModTestData
{
Beatmap = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo).Beatmap,
Mod = new UnknownMod("WNG"),
PassCondition = () => Player.IsLoaded && !Player.LoadedBeatmapSuccessfully
});
}
}
}

View File

@ -185,6 +185,12 @@ namespace osu.Game.Screens.Play
{
var gameplayMods = Mods.Value.Select(m => m.DeepClone()).ToArray();
if (gameplayMods.Any(m => m is UnknownMod))
{
Logger.Log("Gameplay was started with an unknown mod applied.", level: LogLevel.Important);
return;
}
if (Beatmap.Value is DummyWorkingBeatmap)
return;