From c8cdc38efd8419bf12c0a48ea8c41fbb93f7bfdd Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 20 Oct 2021 15:20:30 +0900 Subject: [PATCH] Always compare OnlineIds by >0 --- osu.Game/Models/RealmBeatmapSet.cs | 2 +- osu.Game/Stores/BeatmapImporter.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Models/RealmBeatmapSet.cs b/osu.Game/Models/RealmBeatmapSet.cs index d6e56fd61c..6735510422 100644 --- a/osu.Game/Models/RealmBeatmapSet.cs +++ b/osu.Game/Models/RealmBeatmapSet.cs @@ -63,7 +63,7 @@ namespace osu.Game.Models if (IsManaged && other.IsManaged) return ID == other.ID; - if (OnlineID >= 0 && other.OnlineID >= 0) + if (OnlineID > 0 && other.OnlineID > 0) return OnlineID == other.OnlineID; if (!string.IsNullOrEmpty(Hash) && !string.IsNullOrEmpty(other.Hash)) diff --git a/osu.Game/Stores/BeatmapImporter.cs b/osu.Game/Stores/BeatmapImporter.cs index dc43fda09a..254127cc7e 100644 --- a/osu.Game/Stores/BeatmapImporter.cs +++ b/osu.Game/Stores/BeatmapImporter.cs @@ -74,7 +74,7 @@ namespace osu.Game.Stores // ensure at least one beatmap was able to retrieve or keep an online ID, else drop the set ID. if (hadOnlineBeatmapIDs && !beatmapSet.Beatmaps.Any(b => b.OnlineID > 0)) { - if (beatmapSet.OnlineID > -1) + if (beatmapSet.OnlineID > 0) { beatmapSet.OnlineID = -1; LogForModel(beatmapSet, "Disassociating beatmap set ID due to loss of all beatmap IDs"); @@ -91,7 +91,7 @@ namespace osu.Game.Stores // If this is ever an issue, we can consider marking as pending delete but not resetting the IDs (but care will be required for // beatmaps, which don't have their own `DeletePending` state). - if (beatmapSet.OnlineID > -1) + if (beatmapSet.OnlineID > 0) { var existingSetWithSameOnlineID = realm.All().SingleOrDefault(b => b.OnlineID == beatmapSet.OnlineID); @@ -110,7 +110,7 @@ namespace osu.Game.Stores private void validateOnlineIds(RealmBeatmapSet beatmapSet, Realm realm) { - var beatmapIds = beatmapSet.Beatmaps.Where(b => b.OnlineID > -1).Select(b => b.OnlineID).ToList(); + var beatmapIds = beatmapSet.Beatmaps.Where(b => b.OnlineID > 0).Select(b => b.OnlineID).ToList(); // ensure all IDs are unique if (beatmapIds.GroupBy(b => b).Any(g => g.Count() > 1)) @@ -148,7 +148,7 @@ namespace osu.Game.Stores if (!base.CanSkipImport(existing, import)) return false; - return existing.Beatmaps.Any(b => b.OnlineID > -1); + return existing.Beatmaps.Any(b => b.OnlineID > 0); } protected override bool CanReuseExisting(RealmBeatmapSet existing, RealmBeatmapSet import)