ASYLUM: Fixed a bug from the original game that caused the application to be locked (and occasionally crash) due to the fact that the application was locked in a while loop during the playing of the first sfx item after the intro video.
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@298 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
This commit is contained in:
parent
bffebfd830
commit
f48ab391ac
2 changed files with 39 additions and 18 deletions
|
@ -89,6 +89,8 @@ Common::Error AsylumEngine::init() {
|
||||||
Shared.setSound(_sound);
|
Shared.setSound(_sound);
|
||||||
Shared.setVideo(_video);
|
Shared.setVideo(_video);
|
||||||
|
|
||||||
|
_introPlaying = false;
|
||||||
|
|
||||||
return Common::kNoError;
|
return Common::kNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,10 +125,10 @@ Common::Error AsylumEngine::go() {
|
||||||
// Also, this routine is used to set game flags 4 and 12, so if we're
|
// Also, this routine is used to set game flags 4 and 12, so if we're
|
||||||
// skipping the intro, but not loading a save file, those flags
|
// skipping the intro, but not loading a save file, those flags
|
||||||
// need to be set somewhere else.
|
// need to be set somewhere else.
|
||||||
//playIntro();
|
playIntro();
|
||||||
|
|
||||||
// Enter first scene
|
// Enter first scene
|
||||||
_scene->enterScene();
|
//_scene->enterScene();
|
||||||
|
|
||||||
while (!shouldQuit()) {
|
while (!shouldQuit()) {
|
||||||
checkForEvent(true);
|
checkForEvent(true);
|
||||||
|
@ -162,13 +164,24 @@ void AsylumEngine::playIntro() {
|
||||||
|
|
||||||
_sound->playSfx(introRes, 7);
|
_sound->playSfx(introRes, 7);
|
||||||
|
|
||||||
if (_sound->isSfxActive()) {
|
_introPlaying = true;
|
||||||
while (_sound->isSfxActive()) {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete introRes;
|
delete introRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AsylumEngine::checkForEvent(bool doUpdate) {
|
||||||
|
|
||||||
|
// NOTE
|
||||||
|
// In the original version of Sanitarium, the control loop for the sound
|
||||||
|
// effect that played after the intro video involved a while loop that
|
||||||
|
// executed until the sound handle was released.
|
||||||
|
// This caused the application to be locked until the while loop's execution
|
||||||
|
// completed successfully. Our implementation circumvents this issue
|
||||||
|
// by moving the logic to the event loop and checking whether a flag is
|
||||||
|
// set to determine if control should be returned to the engine.
|
||||||
|
if (_introPlaying) {
|
||||||
|
if (!_sound->isSfxActive()) {
|
||||||
|
_introPlaying = false;
|
||||||
|
|
||||||
// TODO Since we've currently only got one sfx handle to play with in
|
// TODO Since we've currently only got one sfx handle to play with in
|
||||||
// the sound class, entering the scene overwrites the "alarm" loop.
|
// the sound class, entering the scene overwrites the "alarm" loop.
|
||||||
|
@ -180,9 +193,11 @@ void AsylumEngine::playIntro() {
|
||||||
// especially when you examine isSoundinList() or isSoundPlaying())
|
// especially when you examine isSoundinList() or isSoundPlaying())
|
||||||
|
|
||||||
_scene->enterScene();
|
_scene->enterScene();
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsylumEngine::checkForEvent(bool doUpdate) {
|
|
||||||
Common::Event ev;
|
Common::Event ev;
|
||||||
|
|
||||||
if (_system->getEventManager()->pollEvent(ev)) {
|
if (_system->getEventManager()->pollEvent(ev)) {
|
||||||
|
@ -234,6 +249,10 @@ void AsylumEngine::checkForEvent(bool doUpdate) {
|
||||||
else if (_scene->getBlowUpPuzzle()->isActive())
|
else if (_scene->getBlowUpPuzzle()->isActive())
|
||||||
// Pass events to BlowUp Puzzles
|
// Pass events to BlowUp Puzzles
|
||||||
_scene->getBlowUpPuzzle()->handleEvent(&ev, doUpdate);
|
_scene->getBlowUpPuzzle()->handleEvent(&ev, doUpdate);
|
||||||
|
|
||||||
|
if (_introPlaying) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsylumEngine::processDelayedEvents() {
|
void AsylumEngine::processDelayedEvents() {
|
||||||
|
|
|
@ -82,6 +82,8 @@ private:
|
||||||
Common::Language _language;
|
Common::Language _language;
|
||||||
Common::RandomSource _rnd;
|
Common::RandomSource _rnd;
|
||||||
|
|
||||||
|
bool _introPlaying;
|
||||||
|
|
||||||
Console *_console;
|
Console *_console;
|
||||||
Scene *_scene;
|
Scene *_scene;
|
||||||
MainMenu *_mainMenu;
|
MainMenu *_mainMenu;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue