diff options
author | Filippos Karapetis | 2010-06-01 15:11:20 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-06-01 15:11:20 +0000 |
commit | 9c92bd1b810621bdaa779bd3354b10ad048c7924 (patch) | |
tree | 16a56f987b162ff3ca0f1f8ef0ec78e6a762f866 /engines/sci/engine/kparse.cpp | |
parent | e083c20da1aab0090a5fc3ea624c9810c63dad52 (diff) | |
download | scummvm-rg350-9c92bd1b810621bdaa779bd3354b10ad048c7924.tar.gz scummvm-rg350-9c92bd1b810621bdaa779bd3354b10ad048c7924.tar.bz2 scummvm-rg350-9c92bd1b810621bdaa779bd3354b10ad048c7924.zip |
The parser vocabulary remains static throughout the game, thus it has been removed from the engine state
svn-id: r49373
Diffstat (limited to 'engines/sci/engine/kparse.cpp')
-rw-r--r-- | engines/sci/engine/kparse.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/engines/sci/engine/kparse.cpp b/engines/sci/engine/kparse.cpp index 97a75dcb1c..785ff39d22 100644 --- a/engines/sci/engine/kparse.cpp +++ b/engines/sci/engine/kparse.cpp @@ -42,6 +42,7 @@ reg_t kSaid(EngineState *s, int argc, reg_t *argv) { reg_t heap_said_block = argv[0]; byte *said_block; int new_lastmatch; + Vocabulary *voc = g_sci->getVocabulary(); #ifdef DEBUG_PARSER const int debug_parser = 1; #else @@ -63,7 +64,7 @@ reg_t kSaid(EngineState *s, int argc, reg_t *argv) { s->_voc->decipherSaidBlock(said_block); #endif - if (s->_voc->parser_event.isNull() || (readSelectorValue(s->_segMan, s->_voc->parser_event, SELECTOR(claimed)))) { + if (voc->parser_event.isNull() || (readSelectorValue(s->_segMan, voc->parser_event, SELECTOR(claimed)))) { return NULL_REG; } @@ -77,7 +78,7 @@ reg_t kSaid(EngineState *s, int argc, reg_t *argv) { s->r_acc = make_reg(0, 1); if (new_lastmatch != SAID_PARTIAL_MATCH) - writeSelectorValue(s->_segMan, s->_voc->parser_event, SELECTOR(claimed), 1); + writeSelectorValue(s->_segMan, voc->parser_event, SELECTOR(claimed), 1); } else { return NULL_REG; @@ -92,15 +93,15 @@ reg_t kParse(EngineState *s, int argc, reg_t *argv) { char *error; ResultWordList words; reg_t event = argv[1]; - Vocabulary *voc = s->_voc; + Vocabulary *voc = g_sci->getVocabulary(); - s->_voc->parser_event = event; + voc->parser_event = event; bool res = voc->tokenizeString(words, string.c_str(), &error); - s->_voc->parserIsValid = false; /* not valid */ + voc->parserIsValid = false; /* not valid */ if (res && !words.empty()) { - s->_voc->synonymizeTokens(words); + voc->synonymizeTokens(words); s->r_acc = make_reg(0, 1); @@ -117,17 +118,17 @@ reg_t kParse(EngineState *s, int argc, reg_t *argv) { s->r_acc = make_reg(0, 1); writeSelectorValue(segMan, event, SELECTOR(claimed), 1); - invokeSelector(INV_SEL(s, s->_gameObj, syntaxFail, kStopOnInvalidSelector), 2, s->_voc->parser_base, stringpos); + invokeSelector(INV_SEL(s, s->_gameObj, syntaxFail, kStopOnInvalidSelector), 2, voc->parser_base, stringpos); /* Issue warning */ debugC(2, kDebugLevelParser, "Tree building failed"); } else { - s->_voc->parserIsValid = true; + voc->parserIsValid = true; writeSelectorValue(segMan, event, SELECTOR(claimed), 0); #ifdef DEBUG_PARSER - s->_voc->dumpParseTree(); + voc->dumpParseTree(); #endif } @@ -136,11 +137,11 @@ reg_t kParse(EngineState *s, int argc, reg_t *argv) { s->r_acc = make_reg(0, 0); writeSelectorValue(segMan, event, SELECTOR(claimed), 1); if (error) { - s->_segMan->strcpy(s->_voc->parser_base, error); + s->_segMan->strcpy(voc->parser_base, error); debugC(2, kDebugLevelParser, "Word unknown: %s", error); /* Issue warning: */ - invokeSelector(INV_SEL(s, s->_gameObj, wordFail, kStopOnInvalidSelector), 2, s->_voc->parser_base, stringpos); + invokeSelector(INV_SEL(s, s->_gameObj, wordFail, kStopOnInvalidSelector), 2, voc->parser_base, stringpos); free(error); return make_reg(0, 1); /* Tell them that it didn't work */ } @@ -156,12 +157,13 @@ reg_t kSetSynonyms(EngineState *s, int argc, reg_t *argv) { Node *node; int script; int numSynonyms = 0; + Vocabulary *voc = g_sci->getVocabulary(); // Only SCI0-SCI1 EGA games had a parser. In newer versions, this is a stub if (getSciVersion() > SCI_VERSION_1_EGA) return s->r_acc; - s->_voc->clearSynonyms(); + voc->clearSynonyms(); list = s->_segMan->lookupList(readSelector(segMan, object, SELECTOR(elements))); node = s->_segMan->lookupNode(list->first); @@ -193,7 +195,7 @@ reg_t kSetSynonyms(EngineState *s, int argc, reg_t *argv) { 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); + voc->addSynonym(tmp); } } else warning("Synonyms of script.%03d were requested, but script is not available", script); |