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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Fri Feb 27 00:03:36 CET 2009


Revision: 38916
          http://scummvm.svn.sourceforge.net/scummvm/?rev=38916&view=rev
Author:   thebluegr
Date:     2009-02-26 23:03:35 +0000 (Thu, 26 Feb 2009)

Log Message:
-----------
- Removed engine/sys_strings.*
- Renamed sys_string_t -> SystemString, sys_strings_t -> SystemStrings

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/game.cpp
    scummvm/trunk/engines/sci/engine/savegame.cfsml
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/scriptdebug.cpp
    scummvm/trunk/engines/sci/engine/seg_manager.cpp
    scummvm/trunk/engines/sci/engine/seg_manager.h
    scummvm/trunk/engines/sci/engine/vm.h
    scummvm/trunk/engines/sci/include/engine.h
    scummvm/trunk/engines/sci/module.mk

Removed Paths:
-------------
    scummvm/trunk/engines/sci/engine/sys_strings.cpp
    scummvm/trunk/engines/sci/engine/sys_strings.h

Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp	2009-02-26 21:17:53 UTC (rev 38915)
+++ scummvm/trunk/engines/sci/engine/game.cpp	2009-02-26 23:03:35 UTC (rev 38916)
@@ -633,7 +633,11 @@
 
 	s->sys_strings = s->seg_manager->allocateSysStrings(&s->sys_strings_segment);
 	// Allocate static buffer for savegame and CWD directories
-	sys_string_acquire(s->sys_strings, SYS_STRING_SAVEDIR, "savedir", MAX_SAVE_DIR_SIZE);
+	SystemString *str = &s->sys_strings->strings[SYS_STRING_SAVEDIR];
+	str->name = strdup("savedir");
+	str->max_size = MAX_SAVE_DIR_SIZE;
+	str->value = (char*)sci_malloc(MAX_SAVE_DIR_SIZE + 1);
+	str->value[0] = 0; // Set to empty string
 
 	s->save_dir_copy = make_reg(s->sys_strings_segment, SYS_STRING_SAVEDIR);
 	s->save_dir_edit_offset = 0;
@@ -677,7 +681,9 @@
 }
 
 void script_set_gamestate_save_dir(EngineState *s, const char *path) {
-	sys_string_set(s->sys_strings, SYS_STRING_SAVEDIR, path);
+	SystemString *str = &s->sys_strings->strings[SYS_STRING_SAVEDIR];
+	strncpy(str->value, path, str->max_size);
+	str->value[str->max_size] = 0; // Make sure to terminate
 }
 
 void script_free_vm_memory(EngineState *s) {
@@ -759,7 +765,12 @@
 	s->status_bar_foreground = 0;
 	s->status_bar_background = s->resmgr->sci_version >= SCI_VERSION_01_VGA ? 255 : 15;
 
-	sys_string_acquire(s->sys_strings, SYS_STRING_PARSER_BASE, "parser-base", MAX_PARSER_BASE);
+	SystemString *str = &s->sys_strings->strings[SYS_STRING_PARSER_BASE];
+	str->name = strdup("parser-base");
+	str->max_size = MAX_PARSER_BASE;
+	str->value = (char*)sci_malloc(MAX_PARSER_BASE + 1);
+	str->value[0] = 0; // Set to empty string
+
 	s->parser_base = make_reg(s->sys_strings_segment, SYS_STRING_PARSER_BASE);
 
 	s->game_start_time = g_system->getMillis();

Modified: scummvm/trunk/engines/sci/engine/savegame.cfsml
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cfsml	2009-02-26 21:17:53 UTC (rev 38915)
+++ scummvm/trunk/engines/sci/engine/savegame.cfsml	2009-02-26 23:03:35 UTC (rev 38916)
@@ -428,14 +428,14 @@
 	int marked_as_deleted;
 }
 
-RECORD sys_string_t "sys_string_t" {
+RECORD SystemString "SystemString" {
 	string name;
 	int max_size;
 	string value;
 }
 
-RECORD sys_strings_t "sys_strings_t" {
-	sys_string_t strings[STATIC SYS_STRINGS_MAX];
+RECORD SystemStrings "SystemStrings" {
+	SystemString strings[STATIC SYS_STRINGS_MAX];
 }
 
 RECORD dynmem_t "dynmem_t" {
@@ -624,7 +624,7 @@
 		%CFSMLWRITE local_variables_t &foo->data.locals INTO fh;
 	break;
 	case MEM_OBJ_SYS_STRINGS:
-		%CFSMLWRITE sys_strings_t &foo->data.sys_strings INTO fh;
+		%CFSMLWRITE SystemStrings &foo->data.sys_strings INTO fh;
 	break;
 	case MEM_OBJ_STACK:
 		%CFSMLWRITE int &foo->data.stack.nr INTO fh;
@@ -664,7 +664,7 @@
 		%CFSMLREAD local_variables_t &foo->data.locals FROM fh ERRVAR *hiteof LINECOUNTER *line;
 	break;
 	case MEM_OBJ_SYS_STRINGS:
-		%CFSMLREAD sys_strings_t &foo->data.sys_strings FROM fh ERRVAR *hiteof LINECOUNTER *line;
+		%CFSMLREAD SystemStrings &foo->data.sys_strings FROM fh ERRVAR *hiteof LINECOUNTER *line;
 	break;
 	case MEM_OBJ_LISTS:
 		%CFSMLREAD list_table_t &foo->data.lists FROM fh ERRVAR *hiteof LINECOUNTER *line;
@@ -1104,8 +1104,25 @@
 	retval->save_dir_edit_offset = 0;
 	retval->sys_strings_segment = find_unique_seg_by_type(retval->seg_manager, MEM_OBJ_SYS_STRINGS);
 	retval->sys_strings = &(((mem_obj_t *)(GET_SEGMENT(*retval->seg_manager, retval->sys_strings_segment, MEM_OBJ_SYS_STRINGS)))->data.sys_strings);
-	sys_strings_restore(retval->sys_strings, s->sys_strings);
 
+	// Restore system strings
+	SystemString *str;
+
+	// First, pad memory
+	for (int i = 0; i < SYS_STRINGS_MAX; i++) {
+		str = &retval->sys_strings->strings[i];
+		char *data = str->value;
+		if (data) {
+			str->value = (char *)sci_malloc(str->max_size + 1);
+			strcpy(str->value, data);
+			free(data);
+		}
+	}
+
+	str = &retval->sys_strings->strings[SYS_STRING_SAVEDIR];
+	strncpy(str->value, s->sys_strings->strings[SYS_STRING_SAVEDIR].value, str->max_size);
+	str->value[str->max_size] = 0; // Make sure to terminate
+	
 	// Time state:
 	retval->last_wait_time = g_system->getMillis();
 	retval->game_start_time = g_system->getMillis() - retval->game_time * 1000;

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-02-26 21:17:53 UTC (rev 38915)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-02-26 23:03:35 UTC (rev 38916)
@@ -512,8 +512,8 @@
 static int _cfsml_read_node_table_t(Common::SeekableReadStream *fh, node_table_t* save_struc, const char *lastval, int *line, int *hiteof);
 
 #line 382 "engines/sci/engine/savegame.cfsml"
-static void _cfsml_write_sys_strings_t(Common::WriteStream *fh, sys_strings_t* save_struc);
-static int _cfsml_read_sys_strings_t(Common::SeekableReadStream *fh, sys_strings_t* save_struc, const char *lastval, int *line, int *hiteof);
+static void _cfsml_write_SystemString(Common::WriteStream *fh, SystemString* save_struc);
+static int _cfsml_read_SystemString(Common::SeekableReadStream *fh, SystemString* save_struc, const char *lastval, int *line, int *hiteof);
 
 #line 382 "engines/sci/engine/savegame.cfsml"
 static void _cfsml_write_byte(Common::WriteStream *fh, byte* save_struc);
@@ -524,6 +524,10 @@
 static int _cfsml_read_node_t(Common::SeekableReadStream *fh, node_t* save_struc, const char *lastval, int *line, int *hiteof);
 
 #line 382 "engines/sci/engine/savegame.cfsml"
+static void _cfsml_write_SystemStrings(Common::WriteStream *fh, SystemStrings* save_struc);
+static int _cfsml_read_SystemStrings(Common::SeekableReadStream *fh, SystemStrings* save_struc, const char *lastval, int *line, int *hiteof);
+
+#line 382 "engines/sci/engine/savegame.cfsml"
 static void _cfsml_write_list_table_t(Common::WriteStream *fh, list_table_t* save_struc);
 static int _cfsml_read_list_table_t(Common::SeekableReadStream *fh, list_table_t* save_struc, const char *lastval, int *line, int *hiteof);
 
@@ -568,10 +572,6 @@
 static int _cfsml_read_list_t(Common::SeekableReadStream *fh, list_t* save_struc, const char *lastval, int *line, int *hiteof);
 
 #line 382 "engines/sci/engine/savegame.cfsml"
-static void _cfsml_write_sys_string_t(Common::WriteStream *fh, sys_string_t* save_struc);
-static int _cfsml_read_sys_string_t(Common::SeekableReadStream *fh, sys_string_t* save_struc, const char *lastval, int *line, int *hiteof);
-
-#line 382 "engines/sci/engine/savegame.cfsml"
 static void _cfsml_write_script_t(Common::WriteStream *fh, script_t* save_struc);
 static int _cfsml_read_script_t(Common::SeekableReadStream *fh, script_t* save_struc, const char *lastval, int *line, int *hiteof);
 
@@ -2227,34 +2227,32 @@
 
 #line 394 "engines/sci/engine/savegame.cfsml"
 static void
-_cfsml_write_sys_strings_t(Common::WriteStream *fh, sys_strings_t* save_struc)
+_cfsml_write_SystemString(Common::WriteStream *fh, SystemString* save_struc)
 {
 #line 411 "engines/sci/engine/savegame.cfsml"
 	WSprintf(fh, "{\n");
-	WSprintf(fh, "strings = ");
-	int min, max;
-	min = max = SYS_STRINGS_MAX;
-#line 438 "engines/sci/engine/savegame.cfsml"
-	WSprintf(fh, "[%d][\n", max);
-	for (int i = 0; i < min; i++) {
-		_cfsml_write_sys_string_t(fh, &(save_struc->strings[i]));
-		WSprintf(fh, "\n");
-	}
-	WSprintf(fh, "]");
+	WSprintf(fh, "name = ");
+	_cfsml_write_string(fh, (char **) &(save_struc->name));
 	WSprintf(fh, "\n");
+	WSprintf(fh, "max_size = ");
+	_cfsml_write_int(fh, (int*) &(save_struc->max_size));
+	WSprintf(fh, "\n");
+	WSprintf(fh, "value = ");
+	_cfsml_write_string(fh, (char **) &(save_struc->value));
+	WSprintf(fh, "\n");
 	WSprintf(fh, "}");
 }
 
 #line 485 "engines/sci/engine/savegame.cfsml"
 static int
-_cfsml_read_sys_strings_t(Common::SeekableReadStream *fh, sys_strings_t* save_struc, const char *lastval, int *line, int *hiteof)
+_cfsml_read_SystemString(Common::SeekableReadStream *fh, SystemString* save_struc, const char *lastval, int *line, int *hiteof)
 {
 #line 540 "engines/sci/engine/savegame.cfsml"
 	char *token;
 	int assignment, closed;
 
 	if (strcmp(lastval, "{")) {
-		_cfsml_error("Reading record sys_strings_t; expected opening braces in line %d, got \"%s\"\n", *line, lastval);
+		_cfsml_error("Reading record SystemString; expected opening braces in line %d, got \"%s\"\n", *line, lastval);
 		return CFSML_FAILURE;
 	};
 	closed = 0;
@@ -2281,39 +2279,30 @@
 				_cfsml_error("Expected token at line %d\n", *line);
 				return CFSML_FAILURE;
 			}
-				if (!strcmp(token, "strings")) {
-#line 603 "engines/sci/engine/savegame.cfsml"
-			if ((value[0] != '[') || (value[strlen(value) - 1] != '[')) {
-				_cfsml_error("Opening brackets expected at line %d\n", *line);
-				return CFSML_FAILURE;
-			}
-			int max,done,i;
-			// Prepare to restore static array
-			max = SYS_STRINGS_MAX;
-#line 638 "engines/sci/engine/savegame.cfsml"
-			done = i = 0;
-			do {
-			if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
-#line 646 "engines/sci/engine/savegame.cfsml"
-				_cfsml_error("Token expected at line %d\n", *line);
-				return 1;
-			}
-			if (strcmp(value, "]")) {
-				if (i == max) {
-					_cfsml_error("More elements than space available (%d) in '%s' at line %d\n", max, token, *line);
+				if (!strcmp(token, "name")) {
+#line 689 "engines/sci/engine/savegame.cfsml"
+				if (_cfsml_read_string(fh, (char **) &(save_struc->name), value, line, hiteof)) {
+					_cfsml_error("Token expected by _cfsml_read_string() for name at line %d\n", *line);
 					return CFSML_FAILURE;
 				}
-				if (_cfsml_read_sys_string_t(fh, &(save_struc->strings[i++]), value, line, hiteof)) {
-					_cfsml_error("Token expected by _cfsml_read_sys_string_t() for strings[i++] at line %d\n", *line);
+			} else
+				if (!strcmp(token, "max_size")) {
+#line 689 "engines/sci/engine/savegame.cfsml"
+				if (_cfsml_read_int(fh, (int*) &(save_struc->max_size), value, line, hiteof)) {
+					_cfsml_error("Token expected by _cfsml_read_int() for max_size at line %d\n", *line);
 					return CFSML_FAILURE;
 				}
 			} else
-				done = 1;
-			} while (!done);
+				if (!strcmp(token, "value")) {
+#line 689 "engines/sci/engine/savegame.cfsml"
+				if (_cfsml_read_string(fh, (char **) &(save_struc->value), value, line, hiteof)) {
+					_cfsml_error("Token expected by _cfsml_read_string() for value at line %d\n", *line);
+					return CFSML_FAILURE;
+				}
 			} else
 #line 698 "engines/sci/engine/savegame.cfsml"
 			{
-				_cfsml_error("sys_strings_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
+				_cfsml_error("SystemString: Assignment to invalid identifier '%s' in line %d\n", token, *line);
 				return CFSML_FAILURE;
 			}
 		}
@@ -2444,6 +2433,102 @@
 
 #line 394 "engines/sci/engine/savegame.cfsml"
 static void
+_cfsml_write_SystemStrings(Common::WriteStream *fh, SystemStrings* save_struc)
+{
+#line 411 "engines/sci/engine/savegame.cfsml"
+	WSprintf(fh, "{\n");
+	WSprintf(fh, "strings = ");
+	int min, max;
+	min = max = SYS_STRINGS_MAX;
+#line 438 "engines/sci/engine/savegame.cfsml"
+	WSprintf(fh, "[%d][\n", max);
+	for (int i = 0; i < min; i++) {
+		_cfsml_write_SystemString(fh, &(save_struc->strings[i]));
+		WSprintf(fh, "\n");
+	}
+	WSprintf(fh, "]");
+	WSprintf(fh, "\n");
+	WSprintf(fh, "}");
+}
+
+#line 485 "engines/sci/engine/savegame.cfsml"
+static int
+_cfsml_read_SystemStrings(Common::SeekableReadStream *fh, SystemStrings* save_struc, const char *lastval, int *line, int *hiteof)
+{
+#line 540 "engines/sci/engine/savegame.cfsml"
+	char *token;
+	int assignment, closed;
+
+	if (strcmp(lastval, "{")) {
+		_cfsml_error("Reading record SystemStrings; expected opening braces in line %d, got \"%s\"\n", *line, lastval);
+		return CFSML_FAILURE;
+	};
+	closed = 0;
+	do {
+		const char *value;
+		token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
+
+		if (!token) {
+			_cfsml_error("Expected token at line %d\n", *line);
+			return CFSML_FAILURE;
+		}
+		if (!assignment) {
+			if (!strcmp(token, "}"))
+				closed = 1;
+			else {
+				_cfsml_error("Expected assignment or closing braces in line %d\n", *line);
+				return CFSML_FAILURE;
+			}
+		} else {
+			value = "";
+			while (!value || !strcmp(value, ""))
+				value = _cfsml_get_value(fh, line, hiteof);
+			if (!value) {
+				_cfsml_error("Expected token at line %d\n", *line);
+				return CFSML_FAILURE;
+			}
+				if (!strcmp(token, "strings")) {
+#line 603 "engines/sci/engine/savegame.cfsml"
+			if ((value[0] != '[') || (value[strlen(value) - 1] != '[')) {
+				_cfsml_error("Opening brackets expected at line %d\n", *line);
+				return CFSML_FAILURE;
+			}
+			int max,done,i;
+			// Prepare to restore static array
+			max = SYS_STRINGS_MAX;
+#line 638 "engines/sci/engine/savegame.cfsml"
+			done = i = 0;
+			do {
+			if (!(value = _cfsml_get_identifier(fh, line, hiteof, NULL))) {
+#line 646 "engines/sci/engine/savegame.cfsml"
+				_cfsml_error("Token expected at line %d\n", *line);
+				return 1;
+			}
+			if (strcmp(value, "]")) {
+				if (i == max) {
+					_cfsml_error("More elements than space available (%d) in '%s' at line %d\n", max, token, *line);
+					return CFSML_FAILURE;
+				}
+				if (_cfsml_read_SystemString(fh, &(save_struc->strings[i++]), value, line, hiteof)) {
+					_cfsml_error("Token expected by _cfsml_read_SystemString() for strings[i++] at line %d\n", *line);
+					return CFSML_FAILURE;
+				}
+			} else
+				done = 1;
+			} while (!done);
+			} else
+#line 698 "engines/sci/engine/savegame.cfsml"
+			{
+				_cfsml_error("SystemStrings: Assignment to invalid identifier '%s' in line %d\n", token, *line);
+				return CFSML_FAILURE;
+			}
+		}
+	} while (!closed); // Until closing braces are hit
+	return CFSML_SUCCESS;
+}
+
+#line 394 "engines/sci/engine/savegame.cfsml"
+static void
 _cfsml_write_list_table_t(Common::WriteStream *fh, list_table_t* save_struc)
 {
 #line 411 "engines/sci/engine/savegame.cfsml"
@@ -3682,91 +3767,6 @@
 
 #line 394 "engines/sci/engine/savegame.cfsml"
 static void
-_cfsml_write_sys_string_t(Common::WriteStream *fh, sys_string_t* save_struc)
-{
-#line 411 "engines/sci/engine/savegame.cfsml"
-	WSprintf(fh, "{\n");
-	WSprintf(fh, "name = ");
-	_cfsml_write_string(fh, (char **) &(save_struc->name));
-	WSprintf(fh, "\n");
-	WSprintf(fh, "max_size = ");
-	_cfsml_write_int(fh, (int*) &(save_struc->max_size));
-	WSprintf(fh, "\n");
-	WSprintf(fh, "value = ");
-	_cfsml_write_string(fh, (char **) &(save_struc->value));
-	WSprintf(fh, "\n");
-	WSprintf(fh, "}");
-}
-
-#line 485 "engines/sci/engine/savegame.cfsml"
-static int
-_cfsml_read_sys_string_t(Common::SeekableReadStream *fh, sys_string_t* save_struc, const char *lastval, int *line, int *hiteof)
-{
-#line 540 "engines/sci/engine/savegame.cfsml"
-	char *token;
-	int assignment, closed;
-
-	if (strcmp(lastval, "{")) {
-		_cfsml_error("Reading record sys_string_t; expected opening braces in line %d, got \"%s\"\n", *line, lastval);
-		return CFSML_FAILURE;
-	};
-	closed = 0;
-	do {
-		const char *value;
-		token = _cfsml_get_identifier(fh, line, hiteof, &assignment);
-
-		if (!token) {
-			_cfsml_error("Expected token at line %d\n", *line);
-			return CFSML_FAILURE;
-		}
-		if (!assignment) {
-			if (!strcmp(token, "}"))
-				closed = 1;
-			else {
-				_cfsml_error("Expected assignment or closing braces in line %d\n", *line);
-				return CFSML_FAILURE;
-			}
-		} else {
-			value = "";
-			while (!value || !strcmp(value, ""))
-				value = _cfsml_get_value(fh, line, hiteof);
-			if (!value) {
-				_cfsml_error("Expected token at line %d\n", *line);
-				return CFSML_FAILURE;
-			}
-				if (!strcmp(token, "name")) {
-#line 689 "engines/sci/engine/savegame.cfsml"
-				if (_cfsml_read_string(fh, (char **) &(save_struc->name), value, line, hiteof)) {
-					_cfsml_error("Token expected by _cfsml_read_string() for name at line %d\n", *line);
-					return CFSML_FAILURE;
-				}
-			} else
-				if (!strcmp(token, "max_size")) {
-#line 689 "engines/sci/engine/savegame.cfsml"
-				if (_cfsml_read_int(fh, (int*) &(save_struc->max_size), value, line, hiteof)) {
-					_cfsml_error("Token expected by _cfsml_read_int() for max_size at line %d\n", *line);
-					return CFSML_FAILURE;
-				}
-			} else
-				if (!strcmp(token, "value")) {
-#line 689 "engines/sci/engine/savegame.cfsml"
-				if (_cfsml_read_string(fh, (char **) &(save_struc->value), value, line, hiteof)) {
-					_cfsml_error("Token expected by _cfsml_read_string() for value at line %d\n", *line);
-					return CFSML_FAILURE;
-				}
-			} else
-#line 698 "engines/sci/engine/savegame.cfsml"
-			{
-				_cfsml_error("sys_string_t: Assignment to invalid identifier '%s' in line %d\n", token, *line);
-				return CFSML_FAILURE;
-			}
-		}
-	} while (!closed); // Until closing braces are hit
-	return CFSML_SUCCESS;
-}
-
-#line 394 "engines/sci/engine/savegame.cfsml"
-static void
 _cfsml_write_script_t(Common::WriteStream *fh, script_t* save_struc)
 {
 #line 411 "engines/sci/engine/savegame.cfsml"
@@ -4334,7 +4334,7 @@
 	case MEM_OBJ_SYS_STRINGS:
 #line 818 "engines/sci/engine/savegame.cfsml"
 // Auto-generated CFSML data writer code
-	_cfsml_write_sys_strings_t(fh, &foo->data.sys_strings);
+	_cfsml_write_SystemStrings(fh, &foo->data.sys_strings);
 	WSprintf(fh, "\n");
 // End of auto-generated CFSML data writer code
 #line 628 "engines/sci/engine/savegame.cfsml"
@@ -4512,7 +4512,7 @@
 			_cfsml_error = CFSML_FAILURE;
 		} else {
 #line 788 "engines/sci/engine/savegame.cfsml"
-			_cfsml_error = _cfsml_read_sys_strings_t(fh, &foo->data.sys_strings, _cfsml_inp, &(*line), &_cfsml_eof);
+			_cfsml_error = _cfsml_read_SystemStrings(fh, &foo->data.sys_strings, _cfsml_inp, &(*line), &_cfsml_eof);
 		}
 #line 793 "engines/sci/engine/savegame.cfsml"
 		*hiteof = _cfsml_error;
@@ -5232,8 +5232,25 @@
 	retval->save_dir_edit_offset = 0;
 	retval->sys_strings_segment = find_unique_seg_by_type(retval->seg_manager, MEM_OBJ_SYS_STRINGS);
 	retval->sys_strings = &(((mem_obj_t *)(GET_SEGMENT(*retval->seg_manager, retval->sys_strings_segment, MEM_OBJ_SYS_STRINGS)))->data.sys_strings);
-	sys_strings_restore(retval->sys_strings, s->sys_strings);
 
+	// Restore system strings
+	SystemString *str;
+
+	// First, pad memory
+	for (int i = 0; i < SYS_STRINGS_MAX; i++) {
+		str = &retval->sys_strings->strings[i];
+		char *data = str->value;
+		if (data) {
+			str->value = (char *)sci_malloc(str->max_size + 1);
+			strcpy(str->value, data);
+			free(data);
+		}
+	}
+
+	str = &retval->sys_strings->strings[SYS_STRING_SAVEDIR];
+	strncpy(str->value, s->sys_strings->strings[SYS_STRING_SAVEDIR].value, str->max_size);
+	str->value[str->max_size] = 0; // Make sure to terminate
+	
 	// Time state:
 	retval->last_wait_time = g_system->getMillis();
 	retval->game_start_time = g_system->getMillis() - retval->game_time * 1000;
@@ -5319,7 +5336,7 @@
 		}
 	}
 // End of auto-generated CFSML data reader code
-#line 1163 "engines/sci/engine/savegame.cfsml"
+#line 1180 "engines/sci/engine/savegame.cfsml"
 
 	if (read_eof)
 		return false;

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-02-26 21:17:53 UTC (rev 38915)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-02-26 23:03:35 UTC (rev 38916)
@@ -414,7 +414,7 @@
 	break;
 
 	case MEM_OBJ_SYS_STRINGS: {
-		sys_strings_t *strings = &(mobj->data.sys_strings);
+		SystemStrings *strings = &(mobj->data.sys_strings);
 		int i;
 
 		sciprintf("system string table\n");

Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-02-26 21:17:53 UTC (rev 38915)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp	2009-02-26 23:03:35 UTC (rev 38916)
@@ -232,6 +232,7 @@
 int SegManager::deallocate(int seg, bool recursive) {
 	mem_obj_t *mobj;
 	VERIFY(check(seg), "invalid seg id");
+	int i;
 
 	mobj = heap[seg];
 	id_seg_map->removeKey(mobj->segmgr_id);
@@ -255,8 +256,19 @@
 			free(mobj->data.dynmem.buf);
 		mobj->data.dynmem.buf = NULL;
 		break;
-	case MEM_OBJ_SYS_STRINGS:
-		sys_string_free_all(&(mobj->data.sys_strings));
+	case MEM_OBJ_SYS_STRINGS: 
+		for (i = 0; i < SYS_STRINGS_MAX; i++) {
+			SystemString *str = &mobj->data.sys_strings.strings[i];
+			if (str->name) {
+				free(str->name);
+				str->name = NULL;
+
+				free(str->value);
+				str->value = NULL;
+
+				str->max_size = 0;
+			}
+		}
 		break;
 	case MEM_OBJ_STACK:
 		free(mobj->data.stack.entries);
@@ -1193,11 +1205,11 @@
 	return retval;
 }
 
-sys_strings_t *SegManager::allocateSysStrings(seg_id_t *segid) {
+SystemStrings *SegManager::allocateSysStrings(seg_id_t *segid) {
 	mem_obj_t *memobj = allocNonscriptSegment(MEM_OBJ_SYS_STRINGS, segid);
-	sys_strings_t *retval = &(memobj->data.sys_strings);
+	SystemStrings *retval = &(memobj->data.sys_strings);
 
-	memset(retval, 0, sizeof(sys_string_t)*SYS_STRINGS_MAX);
+	memset(retval, 0, sizeof(SystemString)*SYS_STRINGS_MAX);
 
 	return retval;
 }

Modified: scummvm/trunk/engines/sci/engine/seg_manager.h
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.h	2009-02-26 21:17:53 UTC (rev 38915)
+++ scummvm/trunk/engines/sci/engine/seg_manager.h	2009-02-26 23:03:35 UTC (rev 38916)
@@ -300,8 +300,7 @@
 	// Allocates a system string table
 	// Returns   : (dstack_t *): The physical stack
 	//             (seg_id_t) segid: Segment ID of the stack
-	// See also sys_string_acquire();
-	sys_strings_t *allocateSysStrings(seg_id_t *segid);
+	SystemStrings *allocateSysStrings(seg_id_t *segid);
 
 
 	// 6, 7. Lists and Nodes

Deleted: scummvm/trunk/engines/sci/engine/sys_strings.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/sys_strings.cpp	2009-02-26 21:17:53 UTC (rev 38915)
+++ scummvm/trunk/engines/sci/engine/sys_strings.cpp	2009-02-26 23:03:35 UTC (rev 38916)
@@ -1,111 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "sci/tools.h"
-#include "sci/engine/sys_strings.h"
-#include "sci/sci_memory.h"
-
-namespace Sci {
-
-void sys_string_acquire(sys_strings_t *strings, int index, const char *name, int max_len) {
-	sys_string_t *str = strings->strings + index;
-
-	if (index < 0 || index >= SYS_STRINGS_MAX) {
-		fprintf(stderr, "[SYSSTR] Error: Attempt to acquire string #%d\n",
-		        index);
-		BREAKPOINT();
-	}
-
-	if (str->name
-	        && (strcmp(name, str->name)
-	            || (str->max_size != max_len))) {
-		fprintf(stderr, "[SYSSTR] Error: Attempt to re-acquire existing string #%d;"
-		        "was '%s', tried to claim as '%s'\n",
-		        index, str->name, name);
-		BREAKPOINT();
-	}
-
-	str->name = strdup(name);
-	str->max_size = max_len;
-	str->value = (char*)sci_malloc(max_len + 1);
-	str->value[0] = 0; // Set to empty string
-}
-
-int sys_string_set(sys_strings_t *strings, int index, const char *value) {
-	sys_string_t *str = strings->strings + index;
-
-	if (index < 0 || index >= SYS_STRINGS_MAX || !str->name) {
-		fprintf(stderr, "[SYSSTR] Error: Attempt to write to invalid/unused string #%d\n",
-		        index);
-		BREAKPOINT();
-		return 1;
-	}
-
-	strncpy(str->value, value, str->max_size);
-	str->value[str->max_size] = 0; // Make sure to terminate
-
-	return 0;
-}
-
-void sys_string_free(sys_strings_t *strings, int index) {
-	sys_string_t *str = strings->strings + index;
-
-	free(str->name);
-	str->name = NULL;
-
-	free(str->value);
-	str->value = NULL;
-
-	str->max_size = 0;
-}
-
-void sys_string_free_all(sys_strings_t *strings) {
-	int i;
-
-	for (i = 0;i < SYS_STRINGS_MAX;i++) {
-		if (strings->strings[i].name)
-			sys_string_free(strings, i);
-	}
-
-}
-
-void sys_strings_restore(sys_strings_t *new_strings, sys_strings_t *old_strings) {
-	int i;
-
-	// First, pad memory
-	for (i = 0; i < SYS_STRINGS_MAX; i++) {
-		sys_string_t *s = new_strings->strings + i;
-		char *data = s->value;
-		if (data) {
-			s->value = (char *)sci_malloc(s->max_size + 1);
-			strcpy(s->value, data);
-			free(data);
-		}
-	}
-
-	sys_string_set(new_strings, SYS_STRING_SAVEDIR, old_strings->strings[SYS_STRING_SAVEDIR].value);
-}
-
-} // End of namespace Sci

Deleted: scummvm/trunk/engines/sci/engine/sys_strings.h
===================================================================
--- scummvm/trunk/engines/sci/engine/sys_strings.h	2009-02-26 21:17:53 UTC (rev 38915)
+++ scummvm/trunk/engines/sci/engine/sys_strings.h	2009-02-26 23:03:35 UTC (rev 38916)
@@ -1,80 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef SCI_ENGINE_SYS_STRINGS_H
-#define SCI_ENGINE_SYS_STRINGS_H
-
-namespace Sci {
-
-enum {
-	SYS_STRINGS_MAX = 4,
-
-	SYS_STRING_SAVEDIR = 0,
-	SYS_STRING_PARSER_BASE = 1,
-
-	MAX_PARSER_BASE = 64
-};
-
-struct sys_string_t {
-	char *name;
-	int max_size;
-	char *value;
-};
-
-struct sys_strings_t {
-	sys_string_t strings[SYS_STRINGS_MAX];
-};
-
-void sys_string_acquire(sys_strings_t *strings, int index, const char *name, int max_len);
-/* Reserves a new system string
-** Parameters: (sys_strings_t *) strings: The string table to reserve in
-**             (int) index: Index number to reserve
-**             (const char *) name: Name the entry should be tagged with
-**             (int) max_len: Maximum string length in bytes
-*/
-
-int sys_string_set(sys_strings_t *strings, int index, const char *value);
-/* Sets the value of a system string
-** Parameters: (sys_strings_t *) strings: The string table to use
-**             (int) index: Index of the string to write to
-**             (const char *) value: The value to copy
-** Returns   : 0 on success, 1 on error
-** Length clipping is performed.
-*/
-
-void sys_strings_restore(sys_strings_t *new_strings, sys_strings_t *old_strings);
-/* Cleanup system strings after a gamestate restore
-** Parameters: (sys_strings_t *) The freshly loaded system strings to clean up
-**             (sys_strings_t *) The old system strings to clean up
-*/
-
-void sys_string_free_all(sys_strings_t *strings);
-/* Deallocates all allocated system strings
-** Parameters: (sys_strings_t *) strings: The string table to deallocate
-*/
-
-} // End of namespace Sci
-
-#endif // SCI_ENGINE_SYS_STRINGS_H

Modified: scummvm/trunk/engines/sci/engine/vm.h
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.h	2009-02-26 21:17:53 UTC (rev 38915)
+++ scummvm/trunk/engines/sci/engine/vm.h	2009-02-26 23:03:35 UTC (rev 38916)
@@ -32,12 +32,29 @@
 #include "sci/include/vm_types.h"	// for reg_t
 #include "sci/include/heapmgr.h"
 
-#include "sci/engine/sys_strings.h"
-
 namespace Sci {
 
 struct IntMapper;
 
+enum {
+	SYS_STRINGS_MAX = 4,
+
+	SYS_STRING_SAVEDIR = 0,
+	SYS_STRING_PARSER_BASE = 1,
+
+	MAX_PARSER_BASE = 64
+};
+
+struct SystemString {
+	char *name;
+	int max_size;
+	char *value;
+};
+
+struct SystemStrings {
+	SystemString strings[SYS_STRINGS_MAX];
+};
+
 #define VM_STACK_SIZE 0x1000
 /* Number of bytes to be allocated for the stack */
 
@@ -277,7 +294,7 @@
 		clone_table_t clones;
 		local_variables_t locals;
 		dstack_t stack;
-		sys_strings_t sys_strings;
+		SystemStrings sys_strings;
 		list_table_t lists;
 		node_table_t nodes;
 		hunk_table_t hunks;

Modified: scummvm/trunk/engines/sci/include/engine.h
===================================================================
--- scummvm/trunk/engines/sci/include/engine.h	2009-02-26 21:17:53 UTC (rev 38915)
+++ scummvm/trunk/engines/sci/include/engine.h	2009-02-26 23:03:35 UTC (rev 38916)
@@ -226,7 +226,7 @@
 
 	/* System strings */
 	seg_id_t sys_strings_segment;
-	sys_strings_t *sys_strings;
+	SystemStrings *sys_strings;
 
 	/* Parser data: */
 	word_t **parser_words;

Modified: scummvm/trunk/engines/sci/module.mk
===================================================================
--- scummvm/trunk/engines/sci/module.mk	2009-02-26 21:17:53 UTC (rev 38915)
+++ scummvm/trunk/engines/sci/module.mk	2009-02-26 23:03:35 UTC (rev 38916)
@@ -31,7 +31,6 @@
 	engine/scriptconsole.o \
 	engine/scriptdebug.o \
 	engine/seg_manager.o \
-	engine/sys_strings.o \
 	engine/vm.o \
 	gfx/font.o \
 	gfx/gfx_driver.o \


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