mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 05:32:54 +08:00
Add xmldoc and simplify calling
This commit is contained in:
parent
e619c9c1e6
commit
eba3d37a11
@ -141,12 +141,9 @@ namespace osu.Game.Beatmaps
|
||||
// Handle collections using permissive difficulty name to track difficulties.
|
||||
foreach (var originalBeatmap in original.Beatmaps)
|
||||
{
|
||||
var updatedBeatmap = updated.Beatmaps.FirstOrDefault(b => b.DifficultyName == originalBeatmap.DifficultyName);
|
||||
|
||||
if (updatedBeatmap == null)
|
||||
continue;
|
||||
|
||||
updatedBeatmap.TransferCollectionsFrom(realm, originalBeatmap.MD5Hash);
|
||||
updated.Beatmaps
|
||||
.FirstOrDefault(b => b.DifficultyName == originalBeatmap.DifficultyName)?
|
||||
.TransferCollectionReferences(realm, originalBeatmap.MD5Hash);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,13 +214,19 @@ namespace osu.Game.Beatmaps
|
||||
return fileHashX == fileHashY;
|
||||
}
|
||||
|
||||
public void TransferCollectionsFrom(Realm realm, string oldMd5Hash)
|
||||
/// <summary>
|
||||
/// When updating a beatmap, its hashes will change. Collections currently track beatmaps by hash, so they need to be updated.
|
||||
/// This method will handle updating
|
||||
/// </summary>
|
||||
/// <param name="realm">A realm instance in an active write transaction.</param>
|
||||
/// <param name="previousMD5Hash">The previous MD5 hash of the beatmap before update.</param>
|
||||
public void TransferCollectionReferences(Realm realm, string previousMD5Hash)
|
||||
{
|
||||
var collections = realm.All<BeatmapCollection>().AsEnumerable().Where(c => c.BeatmapMD5Hashes.Contains(oldMd5Hash));
|
||||
var collections = realm.All<BeatmapCollection>().AsEnumerable().Where(c => c.BeatmapMD5Hashes.Contains(previousMD5Hash));
|
||||
|
||||
foreach (var c in collections)
|
||||
{
|
||||
c.BeatmapMD5Hashes.Remove(oldMd5Hash);
|
||||
c.BeatmapMD5Hashes.Remove(previousMD5Hash);
|
||||
c.BeatmapMD5Hashes.Add(MD5Hash);
|
||||
}
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
setInfo.CopyChangesToRealm(liveBeatmapSet);
|
||||
|
||||
beatmapInfo.TransferCollectionsFrom(r, oldMd5Hash);
|
||||
beatmapInfo.TransferCollectionReferences(r, oldMd5Hash);
|
||||
|
||||
ProcessBeatmap?.Invoke((liveBeatmapSet, false));
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user