aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk/riven.cpp
diff options
context:
space:
mode:
authorBastien Bouclet2017-07-11 08:23:06 +0200
committerBastien Bouclet2017-07-11 08:29:59 +0200
commitd6fd0ac626e1072408e487e6ada49f17e8ef7c53 (patch)
tree9ddac02f151ce96e3824b7d9ea25cb2df2e9dbc5 /engines/mohawk/riven.cpp
parenteb7306286f124f1f9a2285e840a14bba589c2fac (diff)
downloadscummvm-rg350-d6fd0ac626e1072408e487e6ada49f17e8ef7c53.tar.gz
scummvm-rg350-d6fd0ac626e1072408e487e6ada49f17e8ef7c53.tar.bz2
scummvm-rg350-d6fd0ac626e1072408e487e6ada49f17e8ef7c53.zip
MOHAWK: Riven: Fix card leave scripts when changing stacks
Card leave scripts were using data from the new stack, whereas they should have been using data from the old stack to which they belong. Fixes Trac#9928.
Diffstat (limited to 'engines/mohawk/riven.cpp')
-rw-r--r--engines/mohawk/riven.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index 0fb62bd064..03afafe800 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -287,18 +287,24 @@ void MohawkEngine_Riven::pauseEngineIntern(bool pause) {
// Stack/Card-Related Functions
-void MohawkEngine_Riven::changeToStack(uint16 n) {
+void MohawkEngine_Riven::changeToStack(uint16 stackId) {
// The endings are in reverse order because of the way the 1.02 patch works.
// The only "Data3" file is j_Data3.mhk from that patch. Patch files have higher
// priorities over the regular files and are therefore loaded and checked first.
static const char *endings[] = { "_Data3.mhk", "_Data2.mhk", "_Data1.mhk", "_Data.mhk", "_Sounds.mhk" };
// Don't change stack to the current stack (if the files are loaded)
- if (_stack && _stack->getId() == n && !_mhk.empty())
+ if (_stack && _stack->getId() == stackId && !_mhk.empty())
return;
- // Stop any videos playing
+ // Free resources that may rely on the current stack data being loaded
+ if (_card) {
+ _card->leave();
+ delete _card;
+ _card = nullptr;
+ }
_video->removeVideos();
+ _sound->stopAllSLST();
// Clear the graphics cache; images aren't used across stack boundaries
_gfx->clearCache();
@@ -309,7 +315,7 @@ void MohawkEngine_Riven::changeToStack(uint16 n) {
_mhk.clear();
// Get the prefix character for the destination stack
- char prefix = RivenStacks::getName(n)[0];
+ char prefix = RivenStacks::getName(stackId)[0];
// Load any file that fits the patterns
for (int i = 0; i < ARRAYSIZE(endings); i++) {
@@ -324,13 +330,10 @@ void MohawkEngine_Riven::changeToStack(uint16 n) {
// Make sure we have loaded files
if (_mhk.empty())
- error("Could not load stack %s", RivenStacks::getName(n));
-
- // Stop any currently playing sounds
- _sound->stopAllSLST();
+ error("Could not load stack %s", RivenStacks::getName(stackId));
delete _stack;
- _stack = constructStackById(n);
+ _stack = constructStackById(stackId);
}
RivenStack *MohawkEngine_Riven::constructStackById(uint16 id) {