diff --git a/osu.Game.Tests/Database/BeatmapImporterTests.cs b/osu.Game.Tests/Database/BeatmapImporterTests.cs index e2a0e5a79f..4cdcf507b6 100644 --- a/osu.Game.Tests/Database/BeatmapImporterTests.cs +++ b/osu.Game.Tests/Database/BeatmapImporterTests.cs @@ -458,7 +458,7 @@ namespace osu.Game.Tests.Database realmFactory.Context.Write(() => { foreach (var b in imported.Beatmaps) - b.OnlineID = null; + b.OnlineID = -1; }); deleteBeatmapSet(imported, realmFactory.Context); @@ -509,8 +509,8 @@ namespace osu.Game.Tests.Database Assert.NotNull(imported); Debug.Assert(imported != null); - Assert.AreEqual(null, imported.PerformRead(s => s.Beatmaps[0].OnlineID)); - Assert.AreEqual(null, imported.PerformRead(s => s.Beatmaps[1].OnlineID)); + Assert.AreEqual(-1, imported.PerformRead(s => s.Beatmaps[0].OnlineID)); + Assert.AreEqual(-1, imported.PerformRead(s => s.Beatmaps[1].OnlineID)); }); } diff --git a/osu.Game/Beatmaps/BeatmapManager.cs b/osu.Game/Beatmaps/BeatmapManager.cs index 562cbfabf0..0509a9db47 100644 --- a/osu.Game/Beatmaps/BeatmapManager.cs +++ b/osu.Game/Beatmaps/BeatmapManager.cs @@ -29,7 +29,7 @@ namespace osu.Game.Beatmaps /// Handles general operations related to global beatmap management. /// [ExcludeFromDynamicCompile] - public class BeatmapManager : IModelDownloader, IModelManager, IModelFileManager, ICanAcceptFiles, IWorkingBeatmapCache, IDisposable + public class BeatmapManager : IModelDownloader, IModelManager, IModelFileManager, IWorkingBeatmapCache, IDisposable { private readonly BeatmapModelManager beatmapModelManager; private readonly BeatmapModelDownloader beatmapModelDownloader; diff --git a/osu.Game/Scoring/ScoreManager.cs b/osu.Game/Scoring/ScoreManager.cs index 8494cdcd22..a9791fba7e 100644 --- a/osu.Game/Scoring/ScoreManager.cs +++ b/osu.Game/Scoring/ScoreManager.cs @@ -25,7 +25,7 @@ using osu.Game.Rulesets.Scoring; namespace osu.Game.Scoring { - public class ScoreManager : IModelManager, IModelFileManager, IModelDownloader, ICanAcceptFiles + public class ScoreManager : IModelManager, IModelFileManager, IModelDownloader { private readonly Scheduler scheduler; private readonly Func difficulties; diff --git a/osu.Game/Stores/BeatmapImporter.cs b/osu.Game/Stores/BeatmapImporter.cs index 5f058872d3..4ff09e6cc5 100644 --- a/osu.Game/Stores/BeatmapImporter.cs +++ b/osu.Game/Stores/BeatmapImporter.cs @@ -41,7 +41,7 @@ namespace osu.Game.Stores protected override string[] HashableFileTypes => new[] { ".osu" }; // protected override bool CheckLocalAvailability(RealmBeatmapSet model, System.Linq.IQueryable items) - // => base.CheckLocalAvailability(model, items) || (model.OnlineID != null && items.Any(b => b.OnlineID == model.OnlineID)); + // => base.CheckLocalAvailability(model, items) || (model.OnlineID > -1)); private readonly BeatmapOnlineLookupQueue? onlineLookupQueue; @@ -74,9 +74,9 @@ 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 != null) + if (beatmapSet.OnlineID > -1) { - beatmapSet.OnlineID = null; + beatmapSet.OnlineID = -1; LogForModel(beatmapSet, "Disassociating beatmap set ID due to loss of all beatmap IDs"); } } @@ -91,17 +91,17 @@ 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 != null) + if (beatmapSet.OnlineID > -1) { var existingOnlineId = realm.All().SingleOrDefault(b => b.OnlineID == beatmapSet.OnlineID); if (existingOnlineId != null) { existingOnlineId.DeletePending = true; - existingOnlineId.OnlineID = null; + existingOnlineId.OnlineID = -1; foreach (var b in existingOnlineId.Beatmaps) - b.OnlineID = null; + b.OnlineID = -1; LogForModel(beatmapSet, $"Found existing beatmap set with same OnlineID ({beatmapSet.OnlineID}). It will be deleted."); } @@ -110,7 +110,7 @@ namespace osu.Game.Stores private void validateOnlineIds(RealmBeatmapSet beatmapSet, Realm realm) { - var beatmapIds = beatmapSet.Beatmaps.Where(b => b.OnlineID.HasValue).Select(b => b.OnlineID).ToList(); + var beatmapIds = beatmapSet.Beatmaps.Where(b => b.OnlineID > -1).Select(b => b.OnlineID).ToList(); // ensure all IDs are unique if (beatmapIds.GroupBy(b => b).Any(g => g.Count() > 1)) @@ -140,7 +140,7 @@ namespace osu.Game.Stores } } - void resetIds() => beatmapSet.Beatmaps.ForEach(b => b.OnlineID = null); + void resetIds() => beatmapSet.Beatmaps.ForEach(b => b.OnlineID = -1); } protected override bool CanSkipImport(RealmBeatmapSet existing, RealmBeatmapSet import) @@ -148,7 +148,7 @@ namespace osu.Game.Stores if (!base.CanSkipImport(existing, import)) return false; - return existing.Beatmaps.Any(b => b.OnlineID != null); + return existing.Beatmaps.Any(b => b.OnlineID > -1); } protected override bool CanReuseExisting(RealmBeatmapSet existing, RealmBeatmapSet import) @@ -182,7 +182,7 @@ namespace osu.Game.Stores return new RealmBeatmapSet { - OnlineID = beatmap.BeatmapInfo.BeatmapSet?.OnlineBeatmapSetID, + OnlineID = beatmap.BeatmapInfo.BeatmapSet?.OnlineBeatmapSetID ?? -1, // Metadata = beatmap.Metadata, DateAdded = DateTimeOffset.UtcNow }; @@ -250,7 +250,7 @@ namespace osu.Game.Stores { Hash = hash, DifficultyName = decodedInfo.Version, - OnlineID = decodedInfo.OnlineBeatmapID, + OnlineID = decodedInfo.OnlineBeatmapID ?? -1, AudioLeadIn = decodedInfo.AudioLeadIn, StackLeniency = decodedInfo.StackLeniency, SpecialStyle = decodedInfo.SpecialStyle,