mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 11:03:22 +08:00
Fix incorrect nesting of statements causing completely broken logic
This commit is contained in:
parent
33d3a10708
commit
a5493ce0d1
@ -99,51 +99,51 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
realmContextFactory.Run(realm =>
|
realmContextFactory.Run(realm =>
|
||||||
{
|
{
|
||||||
var sets = realm.All<BeatmapSetInfo>().Where(s => !s.DeletePending && !s.Protected).AsRealmCollection();
|
var usableBeatmapSets = realm.All<BeatmapSetInfo>().Where(s => !s.DeletePending && !s.Protected).AsRealmCollection();
|
||||||
|
|
||||||
int setCount = sets.Count;
|
int setCount = usableBeatmapSets.Count;
|
||||||
|
|
||||||
if (setCount > 0)
|
if (setCount > 0)
|
||||||
{
|
{
|
||||||
var found = sets[RNG.Next(0, setCount - 1)].Beatmaps.FirstOrDefault();
|
var found = usableBeatmapSets[RNG.Next(0, setCount - 1)].Beatmaps.FirstOrDefault();
|
||||||
|
|
||||||
if (found != null)
|
if (found != null)
|
||||||
initialBeatmap = beatmaps.GetWorkingBeatmap(found);
|
initialBeatmap = beatmaps.GetWorkingBeatmap(found);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// we generally want a song to be playing on startup, so use the intro music even if a user has specified not to if no other track is available.
|
// we generally want a song to be playing on startup, so use the intro music even if a user has specified not to if no other track is available.
|
||||||
if (initialBeatmap == null)
|
if (initialBeatmap == null)
|
||||||
|
{
|
||||||
|
if (!loadThemedIntro())
|
||||||
{
|
{
|
||||||
if (!loadThemedIntro())
|
// if we detect that the theme track or beatmap is unavailable this is either first startup or things are in a bad state.
|
||||||
{
|
// this could happen if a user has nuked their files store. for now, reimport to repair this.
|
||||||
// if we detect that the theme track or beatmap is unavailable this is either first startup or things are in a bad state.
|
var import = beatmaps.Import(new ZipArchiveReader(game.Resources.GetStream($"Tracks/{BeatmapFile}"), BeatmapFile)).GetResultSafely();
|
||||||
// this could happen if a user has nuked their files store. for now, reimport to repair this.
|
|
||||||
var import = beatmaps.Import(new ZipArchiveReader(game.Resources.GetStream($"Tracks/{BeatmapFile}"), BeatmapFile)).GetResultSafely();
|
|
||||||
|
|
||||||
import?.PerformWrite(b => b.Protected = true);
|
import?.PerformWrite(b => b.Protected = true);
|
||||||
|
|
||||||
loadThemedIntro();
|
loadThemedIntro();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool loadThemedIntro()
|
bool loadThemedIntro()
|
||||||
|
{
|
||||||
|
var setInfo = beatmaps.QueryBeatmapSet(b => b.Hash == BeatmapHash);
|
||||||
|
|
||||||
|
if (setInfo == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
setInfo.PerformRead(s =>
|
||||||
{
|
{
|
||||||
var setInfo = beatmaps.QueryBeatmapSet(b => b.Hash == BeatmapHash);
|
if (s.Beatmaps.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (setInfo == null)
|
initialBeatmap = beatmaps.GetWorkingBeatmap(s.Beatmaps.First());
|
||||||
return false;
|
});
|
||||||
|
|
||||||
setInfo.PerformRead(s =>
|
return UsingThemedIntro = initialBeatmap != null;
|
||||||
{
|
|
||||||
if (s.Beatmaps.Count == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
initialBeatmap = beatmaps.GetWorkingBeatmap(s.Beatmaps.First());
|
|
||||||
});
|
|
||||||
|
|
||||||
return UsingThemedIntro = initialBeatmap != null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user