From c9c03d69958d7f89358fd776306fcc960c9243cb Mon Sep 17 00:00:00 2001 From: Athanasios Antoniou Date: Sun, 22 Oct 2023 03:34:30 +0300 Subject: [PATCH] KINGDOM: Fix skipping and quitting demo movie (#5372) The detection that the demo movie was skipped is done by the external flag _demoMovieSkipped This is not as clean as it would be updating a reference parameter variable from within playMovie() but that would require changing the signature of playMovie and all of its calls --- engines/kingdom/kingdom.cpp | 4 ++++ engines/kingdom/kingdom.h | 1 + engines/kingdom/logic.cpp | 4 +++- engines/kingdom/logic1.cpp | 8 ++++++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/engines/kingdom/kingdom.cpp b/engines/kingdom/kingdom.cpp index 24beb7787a5..f145d804697 100644 --- a/engines/kingdom/kingdom.cpp +++ b/engines/kingdom/kingdom.cpp @@ -55,6 +55,7 @@ KingdomGame::KingdomGame(OSystem *syst, const ADGameDescription *gameDesc) : Eng _asPtr = nullptr; _quit = false; + _demoMovieSkipped = false; _kingartEntries = nullptr; _tickCount = 0; @@ -527,6 +528,9 @@ void KingdomGame::playMovie(int movieNum) { case Common::EVENT_KEYDOWN: if (event.kbd.keycode == Common::KEYCODE_ESCAPE) { skipMovie = true; + if (movieNum == 54) { + _demoMovieSkipped = true; + } } default: break; diff --git a/engines/kingdom/kingdom.h b/engines/kingdom/kingdom.h index dec18a93ae1..192c346a793 100644 --- a/engines/kingdom/kingdom.h +++ b/engines/kingdom/kingdom.h @@ -151,6 +151,7 @@ namespace Kingdom { bool _iconsClosed; bool _oldIconsClosed; int _pMovie; + bool _demoMovieSkipped; bool _keyActive; bool _iconRedraw; bool _quit; diff --git a/engines/kingdom/logic.cpp b/engines/kingdom/logic.cpp index 627bf769913..5f861b1667d 100644 --- a/engines/kingdom/logic.cpp +++ b/engines/kingdom/logic.cpp @@ -505,10 +505,12 @@ void Logic::gameHelp() { // The demo isn't saving pMovie. // It's obviously a bug and this behavior wasn't kept in ScummVM int oldPMovie = _vm->_pMovie; - while(!_vm->_keyActive) { + _vm->_demoMovieSkipped = false; + while(!_vm->_keyActive && !_vm->shouldQuit() && !_vm->_demoMovieSkipped) { _vm->playMovie(54); _vm->fadeToBlack2(); } + _vm->_demoMovieSkipped = false; _vm->_pMovie = oldPMovie; _vm->_noIFScreen = false; _vm->showPic(106); diff --git a/engines/kingdom/logic1.cpp b/engines/kingdom/logic1.cpp index a880d452624..e557a17b135 100644 --- a/engines/kingdom/logic1.cpp +++ b/engines/kingdom/logic1.cpp @@ -54,11 +54,13 @@ void Logic::GPL1_11() { _vm->_keyActive = false; _vm->_noIFScreen = true; _vm->playSound(0); - while(!_vm->_keyActive) { + _vm->_demoMovieSkipped = false; + while(!_vm->_keyActive && !_vm->shouldQuit() && !_vm->_demoMovieSkipped) { _vm->fadeToBlack2(); _vm->playMovie(54); } - GPLogic1_SubSP10(); + _vm->_demoMovieSkipped = false; + GPLogic1_SubSP10(); // return to main menu break; case 0x194: // CHECKME _QuitFlag = 2; @@ -75,7 +77,9 @@ void Logic::GPL1_11() { _vm->_cursorDrawn = false; _vm->fadeToBlack2(); _vm->playSound(0); + _vm->_demoMovieSkipped = false; _vm->playMovie(54); + _vm->_demoMovieSkipped = false; GPLogic1_SubSP10(); break; default: