mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 12:22:56 +08:00
Fix audio and background file equality incorrectly comparing BeatmapSet.Hash
This commit is contained in:
parent
c6b6f41b71
commit
1cfdea911b
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
@ -151,14 +152,23 @@ namespace osu.Game.Beatmaps
|
||||
public bool AudioEquals(BeatmapInfo? other) => other != null
|
||||
&& BeatmapSet != null
|
||||
&& other.BeatmapSet != null
|
||||
&& BeatmapSet.Hash == other.BeatmapSet.Hash
|
||||
&& Metadata.AudioFile == other.Metadata.AudioFile;
|
||||
&& compareFiles(this, other, m => m.AudioFile);
|
||||
|
||||
public bool BackgroundEquals(BeatmapInfo? other) => other != null
|
||||
&& BeatmapSet != null
|
||||
&& other.BeatmapSet != null
|
||||
&& BeatmapSet.Hash == other.BeatmapSet.Hash
|
||||
&& Metadata.BackgroundFile == other.Metadata.BackgroundFile;
|
||||
&& compareFiles(this, other, m => m.BackgroundFile);
|
||||
|
||||
private static bool compareFiles(BeatmapInfo x, BeatmapInfo y, Func<IBeatmapMetadataInfo, string> getFilename)
|
||||
{
|
||||
Debug.Assert(x.BeatmapSet != null);
|
||||
Debug.Assert(y.BeatmapSet != null);
|
||||
|
||||
string? fileHashX = x.BeatmapSet.Files.FirstOrDefault(f => f.Filename == getFilename(x.BeatmapSet.Metadata))?.File.Hash;
|
||||
string? fileHashY = y.BeatmapSet.Files.FirstOrDefault(f => f.Filename == getFilename(y.BeatmapSet.Metadata))?.File.Hash;
|
||||
|
||||
return fileHashX == fileHashY;
|
||||
}
|
||||
|
||||
IBeatmapMetadataInfo IBeatmapInfo.Metadata => Metadata;
|
||||
IBeatmapSetInfo? IBeatmapInfo.BeatmapSet => BeatmapSet;
|
||||
|
Loading…
Reference in New Issue
Block a user