mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 20:53:00 +08:00
Add error handling on a per-line level in LegacyDecoder
Resolves #2306.
This commit is contained in:
parent
45eaa53d01
commit
b16e25c3e9
@ -21,7 +21,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
return output;
|
||||
}
|
||||
|
||||
protected abstract void ParseStreamInto(StreamReader stream, TOutput beatmap);
|
||||
protected abstract void ParseStreamInto(StreamReader stream, TOutput output);
|
||||
}
|
||||
|
||||
public abstract class Decoder
|
||||
|
@ -13,15 +13,15 @@ namespace osu.Game.Beatmaps.Formats
|
||||
AddDecoder<Beatmap>("{", m => new JsonBeatmapDecoder());
|
||||
}
|
||||
|
||||
protected override void ParseStreamInto(StreamReader stream, Beatmap beatmap)
|
||||
protected override void ParseStreamInto(StreamReader stream, Beatmap output)
|
||||
{
|
||||
stream.BaseStream.Position = 0;
|
||||
stream.DiscardBufferedData();
|
||||
|
||||
stream.ReadToEnd().DeserializeInto(beatmap);
|
||||
stream.ReadToEnd().DeserializeInto(output);
|
||||
|
||||
foreach (var hitObject in beatmap.HitObjects)
|
||||
hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty);
|
||||
foreach (var hitObject in output.HitObjects)
|
||||
hitObject.ApplyDefaults(output.ControlPointInfo, output.BeatmapInfo.BaseDifficulty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
FormatVersion = version;
|
||||
}
|
||||
|
||||
protected override void ParseStreamInto(StreamReader stream, T beatmap)
|
||||
protected override void ParseStreamInto(StreamReader stream, T output)
|
||||
{
|
||||
Section section = Section.None;
|
||||
|
||||
@ -33,14 +33,21 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section))
|
||||
{
|
||||
Logger.Log($"Unknown section \"{line}\" in {beatmap}");
|
||||
Logger.Log($"Unknown section \"{line}\" in {output}");
|
||||
section = Section.None;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
ParseLine(beatmap, section, line);
|
||||
try
|
||||
{
|
||||
ParseLine(output, section, line);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error(e, $"Failed to process line \"{line}\" into {output}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
}
|
||||
|
||||
protected override void ParseLine(SkinConfiguration output, Section section, string line)
|
||||
protected override void ParseLine(SkinConfiguration skin, Section section, string line)
|
||||
{
|
||||
switch (section)
|
||||
{
|
||||
@ -22,17 +22,17 @@ namespace osu.Game.Skinning
|
||||
switch (pair.Key)
|
||||
{
|
||||
case @"Name":
|
||||
output.SkinInfo.Name = pair.Value;
|
||||
skin.SkinInfo.Name = pair.Value;
|
||||
break;
|
||||
case @"Author":
|
||||
output.SkinInfo.Creator = pair.Value;
|
||||
skin.SkinInfo.Creator = pair.Value;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
base.ParseLine(output, section, line);
|
||||
base.ParseLine(skin, section, line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user