mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 12:23:22 +08:00
Log error for invalid events
This commit is contained in:
parent
515d53c360
commit
cd6fe91882
@ -482,5 +482,22 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
Assert.AreEqual(hitObjects[0].Samples[0].Bank, hitObjects[0].Samples[1].Bank);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestDecodeInvalidEvents()
|
||||
{
|
||||
using (var normalResStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
|
||||
using (var normalStream = new StreamReader(normalResStream))
|
||||
using (var resStream = TestResources.OpenResource("invalid-events.osu"))
|
||||
using (var stream = new StreamReader(resStream))
|
||||
{
|
||||
var decoder = Decoder.GetDecoder<Beatmap>(stream);
|
||||
var goodBeatmap = decoder.Decode(normalStream);
|
||||
Beatmap badBeatmap = null;
|
||||
|
||||
Assert.DoesNotThrow(() => badBeatmap = decoder.Decode(stream));
|
||||
Assert.AreEqual(goodBeatmap.HitObjects.Count, badBeatmap.HitObjects.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1004
osu.Game.Tests/Resources/invalid-events.osu
Normal file
1004
osu.Game.Tests/Resources/invalid-events.osu
Normal file
File diff suppressed because it is too large
Load Diff
@ -290,8 +290,12 @@ namespace osu.Game.Beatmaps.Formats
|
||||
string[] split = line.Split(',');
|
||||
|
||||
EventType type;
|
||||
|
||||
if (!Enum.TryParse(split[0], out type))
|
||||
throw new InvalidDataException($@"Unknown event type {split[0]}");
|
||||
{
|
||||
Logger.Log($"A beatmap event could not be parsed and will be ignored: {split[0]}", LoggingTarget.Runtime, LogLevel.Important);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.IO.File;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Storyboards;
|
||||
|
||||
namespace osu.Game.Beatmaps.Formats
|
||||
@ -83,7 +84,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
EventType type;
|
||||
if (!Enum.TryParse(split[0], out type))
|
||||
throw new InvalidDataException($@"Unknown event type {split[0]}");
|
||||
Logger.Log($"A storyboard event could not be parsed and will be ignored: {split[0]}", LoggingTarget.Runtime, LogLevel.Important);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user