[Scummvm-git-logs] scummvm master -> d6fd0ac626e1072408e487e6ada49f17e8ef7c53

bgK bastien.bouclet at gmail.com
Tue Jul 11 08:30:34 CEST 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
d6fd0ac626 MOHAWK: Riven: Fix card leave scripts when changing stacks


Commit: d6fd0ac626e1072408e487e6ada49f17e8ef7c53
    https://github.com/scummvm/scummvm/commit/d6fd0ac626e1072408e487e6ada49f17e8ef7c53
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2017-07-11T08:29:59+02:00

Commit Message:
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.

Changed paths:
    engines/mohawk/riven.cpp
    engines/mohawk/riven.h


diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index 0fb62bd..03afafe 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) {
diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h
index c9fb491..908deb7 100644
--- a/engines/mohawk/riven.h
+++ b/engines/mohawk/riven.h
@@ -123,7 +123,7 @@ public:
 	// Stack/card/script funtions
 	RivenStack *constructStackById(uint16 id);
 	void changeToCard(uint16 dest);
-	void changeToStack(uint16);
+	void changeToStack(uint16 stackId);
 	RivenCard *getCard() const { return _card; }
 	RivenStack *getStack() const { return _stack; }
 





More information about the Scummvm-git-logs mailing list