1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 02:07:34 +08:00

Fix BeatmapInfo-associated member not copying

This commit is contained in:
Bartłomiej Dach 2022-02-06 18:40:51 +01:00
parent fd1c8c3614
commit 1bf5375e74
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497

View File

@ -118,18 +118,12 @@ namespace osu.Game.Beatmaps
var referenceBeatmap = creationParameters.ReferenceBeatmap;
var targetBeatmapSet = creationParameters.BeatmapSet;
var newBeatmapInfo = new BeatmapInfo(creationParameters.Ruleset, new BeatmapDifficulty(), referenceBeatmap.Metadata.DeepClone());
// populate circular beatmap set info <-> beatmap info references manually.
// several places like `BeatmapModelManager.Save()` or `GetWorkingBeatmap()`
// rely on them being freely traversable in both directions for correct operation.
targetBeatmapSet.Beatmaps.Add(newBeatmapInfo);
newBeatmapInfo.BeatmapSet = targetBeatmapSet;
BeatmapInfo newBeatmapInfo;
IBeatmap newBeatmap;
if (creationParameters.ClearAllObjects)
{
newBeatmapInfo = new BeatmapInfo(creationParameters.Ruleset, new BeatmapDifficulty(), referenceBeatmap.Metadata.DeepClone());
newBeatmap = new Beatmap { BeatmapInfo = newBeatmapInfo };
foreach (var timingPoint in referenceBeatmap.ControlPointInfo.TimingPoints)
newBeatmap.ControlPointInfo.Add(timingPoint.Time, timingPoint.DeepClone());
@ -137,9 +131,19 @@ namespace osu.Game.Beatmaps
else
{
newBeatmap = referenceBeatmap.Clone();
newBeatmap.BeatmapInfo = newBeatmapInfo;
newBeatmap.BeatmapInfo = newBeatmapInfo = referenceBeatmap.BeatmapInfo.Clone();
// assign a new ID to the clone.
newBeatmapInfo.ID = Guid.NewGuid();
// clear difficulty name to avoid clashes on save.
newBeatmapInfo.DifficultyName = string.Empty;
}
// populate circular beatmap set info <-> beatmap info references manually.
// several places like `BeatmapModelManager.Save()` or `GetWorkingBeatmap()`
// rely on them being freely traversable in both directions for correct operation.
targetBeatmapSet.Beatmaps.Add(newBeatmapInfo);
newBeatmapInfo.BeatmapSet = targetBeatmapSet;
beatmapModelManager.Save(newBeatmapInfo, newBeatmap);
workingBeatmapCache.Invalidate(targetBeatmapSet);