[Scummvm-cvs-logs] scummvm master -> 4b0d0ecddac516521f563cad54bbc7b77f9c112b

eriktorbjorn eriktorbjorn at telia.com
Fri Mar 15 18:52:34 CET 2013


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:
4b0d0ecdda TOLTECS: Work around undefined subtitle behaviour at script loading


Commit: 4b0d0ecddac516521f563cad54bbc7b77f9c112b
    https://github.com/scummvm/scummvm/commit/4b0d0ecddac516521f563cad54bbc7b77f9c112b
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2013-03-15T10:48:44-07:00

Commit Message:
TOLTECS: Work around undefined subtitle behaviour at script loading

It may be because of an underlying bug, but there is at least one
case where a script is unloaded and replaced by another script while
that script slot still has an active subtitle. This causes it to
print random garbage for me, and may be causing crashes for others.

I've discussed this patch with johndoe, and he was ok with it, so
let's see how it works out.

Changed paths:
    engines/toltecs/screen.cpp
    engines/toltecs/screen.h
    engines/toltecs/script.cpp



diff --git a/engines/toltecs/screen.cpp b/engines/toltecs/screen.cpp
index be91130..1cd2373 100644
--- a/engines/toltecs/screen.cpp
+++ b/engines/toltecs/screen.cpp
@@ -494,6 +494,14 @@ int16 Screen::getTalkTextDuration() {
 	return _talkTextItems[_talkTextItemNum].duration;
 }
 
+void Screen::finishTalkTextItem(int16 slotIndex) {
+	for (int16 i = 0; i <= _talkTextItemNum; i++) {
+		if (_talkTextItems[i].slotIndex == slotIndex) {
+			_talkTextItems[i].duration = 0;
+		}
+	}
+}
+
 void Screen::finishTalkTextItems() {
 	for (int16 i = 0; i <= _talkTextItemNum; i++) {
 		_talkTextItems[i].duration = 0;
diff --git a/engines/toltecs/screen.h b/engines/toltecs/screen.h
index ee565e1..52f4122 100644
--- a/engines/toltecs/screen.h
+++ b/engines/toltecs/screen.h
@@ -183,6 +183,7 @@ public:
 	void addTalkTextItemsToRenderQueue();
 	int16 getTalkTextDuration();
 	bool isTalkTextActive(int16 slotIndex);
+	void finishTalkTextItem(int16 slotIndex);
 	void finishTalkTextItems();
 	void keepTalkTextItemsAlive();
 
diff --git a/engines/toltecs/script.cpp b/engines/toltecs/script.cpp
index 9ea95a2..07d74ac 100644
--- a/engines/toltecs/script.cpp
+++ b/engines/toltecs/script.cpp
@@ -170,6 +170,18 @@ void ScriptInterpreter::setupScriptFunctions() {
 }
 
 void ScriptInterpreter::loadScript(uint resIndex, uint slotIndex) {
+	if (_slots[slotIndex].resIndex && _slots[slotIndex].resIndex != resIndex && _vm->_screen->isTalkTextActive(slotIndex)) {
+		// WORKAROUND: This happens when examining the assembled
+		// pickaxe. It could lead to random characters being printed,
+		// or possibly even crashes, when subtitles are enabled.
+		//
+		// According to johndoe and he said there may be some bug or
+		// missing feature that causes this situation to happen at all,
+		// but he was ok with this workaround for now.
+		warning("Possible script bug: Loading script %d into slot %d that has an active talk text, probably for script %d", resIndex, slotIndex, _slots[slotIndex].resIndex);
+		_vm->_screen->finishTalkTextItem(slotIndex);
+	}
+
 	delete[] _slots[slotIndex].data;
 
  	_slots[slotIndex].resIndex = resIndex;






More information about the Scummvm-git-logs mailing list