AGI: Fixed bug #3424066 - "LSL1 AGI: Password Glitch"

We should not stop looking when a partial sentence match is found, as a
better match might exist later on. In this case, there were two matching
sentences, "Ken" (which is wrong in this case) and "Ken sent me" (which
is correct, but was never reached as the partial match was returned
first)
This commit is contained in:
Filippos Karapetis 2011-10-16 01:10:32 +03:00
parent ca88b03828
commit 69c705a019

View file

@ -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) {