1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-25 17:10:09 +08:00

Merge pull request #17818 from peppy/early-abort-virtual-track

Handle virtual track string to avoid throwing later in lookup
This commit is contained in:
Dan Balasescu
2022-04-14 19:01:30 +09:00
committed by GitHub
Unverified
+13 -1
View File
@@ -26,6 +26,11 @@ namespace osu.Game.Beatmaps
{
private readonly WeakList<BeatmapManagerWorkingBeatmap> workingCache = new WeakList<BeatmapManagerWorkingBeatmap>();
/// <summary>
/// Beatmap files may specify this filename to denote that they don't have an audio track.
/// </summary>
private const string virtual_track_filename = @"virtual";
/// <summary>
/// A default representation of a WorkingBeatmap to use when no beatmap is available.
/// </summary>
@@ -40,7 +45,8 @@ namespace osu.Game.Beatmaps
[CanBeNull]
private readonly GameHost host;
public WorkingBeatmapCache(ITrackStore trackStore, AudioManager audioManager, IResourceStore<byte[]> resources, IResourceStore<byte[]> files, WorkingBeatmap defaultBeatmap = null, GameHost host = null)
public WorkingBeatmapCache(ITrackStore trackStore, AudioManager audioManager, IResourceStore<byte[]> resources, IResourceStore<byte[]> files, WorkingBeatmap defaultBeatmap = null,
GameHost host = null)
{
DefaultBeatmap = defaultBeatmap;
@@ -157,6 +163,9 @@ namespace osu.Game.Beatmaps
if (string.IsNullOrEmpty(Metadata?.AudioFile))
return null;
if (Metadata.AudioFile == virtual_track_filename)
return null;
try
{
return resources.Tracks.Get(BeatmapSetInfo.GetPathForFile(Metadata.AudioFile));
@@ -173,6 +182,9 @@ namespace osu.Game.Beatmaps
if (string.IsNullOrEmpty(Metadata?.AudioFile))
return null;
if (Metadata.AudioFile == virtual_track_filename)
return null;
try
{
var trackData = GetStream(BeatmapSetInfo.GetPathForFile(Metadata.AudioFile));