[Scummvm-cvs-logs] SF.net SVN: scummvm:[41071] scummvm/trunk/engines/sci

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun May 31 17:08:16 CEST 2009


Revision: 41071
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41071&view=rev
Author:   fingolfin
Date:     2009-05-31 15:08:16 +0000 (Sun, 31 May 2009)

Log Message:
-----------
SCI: Fixed loading; added 'const' keywords to several Vocabulary methods

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/state.cpp
    scummvm/trunk/engines/sci/vocabulary.cpp
    scummvm/trunk/engines/sci/vocabulary.h

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-05-31 15:07:55 UTC (rev 41070)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-05-31 15:08:16 UTC (rev 41071)
@@ -823,16 +823,19 @@
 	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 @@
 	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;

Modified: scummvm/trunk/engines/sci/engine/state.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/state.cpp	2009-05-31 15:07:55 UTC (rev 41070)
+++ scummvm/trunk/engines/sci/engine/state.cpp	2009-05-31 15:08:16 UTC (rev 41071)
@@ -120,6 +120,8 @@
 	seg_manager = 0;
 	gc_countdown = 0;
 
+	_vocabulary = 0;
+
 	successor = 0;
 }
 

Modified: scummvm/trunk/engines/sci/vocabulary.cpp
===================================================================
--- scummvm/trunk/engines/sci/vocabulary.cpp	2009-05-31 15:07:55 UTC (rev 41070)
+++ scummvm/trunk/engines/sci/vocabulary.cpp	2009-05-31 15:08:16 UTC (rev 41071)
@@ -171,9 +171,6 @@
 		_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 @@
 	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 @@
 	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());
 }

Modified: scummvm/trunk/engines/sci/vocabulary.h
===================================================================
--- scummvm/trunk/engines/sci/vocabulary.h	2009-05-31 15:07:55 UTC (rev 41070)
+++ scummvm/trunk/engines/sci/vocabulary.h	2009-05-31 15:08:16 UTC (rev 41071)
@@ -256,52 +256,30 @@
 	 */
 	void printParserWords();
 
-	/**
-	 * Copies the parser lists from another vocabulary
-	 */
-	void copyParserListsFrom(Vocabulary *voc);
+	uint getParserBranchesSize() const { return _parserBranches.size(); }
+	const parse_tree_branch_t &getParseTreeBranch(int number) const { return _parserBranches[number]; }
 
-	/**
-	 * 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);
+	uint getOpcodesSize() const { return _opcodes.size(); }
+	const opcode &getOpcode(uint opcode) const { return _opcodes[opcode]; }
 
-	/**
-	 * Copies the kernel lists from another vocabulary
-	 */
-	void copyKernelListsFrom(Vocabulary *voc);
+	uint getSelectorNamesSize() const { return _selectorNames.size(); }
+	const Common::String &getSelectorName(uint selector) const { return _selectorNames[selector]; }
 
-	/**
-	 * 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 getOpcodesSize() { return _opcodes.size(); }
-	opcode getOpcode(uint opcode) { return _opcodes[opcode]; }
-
-	uint getSelectorNamesSize() { return _selectorNames.size(); }
-	Common::String getSelectorName(uint selector) { 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);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list