Merge difficulty creation methods into one

One of them wasn't really doing much anymore and was more obfuscating
what was actually happening at this point.
This commit is contained in:
Bartłomiej Dach 2022-02-03 18:14:30 +01:00
parent b7d7e6612e
commit 6dc0f3fd96
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
2 changed files with 9 additions and 18 deletions

View File

@ -120,15 +120,19 @@ public virtual WorkingBeatmap CreateNewBlankDifficulty(BeatmapSetInfo beatmapSet
// but cases where this isn't true seem rather rare / pathological.
var referenceBeatmap = GetWorkingBeatmap(beatmapSetInfo.Beatmaps.First());
var newBeatmap = new Beatmap
{
BeatmapInfo = new BeatmapInfo(rulesetInfo, new BeatmapDifficulty(), referenceBeatmap.Metadata.DeepClone())
};
var newBeatmapInfo = new BeatmapInfo(rulesetInfo, 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.
beatmapSetInfo.Beatmaps.Add(newBeatmapInfo);
newBeatmapInfo.BeatmapSet = beatmapSetInfo;
var newBeatmap = new Beatmap { BeatmapInfo = newBeatmapInfo };
foreach (var timingPoint in referenceBeatmap.Beatmap.ControlPointInfo.TimingPoints)
newBeatmap.ControlPointInfo.Add(timingPoint.Time, timingPoint.DeepClone());
beatmapModelManager.AddDifficultyToBeatmapSet(beatmapSetInfo, newBeatmap);
beatmapModelManager.Save(newBeatmapInfo, newBeatmap);
workingBeatmapCache.Invalidate(beatmapSetInfo);
return GetWorkingBeatmap(newBeatmap.BeatmapInfo);

View File

@ -90,19 +90,6 @@ public void Save(BeatmapInfo beatmapInfo, IBeatmap beatmapContent, ISkin? beatma
WorkingBeatmapCache?.Invalidate(beatmapInfo);
}
/// <summary>
/// Add a new difficulty to the beatmap set represented by the provided <see cref="BeatmapSetInfo"/>.
/// </summary>
public void AddDifficultyToBeatmapSet(BeatmapSetInfo beatmapSetInfo, Beatmap beatmap)
{
var beatmapInfo = beatmap.BeatmapInfo;
beatmapSetInfo.Beatmaps.Add(beatmapInfo);
beatmapInfo.BeatmapSet = beatmapSetInfo;
Save(beatmapInfo, beatmap);
}
private static string getFilename(BeatmapInfo beatmapInfo)
{
var metadata = beatmapInfo.Metadata;