aboutsummaryrefslogtreecommitdiff
path: root/engines/toltecs/script.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/toltecs/script.cpp')
-rw-r--r--engines/toltecs/script.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/engines/toltecs/script.cpp b/engines/toltecs/script.cpp
index 9ea95a2cd1..476c3a4fcf 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;
@@ -253,7 +265,7 @@ void ScriptInterpreter::execOpcode(byte opcode) {
_subCode = _code;
byte length = readByte();
if (length == 0) {
- warning("Possible script bug detected - opcode length is 0 when calling script function");
+ warning("Opcode length is 0 when calling script function");
return;
}
debug(2, "length = %d", length);
@@ -472,7 +484,9 @@ void ScriptInterpreter::execOpcode(byte opcode) {
_code++;
break;
default:
- error("Invalid opcode %d", opcode);
+ // Most likely a script bug. Throw a warning and ignore it.
+ // The original ignores invalid opcodes as well - bug #3604025.
+ warning("Invalid opcode %d", opcode);
}
}