aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2012-07-01 11:08:08 -0700
committerFilippos Karapetis2012-07-01 11:08:08 -0700
commit2c161796c5688a1f76dcf66f1e66eb9bcd1e0f23 (patch)
tree3bac116e107f2948388444cf26f8cf8a88bc3521
parentd335b78003f3d28d1c9c9aeddf6a46ad1c5f4888 (diff)
parent659d0cfcc39721001f607e4ca51b8eb477708404 (diff)
downloadscummvm-rg350-2c161796c5688a1f76dcf66f1e66eb9bcd1e0f23.tar.gz
scummvm-rg350-2c161796c5688a1f76dcf66f1e66eb9bcd1e0f23.tar.bz2
scummvm-rg350-2c161796c5688a1f76dcf66f1e66eb9bcd1e0f23.zip
Merge pull request #239 from bluegr/skipsavecompression
COMMON: Allow the savefile manager to create uncompressed saves
-rw-r--r--backends/platform/dc/vmsave.cpp5
-rw-r--r--backends/platform/ds/arm9/source/gbampsave.cpp2
-rw-r--r--backends/platform/ds/arm9/source/gbampsave.h2
-rw-r--r--backends/platform/n64/framfs_save_manager.h4
-rw-r--r--backends/platform/n64/pakfs_save_manager.h4
-rw-r--r--backends/platform/ps2/savefilemgr.cpp4
-rw-r--r--backends/platform/ps2/savefilemgr.h2
-rw-r--r--backends/saves/default/default-saves.cpp4
-rw-r--r--backends/saves/default/default-saves.h2
-rw-r--r--common/savefile.h18
-rw-r--r--engines/sci/engine/file.cpp17
11 files changed, 45 insertions, 19 deletions
diff --git a/backends/platform/dc/vmsave.cpp b/backends/platform/dc/vmsave.cpp
index e06dd7fa43..ba3b787942 100644
--- a/backends/platform/dc/vmsave.cpp
+++ b/backends/platform/dc/vmsave.cpp
@@ -316,8 +316,9 @@ public:
class VMSaveManager : public Common::SaveFileManager {
public:
- virtual Common::OutSaveFile *openForSaving(const Common::String &filename) {
- return Common::wrapCompressedWriteStream(new OutVMSave(filename.c_str()));
+ virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true) {
+ OutVMSave *s = new OutVMSave(filename.c_str());
+ return compress ? Common::wrapCompressedWriteStream(s) : s;
}
virtual Common::InSaveFile *openForLoading(const Common::String &filename) {
diff --git a/backends/platform/ds/arm9/source/gbampsave.cpp b/backends/platform/ds/arm9/source/gbampsave.cpp
index 03729c5e6e..3192e2d277 100644
--- a/backends/platform/ds/arm9/source/gbampsave.cpp
+++ b/backends/platform/ds/arm9/source/gbampsave.cpp
@@ -45,7 +45,7 @@ static Common::String getSavePath() {
// GBAMP Save File Manager
//////////////////////////
-Common::OutSaveFile *GBAMPSaveFileManager::openForSaving(const Common::String &filename) {
+Common::OutSaveFile *GBAMPSaveFileManager::openForSaving(const Common::String &filename, bool compress) {
Common::String fileSpec = getSavePath();
if (fileSpec.lastChar() != '/')
fileSpec += '/';
diff --git a/backends/platform/ds/arm9/source/gbampsave.h b/backends/platform/ds/arm9/source/gbampsave.h
index 492054dc52..0d9d9aca8c 100644
--- a/backends/platform/ds/arm9/source/gbampsave.h
+++ b/backends/platform/ds/arm9/source/gbampsave.h
@@ -27,7 +27,7 @@
class GBAMPSaveFileManager : public Common::SaveFileManager {
public:
- virtual Common::OutSaveFile *openForSaving(const Common::String &filename);
+ virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true);
virtual Common::InSaveFile *openForLoading(const Common::String &filename);
virtual bool removeSavefile(const Common::String &filename);
diff --git a/backends/platform/n64/framfs_save_manager.h b/backends/platform/n64/framfs_save_manager.h
index da553e423a..0a88c8666b 100644
--- a/backends/platform/n64/framfs_save_manager.h
+++ b/backends/platform/n64/framfs_save_manager.h
@@ -100,10 +100,10 @@ public:
class FRAMSaveManager : public Common::SaveFileManager {
public:
- virtual Common::OutSaveFile *openForSaving(const Common::String &filename) {
+ virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true) {
OutFRAMSave *s = new OutFRAMSave(filename.c_str());
if (!s->err()) {
- return Common::wrapCompressedWriteStream(s);
+ return compress ? Common::wrapCompressedWriteStream(s) : s;
} else {
delete s;
return 0;
diff --git a/backends/platform/n64/pakfs_save_manager.h b/backends/platform/n64/pakfs_save_manager.h
index e0fcbc1e2d..6e67fb0f5f 100644
--- a/backends/platform/n64/pakfs_save_manager.h
+++ b/backends/platform/n64/pakfs_save_manager.h
@@ -101,10 +101,10 @@ public:
class PAKSaveManager : public Common::SaveFileManager {
public:
- virtual Common::OutSaveFile *openForSaving(const Common::String &filename) {
+ virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true) {
OutPAKSave *s = new OutPAKSave(filename.c_str());
if (!s->err()) {
- return Common::wrapCompressedWriteStream(s);
+ return compress ? Common::wrapCompressedWriteStream(s) : s;
} else {
delete s;
return NULL;
diff --git a/backends/platform/ps2/savefilemgr.cpp b/backends/platform/ps2/savefilemgr.cpp
index 421edc3e2e..46af42e193 100644
--- a/backends/platform/ps2/savefilemgr.cpp
+++ b/backends/platform/ps2/savefilemgr.cpp
@@ -145,7 +145,7 @@ Common::InSaveFile *Ps2SaveFileManager::openForLoading(const Common::String &fil
return Common::wrapCompressedReadStream(sf);
}
-Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const Common::String &filename) {
+Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const Common::String &filename, bool compress) {
Common::FSNode savePath(ConfMan.get("savepath")); // TODO: is this fast?
Common::WriteStream *sf;
@@ -193,7 +193,7 @@ Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const Common::String &fil
}
_screen->wantAnim(false);
- return Common::wrapCompressedWriteStream(sf);
+ return compress ? Common::wrapCompressedWriteStream(sf) : sf;
}
bool Ps2SaveFileManager::removeSavefile(const Common::String &filename) {
diff --git a/backends/platform/ps2/savefilemgr.h b/backends/platform/ps2/savefilemgr.h
index a25fb063ae..163706eace 100644
--- a/backends/platform/ps2/savefilemgr.h
+++ b/backends/platform/ps2/savefilemgr.h
@@ -35,7 +35,7 @@ public:
virtual ~Ps2SaveFileManager();
virtual Common::InSaveFile *openForLoading(const Common::String &filename);
- virtual Common::OutSaveFile *openForSaving(const Common::String &filename);
+ virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true);
virtual Common::StringArray listSavefiles(const Common::String &pattern);
virtual bool removeSavefile(const Common::String &filename);
diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp
index 237c50a1ba..64e7e778b6 100644
--- a/backends/saves/default/default-saves.cpp
+++ b/backends/saves/default/default-saves.cpp
@@ -97,7 +97,7 @@ Common::InSaveFile *DefaultSaveFileManager::openForLoading(const Common::String
return Common::wrapCompressedReadStream(sf);
}
-Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String &filename) {
+Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String &filename, bool compress) {
// Ensure that the savepath is valid. If not, generate an appropriate error.
Common::String savePathName = getSavePath();
checkPath(Common::FSNode(savePathName));
@@ -112,7 +112,7 @@ Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String
// Open the file for saving
Common::WriteStream *sf = file.createWriteStream();
- return Common::wrapCompressedWriteStream(sf);
+ return compress ? Common::wrapCompressedWriteStream(sf) : sf;
}
bool DefaultSaveFileManager::removeSavefile(const Common::String &filename) {
diff --git a/backends/saves/default/default-saves.h b/backends/saves/default/default-saves.h
index 1ea87efc67..c7fca279bc 100644
--- a/backends/saves/default/default-saves.h
+++ b/backends/saves/default/default-saves.h
@@ -38,7 +38,7 @@ public:
virtual Common::StringArray listSavefiles(const Common::String &pattern);
virtual Common::InSaveFile *openForLoading(const Common::String &filename);
- virtual Common::OutSaveFile *openForSaving(const Common::String &filename);
+ virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true);
virtual bool removeSavefile(const Common::String &filename);
protected:
diff --git a/common/savefile.h b/common/savefile.h
index 03a7b52add..da787289ee 100644
--- a/common/savefile.h
+++ b/common/savefile.h
@@ -104,11 +104,23 @@ public:
virtual String popErrorDesc();
/**
- * Open the savefile with the specified name in the given directory for saving.
- * @param name the name of the savefile
+ * Open the savefile with the specified name in the given directory for
+ * saving.
+ *
+ * Saved games are compressed by default, and engines are expected to
+ * always write compressed saves.
+ *
+ * A notable exception is if uncompressed files are needed for
+ * compatibility with games not supported by ScummVM, such as character
+ * exports from the Quest for Glory series. QfG5 is a 3D game and won't be
+ * supported by ScummVM.
+ *
+ * @param name the name of the savefile
+ * @param compress toggles whether to compress the resulting save file
+ * (default) or not.
* @return pointer to an OutSaveFile, or NULL if an error occurred.
*/
- virtual OutSaveFile *openForSaving(const String &name) = 0;
+ virtual OutSaveFile *openForSaving(const String &name, bool compress = true) = 0;
/**
* Open the file with the specified name in the given directory for loading.
diff --git a/engines/sci/engine/file.cpp b/engines/sci/engine/file.cpp
index 0d575f97dd..a0f7ebf4a2 100644
--- a/engines/sci/engine/file.cpp
+++ b/engines/sci/engine/file.cpp
@@ -57,11 +57,24 @@ namespace Sci {
reg_t file_open(EngineState *s, const Common::String &filename, int mode, bool unwrapFilename) {
Common::String englishName = g_sci->getSciLanguageString(filename, K_LANG_ENGLISH);
+ englishName.toLowercase();
+
Common::String wrappedName = unwrapFilename ? g_sci->wrapFilename(englishName) : englishName;
Common::SeekableReadStream *inFile = 0;
Common::WriteStream *outFile = 0;
Common::SaveFileManager *saveFileMan = g_sci->getSaveFileManager();
+ bool isCompressed = true;
+ const SciGameId gameId = g_sci->getGameId();
+ if ((gameId == GID_QFG1 || gameId == GID_QFG1VGA || gameId == GID_QFG2 || gameId == GID_QFG3)
+ && englishName.hasSuffix(".sav")) {
+ // QFG Characters are saved via the CharSave object.
+ // We leave them uncompressed so that they can be imported in later QFG
+ // games.
+ // Rooms/Scripts: QFG1: 601, QFG2: 840, QFG3/4: 52
+ isCompressed = false;
+ }
+
if (mode == _K_FILE_MODE_OPEN_OR_FAIL) {
// Try to open file, abort if not possible
inFile = saveFileMan->openForLoading(wrappedName);
@@ -74,12 +87,12 @@ reg_t file_open(EngineState *s, const Common::String &filename, int mode, bool u
debugC(kDebugLevelFile, " -> file_open(_K_FILE_MODE_OPEN_OR_FAIL): failed to open file '%s'", englishName.c_str());
} else if (mode == _K_FILE_MODE_CREATE) {
// Create the file, destroying any content it might have had
- outFile = saveFileMan->openForSaving(wrappedName);
+ outFile = saveFileMan->openForSaving(wrappedName, isCompressed);
if (!outFile)
debugC(kDebugLevelFile, " -> file_open(_K_FILE_MODE_CREATE): failed to create file '%s'", englishName.c_str());
} else if (mode == _K_FILE_MODE_OPEN_OR_CREATE) {
// Try to open file, create it if it doesn't exist
- outFile = saveFileMan->openForSaving(wrappedName);
+ outFile = saveFileMan->openForSaving(wrappedName, isCompressed);
if (!outFile)
debugC(kDebugLevelFile, " -> file_open(_K_FILE_MODE_CREATE): failed to create file '%s'", englishName.c_str());