diff options
author | Torbjörn Andersson | 2013-03-15 18:48:44 +0100 |
---|---|---|
committer | Torbjörn Andersson | 2013-03-15 18:48:44 +0100 |
commit | 4b0d0ecddac516521f563cad54bbc7b77f9c112b (patch) | |
tree | fcd9cb812ab87d4341b66048d480a4c7e722574d /engines | |
parent | 5dae97223793d1f20898d703e00c9bd30a811f39 (diff) | |
download | scummvm-rg350-4b0d0ecddac516521f563cad54bbc7b77f9c112b.tar.gz scummvm-rg350-4b0d0ecddac516521f563cad54bbc7b77f9c112b.tar.bz2 scummvm-rg350-4b0d0ecddac516521f563cad54bbc7b77f9c112b.zip |
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.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/toltecs/screen.cpp | 8 | ||||
-rw-r--r-- | engines/toltecs/screen.h | 1 | ||||
-rw-r--r-- | engines/toltecs/script.cpp | 12 |
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; |