mirror of https://github.com/ppy/osu
Add patcher support for breaks
This commit is contained in:
parent
4022a8b06c
commit
58701b17f8
|
@ -45,6 +45,7 @@ public void Patch(byte[] currentState, byte[] newState)
|
|||
editorBeatmap.BeginChange();
|
||||
processHitObjects(result, () => newBeatmap ??= readBeatmap(newState));
|
||||
processTimingPoints(() => newBeatmap ??= readBeatmap(newState));
|
||||
processBreaks(() => newBeatmap ??= readBeatmap(newState));
|
||||
processHitObjectLocalData(() => newBeatmap ??= readBeatmap(newState));
|
||||
editorBeatmap.EndChange();
|
||||
}
|
||||
|
@ -75,6 +76,27 @@ private void processTimingPoints(Func<IBeatmap> getNewBeatmap)
|
|||
}
|
||||
}
|
||||
|
||||
private void processBreaks(Func<IBeatmap> getNewBeatmap)
|
||||
{
|
||||
var newBreaks = getNewBeatmap().Breaks.ToArray();
|
||||
|
||||
foreach (var oldBreak in editorBeatmap.Breaks.ToArray())
|
||||
{
|
||||
if (newBreaks.Any(b => b.Equals(oldBreak)))
|
||||
continue;
|
||||
|
||||
editorBeatmap.Breaks.Remove(oldBreak);
|
||||
}
|
||||
|
||||
foreach (var newBreak in newBreaks)
|
||||
{
|
||||
if (editorBeatmap.Breaks.Any(b => b.Equals(newBreak)))
|
||||
continue;
|
||||
|
||||
editorBeatmap.Breaks.Add(newBreak);
|
||||
}
|
||||
}
|
||||
|
||||
private void processHitObjects(DiffResult result, Func<IBeatmap> getNewBeatmap)
|
||||
{
|
||||
findChangedIndices(result, LegacyDecoder<Beatmap>.Section.HitObjects, out var removedIndices, out var addedIndices);
|
||||
|
|
Loading…
Reference in New Issue