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

Log error for invalid events

This commit is contained in:
David Zhao 2019-08-05 19:56:35 +09:00
parent 515d53c360
commit cd6fe91882
4 changed files with 1028 additions and 2 deletions

View File

@ -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);
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -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)
{

View File

@ -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)
{