From dbd5ffaf34e690559380721e0f132b637b8fce33 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sun, 16 Oct 2011 14:36:38 +0300 Subject: AGI: Refine commit #69c705a to always pick the longest matching phrase Thanks to wjp for his observation in the original commit --- engines/agi/words.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'engines/agi/words.cpp') diff --git a/engines/agi/words.cpp b/engines/agi/words.cpp index f6e399245a..1001c66b20 100644 --- a/engines/agi/words.cpp +++ b/engines/agi/words.cpp @@ -134,8 +134,9 @@ int AgiEngine::findWord(const char *word, int *flen) { 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)) { + // Keep looking till we find the word itself, or the whole phrase. + // Try to find the best match (i.e. the longest matching phrase). + if (!strncmp(a[i]->word, word, wlen) && (word[wlen] == 0 || word[wlen] == 0x20) && wlen >= *flen) { *flen = wlen; result = a[i]->id; } -- cgit v1.2.3