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

Fix crash when selecting non-existent IDs from database

This commit is contained in:
ColdVolcano 2017-05-01 19:31:46 -05:00
parent b52781db73
commit 1b52445f86

View File

@ -22,6 +22,8 @@ using osu.Game.Screens.Tournament;
using osu.Framework.Input;
using OpenTK.Input;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Screens.Menu
{
@ -74,10 +76,10 @@ namespace osu.Game.Screens.Menu
if (!menuMusic)
{
trackManager = game.Audio.Track;
int choosableBeatmapsetAmmount = beatmaps.Query<BeatmapSetInfo>().Count();
if (choosableBeatmapsetAmmount > 0)
List<BeatmapSetInfo> choosableBeatmapsets = beatmaps.Query<BeatmapSetInfo>().ToList();
if (choosableBeatmapsets.Count > 0)
{
song = beatmaps.GetWorkingBeatmap(beatmaps.GetWithChildren<BeatmapSetInfo>(RNG.Next(1, choosableBeatmapsetAmmount)).Beatmaps[0]);
song = beatmaps.GetWorkingBeatmap(beatmaps.GetWithChildren<BeatmapSetInfo>(choosableBeatmapsets[RNG.Next(0, choosableBeatmapsets.Count - 1)].ID).Beatmaps[0]);
Beatmap = song;
}
}