aboutsummaryrefslogtreecommitdiff
path: root/engines/agi/words.cpp
diff options
context:
space:
mode:
authorJussi Pitkanen2011-06-16 12:34:40 +0300
committerEugene Sandulenko2011-08-13 23:27:05 +0100
commit368a3722a3cae2326efaf124608605058b274cd5 (patch)
treefa38939b89731a96027a771934db35811d0b773b /engines/agi/words.cpp
parentc731f1f48c780ed09db03c8c5347d5e96da886ac (diff)
downloadscummvm-rg350-368a3722a3cae2326efaf124608605058b274cd5.tar.gz
scummvm-rg350-368a3722a3cae2326efaf124608605058b274cd5.tar.bz2
scummvm-rg350-368a3722a3cae2326efaf124608605058b274cd5.zip
AGI: Implement loader for V1 words.tok dictionary
Diffstat (limited to 'engines/agi/words.cpp')
-rw-r--r--engines/agi/words.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/engines/agi/words.cpp b/engines/agi/words.cpp
index 4004abd697..8b53e9d3a3 100644
--- a/engines/agi/words.cpp
+++ b/engines/agi/words.cpp
@@ -36,6 +36,33 @@ static char *myStrndup(const char *src, int n) {
return tmp;
}
+int AgiEngine::loadWords_v1(Common::File &f) {
+ char str[64];
+ int k;
+
+ // Loop through alphabet, as words in the dictionary file are sorted by
+ // first character
+ f.seek(f.pos() + 26 * 2, SEEK_SET);
+ do {
+ // Read next word
+ for (k = 0; k < (int)sizeof(str) - 1; k++) {
+ str[k] = f.readByte();
+ if (str[k] == 0 || (uint8)str[k] == 0xFF)
+ break;
+ }
+
+ // And store it in our internal dictionary
+ if (k > 0) {
+ AgiWord *w = new AgiWord;
+ w->word = myStrndup(str, k + 1);
+ w->id = f.readUint16LE();
+ _game.words[str[0] - 'a'].push_back(w);
+ }
+ } while((uint8)str[0] != 0xFF);
+
+ return errOK;
+}
+
int AgiEngine::loadWords(const char *fname) {
Common::File fp;
@@ -50,8 +77,7 @@ int AgiEngine::loadWords(const char *fname) {
for (int i = 0; i < 26; i++) {
fp.seek(i * 2, SEEK_SET);
int offset = fp.readUint16BE();
- if (offset == 0)
- continue;
+ if (offset == 0) continue;
fp.seek(offset, SEEK_SET);
int k = fp.readByte();
while (!fp.eos() && !fp.err()) {