Prevented crash when loading non-existent maps

This was SVN commit r1721.
This commit is contained in:
Ykkrosh 2005-01-15 17:20:51 +00:00
parent 4c3dea8a14
commit 551bef482a
2 changed files with 20 additions and 2 deletions

View File

@ -99,7 +99,14 @@ function startLoadingScreen()
function loadSession()
{
startGame();
if (! startGame())
{
// Failed to start the game; go back to the main menu. TODO: display an error message.
GUIObjectHide("loading_screen");
GUIObjectUnhide("pregame_gui");
return;
}
GUIObjectHide("loading_screen");
GUIObjectUnhide("session_gui");
FlipGUI(GUIType);

View File

@ -402,8 +402,19 @@ JSBool startGame(JSContext* cx, JSObject* UNUSEDPARAM(globalObject), unsigned in
else if (!g_Game)
{
g_Game=new CGame();
g_Game->StartGame(&g_GameAttributes);
PSRETURN ret = g_Game->StartGame(&g_GameAttributes);
if (ret != PSRETURN_OK)
{
// Failed to start the game - destroy it, and return false
delete g_Game;
g_Game = NULL;
*rval=BOOLEAN_TO_JSVAL(JS_FALSE);
return JS_TRUE;
}
}
*rval=BOOLEAN_TO_JSVAL(JS_TRUE);
return JS_TRUE;
}