aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/he/script_v80he.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2013-07-15 22:52:03 -0400
committerMatthew Hoops2013-10-05 15:45:36 -0400
commit3bfd42220533a3f2cd19e8f8a726ecc48ee97625 (patch)
treeabf18fc030d69183fe98a854b77bcac386bcac01 /engines/scumm/he/script_v80he.cpp
parent3f65a02ced741979ede333539bac67ead9dbc368 (diff)
downloadscummvm-rg350-3bfd42220533a3f2cd19e8f8a726ecc48ee97625.tar.gz
scummvm-rg350-3bfd42220533a3f2cd19e8f8a726ecc48ee97625.tar.bz2
scummvm-rg350-3bfd42220533a3f2cd19e8f8a726ecc48ee97625.zip
SCUMM: Make all HE saves prepend the target name
This makes HE follow the ScummVM convention of using the target name everywhere. It also fixes having more than one team in both soccer and football. Loading old saves will still work and they will be tried if the newer save names are not found.
Diffstat (limited to 'engines/scumm/he/script_v80he.cpp')
-rw-r--r--engines/scumm/he/script_v80he.cpp49
1 files changed, 23 insertions, 26 deletions
diff --git a/engines/scumm/he/script_v80he.cpp b/engines/scumm/he/script_v80he.cpp
index ae43d714ad..7a8f230fc0 100644
--- a/engines/scumm/he/script_v80he.cpp
+++ b/engines/scumm/he/script_v80he.cpp
@@ -89,14 +89,8 @@ void ScummEngine_v80he::o80_getFileSize() {
byte buffer[256];
copyScriptString(buffer, sizeof(buffer));
- const char *filename = (char *)buffer + convertFilePath(buffer, sizeof(buffer));
- Common::SeekableReadStream *f = 0;
- if (!_saveFileMan->listSavefiles(filename).empty()) {
- f = _saveFileMan->openForLoading(filename);
- } else {
- f = SearchMan.createReadStreamForMember(filename);
- }
+ Common::SeekableReadStream *f = openFileForReading(buffer);
if (!f) {
push(-1);
@@ -143,14 +137,12 @@ void ScummEngine_v80he::o80_readConfigFile() {
byte option[128], section[128], filename[256];
byte *data;
Common::String entry;
- int len, r;
+ int len;
copyScriptString(option, sizeof(option));
copyScriptString(section, sizeof(section));
copyScriptString(filename, sizeof(filename));
- r = convertFilePath(filename, sizeof(filename));
-
if (_game.id == GID_TREASUREHUNT) {
// WORKAROUND: Remove invalid characters
if (!strcmp((char *)section, "Blue'sTreasureHunt-Disc1"))
@@ -159,13 +151,13 @@ void ScummEngine_v80he::o80_readConfigFile() {
memcpy(section, "BluesTreasureHunt-Disc2\0", 24);
}
- if (!strcmp((const char *)filename, "map (i)")) {
+ if (!strcmp((const char *)filename, ":map (i)")) {
// Mac resource fork config file
// (as used by only mustard mac for map data?)
Common::MacResManager resFork;
- if (!resFork.open((const char *)filename) || !resFork.hasResFork())
- error("Could not open '%s'", filename);
+ if (!resFork.open("map (i)") || !resFork.hasResFork())
+ error("Could not open 'map (i)'");
Common::String prefResName = Common::String::format("Pref:%s.%s", (const char *)section, (const char *)option);
Common::SeekableReadStream *res = resFork.getResource(prefResName);
@@ -180,13 +172,14 @@ void ScummEngine_v80he::o80_readConfigFile() {
}
} else {
// Normal Windows INI files
- Common::INIFile confFile;
- if (!strcmp((char *)filename + r, "map.ini"))
- confFile.loadFromFile((const char *)filename + r);
- else
- confFile.loadFromSaveFile((const char *)filename + r);
+ Common::SeekableReadStream *stream = openFileForReading(filename);
- confFile.getKey((const char *)option, (const char *)section, entry);
+ if (stream) {
+ Common::INIFile iniFile;
+ iniFile.loadFromStream(*stream);
+ iniFile.getKey((const char *)option, (const char *)section, entry);
+ delete stream;
+ }
}
byte subOp = fetchScriptByte();
@@ -216,7 +209,7 @@ void ScummEngine_v80he::o80_readConfigFile() {
void ScummEngine_v80he::o80_writeConfigFile() {
byte filename[256], section[256], option[256], string[1024];
- int r, value;
+ int value;
byte subOp = fetchScriptByte();
@@ -240,8 +233,6 @@ void ScummEngine_v80he::o80_writeConfigFile() {
error("o80_writeConfigFile: default type %d", subOp);
}
- r = convertFilePath(filename, sizeof(filename));
-
if (_game.id == GID_TREASUREHUNT) {
// WORKAROUND: Remove invalid characters
if (!strcmp((char *)section, "Blue'sTreasureHunt-Disc1"))
@@ -250,10 +241,16 @@ void ScummEngine_v80he::o80_writeConfigFile() {
memcpy(section, "BluesTreasureHunt-Disc2\0", 24);
}
- Common::INIFile ConfFile;
- ConfFile.loadFromSaveFile((const char *)filename + r);
- ConfFile.setKey((char *)option, (char *)section, (char *)string);
- ConfFile.saveToSaveFile((const char *)filename + r);
+ Common::INIFile iniFile;
+ Common::SeekableReadStream *iniStream = openSaveFileForReading(filename);
+
+ if (iniStream) {
+ iniFile.loadFromStream(*iniStream);
+ delete iniStream;
+ }
+
+ iniFile.setKey((char *)option, (char *)section, (char *)string);
+ iniFile.saveToSaveFile(convertSavePath(filename));
debug(1,"o80_writeConfigFile: Filename %s Section %s Option %s String %s", filename, section, option, string);
}