1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 16:12:54 +08:00

Update usages of OnlineID

This commit is contained in:
Dean Herbert 2021-10-18 16:10:37 +09:00
parent 6904938dc1
commit b3219bb592
4 changed files with 16 additions and 16 deletions

View File

@ -458,7 +458,7 @@ namespace osu.Game.Tests.Database
realmFactory.Context.Write(() => realmFactory.Context.Write(() =>
{ {
foreach (var b in imported.Beatmaps) foreach (var b in imported.Beatmaps)
b.OnlineID = null; b.OnlineID = -1;
}); });
deleteBeatmapSet(imported, realmFactory.Context); deleteBeatmapSet(imported, realmFactory.Context);
@ -509,8 +509,8 @@ namespace osu.Game.Tests.Database
Assert.NotNull(imported); Assert.NotNull(imported);
Debug.Assert(imported != null); Debug.Assert(imported != null);
Assert.AreEqual(null, imported.PerformRead(s => s.Beatmaps[0].OnlineID)); Assert.AreEqual(-1, 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[1].OnlineID));
}); });
} }

View File

@ -29,7 +29,7 @@ namespace osu.Game.Beatmaps
/// Handles general operations related to global beatmap management. /// Handles general operations related to global beatmap management.
/// </summary> /// </summary>
[ExcludeFromDynamicCompile] [ExcludeFromDynamicCompile]
public class BeatmapManager : IModelDownloader<BeatmapSetInfo>, IModelManager<BeatmapSetInfo>, IModelFileManager<BeatmapSetInfo, BeatmapSetFileInfo>, ICanAcceptFiles, IWorkingBeatmapCache, IDisposable public class BeatmapManager : IModelDownloader<BeatmapSetInfo>, IModelManager<BeatmapSetInfo>, IModelFileManager<BeatmapSetInfo, BeatmapSetFileInfo>, IWorkingBeatmapCache, IDisposable
{ {
private readonly BeatmapModelManager beatmapModelManager; private readonly BeatmapModelManager beatmapModelManager;
private readonly BeatmapModelDownloader beatmapModelDownloader; private readonly BeatmapModelDownloader beatmapModelDownloader;

View File

@ -25,7 +25,7 @@ using osu.Game.Rulesets.Scoring;
namespace osu.Game.Scoring namespace osu.Game.Scoring
{ {
public class ScoreManager : IModelManager<ScoreInfo>, IModelFileManager<ScoreInfo, ScoreFileInfo>, IModelDownloader<ScoreInfo>, ICanAcceptFiles public class ScoreManager : IModelManager<ScoreInfo>, IModelFileManager<ScoreInfo, ScoreFileInfo>, IModelDownloader<ScoreInfo>
{ {
private readonly Scheduler scheduler; private readonly Scheduler scheduler;
private readonly Func<BeatmapDifficultyCache> difficulties; private readonly Func<BeatmapDifficultyCache> difficulties;

View File

@ -41,7 +41,7 @@ namespace osu.Game.Stores
protected override string[] HashableFileTypes => new[] { ".osu" }; protected override string[] HashableFileTypes => new[] { ".osu" };
// protected override bool CheckLocalAvailability(RealmBeatmapSet model, System.Linq.IQueryable<RealmBeatmapSet> items) // protected override bool CheckLocalAvailability(RealmBeatmapSet model, System.Linq.IQueryable<RealmBeatmapSet> 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; 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. // 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 (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"); 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 // 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). // beatmaps, which don't have their own `DeletePending` state).
if (beatmapSet.OnlineID != null) if (beatmapSet.OnlineID > -1)
{ {
var existingOnlineId = realm.All<RealmBeatmapSet>().SingleOrDefault(b => b.OnlineID == beatmapSet.OnlineID); var existingOnlineId = realm.All<RealmBeatmapSet>().SingleOrDefault(b => b.OnlineID == beatmapSet.OnlineID);
if (existingOnlineId != null) if (existingOnlineId != null)
{ {
existingOnlineId.DeletePending = true; existingOnlineId.DeletePending = true;
existingOnlineId.OnlineID = null; existingOnlineId.OnlineID = -1;
foreach (var b in existingOnlineId.Beatmaps) 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."); 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) 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 // ensure all IDs are unique
if (beatmapIds.GroupBy(b => b).Any(g => g.Count() > 1)) 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) protected override bool CanSkipImport(RealmBeatmapSet existing, RealmBeatmapSet import)
@ -148,7 +148,7 @@ namespace osu.Game.Stores
if (!base.CanSkipImport(existing, import)) if (!base.CanSkipImport(existing, import))
return false; 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) protected override bool CanReuseExisting(RealmBeatmapSet existing, RealmBeatmapSet import)
@ -182,7 +182,7 @@ namespace osu.Game.Stores
return new RealmBeatmapSet return new RealmBeatmapSet
{ {
OnlineID = beatmap.BeatmapInfo.BeatmapSet?.OnlineBeatmapSetID, OnlineID = beatmap.BeatmapInfo.BeatmapSet?.OnlineBeatmapSetID ?? -1,
// Metadata = beatmap.Metadata, // Metadata = beatmap.Metadata,
DateAdded = DateTimeOffset.UtcNow DateAdded = DateTimeOffset.UtcNow
}; };
@ -250,7 +250,7 @@ namespace osu.Game.Stores
{ {
Hash = hash, Hash = hash,
DifficultyName = decodedInfo.Version, DifficultyName = decodedInfo.Version,
OnlineID = decodedInfo.OnlineBeatmapID, OnlineID = decodedInfo.OnlineBeatmapID ?? -1,
AudioLeadIn = decodedInfo.AudioLeadIn, AudioLeadIn = decodedInfo.AudioLeadIn,
StackLeniency = decodedInfo.StackLeniency, StackLeniency = decodedInfo.StackLeniency,
SpecialStyle = decodedInfo.SpecialStyle, SpecialStyle = decodedInfo.SpecialStyle,