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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Wed Apr 22 19:53:29 CEST 2009


Revision: 40078
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40078&view=rev
Author:   fingolfin
Date:     2009-04-22 17:53:29 +0000 (Wed, 22 Apr 2009)

Log Message:
-----------
SCI: Changed knames (kernel function name table) to Common::StringList

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/game.cpp
    scummvm/trunk/engines/sci/engine/kernel.cpp
    scummvm/trunk/engines/sci/engine/kernel.h
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/scriptconsole.cpp
    scummvm/trunk/engines/sci/engine/scriptdebug.cpp
    scummvm/trunk/engines/sci/engine/state.cpp
    scummvm/trunk/engines/sci/engine/state.h
    scummvm/trunk/engines/sci/engine/vm.h
    scummvm/trunk/engines/sci/scicore/vocab_debug.cpp
    scummvm/trunk/engines/sci/scicore/vocabulary.h

Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp	2009-04-22 17:52:56 UTC (rev 40077)
+++ scummvm/trunk/engines/sci/engine/game.cpp	2009-04-22 17:53:29 UTC (rev 40078)
@@ -77,11 +77,10 @@
 	vocab_free_rule_list(s->parser_rules);
 
 	s->_selectorNames.clear();
-	vocabulary_free_knames(s->kernel_names);
+	s->_kernelNames.clear();
 	vocabulary_free_opcodes(s->opcodes);
 	s->opcodes = NULL;
 
-	s->kernel_names = NULL;
 	s->opcodes = NULL;
 }
 
@@ -477,7 +476,7 @@
 	s->execution_stack_base = -1; // No vm is running yet
 	s->execution_stack_pos = -1;   // Start at execution stack position 0
 
-	s->kernel_names = vocabulary_get_knames(s->resmgr, &s->kernel_names_nr);
+	vocabulary_get_knames(s->resmgr, s->_kernelNames);
 	script_map_kernel(s);
 	// Maps the kernel functions
 

Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp	2009-04-22 17:52:56 UTC (rev 40077)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp	2009-04-22 17:53:29 UTC (rev 40078)
@@ -232,16 +232,11 @@
 	return reg;
 }
 
-int has_kernel_function(EngineState *s, const char *kname) {
-	int i = 0;
+bool has_kernel_function(EngineState *s, const char *kname) {
+	Common::StringList::const_iterator it
+		= Common::find(s->_kernelNames.begin(), s->_kernelNames.end(), kname);
 
-	while (s->kernel_names[i]) {
-		if (!strcmp(s->kernel_names[i], kname))
-			return 1;
-		i++;
-	}
-
-	return 0;
+	return (it != s->_kernelNames.end());
 }
 
 // Returns a pointer to the memory indicated by the specified handle
@@ -496,7 +491,7 @@
 reg_t kstub(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	int i;
 
-	sciprintf("Unimplemented syscall: %s[%x](", s->kernel_names[funct_nr], funct_nr);
+	sciprintf("Unimplemented syscall: %s[%x](", s->_kernelNames[funct_nr].c_str(), funct_nr);
 
 	for (i = 0; i < argc; i++) {
 		sciprintf(PREG, PRINT_REG(argv[i]));
@@ -508,13 +503,13 @@
 }
 
 reg_t kNOP(EngineState *s, int funct_nr, int argc, reg_t *argv) {
-	const char *problem = (const char*)(s->kfunct_table[funct_nr].orig_name ? "unmapped" : "NOP");
+	warning("Kernel function 0x%02x invoked: unmapped", funct_nr);
 
-	warning("Kernel function 0x%02x invoked: %s", funct_nr, problem);
-
-	if (s->kfunct_table[funct_nr].orig_name && strcmp(s->kfunct_table[funct_nr].orig_name, SCRIPT_UNKNOWN_FUNCTION_STRING)) {
-		warning(" (but its name is known to be %s)", s->kfunct_table[funct_nr].orig_name);
+/* TODO: re-enable this
+	if (s->kfunct_table[funct_nr].orig_name != SCRIPT_UNKNOWN_FUNCTION_STRING) {
+		warning(" (but its name is known to be %s)", s->kfunct_table[funct_nr].orig_name.c_str());
 	}
+*/
 
 	return NULL_REG;
 }
@@ -599,11 +594,10 @@
 }
 
 int script_map_kernel(EngineState *s) {
-	int functnr;
 	int mapped = 0;
 	int ignored = 0;
-	int functions_nr = s->kernel_names_nr;
-	int max_functions_nr = sci_max_allowed_unknown_kernel_functions[s->resmgr->_sciVersion];
+	uint functions_nr = s->_kernelNames.size();
+	uint max_functions_nr = sci_max_allowed_unknown_kernel_functions[s->resmgr->_sciVersion];
 
 	if (functions_nr < max_functions_nr) {
 		warning("SCI version believed to have %d kernel"
@@ -616,21 +610,21 @@
 	s->kfunct_table = (kfunct_sig_pair_t*)sci_malloc(sizeof(kfunct_sig_pair_t) * functions_nr);
 	s->kfunct_nr = functions_nr;
 
-	for (functnr = 0; functnr < functions_nr; functnr++) {
+	for (uint functnr = 0; functnr < functions_nr; functnr++) {
 		int seeker, found = -1;
-		char *sought_name = NULL;
+		Common::String sought_name;
 
-		if (functnr < s->kernel_names_nr)
-			sought_name = s->kernel_names[functnr];
+		if (functnr < s->_kernelNames.size())
+			sought_name = s->_kernelNames[functnr];
 
-		if (sought_name)
+		if (!sought_name.empty())
 			for (seeker = 0; (found == -1) && kfunct_mappers[seeker].type != KF_TERMINATOR; seeker++)
-				if (kfunct_mappers[seeker].name && strcmp(kfunct_mappers[seeker].name, sought_name) == 0)
+				if (kfunct_mappers[seeker].name && sought_name == kfunct_mappers[seeker].name)
 					found = seeker; // Found a kernel function with the same name!
 
 		if (found == -1) {
-			if (sought_name) {
-				warning("Kernel function %s[%x] unmapped", s->kernel_names[functnr], functnr);
+			if (!sought_name.empty()) {
+				warning("Kernel function %s[%x] unmapped", s->_kernelNames[functnr].c_str(), functnr);
 				s->kfunct_table[functnr].fun = kNOP;
 			} else {
 				warning("Flagging kernel function %x as unknown", functnr);
@@ -638,7 +632,9 @@
 			}
 
 			s->kfunct_table[functnr].signature = NULL;
+/* TODO: re-enable this
 			s->kfunct_table[functnr].orig_name = sought_name;
+*/
 		} else
 			switch (kfunct_mappers[found].type) {
 			case KF_OLD:
@@ -659,7 +655,7 @@
 
 	} // for all functions requesting to be mapped
 
-	sciprintf("Handled %d/%d kernel functions, mapping %d", mapped + ignored, s->kernel_names_nr, mapped);
+	sciprintf("Handled %d/%d kernel functions, mapping %d", mapped + ignored, s->_kernelNames.size(), mapped);
 	if (ignored)
 		sciprintf(" and ignoring %d", ignored);
 	sciprintf(".\n");

Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h	2009-04-22 17:52:56 UTC (rev 40077)
+++ scummvm/trunk/engines/sci/engine/kernel.h	2009-04-22 17:53:29 UTC (rev 40078)
@@ -109,7 +109,7 @@
 
 #define CHECK_THIS_KERNEL_FUNCTION if (s->debug_mode & (1 << SCIkFUNCCHK_NR)) {\
 	int i;\
-	sciprintf("Kernel CHECK: %s[%x](", s->kernel_names[funct_nr], funct_nr); \
+	sciprintf("Kernel CHECK: %s[%x](", s->_kernelNames[funct_nr].c_str(), funct_nr); \
 	for (i = 0; i < argc; i++) { \
 		sciprintf("%04x", 0xffff & UKPV(i)); \
 		if (i+1 < argc) sciprintf(", "); \

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-04-22 17:52:56 UTC (rev 40077)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-04-22 17:53:29 UTC (rev 40078)
@@ -903,8 +903,7 @@
 
 	// static VM/Kernel information:
 	retval->_selectorNames = s->_selectorNames;
-	retval->kernel_names_nr = s->kernel_names_nr;
-	retval->kernel_names = s->kernel_names;
+	retval->_kernelNames = s->_kernelNames;
 	retval->kfunct_table = s->kfunct_table;
 	retval->kfunct_nr = s->kfunct_nr;
 	retval->opcodes = s->opcodes;

Modified: scummvm/trunk/engines/sci/engine/scriptconsole.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptconsole.cpp	2009-04-22 17:52:56 UTC (rev 40077)
+++ scummvm/trunk/engines/sci/engine/scriptconsole.cpp	2009-04-22 17:53:29 UTC (rev 40078)
@@ -1029,26 +1029,24 @@
 }
 
 static int c_kernelnames(EngineState * s) {
-	int knamectr;
-	char **knames = vocabulary_get_knames(s->resmgr, &knamectr);
-	int seeker = 0;
+	Common::StringList knames;
 
 	if (NULL == s) {
 		sciprintf("console.c: c_kernelnames NULL passed for parameter s\n");
 		return -1;
 	}
 
-	if (!knames) {
+	vocabulary_get_knames(s->resmgr, knames);
+
+	if (knames.empty()) {
 		sciprintf("No kernel name table found!\n");
 		return 1;
 	}
 
 	sciprintf("Syscalls in numeric order:\n");
-	for (seeker = 0; seeker < knamectr; seeker++)
-		sciprintf("%03x: %s\n", seeker, knames[seeker]);
+	for (uint seeker = 0; seeker < knames.size(); seeker++)
+		sciprintf("%03x: %s\n", seeker, knames[seeker].c_str());
 
-	vocabulary_free_knames(knames);
-
 	return 0;
 }
 

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-04-22 17:52:56 UTC (rev 40077)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-04-22 17:53:29 UTC (rev 40078)
@@ -1344,7 +1344,7 @@
 
 			if (opcode == op_callk)
 				sciprintf(" %s[%x]", (param_value < s->kfunct_nr) ?
-							((param_value < s->kernel_names_nr) ? s->kernel_names[param_value] : "[Unknown(postulated)]")
+							((param_value < s->_kernelNames.size()) ? s->_kernelNames[param_value].c_str() : "[Unknown(postulated)]")
 							: "<invalid>", param_value);
 			else
 				sciprintf(opsize ? " %02x" : " %04x", param_value);
@@ -1564,7 +1564,7 @@
 		break;
 
 		case EXEC_STACK_TYPE_KERNEL: // Kernel function
-			sciprintf(" %x:[%x]  k%s(", i, call->origin, s->kernel_names[-(call->selector)-42]);
+			sciprintf(" %x:[%x]  k%s(", i, call->origin, s->_kernelNames[-(call->selector)-42].c_str());
 			break;
 
 		case EXEC_STACK_TYPE_VARSELECTOR:
@@ -2111,17 +2111,15 @@
 		   and scan the function table to find out the index. */
 		callk_index = strtoul(cmd_params [0].str, &endptr, 0);
 		if (*endptr != '\0') {
-			int i;
-
 			callk_index = -1;
-			for (i = 0; i < s->kernel_names_nr; i++)
-				if (!strcmp(cmd_params [0].str, s->kernel_names [i])) {
+			for (uint i = 0; i < s->_kernelNames.size(); i++)
+				if (cmd_params [0].str == s->_kernelNames[i]) {
 					callk_index = i;
 					break;
 				}
 
 			if (callk_index == -1) {
-				sciprintf("Unknown kernel function '%s'\n", cmd_params [0].str);
+				sciprintf("Unknown kernel function '%s'\n", cmd_params[0].str);
 				return 1;
 			}
 		}

Modified: scummvm/trunk/engines/sci/engine/state.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/state.cpp	2009-04-22 17:52:56 UTC (rev 40077)
+++ scummvm/trunk/engines/sci/engine/state.cpp	2009-04-22 17:53:29 UTC (rev 40078)
@@ -157,9 +157,6 @@
 	seg_manager = 0;
 	gc_countdown = 0;
 
-	kernel_names_nr = 0;
-	kernel_names = 0;
-
 	kfunct_table = 0;
 	kfunct_nr = 0;
 

Modified: scummvm/trunk/engines/sci/engine/state.h
===================================================================
--- scummvm/trunk/engines/sci/engine/state.h	2009-04-22 17:52:56 UTC (rev 40077)
+++ scummvm/trunk/engines/sci/engine/state.h	2009-04-22 17:53:29 UTC (rev 40078)
@@ -269,8 +269,7 @@
 	int gc_countdown; /* Number of kernel calls until next gc */
 
 	Common::StringList _selectorNames;
-	int kernel_names_nr; /* Number of kernel function names */
-	char **kernel_names; /* List of kernel names */
+	Common::StringList _kernelNames; /* List of kernel names */
 
 	kfunct_sig_pair_t *kfunct_table; /* Table of kernel functions */
 	int kfunct_nr; /* Number of mapped kernel functions; may be more than

Modified: scummvm/trunk/engines/sci/engine/vm.h
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.h	2009-04-22 17:52:56 UTC (rev 40077)
+++ scummvm/trunk/engines/sci/engine/vm.h	2009-04-22 17:53:29 UTC (rev 40078)
@@ -756,7 +756,7 @@
 
 int script_map_kernel(EngineState *s);
 /* Maps kernel functions
-** Parameters: (EngineState *) s: The state which the kernel_names are retrieved from
+** Parameters: (EngineState *) s: The state which the _kernelNames are retrieved from
 ** Returns   : (void)
 ** This function reads from and writes to s. It is called by script_run().
 */
@@ -776,11 +776,11 @@
 ** Returns   : (reg_t) The handle
 */
 
-int has_kernel_function(EngineState *s, const char *kname);
+bool has_kernel_function(EngineState *s, const char *kname);
 /* Detects whether a particular kernel function is required in the game
 ** Parameters: (EngineState *) s: Pointer to the EngineState to operate on
 **             (const char *) kname: The name of the desired kernel function
-** Returns   : (int) 1 if the kernel function is listed in the kernel table,
+** Returns   : (bool) 1 if the kernel function is listed in the kernel table,
 **                   0 otherwise
 */
 

Modified: scummvm/trunk/engines/sci/scicore/vocab_debug.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/vocab_debug.cpp	2009-04-22 17:52:56 UTC (rev 40077)
+++ scummvm/trunk/engines/sci/scicore/vocab_debug.cpp	2009-04-22 17:53:29 UTC (rev 40078)
@@ -393,86 +393,58 @@
 }
 
 // Alternative kernel func names retriever. Required for KQ1/SCI (at least).
-static char **_vocabulary_get_knames0alt(int *names, Resource *r) {
-	unsigned int mallocsize = 32;
-	char **retval = (char **)sci_malloc(sizeof(char *) * mallocsize);
-	unsigned int i = 0, index = 0;
+static void _vocabulary_get_knames0alt(const Resource *r, Common::StringList &names) {
+	uint idx = 0;
 
-	while (index < r->size) {
-		int slen = strlen((char *) r->data + index) + 1;
-
-		retval[i] = (char *)sci_malloc(slen);
-		memcpy(retval[i++], r->data + index, slen);
-		// Wouldn't normally read this, but the cleanup code wants to free() this
-
-		index += slen;
-
-		if (i == mallocsize)
-			retval = (char **)sci_realloc(retval, sizeof(char *) * (mallocsize <<= 1));
+	while (idx < r->size) {
+		Common::String tmp((const char *)r->data + idx);
+		names.push_back(tmp);
+		idx += tmp.size() + 1;
 	}
 
-	*names = i + 1;
-	retval = (char **)sci_realloc(retval, sizeof(char *) * (i + 2));
-	retval[i] = (char *)sci_malloc(strlen(SCRIPT_UNKNOWN_FUNCTION_STRING) + 1);
-	strcpy(retval[i], SCRIPT_UNKNOWN_FUNCTION_STRING);
 	// The mystery kernel function- one in each SCI0 package
-
-	retval[i + 1] = NULL; // Required for cleanup
-
-	return retval;
+	names.push_back(SCRIPT_UNKNOWN_FUNCTION_STRING);
 }
 
-static char **vocabulary_get_knames0(ResourceManager *resmgr, int* names) {
-	char** t;
+static void vocabulary_get_knames0(ResourceManager *resmgr, Common::StringList &names) {
 	int count, i, index = 2, empty_to_add = 1;
 	Resource *r = resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_KNAMES, 0);
 
 	if (!r) { // No kernel name table found? Fall back to default table
-		t = (char **)sci_malloc((SCI0_KNAMES_DEFAULT_ENTRIES_NR + 1) * sizeof(char*));
-		*names = SCI0_KNAMES_DEFAULT_ENTRIES_NR - 1; // index of last element
-
+		names.resize(SCI0_KNAMES_DEFAULT_ENTRIES_NR);
 		for (i = 0; i < SCI0_KNAMES_DEFAULT_ENTRIES_NR; i++)
-			t[i] = sci_strdup(sci0_default_knames[i]);
-
-		t[SCI0_KNAMES_DEFAULT_ENTRIES_NR] = NULL; // Terminate list
-
-		return t;
+			names[i] = sci0_default_knames[i];
+		return;
 	}
 
 	count = getInt(r->data);
 
-	if (count > 1023)
-		return _vocabulary_get_knames0alt(names, r);
+	if (count > 1023) {
+		_vocabulary_get_knames0alt(r, names);
+		return;
+	}
 
 	if (count < SCI0_KNAMES_WELL_DEFINED) {
 		empty_to_add = SCI0_KNAMES_WELL_DEFINED - count;
 		sciprintf("Less than %d kernel functions; adding %d\n", SCI0_KNAMES_WELL_DEFINED, empty_to_add);
 	}
 
-	t = (char **)sci_malloc(sizeof(char*) * (count + 1 + empty_to_add));
+	names.resize(count + 1 + empty_to_add);
+
 	for (i = 0; i < count; i++) {
 		int offset = getInt(r->data + index);
 		int len = getInt(r->data + offset);
 		//fprintf(stderr,"Getting name %d of %d...\n", i, count);
 		index += 2;
-		t[i] = (char *)sci_malloc(len + 1);
-		memcpy(t[i], r->data + offset + 2, len);
-		t[i][len] = '\0';
+		names[i] = Common::String((const char *)r->data + offset + 2, len);
 	}
 
 	for (i = 0; i < empty_to_add; i++) {
-		t[count + i] = (char *)sci_malloc(strlen(SCRIPT_UNKNOWN_FUNCTION_STRING) + 1);
-		strcpy(t[count + i], SCRIPT_UNKNOWN_FUNCTION_STRING);
+		names[count + i] = SCRIPT_UNKNOWN_FUNCTION_STRING;
 	}
-
-	t[count+empty_to_add] = 0;
-	*names = count + empty_to_add;
-
-	return t;
 }
 
-static char **vocabulary_get_knames1(ResourceManager *resmgr, int *count) {
-	char **t = NULL;
+static void vocabulary_get_knames1(ResourceManager *resmgr, Common::StringList &names) {
 	// vocab.999/999.voc is notoriously unreliable in SCI1 games, and should not be used
 	// We hardcode the default SCI1 kernel names here (i.e. the ones inside the "special"
 	// 999.voc file from FreeSCI). All SCI1 games seem to be working with this change, but
@@ -480,53 +452,14 @@
 	// that all SCI1 games use the same kernel vocabulary names though, so this seems to be
 	// a safe change. If there's any SCI1 game with different kernel vocabulary names, we can
 	// add special flags to it to our detector
-	t = (char **)sci_malloc((SCI1_KNAMES_DEFAULT_ENTRIES_NR + 1) * sizeof(char*));
-	*count = SCI1_KNAMES_DEFAULT_ENTRIES_NR;
 
+	names.resize(SCI1_KNAMES_DEFAULT_ENTRIES_NR);
 	for (int i = 0; i < SCI1_KNAMES_DEFAULT_ENTRIES_NR; i++)
-		t[i] = sci_strdup(sci1_default_knames[i]);
-
-	t[SCI1_KNAMES_DEFAULT_ENTRIES_NR] = NULL; // Terminate list
-
-	return t;
-
-// Previous code, which used the unreliable 999.voc resource
-#if 0
-	unsigned int size = 64, used = 0, pos = 0;
-	Resource *r = resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_KNAMES, 0);
-
-	if (r == NULL) {// failed to open vocab.999 (happens with SCI1 demos)
-		t = (char **)sci_malloc((SCI1_KNAMES_DEFAULT_ENTRIES_NR + 1) * sizeof(char*));
-		*count = SCI1_KNAMES_DEFAULT_ENTRIES_NR - 1; // index of last element
-
-		for (int i = 0; i < SCI1_KNAMES_DEFAULT_ENTRIES_NR; i++)
-			t[i] = sci_strdup(sci1_default_knames[i]);
-
-		t[SCI1_KNAMES_DEFAULT_ENTRIES_NR] = NULL; // Terminate list
-
-		return t;
-	}
-	while (pos < r->size) {
-		int len;
-		if ((used == size - 1) || (!t)) {
-			size *= 2;
-			t = (char **)sci_realloc(t, size * sizeof(char*));
-		}
-		len = strlen((char *)r->data + pos);
-		t[used] = (char *)sci_malloc(len + 1);
-		strcpy(t[used], (char *)r->data + pos);
-		used++;
-		pos += len + 1;
-	}
-	*count = used;
-	t = (char **)sci_realloc(t, (used + 1) * sizeof(char*));
-	t[used] = NULL;
-
-	return t;
-#endif
+		names[i] = sci1_default_knames[i];
 }
+
 //
-static char **vocabulary_get_knames11(ResourceManager *resmgr, int *count) {
+static void vocabulary_get_knames11(ResourceManager *resmgr, Common::StringList &names) {
 /*
  999.voc format for SCI1.1 games:
 	[b] # of kernel functions
@@ -536,33 +469,29 @@
     {[w name-len][function name]}
 		...
 */
-	char **t = NULL;
 	//unsigned int size = 64, pos = 3;
 	int len;
 	Resource *r = resmgr->findResource(kResourceTypeVocab, VOCAB_RESOURCE_KNAMES, 0);
 	if(r == NULL) // failed to open vocab.999 (happens with SCI1 demos)
-		return 0; // FIXME: should return a default table for this engine 
-	byte nCnt = *r->data, i;
-	t = (char **)sci_malloc(nCnt * sizeof(char*) + 1);
+		return; // FIXME: should return a default table for this engine 
+	const byte nCnt = *r->data;
 	
-	for (i = 0; i < nCnt; i++) {
+	names.resize(nCnt);
+	for (int i = 0; i < nCnt; i++) {
 		int off = READ_LE_UINT16(r->data + 2 * i + 2);
 		len = READ_LE_UINT16(r->data + off);
-		t[i] = (char *)sci_malloc(len + 1);
-		memcpy(t[i], (char *)r->data + off + 2, len);
-		t[i][len] = 0;
+		names[i] = Common::String((char *)r->data + off + 2, len);
 	}
-	*count = nCnt;
-	t[nCnt] = NULL;
-
-	return t;
 }
 
-char **vocabulary_get_knames(ResourceManager *resmgr, int *count) {
+void vocabulary_get_knames(ResourceManager *resmgr, Common::StringList &names) {
+	names.clear();
+
 	switch (resmgr->_sciVersion) {
 	case SCI_VERSION_0:
 	case SCI_VERSION_01:
-		return vocabulary_get_knames0(resmgr, count);
+		vocabulary_get_knames0(resmgr, names);
+		break;
 	case SCI_VERSION_01_VGA:
 	case SCI_VERSION_01_VGA_ODD:
 		// HACK: KQ5 needs the SCI1 default vocabulary names to work correctly.
@@ -572,27 +501,19 @@
 		// return vocabulary_get_knames0(resmgr, count);
 	case SCI_VERSION_1_EARLY:
 	case SCI_VERSION_1_LATE:
-		return vocabulary_get_knames1(resmgr, count);
+		vocabulary_get_knames1(resmgr, names);
+		break;
 	case SCI_VERSION_1_1:
-		return vocabulary_get_knames11(resmgr, count);
+		vocabulary_get_knames11(resmgr, names);
+		break;
 #ifdef ENABLE_SCI32
 	case SCI_VERSION_32:
-		return vocabulary_get_knames11(resmgr, count);
+		vocabulary_get_knames11(resmgr, names);
 #endif
+		break;
 	default:
-		return 0;
+		break;
 	}
 }
 
-void vocabulary_free_knames(char **names) {
-	int i = 0;
-
-	while (names[i]) {
-		free(names[i]);
-		i++;
-	}
-
-	free(names);
-}
-
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/scicore/vocabulary.h
===================================================================
--- scummvm/trunk/engines/sci/scicore/vocabulary.h	2009-04-22 17:52:56 UTC (rev 40077)
+++ scummvm/trunk/engines/sci/scicore/vocabulary.h	2009-04-22 17:53:29 UTC (rev 40078)
@@ -211,15 +211,14 @@
 */
 
 /**
- * Returns a null terminated array of kernel function names.
+ * Fills a StringList with kernel function names.
  *
  * This function reads the kernel function name table from resource_map,
- * and returns a null terminated array of deep copies of them.
- * The returned array has the same format regardless of the format of the
+ * and fills the given StringList with them.
+ * The resulting list has the same format regardless of the format of the
  * name table of the resource (the format changed between version 0 and 1).
  */
-char **vocabulary_get_knames(ResourceManager *resmgr, int* count);
-void vocabulary_free_knames(char** names);
+void vocabulary_get_knames(ResourceManager *resmgr, Common::StringList &names);
 
 
 /**


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