From c7c5837ec1546f27061d154cb2efeeaea839f172 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 5 Dec 2018 01:45:32 +0900 Subject: [PATCH 1/4] Fix GetWorkingBeatmap potentially loading same beatmap twice This could be seen when using the previous/next buttons in the MusicController while at song select. --- osu.Game/Beatmaps/BeatmapManager.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 8728d776d0..603f3f1d48 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -249,10 +249,13 @@ namespace osu.Game.Beatmaps /// Retrieve a instance for the provided /// /// The beatmap to lookup. - /// The currently loaded . Allows for optimisation where elements are shared with the new beatmap. + /// The currently loaded . Allows for optimisation where elements are shared with the new beatmap. May be returned if beatmapInfo requested matches /// A instance correlating to the provided . public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null) { + if (previous != null && previous.BeatmapInfo.ID == beatmapInfo.ID) + return previous; + if (beatmapInfo?.BeatmapSet == null || beatmapInfo == DefaultBeatmap?.BeatmapInfo) return DefaultBeatmap; From b5ba74a6282e9001456b097153cbe55b47460c32 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 5 Dec 2018 02:12:15 +0900 Subject: [PATCH 2/4] Add more specific checks --- osu.Game/Beatmaps/BeatmapManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 603f3f1d48..c179821a7c 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -253,7 +253,7 @@ namespace osu.Game.Beatmaps /// A instance correlating to the provided . public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null) { - if (previous != null && previous.BeatmapInfo.ID == beatmapInfo.ID) + if (beatmapInfo?.ID > 0 && previous != null && previous.BeatmapInfo?.ID == beatmapInfo.ID) return previous; if (beatmapInfo?.BeatmapSet == null || beatmapInfo == DefaultBeatmap?.BeatmapInfo) From 94045413ceae0f5d681e4c05070b212049eee235 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 5 Dec 2018 19:44:01 +0900 Subject: [PATCH 3/4] Change statistics to be int for now --- osu.Game.Tests/Scores/IO/ImportScoreTest.cs | 2 +- osu.Game.Tests/Visual/TestCaseResults.cs | 2 +- .../Online/API/Requests/Responses/APIScoreInfo.cs | 2 +- osu.Game/Scoring/Legacy/LegacyScoreParser.cs | 12 ++++++------ osu.Game/Scoring/ScoreInfo.cs | 4 ++-- osu.Game/Screens/Ranking/ResultsPageScore.cs | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/osu.Game.Tests/Scores/IO/ImportScoreTest.cs b/osu.Game.Tests/Scores/IO/ImportScoreTest.cs index 66363deb7c..7ee7acd539 100644 --- a/osu.Game.Tests/Scores/IO/ImportScoreTest.cs +++ b/osu.Game.Tests/Scores/IO/ImportScoreTest.cs @@ -100,7 +100,7 @@ namespace osu.Game.Tests.Scores.IO var toImport = new ScoreInfo { - Statistics = new Dictionary + Statistics = new Dictionary { { HitResult.Perfect, 100 }, { HitResult.Miss, 50 } diff --git a/osu.Game.Tests/Visual/TestCaseResults.cs b/osu.Game.Tests/Visual/TestCaseResults.cs index dfe1cdbfb0..6a20a808b6 100644 --- a/osu.Game.Tests/Visual/TestCaseResults.cs +++ b/osu.Game.Tests/Visual/TestCaseResults.cs @@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual MaxCombo = 123, Rank = ScoreRank.A, Date = DateTimeOffset.Now, - Statistics = new Dictionary + Statistics = new Dictionary { { HitResult.Great, 50 }, { HitResult.Good, 20 }, diff --git a/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs b/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs index 838c4f95e4..b26bc751b9 100644 --- a/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs +++ b/osu.Game/Online/API/Requests/Responses/APIScoreInfo.cs @@ -65,7 +65,7 @@ namespace osu.Game.Online.API.Requests.Responses } [JsonProperty(@"statistics")] - private Dictionary jsonStats + private Dictionary jsonStats { set { diff --git a/osu.Game/Scoring/Legacy/LegacyScoreParser.cs b/osu.Game/Scoring/Legacy/LegacyScoreParser.cs index 13fe021f95..3184f776a7 100644 --- a/osu.Game/Scoring/Legacy/LegacyScoreParser.cs +++ b/osu.Game/Scoring/Legacy/LegacyScoreParser.cs @@ -116,12 +116,12 @@ namespace osu.Game.Scoring.Legacy private void calculateAccuracy(ScoreInfo score) { - int countMiss = (int)score.Statistics[HitResult.Miss]; - int count50 = (int)score.Statistics[HitResult.Meh]; - int count100 = (int)score.Statistics[HitResult.Good]; - int count300 = (int)score.Statistics[HitResult.Great]; - int countGeki = (int)score.Statistics[HitResult.Perfect]; - int countKatu = (int)score.Statistics[HitResult.Ok]; + int countMiss = score.Statistics[HitResult.Miss]; + int count50 = score.Statistics[HitResult.Meh]; + int count100 = score.Statistics[HitResult.Good]; + int count300 = score.Statistics[HitResult.Great]; + int countGeki = score.Statistics[HitResult.Perfect]; + int countKatu = score.Statistics[HitResult.Ok]; switch (score.Ruleset.ID) { diff --git a/osu.Game/Scoring/ScoreInfo.cs b/osu.Game/Scoring/ScoreInfo.cs index e6bab194b0..fb894e621e 100644 --- a/osu.Game/Scoring/ScoreInfo.cs +++ b/osu.Game/Scoring/ScoreInfo.cs @@ -104,7 +104,7 @@ namespace osu.Game.Scoring public DateTimeOffset Date { get; set; } [JsonIgnore] - public Dictionary Statistics = new Dictionary(); + public Dictionary Statistics = new Dictionary(); [Column("Statistics")] public string StatisticsJson @@ -118,7 +118,7 @@ namespace osu.Game.Scoring return; } - Statistics = JsonConvert.DeserializeObject>(value); + Statistics = JsonConvert.DeserializeObject>(value); } } diff --git a/osu.Game/Screens/Ranking/ResultsPageScore.cs b/osu.Game/Screens/Ranking/ResultsPageScore.cs index 153d154d40..62103314e1 100644 --- a/osu.Game/Screens/Ranking/ResultsPageScore.cs +++ b/osu.Game/Screens/Ranking/ResultsPageScore.cs @@ -196,9 +196,9 @@ namespace osu.Game.Screens.Ranking private class DrawableScoreStatistic : Container { - private readonly KeyValuePair statistic; + private readonly KeyValuePair statistic; - public DrawableScoreStatistic(KeyValuePair statistic) + public DrawableScoreStatistic(KeyValuePair statistic) { this.statistic = statistic; From 67a759122acf0bba9b11dab0346ff1780e051b4d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 6 Dec 2018 14:59:17 +0900 Subject: [PATCH 4/4] Fix update code crashing when no internet connection is available --- osu.Desktop/Updater/SimpleUpdateManager.cs | 38 +++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/osu.Desktop/Updater/SimpleUpdateManager.cs b/osu.Desktop/Updater/SimpleUpdateManager.cs index 6c363422f7..e404ccd2b3 100644 --- a/osu.Desktop/Updater/SimpleUpdateManager.cs +++ b/osu.Desktop/Updater/SimpleUpdateManager.cs @@ -41,24 +41,32 @@ namespace osu.Desktop.Updater private async void checkForUpdateAsync() { - var releases = new JsonWebRequest("https://api.github.com/repos/ppy/osu/releases/latest"); - await releases.PerformAsync(); - - var latest = releases.ResponseObject; - - if (latest.TagName != version) + try { - notificationOverlay.Post(new SimpleNotification + var releases = new JsonWebRequest("https://api.github.com/repos/ppy/osu/releases/latest"); + + await releases.PerformAsync(); + + var latest = releases.ResponseObject; + + if (latest.TagName != version) { - Text = $"A newer release of osu! has been found ({version} → {latest.TagName}).\n\n" - + "Click here to download the new version, which can be installed over the top of your existing installation", - Icon = FontAwesome.fa_upload, - Activated = () => + notificationOverlay.Post(new SimpleNotification { - host.OpenUrlExternally(getBestUrl(latest)); - return true; - } - }); + Text = $"A newer release of osu! has been found ({version} → {latest.TagName}).\n\n" + + "Click here to download the new version, which can be installed over the top of your existing installation", + Icon = FontAwesome.fa_upload, + Activated = () => + { + host.OpenUrlExternally(getBestUrl(latest)); + return true; + } + }); + } + } + catch + { + // we shouldn't crash on a web failure. or any failure for the matter. } }