From d86e81f07c860efdba6a407297d75cbd370d238b Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 25 Sep 2017 17:52:57 +0900 Subject: [PATCH] Better expression to avoid invalid values --- osu.Game/Beatmaps/BeatmapInfo.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/BeatmapInfo.cs b/osu.Game/Beatmaps/BeatmapInfo.cs index 3cd6294b4a..5e4e122fb5 100644 --- a/osu.Game/Beatmaps/BeatmapInfo.cs +++ b/osu.Game/Beatmaps/BeatmapInfo.cs @@ -82,7 +82,21 @@ namespace osu.Game.Beatmaps public string StoredBookmarks { get { return string.Join(",", Bookmarks); } - set { Bookmarks = value?.Split(',').Select(v => int.Parse(v.Trim())).ToArray() ?? new int[0]; } + set + { + if (string.IsNullOrEmpty(value)) + { + Bookmarks = new int[0]; + return; + } + + Bookmarks = value.Split(',').Select(v => + { + int val; + bool result = int.TryParse(v, out val); + return new { result, val }; + }).Where(p => p.result).Select(p => p.val).ToArray(); + } } [Ignore]