1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Fix some nullrefs when running visualtests with no maps loaded.

This commit is contained in:
Dean Herbert 2017-01-24 16:01:49 +09:00
parent d17bef12b6
commit 162e183b36
4 changed files with 9 additions and 4 deletions

View File

@ -29,7 +29,9 @@ namespace osu.Desktop.VisualTests.Tests
[BackgroundDependencyLoader]
private void load(BeatmapDatabase db)
{
beatmap = db.GetWorkingBeatmap(db.Query<BeatmapInfo>().Where(b => b.Mode == PlayMode.Osu).FirstOrDefault());
var beatmapInfo = db.Query<BeatmapInfo>().Where(b => b.Mode == PlayMode.Osu).FirstOrDefault();
if (beatmapInfo != null)
beatmap = db.GetWorkingBeatmap(beatmapInfo);
}
public override void Reset()

View File

@ -18,7 +18,8 @@ namespace osu.Game.Beatmaps.Drawables
[BackgroundDependencyLoader]
private void load(OsuGameBase game)
{
Texture = working.Background;
if (working.Background != null)
Texture = working.Background;
}
}
}

View File

@ -30,6 +30,8 @@ namespace osu.Game.Beatmaps
{
if (background != null) return background;
if (BeatmapInfo.Metadata?.BackgroundFile == null) return null;
try
{
using (var reader = GetReader())

View File

@ -56,8 +56,8 @@ namespace osu.Game.Modes.Objects.Drawables
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
string hitType = (HitObject.Sample.Type == SampleType.None ? SampleType.Normal : HitObject.Sample.Type).ToString().ToLower();
string sampleSet = HitObject.Sample.Set.ToString().ToLower();
string hitType = ((HitObject.Sample?.Type ?? SampleType.None) == SampleType.None ? SampleType.Normal : HitObject.Sample.Type).ToString().ToLower();
string sampleSet = (HitObject.Sample?.Set ?? SampleSet.Normal).ToString().ToLower();
sample = audio.Sample.Get($@"Gameplay/{sampleSet}-hit{hitType}");
}