mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-12-25 22:47:52 +00:00
Fix Freeplay Crash when song is invalid
This commit is contained in:
parent
34a6e16385
commit
c0485fd1a2
|
@ -29,6 +29,7 @@ import funkin.graphics.shaders.StrokeShader;
|
|||
import funkin.input.Controls;
|
||||
import funkin.play.PlayStatePlaylist;
|
||||
import funkin.play.song.Song;
|
||||
import funkin.ui.story.Level;
|
||||
import funkin.save.Save;
|
||||
import funkin.save.Save.SaveScoreData;
|
||||
import funkin.ui.AtlasText;
|
||||
|
@ -191,10 +192,24 @@ class FreeplayState extends MusicBeatSubState
|
|||
// programmatically adds the songs via LevelRegistry and SongRegistry
|
||||
for (levelId in LevelRegistry.instance.listSortedLevelIds())
|
||||
{
|
||||
for (songId in LevelRegistry.instance.parseEntryData(levelId).songs)
|
||||
var level:Level = LevelRegistry.instance.fetchEntry(levelId);
|
||||
|
||||
if (level == null)
|
||||
{
|
||||
trace('[WARN] Could not find level with id (${levelId})');
|
||||
continue;
|
||||
}
|
||||
|
||||
for (songId in level.getSongs())
|
||||
{
|
||||
var song:Song = SongRegistry.instance.fetchEntry(songId);
|
||||
|
||||
if (song == null)
|
||||
{
|
||||
trace('[WARN] Could not find song with id (${songId})');
|
||||
continue;
|
||||
}
|
||||
|
||||
// Only display songs which actually have available charts for the current character.
|
||||
var availableDifficultiesForSong:Array<String> = song.listDifficulties(displayedVariations, false);
|
||||
if (availableDifficultiesForSong.length == 0) continue;
|
||||
|
|
Loading…
Reference in a new issue