aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Bouclet2017-07-29 18:20:45 +0200
committerBastien Bouclet2017-07-29 18:20:45 +0200
commit69c1f70818aaf83f97bf7131cdf9423c0a75027f (patch)
tree787e2293f0a2785cbb2c173a83106c5c3efb41c1
parent8c587b54ab92a5f21fae2c1db8ebdedaf61b521e (diff)
downloadscummvm-rg350-69c1f70818aaf83f97bf7131cdf9423c0a75027f.tar.gz
scummvm-rg350-69c1f70818aaf83f97bf7131cdf9423c0a75027f.tar.bz2
scummvm-rg350-69c1f70818aaf83f97bf7131cdf9423c0a75027f.zip
MOHAWK: Riven: Let the gameloop gracefully end when quitting
Prevents the quit confirmation dialog from being displayed at the end of the game's ending if it is enabled. Fixes #9943.
-rw-r--r--engines/mohawk/riven.cpp13
-rw-r--r--engines/mohawk/riven.h12
-rw-r--r--engines/mohawk/riven_graphics.cpp4
-rw-r--r--engines/mohawk/riven_inventory.cpp2
-rw-r--r--engines/mohawk/riven_stack.cpp10
-rw-r--r--engines/mohawk/riven_stacks/aspit.cpp6
-rw-r--r--engines/mohawk/riven_stacks/bspit.cpp8
-rw-r--r--engines/mohawk/riven_stacks/domespit.cpp2
-rw-r--r--engines/mohawk/riven_stacks/jspit.cpp8
-rw-r--r--engines/mohawk/riven_stacks/ospit.cpp12
-rw-r--r--engines/mohawk/riven_stacks/tspit.cpp2
-rw-r--r--engines/mohawk/riven_video.cpp2
12 files changed, 49 insertions, 32 deletions
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index d3f9e61d9f..59a41f5258 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -58,6 +58,7 @@ MohawkEngine_Riven::MohawkEngine_Riven(OSystem *syst, const MohawkGameDescriptio
_showHotspots = false;
_activatedPLST = false;
_activatedSLST = false;
+ _gameEnded = false;
_extrasFile = nullptr;
_stack = nullptr;
_gfx = nullptr;
@@ -186,7 +187,7 @@ Common::Error MohawkEngine_Riven::run() {
}
- while (!shouldQuit())
+ while (!hasGameEnded())
doFrame();
return Common::kNoError;
@@ -424,7 +425,7 @@ Common::SeekableReadStream *MohawkEngine_Riven::getExtrasResource(uint32 tag, ui
void MohawkEngine_Riven::delay(uint32 ms) {
uint32 startTime = _system->getMillis();
- while (_system->getMillis() < startTime + ms && !shouldQuit()) {
+ while (_system->getMillis() < startTime + ms && !hasGameEnded()) {
doFrame();
}
}
@@ -497,6 +498,14 @@ bool MohawkEngine_Riven::canSaveGameStateCurrently() {
return canLoadGameStateCurrently();
}
+bool MohawkEngine_Riven::hasGameEnded() const {
+ return _gameEnded || shouldQuit();
+}
+
+void MohawkEngine_Riven::setGameEnded() {
+ _gameEnded = true;
+}
+
bool ZipMode::operator== (const ZipMode &z) const {
return z.name == name && z.id == id;
}
diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h
index 608ebddb84..4c4e303fa3 100644
--- a/engines/mohawk/riven.h
+++ b/engines/mohawk/riven.h
@@ -117,6 +117,8 @@ private:
RivenCard *_card;
RivenStack *_stack;
+ bool _gameEnded;
+
// Variables
void initVars();
@@ -144,6 +146,16 @@ public:
bool _activatedSLST;
void runLoadDialog();
void delay(uint32 ms);
+
+ /**
+ * Has the game ended, or has the user requested to quit?
+ */
+ bool hasGameEnded() const;
+
+ /**
+ * End the game gracefully
+ */
+ void setGameEnded();
};
} // End of namespace Mohawk
diff --git a/engines/mohawk/riven_graphics.cpp b/engines/mohawk/riven_graphics.cpp
index 270b0c88ca..86b70d37ee 100644
--- a/engines/mohawk/riven_graphics.cpp
+++ b/engines/mohawk/riven_graphics.cpp
@@ -546,7 +546,7 @@ void RivenGraphics::runScheduledTransition() {
uint32 startTime = _vm->_system->getMillis();
uint32 timeElapsed = 0;
bool transitionComplete = false;
- while (timeElapsed < _transitionDuration && !transitionComplete && !_vm->shouldQuit()) {
+ while (timeElapsed < _transitionDuration && !transitionComplete && !_vm->hasGameEnded()) {
transitionComplete = effect->drawFrame(timeElapsed);
_vm->doFrame();
@@ -557,7 +557,7 @@ void RivenGraphics::runScheduledTransition() {
effect->drawFrame(_transitionDuration);
}
} else {
- for (uint frame = 1; frame <= _transitionFrames && !_vm->shouldQuit(); frame++) {
+ for (uint frame = 1; frame <= _transitionFrames && !_vm->hasGameEnded(); frame++) {
effect->drawFrame(frame);
_vm->doFrame();
diff --git a/engines/mohawk/riven_inventory.cpp b/engines/mohawk/riven_inventory.cpp
index 9872e79a3e..b4304eceec 100644
--- a/engines/mohawk/riven_inventory.cpp
+++ b/engines/mohawk/riven_inventory.cpp
@@ -107,7 +107,7 @@ void RivenInventory::checkClick(const Common::Point &mousePos) {
_vm->changeToCard(12);
} else if (_vm->getStack()->getId() == kStackAspit && _vm->getCard()->getId() == 12) {
// From the "quit" screen, just quit
- _vm->quitGame();
+ _vm->setGameEnded();
} else {
// Otherwise, return to the main menu
if (_vm->getStack()->getId() != kStackAspit)
diff --git a/engines/mohawk/riven_stack.cpp b/engines/mohawk/riven_stack.cpp
index 0a274b2cc2..2e1fd69082 100644
--- a/engines/mohawk/riven_stack.cpp
+++ b/engines/mohawk/riven_stack.cpp
@@ -200,7 +200,7 @@ void RivenStack::runCredits(uint16 video, uint32 delay) {
RivenVideo *videoPtr = _vm->_video->getSlot(video);
- while (!_vm->shouldQuit() && _vm->_gfx->getCurCreditsImage() <= 320) {
+ while (!_vm->hasGameEnded() && _vm->_gfx->getCurCreditsImage() <= 320) {
if (videoPtr->getCurFrame() >= (int32)videoPtr->getFrameCount() - 1) {
if (nextCreditsFrameStart == 0) {
// Set us up to start after delay ms
@@ -220,11 +220,7 @@ void RivenStack::runCredits(uint16 video, uint32 delay) {
_vm->doFrame();
}
- if (_vm->shouldQuit()) {
- return; // Allow return to launcher
- }
-
- _vm->quitGame();
+ _vm->setGameEnded();
}
void RivenStack::installCardTimer() {
@@ -348,7 +344,7 @@ void RivenStack::removeTimer() {
bool RivenStack::pageTurn(RivenTransition transition) {
// Wait until the previous page turn sound completes
- while (_vm->_sound->isEffectPlaying() && !_vm->shouldQuit()) {
+ while (_vm->_sound->isEffectPlaying() && !_vm->hasGameEnded()) {
if (!mouseIsDown()) {
return false;
}
diff --git a/engines/mohawk/riven_stacks/aspit.cpp b/engines/mohawk/riven_stacks/aspit.cpp
index c8d5dec377..a31aa902ec 100644
--- a/engines/mohawk/riven_stacks/aspit.cpp
+++ b/engines/mohawk/riven_stacks/aspit.cpp
@@ -131,7 +131,7 @@ void ASpit::xaatrusbooknextpage(const ArgumentArray &args) {
// Keep turning pages while the mouse is pressed
bool firstPageTurn = true;
- while ((mouseIsDown() || firstPageTurn) && !_vm->shouldQuit()) {
+ while ((mouseIsDown() || firstPageTurn) && !_vm->hasGameEnded()) {
// Check for the last page
if (((_vm->getFeatures() & GF_DEMO) && page == 6) || page == 10)
return;
@@ -236,7 +236,7 @@ void ASpit::xacathbooknextpage(const ArgumentArray &args) {
// Keep turning pages while the mouse is pressed
bool firstPageTurn = true;
- while ((mouseIsDown() || firstPageTurn) && !_vm->shouldQuit()) {
+ while ((mouseIsDown() || firstPageTurn) && !_vm->hasGameEnded()) {
// Check for the last page
if (page == 49)
return;
@@ -346,7 +346,7 @@ void ASpit::xaenablemenuintro(const ArgumentArray &args) {
void ASpit::xademoquit(const ArgumentArray &args) {
// Exactly as it says on the tin. In the demo, this function quits.
- _vm->quitGame();
+ _vm->setGameEnded();
}
void ASpit::xaexittomain(const ArgumentArray &args) {
diff --git a/engines/mohawk/riven_stacks/bspit.cpp b/engines/mohawk/riven_stacks/bspit.cpp
index 51d3656761..b1ba5abd7b 100644
--- a/engines/mohawk/riven_stacks/bspit.cpp
+++ b/engines/mohawk/riven_stacks/bspit.cpp
@@ -126,7 +126,7 @@ void BSpit::xblabbooknextpage(const ArgumentArray &args) {
// Keep turning pages while the mouse is pressed
bool firstPageTurn = true;
- while ((mouseIsDown() || firstPageTurn) && !_vm->shouldQuit()) {
+ while ((mouseIsDown() || firstPageTurn) && !_vm->hasGameEnded()) {
// Check for the last page
if (page == 22)
return;
@@ -313,7 +313,7 @@ void BSpit::xbait(const ArgumentArray &args) {
_vm->_cursor->setCursor(kRivenPelletCursor);
// Loop until the player lets go (or quits)
- while (mouseIsDown() && !_vm->shouldQuit()) {
+ while (mouseIsDown() && !_vm->hasGameEnded()) {
_vm->doFrame();
}
@@ -369,7 +369,7 @@ void BSpit::xbaitplate(const ArgumentArray &args) {
_vm->getCard()->drawPicture(3);
// Loop until the player lets go (or quits)
- while (mouseIsDown() && !_vm->shouldQuit()) {
+ while (mouseIsDown() && !_vm->hasGameEnded()) {
_vm->doFrame();
}
@@ -485,7 +485,7 @@ void BSpit::xbchipper(const ArgumentArray &args) {
Common::Point startPos = getMouseDragStartPosition();
bool pulledLever = false;
- while (mouseIsDown() && !_vm->shouldQuit()) {
+ while (mouseIsDown() && !_vm->hasGameEnded()) {
Common::Point pos = getMousePosition();
if (pos.y > startPos.y) {
pulledLever = true;
diff --git a/engines/mohawk/riven_stacks/domespit.cpp b/engines/mohawk/riven_stacks/domespit.cpp
index dfbb0b40c5..592ffeb221 100644
--- a/engines/mohawk/riven_stacks/domespit.cpp
+++ b/engines/mohawk/riven_stacks/domespit.cpp
@@ -150,7 +150,7 @@ void DomeSpit::dragDomeSlider(uint16 startHotspot) {
// We've clicked down, so show the closed hand cursor
_vm->_cursor->setCursor(kRivenClosedHandCursor);
- while (mouseIsDown() && !_vm->shouldQuit()) {
+ while (mouseIsDown() && !_vm->hasGameEnded()) {
int16 hoveredHotspot = getSliderSlotAtPos(startHotspot, getMousePosition());
if (hoveredHotspot >= 0) {
if (hoveredHotspot > draggedSliderSlot && draggedSliderSlot < 24 && !isSliderAtSlot(draggedSliderSlot + 1)) {
diff --git a/engines/mohawk/riven_stacks/jspit.cpp b/engines/mohawk/riven_stacks/jspit.cpp
index f99664535d..6a29145e4a 100644
--- a/engines/mohawk/riven_stacks/jspit.cpp
+++ b/engines/mohawk/riven_stacks/jspit.cpp
@@ -108,7 +108,7 @@ void JSpit::xcheckicons(const ArgumentArray &args) {
_vm->_sound->playSound(46);
// Wait until the stones have finished rising
- while (_vm->_sound->isEffectPlaying() && !_vm->shouldQuit()) {
+ while (_vm->_sound->isEffectPlaying() && !_vm->hasGameEnded()) {
_vm->doFrame();
}
}
@@ -358,7 +358,7 @@ int JSpit::jspitElevatorLoop() {
_vm->_cursor->setCursor(kRivenClosedHandCursor);
- while (mouseIsDown() && !_vm->shouldQuit()) {
+ while (mouseIsDown() && !_vm->hasGameEnded()) {
_vm->doFrame();
Common::Point pos = getMousePosition();
@@ -388,7 +388,7 @@ void JSpit::xhandlecontrolup(const ArgumentArray &args) {
// TODO: Maybe queue a sound using the stored movie opcode instead
bool playedSound = false;
- while (!secondVideo->endOfVideo() && !_vm->shouldQuit()) {
+ while (!secondVideo->endOfVideo() && !_vm->hasGameEnded()) {
_vm->doFrame();
if (!playedSound && secondVideo->getTime() > 3333) {
@@ -549,7 +549,7 @@ void JSpit::sunnersPlayVideo(RivenVideo *video, uint32 destCardGlobalId, bool su
video->enable();
video->play();
- while (!video->endOfVideo() && !_vm->shouldQuit()) {
+ while (!video->endOfVideo() && !_vm->hasGameEnded()) {
_vm->doFrame();
if (mouseIsDown()) {
diff --git a/engines/mohawk/riven_stacks/ospit.cpp b/engines/mohawk/riven_stacks/ospit.cpp
index c48bebc644..8da1698ad3 100644
--- a/engines/mohawk/riven_stacks/ospit.cpp
+++ b/engines/mohawk/riven_stacks/ospit.cpp
@@ -89,17 +89,17 @@ void OSpit::xbookclick(const ArgumentArray &args) {
debug(0, "\tHotspot = %d -> %s", args[3], hotspotName.c_str());
// Just let the video play while we wait until Gehn opens the trap book for us
- while (video->getTime() < startTime && !_vm->shouldQuit()) {
+ while (video->getTime() < startTime && !_vm->hasGameEnded()) {
_vm->doFrame();
}
// Break out if we're quitting
- if (_vm->shouldQuit())
+ if (_vm->hasGameEnded())
return;
// OK, Gehn has opened the trap book and has asked us to go in. Let's watch
// and see what the player will do...
- while (video->getTime() < endTime && !_vm->shouldQuit()) {
+ while (video->getTime() < endTime && !_vm->hasGameEnded()) {
if (hotspotRect.contains(getMousePosition()))
_vm->_cursor->setCursor(kRivenOpenHandCursor);
else
@@ -135,7 +135,7 @@ void OSpit::xbookclick(const ArgumentArray &args) {
}
// Break out if we're quitting
- if (_vm->shouldQuit())
+ if (_vm->hasGameEnded())
return;
// If there was no click and this is the third time Gehn asks us to
@@ -218,7 +218,7 @@ void OSpit::xogehnbooknextpage(const ArgumentArray &args) {
// Keep turning pages while the mouse is pressed
bool firstPageTurn = true;
- while ((mouseIsDown() || firstPageTurn) && !_vm->shouldQuit()) {
+ while ((mouseIsDown() || firstPageTurn) && !_vm->hasGameEnded()) {
// Check for the last page
if (page == 13)
return;
@@ -243,7 +243,7 @@ void OSpit::xgwatch(const ArgumentArray &args) {
uint32 prisonCombo = _vm->_vars["pcorrectorder"];
byte curSound = 0;
- while (curSound < 5 && !_vm->shouldQuit()) {
+ while (curSound < 5 && !_vm->hasGameEnded()) {
// Play a sound every half second
_vm->_sound->playSound(getComboDigit(prisonCombo, curSound) + 13);
_vm->delay(500);
diff --git a/engines/mohawk/riven_stacks/tspit.cpp b/engines/mohawk/riven_stacks/tspit.cpp
index 54eae99fc9..3abd0a6b43 100644
--- a/engines/mohawk/riven_stacks/tspit.cpp
+++ b/engines/mohawk/riven_stacks/tspit.cpp
@@ -369,7 +369,7 @@ void TSpit::xtakeit(const ArgumentArray &args) {
_vm->getCard()->drawPicture(1);
// Loop until the player lets go (or quits)
- while (mouseIsDown() && !_vm->shouldQuit()) {
+ while (mouseIsDown() && !_vm->hasGameEnded()) {
_vm->doFrame();
}
diff --git a/engines/mohawk/riven_video.cpp b/engines/mohawk/riven_video.cpp
index fd2b0c6d54..6923fbd4d1 100644
--- a/engines/mohawk/riven_video.cpp
+++ b/engines/mohawk/riven_video.cpp
@@ -236,7 +236,7 @@ void RivenVideo::playBlocking(int32 endTime) {
}
bool continuePlaying = true;
- while (!endOfVideo() && !_vm->shouldQuit() && continuePlaying) {
+ while (!endOfVideo() && !_vm->hasGameEnded() && continuePlaying) {
// Draw a frame
_vm->doFrame();