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 | |
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')
-rw-r--r-- | engines/scumm/script.cpp | 17 | ||||
-rw-r--r-- | engines/scumm/script_v0.cpp | 3 | ||||
-rw-r--r-- | engines/scumm/scumm_v0.h | 1 | ||||
-rw-r--r-- | engines/scumm/verbs.cpp | 3 |
4 files changed, 21 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) { diff --git a/engines/scumm/script_v0.cpp b/engines/scumm/script_v0.cpp index 4d9a206118..4081123e13 100644 --- a/engines/scumm/script_v0.cpp +++ b/engines/scumm/script_v0.cpp @@ -979,6 +979,9 @@ void ScummEngine_v0::resetSentence() { _walkToObjectState = kWalkToObjectStateDone; _redrawSentenceLine = true; + + _sentenceNum = 0; + _sentenceNestedCount = 0; } } // End of namespace Scumm diff --git a/engines/scumm/scumm_v0.h b/engines/scumm/scumm_v0.h index e25d6f5826..8b13569042 100644 --- a/engines/scumm/scumm_v0.h +++ b/engines/scumm/scumm_v0.h @@ -55,6 +55,7 @@ protected: int _cmdVerb; // script verb int _cmdObject; // 1st script object (see OBJECT_V0()) int _cmdObject2; // 2nd script object or actor (see OBJECT_V0()) + int _sentenceNestedCount; int _walkToObject; int _walkToObjectState; diff --git a/engines/scumm/verbs.cpp b/engines/scumm/verbs.cpp index 91c9cc159a..7a099adae9 100644 --- a/engines/scumm/verbs.cpp +++ b/engines/scumm/verbs.cpp @@ -689,6 +689,9 @@ int ScummEngine_v0::activeVerbPrep() { } void ScummEngine_v0::verbExec() { + _sentenceNum = 0; + _sentenceNestedCount = 0; + if (_activeVerb == kVerbWhatIs) return; |