diff options
-rw-r--r-- | engines/agi/words.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/engines/agi/words.cpp b/engines/agi/words.cpp index ec6928f8ed..f6e399245a 100644 --- a/engines/agi/words.cpp +++ b/engines/agi/words.cpp @@ -120,6 +120,7 @@ void AgiEngine::unloadWords() { */ int AgiEngine::findWord(const char *word, int *flen) { int c; + int result = -1; debugC(2, kDebugLevelScripts, "find_word(%s)", word); @@ -130,15 +131,17 @@ int AgiEngine::findWord(const char *word, int *flen) { *flen = 0; Common::Array<AgiWord*> &a = _game.words[c]; + for (int i = 0; i < (int)a.size(); i++) { int wlen = strlen(a[i]->word); + // Keep looking till we find the word itself, or the whole phrase if (!strncmp(a[i]->word, word, wlen) && (word[wlen] == 0 || word[wlen] == 0x20)) { *flen = wlen; - return a[i]->id; + result = a[i]->id; } } - return -1; + return result; } void AgiEngine::dictionaryWords(char *msg) { |