Do not close game if custom level has assets issues

It's quite rude to close the game entirely if there is trouble with
assets. Instead, just unload the assets and gracefully return to the
title screen.
This commit is contained in:
Misa
2021-08-06 20:57:34 -07:00
committed by Ethan Lee
parent ed9cb4ca6d
commit 8dc5d69ef3
12 changed files with 118 additions and 46 deletions

View File

@@ -2634,6 +2634,14 @@ void scriptclass::resetgametomenu(void)
game.createmenu(Menu::gameover);
}
static void gotoerrorloadinglevel(void)
{
game.createmenu(Menu::errorloadinglevel);
graphics.fademode = 4; /* start fade in */
music.currentsong = -1; /* otherwise music.play won't work */
music.play(6); /* title screen music */
}
void scriptclass::startgamemode( int t )
{
switch(t)
@@ -3152,7 +3160,11 @@ void scriptclass::startgamemode( int t )
//Initilise the level
//First up, find the start point
std::string filename = std::string(ed.ListOfMetaData[game.playcustomlevel].filename);
ed.load(filename);
if (!ed.load(filename))
{
gotoerrorloadinglevel();
break;
}
ed.findstartpoint();
game.gamestate = GAMEMODE;
@@ -3190,7 +3202,11 @@ void scriptclass::startgamemode( int t )
//Initilise the level
//First up, find the start point
std::string filename = std::string(ed.ListOfMetaData[game.playcustomlevel].filename);
ed.load(filename);
if (!ed.load(filename))
{
gotoerrorloadinglevel();
break;
}
ed.findstartpoint();
game.gamestate = GAMEMODE;