diff options
author | Tobias Gunkel | 2012-01-22 23:20:27 +0100 |
---|---|---|
committer | Tobias Gunkel | 2012-02-11 08:29:21 +0100 |
commit | e3f9a09d49aaeb4657862ca734d20279e75c869f (patch) | |
tree | 25f8ac0f69079638444fedc48417b62e430ed655 /engines/scumm/script.cpp | |
parent | fb684565412c69aeb0d0a9837fc5a76b98cbe285 (diff) | |
download | scummvm-rg350-e3f9a09d49aaeb4657862ca734d20279e75c869f.tar.gz scummvm-rg350-e3f9a09d49aaeb4657862ca734d20279e75c869f.tar.bz2 scummvm-rg350-e3f9a09d49aaeb4657862ca734d20279e75c869f.zip |
SCUMM: keep track of the number of nested script calls for a sentence
command in v0
If for instance an object necessary for the sentence command is not reachable or pickupable (try to use faucet (object 55) with jar with water in microwave (object 50), the pick-up script of the jar will tell the actor to pickup object 99 (jar not in microwave)) the actor will try to pick-up the jar infinitely.
This is fixed by counting the amount of nested scripts the sentence command has called (directly or indirectly) so far and aborts it if there have been too many.
Diffstat (limited to 'engines/scumm/script.cpp')
-rw-r--r-- | engines/scumm/script.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp index cda2b3cd82..b51452170a 100644 --- a/engines/scumm/script.cpp +++ b/engines/scumm/script.cpp @@ -1209,8 +1209,7 @@ void ScummEngine_v0::checkAndRunSentenceScript() { return; } - // FIXME: should this be executed? - //_currentScript = 0xFF; + _currentScript = 0xFF; assert(st.objectA); @@ -1233,7 +1232,19 @@ void ScummEngine_v0::checkAndRunSentenceScript() { _cmdObject2 = st.objectB; _sentenceNum--; - // TODO: check sentenceNum + // abort sentence execution if the number of nested scripts is too high. + // This might happen for instance if the sentence command depends on an + // object that the actor has to pick-up in a nested doSentence() call. + // If the actor is not able to pick-up the object (e.g. because it is not + // reachable or pickupable) a nested pick-up command is triggered again + // and again, so the actual sentence command will never be executed. + // In this case the sentence command has to be aborted. + _sentenceNestedCount++; + if (_sentenceNestedCount > 6) { + _sentenceNestedCount = 0; + _sentenceNum = 0; + return; + } if (whereIsObject(st.objectA) != WIO_INVENTORY) { if (_currentMode != kModeKeypad) { |