diff options
author | Filippos Karapetis | 2011-10-16 14:36:38 +0300 |
---|---|---|
committer | Filippos Karapetis | 2011-10-16 14:36:38 +0300 |
commit | dbd5ffaf34e690559380721e0f132b637b8fce33 (patch) | |
tree | 2dc452e9fae6f78a5e258cc268e05888539273a1 /engines/agi/words.cpp | |
parent | ffe70730374b2e1c0b9e47832d115e26fa1c8119 (diff) | |
download | scummvm-rg350-dbd5ffaf34e690559380721e0f132b637b8fce33.tar.gz scummvm-rg350-dbd5ffaf34e690559380721e0f132b637b8fce33.tar.bz2 scummvm-rg350-dbd5ffaf34e690559380721e0f132b637b8fce33.zip |
AGI: Refine commit #69c705a to always pick the longest matching phrase
Thanks to wjp for his observation in the original commit
Diffstat (limited to 'engines/agi/words.cpp')
-rw-r--r-- | engines/agi/words.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
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; } |