diff options
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/savegame.cpp | 17 | ||||
-rw-r--r-- | engines/sci/engine/state.cpp | 2 | ||||
-rw-r--r-- | engines/sci/vocabulary.cpp | 30 | ||||
-rw-r--r-- | engines/sci/vocabulary.h | 42 |
4 files changed, 24 insertions, 67 deletions
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 6fa75ffa66..e817b798ec 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -823,16 +823,19 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { retval->game_start_time = g_system->getMillis() - retval->game_time * 1000; // static parser information: - retval->_vocabulary->copyParserListsFrom(s->_vocabulary); + assert(0 == retval->_vocabulary); + retval->_vocabulary = s->_vocabulary; +// s->_vocabulary = 0; // FIXME: We should set s->_vocabulary to 0 here, +// else it could be freed when the old EngineState is freed. Luckily, this freeing currently +// never happens, so we don't need to. This is lucky, because the fact that the kernel function +// and selector tables are stored in the Vocabulary (????) makes it impossible for us to +// free the vocabulary here. + + retval->parser_base = make_reg(s->sys_strings_segment, SYS_STRING_PARSER_BASE); // static VM/Kernel information: - retval->_vocabulary->copyKernelListsFrom(s->_vocabulary); retval->_kfuncTable = s->_kfuncTable; - memcpy(&(retval->_vocabulary->_selectorMap), &(s->_vocabulary->_selectorMap), sizeof(selector_map_t)); - - retval->parser_base = make_reg(s->sys_strings_segment, SYS_STRING_PARSER_BASE); - // Copy breakpoint information from current game instance retval->have_bp = s->have_bp; retval->bp_list = s->bp_list; @@ -841,7 +844,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { retval->have_mouse_flag = 1; retval->successor = NULL; - retval->pic_priority_table = (int*)gfxop_get_pic_metainfo(retval->gfx_state); + retval->pic_priority_table = (int *)gfxop_get_pic_metainfo(retval->gfx_state); retval->_gameName = obj_get_name(retval, retval->game_obj); retval->_sound._it = NULL; diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index 6ade204930..b8853706ab 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -120,6 +120,8 @@ EngineState::EngineState() : _dirseeker(this) { seg_manager = 0; gc_countdown = 0; + _vocabulary = 0; + successor = 0; } diff --git a/engines/sci/vocabulary.cpp b/engines/sci/vocabulary.cpp index 01d237a780..bb88910833 100644 --- a/engines/sci/vocabulary.cpp +++ b/engines/sci/vocabulary.cpp @@ -171,9 +171,6 @@ bool Vocabulary::getOpcodes() { _opcodes[i].type = READ_LE_UINT16(r->data + offset + 2); // QFG3 has empty opcodes _opcodes[i].name = len > 0 ? Common::String((char *)r->data + offset + 4, len) : "Dummy"; -#if 1 //def VOCABULARY_DEBUG - printf("Opcode %02X: %s, %d\n", i, _opcodes[i].name.c_str(), _opcodes[i].type); -#endif } return true; @@ -536,30 +533,7 @@ void Vocabulary::printParserWords() { con->DebugPrintf("\n"); } -void Vocabulary::copyParserListsFrom(Vocabulary *voc) { - voc->copyParserListsTo(_parserSuffixes, *_parserRules, _parserBranches, _parserWords); -} - -void Vocabulary::copyParserListsTo(SuffixList &parserSuffixes, parse_rule_list_t &parserRules, - Common::Array<parse_tree_branch_t> &parserBranches, WordMap &parserWords) { - parserSuffixes = _parserSuffixes; - parserRules = *_parserRules; - parserBranches = _parserBranches; - parserWords = _parserWords; -} - -void Vocabulary::copyKernelListsFrom(Vocabulary *voc) { - voc->copyKernelListsTo(_opcodes, _selectorNames, _kernelNames); -} - -void Vocabulary::copyKernelListsTo(Common::Array<opcode> &opcodes, Common::StringList &selectorNames, - Common::StringList &kernelNames) { - _opcodes = opcodes; - _selectorNames = selectorNames; - _kernelNames = kernelNames; -} - -int Vocabulary::findSelector(const char *selectorName) { +int Vocabulary::findSelector(const char *selectorName) const { for (uint pos = 0; pos < _selectorNames.size(); ++pos) { if (_selectorNames[pos] == selectorName) return pos; @@ -570,7 +544,7 @@ int Vocabulary::findSelector(const char *selectorName) { return -1; } -bool Vocabulary::hasKernelFunction(const char *functionName) { +bool Vocabulary::hasKernelFunction(const char *functionName) const { Common::StringList::const_iterator it = Common::find(_kernelNames.begin(), _kernelNames.end(), functionName); return (it != _kernelNames.end()); } diff --git a/engines/sci/vocabulary.h b/engines/sci/vocabulary.h index f1b2ef867b..f5e6a466a4 100644 --- a/engines/sci/vocabulary.h +++ b/engines/sci/vocabulary.h @@ -256,52 +256,30 @@ public: */ void printParserWords(); - /** - * Copies the parser lists from another vocabulary - */ - void copyParserListsFrom(Vocabulary *voc); - - /** - * Gets the internal parser lists, for vocabulary copying - */ - void copyParserListsTo(SuffixList &parserSuffixes, parse_rule_list_t &parserRules, - Common::Array<parse_tree_branch_t> &parserBranches, WordMap &parserWords); - - /** - * Copies the kernel lists from another vocabulary - */ - void copyKernelListsFrom(Vocabulary *voc); - - /** - * Gets the internal kernel lists, for vocabulary copying - */ - void copyKernelListsTo(Common::Array<opcode> &opcodes, Common::StringList &selectorNames, - Common::StringList &kernelNames); - - uint getParserBranchesSize() { return _parserBranches.size(); } - parse_tree_branch_t getParseTreeBranch(int number) { return _parserBranches[number]; } + uint getParserBranchesSize() const { return _parserBranches.size(); } + const parse_tree_branch_t &getParseTreeBranch(int number) const { return _parserBranches[number]; } - uint getOpcodesSize() { return _opcodes.size(); } - opcode getOpcode(uint opcode) { return _opcodes[opcode]; } + uint getOpcodesSize() const { return _opcodes.size(); } + const opcode &getOpcode(uint opcode) const { return _opcodes[opcode]; } - uint getSelectorNamesSize() { return _selectorNames.size(); } - Common::String getSelectorName(uint selector) { return _selectorNames[selector]; } + uint getSelectorNamesSize() const { return _selectorNames.size(); } + const Common::String &getSelectorName(uint selector) const { return _selectorNames[selector]; } /* Determines the selector ID of a selector by its name ** (const char *) selectorName: Name of the selector to look up ** Returns : (int) The appropriate selector ID, or -1 on error */ - int findSelector(const char *selectorName); + int findSelector(const char *selectorName) const; /* Detects whether a particular kernel function is required in the game ** (const char *) functionName: The name of the desired kernel function ** Returns : (bool) true if the kernel function is listed in the kernel table, ** false otherwise */ - bool hasKernelFunction(const char *functionName); + bool hasKernelFunction(const char *functionName) const; - uint getKernelNamesSize() { return _kernelNames.size(); } - Common::String getKernelName(uint number) { return _kernelNames[number]; } + uint getKernelNamesSize() const { return _kernelNames.size(); } + const Common::String &getKernelName(uint number) const { return _kernelNames[number]; } // Script dissection/dumping functions void dissectScript(int scriptNumber); |