aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/toltecs/screen.cpp8
-rw-r--r--engines/toltecs/screen.h1
-rw-r--r--engines/toltecs/script.cpp12
3 files changed, 21 insertions, 0 deletions
diff --git a/engines/toltecs/screen.cpp b/engines/toltecs/screen.cpp
index be91130c0a..1cd2373b43 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 ee565e1882..52f412251e 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 9ea95a2cd1..07d74ac369 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;