From 5dc495e41dac27e8f4954c1da82f56830764ae54 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 28 Oct 2016 21:08:32 +0900 Subject: [PATCH] Avoid accessing the beatmap too early. --- osu.Game/Beatmaps/WorkingBeatmap.cs | 10 +++++----- osu.Game/GameModes/Play/PlaySongSelect.cs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 04c9cadd88..4deed53465 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -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; } } diff --git a/osu.Game/GameModes/Play/PlaySongSelect.cs b/osu.Game/GameModes/Play/PlaySongSelect.cs index 4b7bf54fc6..ba2e993b8e 100644 --- a/osu.Game/GameModes/Play/PlaySongSelect.cs +++ b/osu.Game/GameModes/Play/PlaySongSelect.cs @@ -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); }