Fix custom rulesets not importing scores at all

Replaces the error with the ability to import, minus replays.

Closes https://github.com/ppy/osu/issues/17350 (arguably, but let's go with it for now).
This commit is contained in:
Dean Herbert 2022-07-07 14:49:22 +09:00
parent e5dd7b1654
commit 9d730f8440

View File

@ -22,6 +22,7 @@ using osu.Framework.Threading;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Extensions;
using osu.Game.Graphics.Containers;
using osu.Game.IO.Archives;
using osu.Game.Online.API;
@ -1064,12 +1065,15 @@ namespace osu.Game.Screens.Play
if (DrawableRuleset.ReplayScore != null)
return Task.CompletedTask;
LegacyByteArrayReader replayReader;
LegacyByteArrayReader replayReader = null;
using (var stream = new MemoryStream())
if (score.ScoreInfo.Ruleset.IsLegacyRuleset())
{
new LegacyScoreEncoder(score, GameplayState.Beatmap).Encode(stream);
replayReader = new LegacyByteArrayReader(stream.ToArray(), "replay.osr");
using (var stream = new MemoryStream())
{
new LegacyScoreEncoder(score, GameplayState.Beatmap).Encode(stream);
replayReader = new LegacyByteArrayReader(stream.ToArray(), "replay.osr");
}
}
// the import process will re-attach managed beatmap/rulesets to this score. we don't want this for now, so create a temporary copy to import.