From b0095ee54832dc8e00ab4b7491bf482bdfd7225b Mon Sep 17 00:00:00 2001 From: Susko3 Date: Thu, 1 Feb 2024 18:38:18 +0100 Subject: [PATCH 01/13] Apply NRT --- osu.Game/Updater/SimpleUpdateManager.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/osu.Game/Updater/SimpleUpdateManager.cs b/osu.Game/Updater/SimpleUpdateManager.cs index bc1b0919b8..77de68d63e 100644 --- a/osu.Game/Updater/SimpleUpdateManager.cs +++ b/osu.Game/Updater/SimpleUpdateManager.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Linq; using System.Runtime.InteropServices; @@ -22,10 +20,10 @@ namespace osu.Game.Updater /// public partial class SimpleUpdateManager : UpdateManager { - private string version; + private string version = null!; [Resolved] - private GameHost host { get; set; } + private GameHost host { get; set; } = null!; [BackgroundDependencyLoader] private void load(OsuGameBase game) @@ -76,7 +74,7 @@ namespace osu.Game.Updater private string getBestUrl(GitHubRelease release) { - GitHubAsset bestAsset = null; + GitHubAsset? bestAsset = null; switch (RuntimeInfo.OS) { From b9d750cfee9c18a6226c74b0ca5d452279234f5f Mon Sep 17 00:00:00 2001 From: Susko3 Date: Thu, 1 Feb 2024 18:55:34 +0100 Subject: [PATCH 02/13] Convert to try-get and don't fall back to release URL --- osu.Game/Updater/SimpleUpdateManager.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/osu.Game/Updater/SimpleUpdateManager.cs b/osu.Game/Updater/SimpleUpdateManager.cs index 77de68d63e..a7671551ef 100644 --- a/osu.Game/Updater/SimpleUpdateManager.cs +++ b/osu.Game/Updater/SimpleUpdateManager.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; @@ -46,7 +47,7 @@ namespace osu.Game.Updater version = version.Split('-').First(); string latestTagName = latest.TagName.Split('-').First(); - if (latestTagName != version) + if (latestTagName != version && tryGetBestUrl(latest, out string? url)) { Notifications.Post(new SimpleNotification { @@ -55,7 +56,7 @@ namespace osu.Game.Updater Icon = FontAwesome.Solid.Download, Activated = () => { - host.OpenUrlExternally(getBestUrl(latest)); + host.OpenUrlExternally(url); return true; } }); @@ -72,8 +73,9 @@ namespace osu.Game.Updater return false; } - private string getBestUrl(GitHubRelease release) + private bool tryGetBestUrl(GitHubRelease release, [NotNullWhen(true)] out string? url) { + url = null; GitHubAsset? bestAsset = null; switch (RuntimeInfo.OS) @@ -94,15 +96,18 @@ namespace osu.Game.Updater case RuntimeInfo.Platform.iOS: // iOS releases are available via testflight. this link seems to work well enough for now. // see https://stackoverflow.com/a/32960501 - return "itms-beta://beta.itunes.apple.com/v1/app/1447765923"; + url = "itms-beta://beta.itunes.apple.com/v1/app/1447765923"; + break; case RuntimeInfo.Platform.Android: - // on our testing device this causes the download to magically disappear. + // on our testing device using the .apk URL causes the download to magically disappear. //bestAsset = release.Assets?.Find(f => f.Name.EndsWith(".apk")); + url = release.HtmlUrl; break; } - return bestAsset?.BrowserDownloadUrl ?? release.HtmlUrl; + url ??= bestAsset?.BrowserDownloadUrl; + return url != null; } } } From f92751a7d29baf4bdc81d60725e00b8b7bb7db02 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Thu, 1 Feb 2024 18:56:38 +0100 Subject: [PATCH 03/13] Don't suggest an update on mobile if it isn't available --- osu.Game/Updater/SimpleUpdateManager.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/osu.Game/Updater/SimpleUpdateManager.cs b/osu.Game/Updater/SimpleUpdateManager.cs index a7671551ef..0f9d5b929f 100644 --- a/osu.Game/Updater/SimpleUpdateManager.cs +++ b/osu.Game/Updater/SimpleUpdateManager.cs @@ -94,15 +94,18 @@ namespace osu.Game.Updater break; case RuntimeInfo.Platform.iOS: - // iOS releases are available via testflight. this link seems to work well enough for now. - // see https://stackoverflow.com/a/32960501 - url = "itms-beta://beta.itunes.apple.com/v1/app/1447765923"; + if (release.Assets?.Exists(f => f.Name.EndsWith(".ipa", StringComparison.Ordinal)) == true) + // iOS releases are available via testflight. this link seems to work well enough for now. + // see https://stackoverflow.com/a/32960501 + url = "itms-beta://beta.itunes.apple.com/v1/app/1447765923"; + break; case RuntimeInfo.Platform.Android: - // on our testing device using the .apk URL causes the download to magically disappear. - //bestAsset = release.Assets?.Find(f => f.Name.EndsWith(".apk")); - url = release.HtmlUrl; + if (release.Assets?.Exists(f => f.Name.EndsWith(".apk", StringComparison.Ordinal)) == true) + // on our testing device using the .apk URL causes the download to magically disappear. + url = release.HtmlUrl; + break; } From 0da67e64b371c75aa76a4c01e6c3762aa208c603 Mon Sep 17 00:00:00 2001 From: kongehund <63306696+kongehund@users.noreply.github.com> Date: Tue, 6 Feb 2024 00:28:39 +0100 Subject: [PATCH 04/13] Fix deselecting slider adding control points --- .../Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs index 3575e15d1d..e421d497e7 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/Sliders/SliderSelectionBlueprint.cs @@ -171,7 +171,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders return false; // Allow right click to be handled by context menu case MouseButton.Left: - if (e.ControlPressed && IsSelected) + // If there's more than two objects selected, ctrl+click should deselect + if (e.ControlPressed && IsSelected && selectedObjects.Count < 2) { changeHandler?.BeginChange(); placementControlPoint = addControlPoint(e.MousePosition); From 0d7e82ab8df41e6950d97c1fa67e28389ca699d0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 8 Feb 2024 00:20:53 +0800 Subject: [PATCH 05/13] Improve exception logging of unobserved exceptions via `FireAndForget` Coming from https://github.com/ppy/osu/issues/27076, where the log output makes finding where the exception arrived for nigh impossible. --- osu.Game/Online/Multiplayer/MultiplayerClientExtensions.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Online/Multiplayer/MultiplayerClientExtensions.cs b/osu.Game/Online/Multiplayer/MultiplayerClientExtensions.cs index 2083aa4e28..d846e7f566 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerClientExtensions.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerClientExtensions.cs @@ -23,9 +23,12 @@ namespace osu.Game.Online.Multiplayer Debug.Assert(exception != null); - string message = exception.GetHubExceptionMessage() ?? exception.Message; + if (exception.GetHubExceptionMessage() is string message) + // Hub exceptions generally contain something we can show the user directly. + Logger.Log(message, level: LogLevel.Important); + else + Logger.Error(exception, $"Unobserved exception occurred via {nameof(FireAndForget)} call: {exception.Message}"); - Logger.Log(message, level: LogLevel.Important); onError?.Invoke(exception); } else From 666c57da5023627624c546c4450c7f04af676b5c Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 30 Dec 2023 12:17:14 -0800 Subject: [PATCH 06/13] Fix profile current location and interests icons not matching web --- osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs b/osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs index 85751e7457..83ddb024c6 100644 --- a/osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs +++ b/osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs @@ -144,8 +144,8 @@ namespace osu.Game.Overlays.Profile.Header bool anyInfoAdded = false; - anyInfoAdded |= tryAddInfo(FontAwesome.Solid.MapMarker, user.Location); - anyInfoAdded |= tryAddInfo(FontAwesome.Solid.Heart, user.Interests); + anyInfoAdded |= tryAddInfo(FontAwesome.Solid.MapMarkerAlt, user.Location); + anyInfoAdded |= tryAddInfo(FontAwesome.Regular.Heart, user.Interests); anyInfoAdded |= tryAddInfo(FontAwesome.Solid.Suitcase, user.Occupation); if (anyInfoAdded) From ed2362b63da113e45e46756a47b94a3938ce4973 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 30 Dec 2023 12:17:46 -0800 Subject: [PATCH 07/13] Fix icon family and weight not transferring to text conversion --- osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs b/osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs index 83ddb024c6..d5b4d844b2 100644 --- a/osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs +++ b/osu.Game/Overlays/Profile/Header/BottomHeaderContainer.cs @@ -171,7 +171,7 @@ namespace osu.Game.Overlays.Profile.Header bottomLinkContainer.AddIcon(icon, text => { - text.Font = text.Font.With(size: 10); + text.Font = text.Font.With(icon.Family, 10, icon.Weight); text.Colour = iconColour; }); From bfeb90c1b6d7e09edf59c42ed14a567a4bcdee7e Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Sat, 10 Feb 2024 17:20:17 +0900 Subject: [PATCH 08/13] Add additional gameplay metadata to room score request --- osu.Game/Online/Rooms/CreateRoomScoreRequest.cs | 10 +++++++++- osu.Game/Screens/Play/RoomSubmittingPlayer.cs | 12 +++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/osu.Game/Online/Rooms/CreateRoomScoreRequest.cs b/osu.Game/Online/Rooms/CreateRoomScoreRequest.cs index c31c6a929a..e0f91032fd 100644 --- a/osu.Game/Online/Rooms/CreateRoomScoreRequest.cs +++ b/osu.Game/Online/Rooms/CreateRoomScoreRequest.cs @@ -1,8 +1,10 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Globalization; using System.Net.Http; using osu.Framework.IO.Network; +using osu.Game.Beatmaps; using osu.Game.Online.API; namespace osu.Game.Online.Rooms @@ -11,12 +13,16 @@ namespace osu.Game.Online.Rooms { private readonly long roomId; private readonly long playlistItemId; + private readonly BeatmapInfo beatmapInfo; + private readonly int rulesetId; private readonly string versionHash; - public CreateRoomScoreRequest(long roomId, long playlistItemId, string versionHash) + public CreateRoomScoreRequest(long roomId, long playlistItemId, BeatmapInfo beatmapInfo, int rulesetId, string versionHash) { this.roomId = roomId; this.playlistItemId = playlistItemId; + this.beatmapInfo = beatmapInfo; + this.rulesetId = rulesetId; this.versionHash = versionHash; } @@ -25,6 +31,8 @@ namespace osu.Game.Online.Rooms var req = base.CreateWebRequest(); req.Method = HttpMethod.Post; req.AddParameter("version_hash", versionHash); + req.AddParameter("beatmap_hash", beatmapInfo.MD5Hash); + req.AddParameter("ruleset_id", rulesetId.ToString(CultureInfo.InvariantCulture)); return req; } diff --git a/osu.Game/Screens/Play/RoomSubmittingPlayer.cs b/osu.Game/Screens/Play/RoomSubmittingPlayer.cs index e21daa737e..3f74f49384 100644 --- a/osu.Game/Screens/Play/RoomSubmittingPlayer.cs +++ b/osu.Game/Screens/Play/RoomSubmittingPlayer.cs @@ -4,6 +4,7 @@ #nullable disable using System.Diagnostics; +using osu.Game.Extensions; using osu.Game.Online.API; using osu.Game.Online.Rooms; using osu.Game.Scoring; @@ -30,7 +31,16 @@ namespace osu.Game.Screens.Play if (!(Room.RoomID.Value is long roomId)) return null; - return new CreateRoomScoreRequest(roomId, PlaylistItem.ID, Game.VersionHash); + int beatmapId = Beatmap.Value.BeatmapInfo.OnlineID; + int rulesetId = Ruleset.Value.OnlineID; + + if (beatmapId <= 0) + return null; + + if (!Ruleset.Value.IsLegacyRuleset()) + return null; + + return new CreateRoomScoreRequest(roomId, PlaylistItem.ID, Beatmap.Value.BeatmapInfo, rulesetId, Game.VersionHash); } protected override APIRequest CreateSubmissionRequest(Score score, long token) From ae5f108f01444dc4c7449858ed77f63ba22d153e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 10 Feb 2024 13:08:26 +0100 Subject: [PATCH 09/13] Add visual test coverage of user profile info section --- osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs index bc8f75d4ce..1b9ca8717a 100644 --- a/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs +++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs @@ -206,6 +206,12 @@ namespace osu.Game.Tests.Visual.Online Total = 50 }, SupportLevel = 2, + Location = "Somewhere", + Interests = "Rhythm games", + Occupation = "Gamer", + Twitter = "test_user", + Discord = "test_user", + Website = "https://google.com", }; } } From 6894f17b2311019a18cd1553b569998e263981f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 10 Feb 2024 15:34:12 +0100 Subject: [PATCH 10/13] Add test coverage --- .../Editor/TestSceneOsuComposerSelection.cs | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuComposerSelection.cs b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuComposerSelection.cs index 623cefff6b..b97fe5c5a8 100644 --- a/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuComposerSelection.cs +++ b/osu.Game.Rulesets.Osu.Tests/Editor/TestSceneOsuComposerSelection.cs @@ -124,6 +124,113 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor AddAssert("selection preserved", () => EditorBeatmap.SelectedHitObjects.Count == 2); } + [Test] + public void TestControlClickAddsControlPointsIfSingleSliderSelected() + { + var firstSlider = new Slider + { + StartTime = 0, + Position = new Vector2(0, 0), + Path = new SliderPath + { + ControlPoints = + { + new PathControlPoint(), + new PathControlPoint(new Vector2(100)) + } + } + }; + var secondSlider = new Slider + { + StartTime = 1000, + Position = new Vector2(200, 200), + Path = new SliderPath + { + ControlPoints = + { + new PathControlPoint(), + new PathControlPoint(new Vector2(100, -100)) + } + } + }; + + AddStep("add objects", () => EditorBeatmap.AddRange(new HitObject[] { firstSlider, secondSlider })); + AddStep("select first slider", () => EditorBeatmap.SelectedHitObjects.AddRange(new HitObject[] { secondSlider })); + + AddStep("move mouse to middle of slider", () => + { + var pos = blueprintContainer.SelectionBlueprints + .First(s => s.Item == secondSlider) + .ChildrenOfType().First() + .ScreenSpaceDrawQuad.Centre; + + InputManager.MoveMouseTo(pos); + }); + AddStep("control-click left mouse", () => + { + InputManager.PressKey(Key.ControlLeft); + InputManager.Click(MouseButton.Left); + InputManager.ReleaseKey(Key.ControlLeft); + }); + AddAssert("selection preserved", () => EditorBeatmap.SelectedHitObjects.Count, () => Is.EqualTo(1)); + AddAssert("slider has 3 anchors", () => secondSlider.Path.ControlPoints.Count, () => Is.EqualTo(3)); + } + + [Test] + public void TestControlClickDoesNotAddSliderControlPointsIfMultipleObjectsSelected() + { + var firstSlider = new Slider + { + StartTime = 0, + Position = new Vector2(0, 0), + Path = new SliderPath + { + ControlPoints = + { + new PathControlPoint(), + new PathControlPoint(new Vector2(100)) + } + } + }; + var secondSlider = new Slider + { + StartTime = 1000, + Position = new Vector2(200, 200), + Path = new SliderPath + { + ControlPoints = + { + new PathControlPoint(), + new PathControlPoint(new Vector2(100, -100)) + } + } + }; + + AddStep("add objects", () => EditorBeatmap.AddRange(new HitObject[] { firstSlider, secondSlider })); + AddStep("select first slider", () => EditorBeatmap.SelectedHitObjects.AddRange(new HitObject[] { firstSlider, secondSlider })); + + AddStep("move mouse to middle of slider", () => + { + var pos = blueprintContainer.SelectionBlueprints + .First(s => s.Item == secondSlider) + .ChildrenOfType().First() + .ScreenSpaceDrawQuad.Centre; + + InputManager.MoveMouseTo(pos); + }); + AddStep("control-click left mouse", () => + { + InputManager.PressKey(Key.ControlLeft); + InputManager.Click(MouseButton.Left); + InputManager.ReleaseKey(Key.ControlLeft); + }); + AddAssert("selection not preserved", () => EditorBeatmap.SelectedHitObjects.Count, () => Is.EqualTo(1)); + AddAssert("second slider not selected", + () => blueprintContainer.SelectionBlueprints.First(s => s.Item == secondSlider).IsSelected, + () => Is.False); + AddAssert("slider still has 2 anchors", () => secondSlider.Path.ControlPoints.Count, () => Is.EqualTo(2)); + } + private ComposeBlueprintContainer blueprintContainer => Editor.ChildrenOfType().First(); From d99187302894c50cee5f84b493e7050f899cc21e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 10 Feb 2024 15:54:43 +0100 Subject: [PATCH 11/13] Add note to never run release config to contributing guidelines See https://discord.com/channels/188630481301012481/188630652340404224/1205886296439136286 for the latest instance of this, but this really keeps happening. Maybe someone will read this and stop themselves from making the same mistake. One can dream. --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4106641adb..4f969ab915 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,6 +68,7 @@ Aside from the above, below is a brief checklist of things to watch out when you - Please do not make code changes via the GitHub web interface. - Please add tests for your changes. We expect most new features and bugfixes to have test coverage, unless the effort of adding them is prohibitive. The visual testing methodology we use is described in more detail [here](https://github.com/ppy/osu-framework/wiki/Development-and-Testing). - Please run tests and code style analysis (via `InspectCode.{ps1,sh}` scripts in the root of this repository) before opening the PR. This is particularly important if you're a first-time contributor, as CI will not run for your PR until we allow it to do so. +- Do not run the game in release configuration at any point during your testing (the sole exception to this being benchmarks). Using release is an unnecessary and harmful practice, and can even lead to you losing your local realm database if you start making changes to the schema. The debug configuration has a completely separated full-stack environment, including a development website instance at https://dev.ppy.sh/. It is permitted to register an account on that development instance for testing purposes and not worry about multi-accounting infractions. After you're done with your changes and you wish to open the PR, please observe the following recommendations: From bd04377643d3f42836ff10b6fc6af53728fee215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 10 Feb 2024 16:42:19 +0100 Subject: [PATCH 12/13] Tell people to not run in release harder Co-authored-by: Dean Herbert --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4f969ab915..0fe6b6fb4d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,7 +68,7 @@ Aside from the above, below is a brief checklist of things to watch out when you - Please do not make code changes via the GitHub web interface. - Please add tests for your changes. We expect most new features and bugfixes to have test coverage, unless the effort of adding them is prohibitive. The visual testing methodology we use is described in more detail [here](https://github.com/ppy/osu-framework/wiki/Development-and-Testing). - Please run tests and code style analysis (via `InspectCode.{ps1,sh}` scripts in the root of this repository) before opening the PR. This is particularly important if you're a first-time contributor, as CI will not run for your PR until we allow it to do so. -- Do not run the game in release configuration at any point during your testing (the sole exception to this being benchmarks). Using release is an unnecessary and harmful practice, and can even lead to you losing your local realm database if you start making changes to the schema. The debug configuration has a completely separated full-stack environment, including a development website instance at https://dev.ppy.sh/. It is permitted to register an account on that development instance for testing purposes and not worry about multi-accounting infractions. +- **Do not run the game in release configuration at any point during your testing** (the sole exception to this being benchmarks). Using release is an unnecessary and harmful practice, and can even lead to you losing your local realm database if you start making changes to the schema. The debug configuration has a completely separated full-stack environment, including a development website instance at https://dev.ppy.sh/. It is permitted to register an account on that development instance for testing purposes and not worry about multi-accounting infractions. After you're done with your changes and you wish to open the PR, please observe the following recommendations: From 901b82384d5fbc224c18b96347bc3b07e37b0e8b Mon Sep 17 00:00:00 2001 From: tsunyoku Date: Sat, 10 Feb 2024 15:42:55 +0000 Subject: [PATCH 13/13] replace linq usage in `Previous` and `Next` with more direct computation --- .../Difficulty/Preprocessing/DifficultyHitObject.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/osu.Game/Rulesets/Difficulty/Preprocessing/DifficultyHitObject.cs b/osu.Game/Rulesets/Difficulty/Preprocessing/DifficultyHitObject.cs index 9ce0906dea..9785865192 100644 --- a/osu.Game/Rulesets/Difficulty/Preprocessing/DifficultyHitObject.cs +++ b/osu.Game/Rulesets/Difficulty/Preprocessing/DifficultyHitObject.cs @@ -4,7 +4,6 @@ #nullable disable using System.Collections.Generic; -using System.Linq; using osu.Game.Rulesets.Objects; namespace osu.Game.Rulesets.Difficulty.Preprocessing @@ -65,8 +64,16 @@ namespace osu.Game.Rulesets.Difficulty.Preprocessing EndTime = hitObject.GetEndTime() / clockRate; } - public DifficultyHitObject Previous(int backwardsIndex) => difficultyHitObjects.ElementAtOrDefault(Index - (backwardsIndex + 1)); + public DifficultyHitObject Previous(int backwardsIndex) + { + int index = Index - (backwardsIndex + 1); + return index >= 0 && index < difficultyHitObjects.Count ? difficultyHitObjects[index] : default; + } - public DifficultyHitObject Next(int forwardsIndex) => difficultyHitObjects.ElementAtOrDefault(Index + (forwardsIndex + 1)); + public DifficultyHitObject Next(int forwardsIndex) + { + int index = Index + (forwardsIndex + 1); + return index >= 0 && index < difficultyHitObjects.Count ? difficultyHitObjects[index] : default; + } } }