diff options
author | Colin Snover | 2017-08-05 22:31:14 -0500 |
---|---|---|
committer | Colin Snover | 2017-09-03 20:58:09 -0500 |
commit | 6e35676a9efa9247edccd7acca069610f1a493ee (patch) | |
tree | f4a3d19c044568f98af246f186ba578bf95f794f | |
parent | be64c6ba8b5f4a81e6703b5a6325b7a7112c14d4 (diff) | |
download | scummvm-rg350-6e35676a9efa9247edccd7acca069610f1a493ee.tar.gz scummvm-rg350-6e35676a9efa9247edccd7acca069610f1a493ee.tar.bz2 scummvm-rg350-6e35676a9efa9247edccd7acca069610f1a493ee.zip |
SCI32: Fix load from launcher for Lighthouse
Launcher loads of games without a saved Robot were fine, but games
that were saved with a Robot (e.g. room 480 when facing the water)
would crash.
-rw-r--r-- | engines/sci/engine/guest_additions.cpp | 45 | ||||
-rw-r--r-- | engines/sci/engine/guest_additions.h | 4 | ||||
-rw-r--r-- | engines/sci/engine/kvideo.cpp | 6 |
3 files changed, 39 insertions, 16 deletions
diff --git a/engines/sci/engine/guest_additions.cpp b/engines/sci/engine/guest_additions.cpp index 17ae74e25a..0e4e35f7d8 100644 --- a/engines/sci/engine/guest_additions.cpp +++ b/engines/sci/engine/guest_additions.cpp @@ -254,28 +254,47 @@ void GuestAdditions::segManSaveLoadScriptHook(Script &script) const { #endif bool GuestAdditions::kGetEventHook() const { - if (_state->_delayedRestoreGameId != -1) { - return g_sci->_guestAdditions->restoreFromLauncher(); + if (_state->_delayedRestoreGameId == -1) { + return false; + } + + // Loading a save game while Lighthouse is still initializing itself will + // cause loading to fail if the save game contains a saved Robot state, + // because the Robot will try to restore itself into a game plane which does + // not exist yet + if (g_sci->getGameId() == GID_LIGHTHOUSE) { + Common::List<ExecStack>::const_iterator it; + for (it = _state->_executionStack.begin(); it != _state->_executionStack.end(); ++it) { + const ExecStack &call = *it; + const reg_t gameObject = g_sci->getGameObject(); + if (call.sendp == gameObject && call.debugSelector == SELECTOR(init)) { + return false; + } + } } - return false; + + return g_sci->_guestAdditions->restoreFromLauncher(); } bool GuestAdditions::kWaitHook() const { - if (_state->_delayedRestoreGameId != -1 && - // kWait cannot be used in Phant2 for delayed restore because it is - // called during the fade-in of music in the intro room, before graphics - // are fully initialized, which causes "Click to continue" text to be - // brokenly drawn over the game and then crashes the engine on the next - // room transition - g_sci->getGameId() != GID_PHANTASMAGORIA2) { + if (_state->_delayedRestoreGameId == -1) { + return false; + } - return g_sci->_guestAdditions->restoreFromLauncher(); + // kWait cannot be used in Phant2 for delayed restore because it is + // called during the fade-in of music in the intro room, before graphics + // are fully initialized, which causes "Click to continue" text to be + // brokenly drawn over the game and then crashes the engine on the next + // room transition + if (g_sci->getGameId() == GID_PHANTASMAGORIA2) { + return false; } - return false; + + return g_sci->_guestAdditions->restoreFromLauncher(); } #ifdef ENABLE_SCI32 -bool GuestAdditions::kPlayDuckPlayHook() const { +bool GuestAdditions::kPlayDuckPlayVMDHook() const { return _state->_delayedRestoreGameId != -1; } #endif diff --git a/engines/sci/engine/guest_additions.h b/engines/sci/engine/guest_additions.h index cfa1139c5f..36264b946b 100644 --- a/engines/sci/engine/guest_additions.h +++ b/engines/sci/engine/guest_additions.h @@ -148,9 +148,9 @@ public: #ifdef ENABLE_SCI32 /** - * Guest additions hook for kPlayDuck(Play). + * Guest additions hook for kPlayDuck(Play) and kPlayVMD(PlayUntilEvent). */ - bool kPlayDuckPlayHook() const; + bool kPlayDuckPlayVMDHook() const; #endif #pragma mark - diff --git a/engines/sci/engine/kvideo.cpp b/engines/sci/engine/kvideo.cpp index feb98f2eef..98b2ba2b85 100644 --- a/engines/sci/engine/kvideo.cpp +++ b/engines/sci/engine/kvideo.cpp @@ -444,6 +444,10 @@ reg_t kPlayVMDGetStatus(EngineState *s, int argc, reg_t *argv) { } reg_t kPlayVMDPlayUntilEvent(EngineState *s, int argc, reg_t *argv) { + if (g_sci->_guestAdditions->kPlayDuckPlayVMDHook()) { + return make_reg(0, VMDPlayer::kEventFlagEnd); + } + const VMDPlayer::EventFlags flags = (VMDPlayer::EventFlags)argv[0].toUint16(); const int16 lastFrameNo = argc > 1 ? argv[1].toSint16() : -1; const int16 yieldInterval = argc > 2 ? argv[2].toSint16() : -1; @@ -485,7 +489,7 @@ reg_t kPlayDuck(EngineState *s, int argc, reg_t *argv) { } reg_t kPlayDuckPlay(EngineState *s, int argc, reg_t *argv) { - if (g_sci->_guestAdditions->kPlayDuckPlayHook()) { + if (g_sci->_guestAdditions->kPlayDuckPlayVMDHook()) { return NULL_REG; } kPlayDuckOpen(s, argc, argv); |