[Scummvm-cvs-logs] CVS: scummvm/scumm script_v72he.cpp,2.252,2.253 script_v7he.cpp,2.143,2.144

kirben kirben at users.sourceforge.net
Tue Apr 12 23:54:41 CEST 2005


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14770/scumm

Modified Files:
	script_v72he.cpp script_v7he.cpp 
Log Message:

Read/write INI entries from config file in HE games.


Index: script_v72he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v72he.cpp,v
retrieving revision 2.252
retrieving revision 2.253
diff -u -d -r2.252 -r2.253
--- script_v72he.cpp	12 Apr 2005 07:52:13 -0000	2.252
+++ script_v72he.cpp	13 Apr 2005 06:53:38 -0000	2.253
@@ -2069,7 +2069,9 @@
 
 void ScummEngine_v72he::o72_readINI() {
 	byte option[100];
-	int type;
+	ArrayHeader *ah;
+	const char *entry;
+	int len, type;
 
 	// we pretend that we don't have .ini file
 	copyScriptString(option);
@@ -2081,19 +2083,22 @@
 		if (!strcmp((char *)option, "NoPrinting"))
 			push(1);
 		else
-			push(0);
+			push(ConfMan.getInt((char *)option));
 		break;
 	case 77: // HE 100
 	case 7: // string
+		entry = (ConfMan.get((char *)option).c_str());
+
 		writeVar(0, 0);
-		defineArray(0, kStringArray, 0, 0, 0, 0);
-		writeArray(0, 0, 0, 0);
-		push(readVar(0)); // var ID string
+		len = resStrLen((const byte *)entry) + 1;
+		ah = defineArray(0, kStringArray, 0, 0, 0, len);
+		memcpy(ah->data, entry, len);
+
+		push(readVar(0));
 		break;
 	default:
 		error("o72_readINI: default type %d", type);
 	}
-	debug(0, "o72_readINI (%d) %s", type, option);
 }
 
 void ScummEngine_v72he::o72_writeINI() {
@@ -2107,17 +2112,19 @@
 	case 6: // number
 		value = pop();
 		copyScriptString(option);
-		debug(1,"o72_writeINI: %s set to %d", option, value);
+		ConfMan.set((char *)option, value); 
 		break;
 	case 77: // HE 100
 	case 7: // string
 		copyScriptString(string);
 		copyScriptString(option);
-		debug(1,"o72_writeINI: %s set to %s", option, string);
+		ConfMan.set((char *)option, (char *)string); 
 		break;
 	default:
 		error("o72_writeINI: default type %d", type);
 	}
+
+	ConfMan.flushToDisk();
 }
 
 void ScummEngine_v72he::o72_getResourceSize() {

Index: script_v7he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v7he.cpp,v
retrieving revision 2.143
retrieving revision 2.144
diff -u -d -r2.143 -r2.144
--- script_v7he.cpp	12 Apr 2005 13:18:40 -0000	2.143
+++ script_v7he.cpp	13 Apr 2005 06:53:38 -0000	2.144
@@ -844,7 +844,6 @@
 	appendSubstring(dst, src, srcOffs, len);
 
 	push(dst);
-	debug(1,"o70_appendString");
 }
 
 void ScummEngine_v70he::o70_concatString() {
@@ -861,7 +860,6 @@
 	appendSubstring(dst, src2, 0, -1);
 
 	push(dst);
-	debug(1,"o70_concatString");
 }
 
 void ScummEngine_v70he::o70_compareString() {
@@ -890,15 +888,14 @@
 
 	result = (*string1 > *string2) ? -1 : 1;
 	push(result);
-	debug(1,"o70_compareString (%d, %d, %d)", array1, array2, result);
 }
 
 void ScummEngine_v70he::o70_readINI() {
-	int len;
-	int type;
 	byte option[256];
+	ArrayHeader *ah;
+	const char *entry;
+	int len, type;
 
-	// we pretend that we don't have .ini file
 	addMessageToStack(_scriptPointer, option, sizeof(option));
 	len = resStrLen(_scriptPointer);
 	_scriptPointer += len + 1;
@@ -909,13 +906,17 @@
 		if (!strcmp((char *)option, "NoPrinting"))
 			push(1);
 		else
-			push(0);
+			push(ConfMan.getInt((char *)option));
 		break;
 	case 2: // string
+		entry = (ConfMan.get((char *)option).c_str());
+
 		writeVar(0, 0);
-		defineArray(0, kStringArray, 0, 0);
-		writeArray(0, 0, 0, 0);
-		push(readVar(0)); // var ID string
+		len = resStrLen((const byte *)entry) + 1;
+		ah = defineArray(0, kStringArray, 0, len);
+		memcpy(ah->data, entry, len);
+
+		push(readVar(0));
 		break;
 	default:
 		error("o70_readINI: default type %d", type);
@@ -924,7 +925,7 @@
 
 void ScummEngine_v70he::o70_writeINI() {
 	int type, value;
-	byte option[256], option2[256];
+	byte option[256], string[256];
 	int len;
 	
 	type = pop();
@@ -936,13 +937,13 @@
 
 	switch (type) {
 	case 1: // number
-		debug(1, "o70_writeINI: %s set to %d", option, value);
+		ConfMan.set((char *)option, value); 
 		break;
 	case 2: // string
-		addMessageToStack(_scriptPointer, option2, sizeof(option2));
+		addMessageToStack(_scriptPointer, string, sizeof(string));
 		len = resStrLen(_scriptPointer);
 		_scriptPointer += len + 1;
-		debug(1, "o70_writeINI: %s set to %s", option, option2);
+		ConfMan.set((char *)option, (char *)string); 
 		break;
 	default:
 		error("o70_writeINI: default type %d", type);
@@ -971,7 +972,6 @@
 	}
 
 	push(len);
-	debug(1,"o70_getStringLenForWidth (%d)", len);
 }
 
 void ScummEngine_v70he::o70_getCharIndexInString() {
@@ -1013,7 +1013,6 @@
 	}
 
 	push(-1);
-	debug(1,"o70_getCharIndexInString");
 }
 
 void ScummEngine_v70he::o70_setFilePath() {





More information about the Scummvm-git-logs mailing list