1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 04:05:35 +08:00

Avoid accessing the beatmap too early.

This commit is contained in:
Dean Herbert 2016-10-28 21:08:32 +09:00
parent 10ef34b805
commit 5dc495e41d
2 changed files with 7 additions and 7 deletions

View File

@ -12,7 +12,7 @@ namespace osu.Game.Beatmaps
{
public class WorkingBeatmap : IDisposable
{
private BeatmapInfo beatmapInfo;
public BeatmapInfo BeatmapInfo;
public readonly ArchiveReader Reader;
@ -25,7 +25,7 @@ namespace osu.Game.Beatmaps
try
{
using (var stream = new StreamReader(Reader.ReadFile(beatmapInfo.Path)))
using (var stream = new StreamReader(Reader.ReadFile(BeatmapInfo.Path)))
beatmap = BeatmapDecoder.GetDecoder(stream)?.Decode(stream);
}
catch { }
@ -44,7 +44,7 @@ namespace osu.Game.Beatmaps
try
{
var trackData = Reader.ReadFile(beatmapInfo.Metadata.AudioFile);
var trackData = Reader.ReadFile(BeatmapInfo.Metadata.AudioFile);
if (trackData != null)
track = new AudioTrackBass(trackData);
}
@ -57,7 +57,7 @@ namespace osu.Game.Beatmaps
public WorkingBeatmap(BeatmapInfo beatmapInfo = null, ArchiveReader reader = null)
{
this.beatmapInfo = beatmapInfo;
this.BeatmapInfo = beatmapInfo;
Reader = reader;
}
@ -80,7 +80,7 @@ namespace osu.Game.Beatmaps
public void TransferTo(WorkingBeatmap working)
{
if (track != null && working.beatmapInfo.Metadata.AudioFile == beatmapInfo.Metadata.AudioFile && working.beatmapInfo.BeatmapSet.Path == beatmapInfo.BeatmapSet.Path)
if (track != null && working.BeatmapInfo.Metadata.AudioFile == BeatmapInfo.Metadata.AudioFile && working.BeatmapInfo.BeatmapSet.Path == BeatmapInfo.BeatmapSet.Path)
working.track = track;
}
}

View File

@ -169,7 +169,7 @@ namespace osu.Game.GameModes.Play
protected override void OnBeatmapChanged(WorkingBeatmap beatmap)
{
base.OnBeatmapChanged(beatmap);
selectBeatmap(beatmap.Beatmap.BeatmapInfo);
selectBeatmap(beatmap.BeatmapInfo);
}
private void selectBeatmap(BeatmapInfo beatmap)
@ -192,7 +192,7 @@ namespace osu.Game.GameModes.Play
{
selectedBeatmapInfo = beatmap;
if (!beatmap.Equals(Beatmap?.Beatmap?.BeatmapInfo))
if (!beatmap.Equals(Beatmap?.BeatmapInfo))
{
Beatmap = database.GetWorkingBeatmap(beatmap, Beatmap);
}