mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-12-26 15:07:14 +00:00
Merge pull request #2457 from gamerbross/bugfix/freeplay-no-song-data-crash
[BUGFIX] Freeplay Crash when song is invalid
This commit is contained in:
commit
fd9cfc2cb1
|
@ -29,6 +29,7 @@ import funkin.graphics.shaders.StrokeShader;
|
||||||
import funkin.input.Controls;
|
import funkin.input.Controls;
|
||||||
import funkin.play.PlayStatePlaylist;
|
import funkin.play.PlayStatePlaylist;
|
||||||
import funkin.play.song.Song;
|
import funkin.play.song.Song;
|
||||||
|
import funkin.ui.story.Level;
|
||||||
import funkin.save.Save;
|
import funkin.save.Save;
|
||||||
import funkin.save.Save.SaveScoreData;
|
import funkin.save.Save.SaveScoreData;
|
||||||
import funkin.ui.AtlasText;
|
import funkin.ui.AtlasText;
|
||||||
|
@ -191,10 +192,24 @@ class FreeplayState extends MusicBeatSubState
|
||||||
// programmatically adds the songs via LevelRegistry and SongRegistry
|
// programmatically adds the songs via LevelRegistry and SongRegistry
|
||||||
for (levelId in LevelRegistry.instance.listSortedLevelIds())
|
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);
|
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.
|
// Only display songs which actually have available charts for the current character.
|
||||||
var availableDifficultiesForSong:Array<String> = song.listDifficulties(displayedVariations, false);
|
var availableDifficultiesForSong:Array<String> = song.listDifficulties(displayedVariations, false);
|
||||||
if (availableDifficultiesForSong.length == 0) continue;
|
if (availableDifficultiesForSong.length == 0) continue;
|
||||||
|
|
Loading…
Reference in a new issue