mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 16:43:52 +09:00
Log error for invalid beatmap/storyboard events instead of thro… (#5611)
Log error for invalid beatmap/storyboard events instead of throwing Co-authored-by: Dan Balasescu <smoogipoo@smgi.me>
This commit is contained in:
@ -482,5 +482,17 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
Assert.AreEqual(hitObjects[0].Samples[0].Bank, hitObjects[0].Samples[1].Bank);
|
Assert.AreEqual(hitObjects[0].Samples[0].Bank, hitObjects[0].Samples[1].Bank);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestInvalidEventStillPasses()
|
||||||
|
{
|
||||||
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||||
|
|
||||||
|
using (var badResStream = TestResources.OpenResource("invalid-events.osu"))
|
||||||
|
using (var badStream = new StreamReader(badResStream))
|
||||||
|
{
|
||||||
|
Assert.DoesNotThrow(() => decoder.Decode(badStream));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
osu.Game.Tests/Resources/invalid-events.osu
Normal file
14
osu.Game.Tests/Resources/invalid-events.osu
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
osu file format v14
|
||||||
|
|
||||||
|
[Events]
|
||||||
|
bad,event,this,should,fail
|
||||||
|
//Background and Video events
|
||||||
|
0,0,"machinetop_background.jpg",0,0
|
||||||
|
//Break Periods
|
||||||
|
2,122474,140135
|
||||||
|
//Storyboard Layer 0 (Background)
|
||||||
|
this,is,also,bad
|
||||||
|
//Storyboard Layer 1 (Fail)
|
||||||
|
//Storyboard Layer 2 (Pass)
|
||||||
|
//Storyboard Layer 3 (Foreground)
|
||||||
|
//Storyboard Sound Samples
|
@ -5,7 +5,6 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.IO.File;
|
using osu.Framework.IO.File;
|
||||||
using osu.Framework.Logging;
|
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Rulesets.Objects.Legacy;
|
using osu.Game.Rulesets.Objects.Legacy;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
@ -290,8 +289,9 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
string[] split = line.Split(',');
|
string[] split = line.Split(',');
|
||||||
|
|
||||||
EventType type;
|
EventType type;
|
||||||
|
|
||||||
if (!Enum.TryParse(split[0], out type))
|
if (!Enum.TryParse(split[0], out type))
|
||||||
throw new InvalidDataException($@"Unknown event type {split[0]}");
|
throw new InvalidDataException($@"Unknown event type: {split[0]}");
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@ -318,8 +318,6 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleTimingPoint(string line)
|
private void handleTimingPoint(string line)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
string[] split = line.Split(',');
|
string[] split = line.Split(',');
|
||||||
|
|
||||||
@ -395,15 +393,6 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
AutoGenerated = timingChange
|
AutoGenerated = timingChange
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (FormatException)
|
|
||||||
{
|
|
||||||
Logger.Log("A timing point could not be parsed correctly and will be ignored", LoggingTarget.Runtime, LogLevel.Important);
|
|
||||||
}
|
|
||||||
catch (OverflowException)
|
|
||||||
{
|
|
||||||
Logger.Log("A timing point could not be parsed correctly and will be ignored", LoggingTarget.Runtime, LogLevel.Important);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleTimingControlPoint(TimingControlPoint newPoint)
|
private void handleTimingControlPoint(TimingControlPoint newPoint)
|
||||||
{
|
{
|
||||||
|
@ -49,7 +49,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.Error(e, $"Failed to process line \"{line}\" into {output}");
|
Logger.Log($"Failed to process line \"{line}\" into {output}: {e.Message}", LoggingTarget.Runtime, LogLevel.Important);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,8 +82,9 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
storyboardSprite = null;
|
storyboardSprite = null;
|
||||||
|
|
||||||
EventType type;
|
EventType type;
|
||||||
|
|
||||||
if (!Enum.TryParse(split[0], out type))
|
if (!Enum.TryParse(split[0], out type))
|
||||||
throw new InvalidDataException($@"Unknown event type {split[0]}");
|
throw new InvalidDataException($@"Unknown event type: {split[0]}");
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,6 @@ using osu.Game.Beatmaps.Formats;
|
|||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Logging;
|
|
||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Objects.Legacy
|
namespace osu.Game.Rulesets.Objects.Legacy
|
||||||
@ -40,8 +39,6 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
|
|
||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
public override HitObject Parse(string text)
|
public override HitObject Parse(string text)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
string[] split = text.Split(',');
|
string[] split = text.Split(',');
|
||||||
|
|
||||||
@ -219,10 +216,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result == null)
|
if (result == null)
|
||||||
{
|
throw new InvalidDataException($"Unknown hit object type: {split[3]}");
|
||||||
Logger.Log($"Unknown hit object type: {type}. Skipped.", level: LogLevel.Error);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.StartTime = startTime;
|
result.StartTime = startTime;
|
||||||
|
|
||||||
@ -233,17 +227,6 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
catch (FormatException)
|
|
||||||
{
|
|
||||||
Logger.Log("A hitobject could not be parsed correctly and will be ignored", LoggingTarget.Runtime, LogLevel.Important);
|
|
||||||
}
|
|
||||||
catch (OverflowException)
|
|
||||||
{
|
|
||||||
Logger.Log("A hitobject could not be parsed correctly and will be ignored", LoggingTarget.Runtime, LogLevel.Important);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void readCustomSampleBanks(string str, SampleBankInfo bankInfo)
|
private void readCustomSampleBanks(string str, SampleBankInfo bankInfo)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user