ASYLUM: Check that a scene exists before trying to load it

git-svn-id: http://asylumengine.googlecode.com/svn/trunk@489 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
This commit is contained in:
Julien Templier 2010-11-05 00:35:45 +00:00 committed by Eugene Sandulenko
parent 582794ff12
commit 9249130d59
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
2 changed files with 12 additions and 5 deletions

View File

@ -311,6 +311,10 @@ void AsylumEngine::processDelayedEvents() {
// XXX Flag 183 indicates whether the actionlist is currently
// processing
if (sceneIdx >= 0 && isGameFlagNotSet(kGameFlagScriptProcessing)) {
// Reset delayed scene
_scene->actions()->setDelayedSceneIndex(-1);
_sound->stopMusic();
_sound->stopAllSounds();
@ -319,8 +323,6 @@ void AsylumEngine::processDelayedEvents() {
_scene = new Scene(sceneIdx, this);
_scene->enterScene();
_scene->actions()->setDelayedSceneIndex(-1);
}
}

View File

@ -280,12 +280,17 @@ bool Console::cmdChangeScene(int32 argc, const char **argv) {
return true;
}
if (atoi(argv[1]) - 4 < 1 || atoi(argv[1]) - 4 >= 15) {
DebugPrintf("[Error] Invalid world: %d\n", atoi(argv[1]));
int index = atoi(argv[1]);
// Check if the scene exists
char filename[20];
sprintf(filename, "scn.%03d", index);
if (!SearchMan.hasFile(filename)) {
DebugPrintf("[Error] Scene %d does not exists\n", index);
return true;
}
_vm->scene()->actions()->setDelayedSceneIndex(atoi(argv[1]));
_vm->scene()->actions()->setDelayedSceneIndex(index);
// FIXME push the script index into the script queue
// XXX is this right or should it be ws->actionListIdx???
//_vm->scene()->actions()->setScriptByIndex(0);