aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/kscripts.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2010-01-23 19:10:56 +0000
committerFilippos Karapetis2010-01-23 19:10:56 +0000
commit722233fd0ddc4447b30f352f6b4bb19728d824fa (patch)
tree8f70437935084ea34abc658165188ef86f4a89aa /engines/sci/engine/kscripts.cpp
parentedbc3683987faf7487b10513a812ca2857a04771 (diff)
downloadscummvm-rg350-722233fd0ddc4447b30f352f6b4bb19728d824fa.tar.gz
scummvm-rg350-722233fd0ddc4447b30f352f6b4bb19728d824fa.tar.bz2
scummvm-rg350-722233fd0ddc4447b30f352f6b4bb19728d824fa.zip
- Moved all of the parser-related variables inside the Vocabulary class
- Moved the kSetSynonyms() function inside kscripts (as it's for script synonyms, not parser word synonyms) - The parser vocabulary is now only initialized for SCI0 and SCI01 games, which had a parser svn-id: r47483
Diffstat (limited to 'engines/sci/engine/kscripts.cpp')
-rw-r--r--engines/sci/engine/kscripts.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp
index 16ef002e66..73d440aea5 100644
--- a/engines/sci/engine/kscripts.cpp
+++ b/engines/sci/engine/kscripts.cpp
@@ -242,4 +242,57 @@ reg_t kRespondsTo(EngineState *s, int argc, reg_t *argv) {
return make_reg(0, s->_segMan->isHeapObject(obj) && lookup_selector(s->_segMan, obj, selector, NULL, NULL) != kSelectorNone);
}
+reg_t kSetSynonyms(EngineState *s, int argc, reg_t *argv) {
+ SegManager *segMan = s->_segMan;
+ reg_t object = argv[0];
+ List *list;
+ Node *node;
+ int script;
+ int numSynonyms = 0;
+
+ list = s->_segMan->lookupList(GET_SEL32(segMan, object, elements));
+ node = s->_segMan->lookupNode(list->first);
+
+ while (node) {
+ reg_t objpos = node->value;
+ int seg;
+
+ script = GET_SEL32V(segMan, objpos, number);
+ seg = s->_segMan->getScriptSegment(script);
+
+ if (seg > 0)
+ numSynonyms = s->_segMan->getScript(seg)->getSynonymsNr();
+
+ if (numSynonyms) {
+ byte *synonyms = s->_segMan->getScript(seg)->getSynonyms();
+
+ if (synonyms) {
+ debugC(2, kDebugLevelParser, "Setting %d synonyms for script.%d\n",
+ numSynonyms, script);
+
+ if (numSynonyms > 16384) {
+ error("Segtable corruption: script.%03d has %d synonyms",
+ script, numSynonyms);
+ /* We used to reset the corrupted value here. I really don't think it's appropriate.
+ * Lars */
+ } else
+ for (int i = 0; i < numSynonyms; i++) {
+ synonym_t tmp;
+ tmp.replaceant = (int16)READ_LE_UINT16(synonyms + i * 4);
+ tmp.replacement = (int16)READ_LE_UINT16(synonyms + i * 4 + 2);
+ s->_voc->addSynonym(tmp);
+ }
+ } else
+ warning("Synonyms of script.%03d were requested, but script is not available", script);
+
+ }
+
+ node = s->_segMan->lookupNode(node->succ);
+ }
+
+ debugC(2, kDebugLevelParser, "A total of %d synonyms are active now.\n", numSynonyms);
+
+ return s->r_acc;
+}
+
} // End of namespace Sci