diff options
Diffstat (limited to 'scumm')
| -rw-r--r-- | scumm/intern.h | 1 | ||||
| -rw-r--r-- | scumm/script_v72he.cpp | 64 | ||||
| -rw-r--r-- | scumm/script_v80he.cpp | 49 | 
3 files changed, 79 insertions, 35 deletions
diff --git a/scumm/intern.h b/scumm/intern.h index 34288bfcbe..6bcbe42be8 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -823,6 +823,7 @@ protected:  	virtual void decodeParseString(int a, int b);  	void decodeScriptString(byte *dst, bool scriptString = false);  	void copyScriptString(byte *dst, int dstSize); +	void convertFilePath(byte *dst);  	byte *heFindResourceData(uint32 tag, byte *ptr);  	byte *heFindResource(uint32 tag, byte *ptr); diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp index 0c5f7d3ee7..11f2d88851 100644 --- a/scumm/script_v72he.cpp +++ b/scumm/script_v72he.cpp @@ -518,6 +518,42 @@ void ScummEngine_v72he::readArrayFromIndexFile() {  	}  } +void ScummEngine_v72he::convertFilePath(byte *dst) { +	// Switch all \ to / for portablity +	int len = resStrLen(dst) + 1; +	for (int i = 0; i < len; i++) { +		if (dst[i] == '\\') +			dst[i] = '/'; +	} + +	// Strip path +	int r = 0; +	if (dst[0] == '.' && dst[1] == '/') { +		r = 2; +	} else if (dst[0] == 'c' && dst[1] == ':') { +		for (r = len; r != 0; r--) { +			if (dst[r - 1] == '/') +				break; +		} +	} + +	File f; +	char filePath[256], newFilePath[256]; + +	sprintf(filePath, "%s%s", _gameDataPath.c_str(), dst + r); +	if (f.exists(filePath)) { +		sprintf(newFilePath, "%s%s", _gameDataPath.c_str(), dst + r); +	} else { +		sprintf(newFilePath, "%s%s", _saveFileMan->getSavePath(), dst + r); +	} + +	len = resStrLen((const byte *)newFilePath); +	memcpy(dst, newFilePath, len); +	dst[len] = 0; + +	debug(0, "convertFilePath: newFilePath is %s", newFilePath); +}	 +  void ScummEngine_v72he::copyScriptString(byte *dst, int dstSize) {  	byte string[1024];  	byte chr; @@ -1506,7 +1542,7 @@ void ScummEngine_v72he::o72_arrayOps() {  		c = pop();  		id = readVar(array);  		if (id == 0) { -			defineArray(array, kDwordArray, 0, 0, 0, b + c); +			defineArray(array, kDwordArray, 0, 0, 0, b + c - 1);  		}  		while (c--) {  			writeArray(array, 0, b + c, pop()); @@ -1670,7 +1706,7 @@ void ScummEngine_v72he::o72_jumpToScript() {  }  void ScummEngine_v72he::o72_openFile() { -	int mode, slot, len, i; +	int mode, slot, i;  	byte filename[256];  	mode = pop(); @@ -1686,22 +1722,8 @@ void ScummEngine_v72he::o72_openFile() {  		strcpy((char *)filename, buf1);  	} -	int r = 0; -	if (filename[0] == 'c' && filename[1] == ':') { -		// Strip path -		for (r = strlen((char*)filename); r != 0; r--) { -			if (filename[r - 1] == '\\') -				break; -		} -	} else { -		// Switch all \ to / for portablity -		len = resStrLen(filename) + 1; -		for (i = 0; i < len; i++) { -			if (filename[i] == '\\') -				filename[i] = '/'; -		} -	} -	debug(0,"Final filename to %s", filename + r); +	convertFilePath(filename); +	debug(0,"Final filename to %s", filename);  	slot = -1;  	for (i = 0; i < 17; i++) { @@ -1714,12 +1736,10 @@ void ScummEngine_v72he::o72_openFile() {  	if (slot != -1) {  		switch(mode) {  		case 1: -			_hFileTable[slot].open((char*)filename + r, File::kFileReadMode, _saveFileMan->getSavePath()); -			if (_hFileTable[slot].isOpen() == false) -				_hFileTable[slot].open((char*)filename + r, File::kFileReadMode); +			_hFileTable[slot].open((char*)filename, File::kFileReadMode);  			break;  		case 2: -			_hFileTable[slot].open((char*)filename + r, File::kFileWriteMode, _saveFileMan->getSavePath()); +			_hFileTable[slot].open((char*)filename, File::kFileWriteMode);  			break;  		default:  			error("o72_openFile(): wrong open file mode %d", mode); diff --git a/scumm/script_v80he.cpp b/scumm/script_v80he.cpp index 482315f47b..e1365581e0 100644 --- a/scumm/script_v80he.cpp +++ b/scumm/script_v80he.cpp @@ -449,35 +449,47 @@ void ScummEngine_v80he::o80_localizeArrayToRoom() {  }  void ScummEngine_v80he::o80_readConfigFile() { -	byte name[128], section[128], filename[256]; -	int type; +	byte option[128], section[128], filename[256]; +	ArrayHeader *ah; +	const char *entry; +	int len, type;  	// we pretend that we don't have .ini file +	copyScriptString(option, sizeof(option));  	copyScriptString(section, sizeof(section)); -	copyScriptString(name, sizeof(name));  	copyScriptString(filename, sizeof(filename)); +	convertFilePath(filename);  	type = fetchScriptByte(); +	ConfMan.loadConfigFile((const char *)filename); +  	switch (type) {  	case 43: // HE 100  	case 6: // number -		push(0); +		push(ConfMan.getInt((char *)option, (char *)section));  		break;  	case 77: // HE 100  	case 7: // string +		entry = (ConfMan.get((char *)option, (char *)section).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); +		ah = defineArray(0, kStringArray, 0, 0, 0, len); +		memcpy(ah->data, entry, len); + +		push(readVar(0));  		break;  	default:  		error("o80_readConfigFile: default type %d", type);  	} -	debug(0, "o80_readConfigFile: Filename %s Section %s Name %s", filename, section, name); + +	ConfMan.loadDefaultConfigFile(); + +	debug(0, "o80_readConfigFile: Filename %s Section %s Option %s", filename, section, option);  }  void ScummEngine_v80he::o80_writeConfigFile() { -	byte filename[256], section[256], name[256], string[1024]; +	byte filename[256], section[256], option[256], string[1024];  	int type, value;  	// we pretend that we don't have .ini file @@ -487,22 +499,33 @@ void ScummEngine_v80he::o80_writeConfigFile() {  	case 43: // HE 100  	case 6: // number  		value = pop(); +		copyScriptString(option, sizeof(option));  		copyScriptString(section, sizeof(section)); -		copyScriptString(name, sizeof(name));  		copyScriptString(filename, sizeof(filename)); -		debug(1,"o80_writeConfigFile: Filename %s Section %s Name %s Value %d", filename, section, name, value); +		convertFilePath(filename); + +		ConfMan.loadConfigFile((const char *)filename); +		ConfMan.set((char *)option, value, (char *)section);  +		debug(0,"o80_writeConfigFile: Filename %s Section %s Option %s Value %d", filename, section, option, value);  		break;  	case 77: // HE 100  	case 7: // string  		copyScriptString(string, sizeof(string)); +		copyScriptString(option, sizeof(option));  		copyScriptString(section, sizeof(section)); -		copyScriptString(name, sizeof(name));  		copyScriptString(filename, sizeof(filename)); -		debug(1,"o80_writeConfigFile: Filename %s Section %s Name %s String %s", filename, section, name, string); +		convertFilePath(filename); + +		ConfMan.loadConfigFile((const char *)filename); +		ConfMan.set((char *)option, (char *)string, (char *)section);  +		debug(0,"o80_writeConfigFile: Filename %s Section %s Option %s String %s", filename, section, option, string);  		break;  	default:  		error("o80_writeConfigFile: default type %d", type);  	} + +	ConfMan.flushToDisk(); +	ConfMan.loadDefaultConfigFile();  }  void ScummEngine_v80he::o80_cursorCommand() {  | 
