1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 02:12:56 +08:00

Merge pull request #29577 from peppy/skin-deserialise-fix

Fix some older lazer skins failing to load properly
This commit is contained in:
Dean Herbert 2024-08-23 23:17:01 +09:00 committed by GitHub
commit a30fe9daff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 37 additions and 0 deletions

View File

@ -12,6 +12,7 @@ using osu.Framework.IO.Stores;
using osu.Game.Audio;
using osu.Game.IO;
using osu.Game.IO.Archives;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Play.HUD;
using osu.Game.Screens.Play.HUD.HitErrorMeters;
using osu.Game.Skinning;
@ -125,6 +126,18 @@ namespace osu.Game.Tests.Skins
}
}
[Test]
public void TestDeserialiseInvalidDrawables()
{
using (var stream = TestResources.OpenResource("Archives/argon-invalid-drawable.osk"))
using (var storage = new ZipArchiveReader(stream))
{
var skin = new TestSkin(new SkinInfo(), null, storage);
Assert.That(skin.LayoutInfos.Any(kvp => kvp.Value.AllDrawables.Any(d => d.Type == typeof(StarFountain))), Is.False);
}
}
[Test]
public void TestDeserialiseModifiedClassic()
{

View File

@ -248,9 +248,33 @@ namespace osu.Game.Skinning
applyMigration(layout, target, i);
layout.Version = SkinLayoutInfo.LATEST_VERSION;
foreach (var kvp in layout.DrawableInfo.ToArray())
{
foreach (var di in kvp.Value)
{
if (!isValidDrawable(di))
layout.DrawableInfo[kvp.Key] = kvp.Value.Where(i => i.Type != di.Type).ToArray();
}
}
return layout;
}
private bool isValidDrawable(SerialisedDrawableInfo di)
{
if (!typeof(ISerialisableDrawable).IsAssignableFrom(di.Type))
return false;
foreach (var child in di.Children)
{
if (!isValidDrawable(child))
return false;
}
return true;
}
private void applyMigration(SkinLayoutInfo layout, GlobalSkinnableContainers target, int version)
{
switch (version)