aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Tkachev2016-06-18 18:49:46 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commitaee713141b3a401f08e63cd9ccf5ce3dfe1cb06e (patch)
tree20fb764d74405090278d2b498076c05fe22e266c
parent81106b04440d76238da0fa0166eb3032b6db591e (diff)
downloadscummvm-rg350-aee713141b3a401f08e63cd9ccf5ce3dfe1cb06e.tar.gz
scummvm-rg350-aee713141b3a401f08e63cd9ccf5ce3dfe1cb06e.tar.bz2
scummvm-rg350-aee713141b3a401f08e63cd9ccf5ce3dfe1cb06e.zip
CLOUD: Make OutSaveFile start saves sync
It had to become a proxy class in order to do that. finalize() starts the saves sync.
-rw-r--r--backends/platform/ds/arm9/source/gbampsave.cpp2
-rw-r--r--backends/platform/n64/framfs_save_manager.h2
-rw-r--r--backends/platform/n64/pakfs_save_manager.h2
-rw-r--r--backends/platform/ps2/savefilemgr.cpp2
-rw-r--r--backends/saves/default/default-saves.cpp2
-rw-r--r--backends/saves/savefile.cpp24
-rw-r--r--common/savefile.h15
-rw-r--r--engines/kyra/saveload_eob.cpp4
-rw-r--r--engines/kyra/saveload_hof.cpp2
-rw-r--r--engines/kyra/saveload_lok.cpp2
-rw-r--r--engines/kyra/saveload_lol.cpp2
-rw-r--r--engines/kyra/saveload_mr.cpp2
-rw-r--r--engines/tsage/stP1kAlMbin0 -> 24604948 bytes
13 files changed, 49 insertions, 12 deletions
diff --git a/backends/platform/ds/arm9/source/gbampsave.cpp b/backends/platform/ds/arm9/source/gbampsave.cpp
index ef6091e2a2..236ec55801 100644
--- a/backends/platform/ds/arm9/source/gbampsave.cpp
+++ b/backends/platform/ds/arm9/source/gbampsave.cpp
@@ -56,7 +56,7 @@ Common::OutSaveFile *GBAMPSaveFileManager::openForSaving(const Common::String &f
Common::WriteStream *stream = DS::DSFileStream::makeFromPath(fileSpec, true);
// Use a write buffer
stream = Common::wrapBufferedWriteStream(stream, SAVE_BUFFER_SIZE);
- return stream;
+ return new OutSaveFile(stream);
}
Common::InSaveFile *GBAMPSaveFileManager::openForLoading(const Common::String &filename) {
diff --git a/backends/platform/n64/framfs_save_manager.h b/backends/platform/n64/framfs_save_manager.h
index 9bd4ee579e..aa26942bdc 100644
--- a/backends/platform/n64/framfs_save_manager.h
+++ b/backends/platform/n64/framfs_save_manager.h
@@ -106,7 +106,7 @@ public:
virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true) {
OutFRAMSave *s = new OutFRAMSave(filename.c_str());
if (!s->err()) {
- return compress ? Common::wrapCompressedWriteStream(s) : s;
+ return new OutSaveFile(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 0c08f0c506..31aa01444c 100644
--- a/backends/platform/n64/pakfs_save_manager.h
+++ b/backends/platform/n64/pakfs_save_manager.h
@@ -108,7 +108,7 @@ public:
virtual Common::OutSaveFile *openForSaving(const Common::String &filename, bool compress = true) {
OutPAKSave *s = new OutPAKSave(filename.c_str());
if (!s->err()) {
- return compress ? Common::wrapCompressedWriteStream(s) : s;
+ return new OutSaveFile(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 4fd2b1c72b..569d0e13e3 100644
--- a/backends/platform/ps2/savefilemgr.cpp
+++ b/backends/platform/ps2/savefilemgr.cpp
@@ -192,7 +192,7 @@ Common::OutSaveFile *Ps2SaveFileManager::openForSaving(const Common::String &fil
}
_screen->wantAnim(false);
- return compress ? Common::wrapCompressedWriteStream(sf) : sf;
+ return new OutSaveFile(compress ? Common::wrapCompressedWriteStream(sf) : sf);
}
bool Ps2SaveFileManager::removeSavefile(const Common::String &filename) {
diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp
index 3fcb3cb3b3..e20ce31d18 100644
--- a/backends/saves/default/default-saves.cpp
+++ b/backends/saves/default/default-saves.cpp
@@ -156,7 +156,7 @@ Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String
// Open the file for saving.
Common::WriteStream *const sf = fileNode.createWriteStream();
- Common::OutSaveFile *const result = compress ? Common::wrapCompressedWriteStream(sf) : sf;
+ Common::OutSaveFile *const result = new Common::OutSaveFile(compress ? Common::wrapCompressedWriteStream(sf) : sf);
// Add file to cache now that it exists.
_saveFileCache[filename] = Common::FSNode(fileNode.getPath());
diff --git a/backends/saves/savefile.cpp b/backends/saves/savefile.cpp
index b04c53d832..1f007ca713 100644
--- a/backends/saves/savefile.cpp
+++ b/backends/saves/savefile.cpp
@@ -23,9 +23,33 @@
#include "common/util.h"
#include "common/savefile.h"
#include "common/str.h"
+#ifdef USE_CLOUD
+#include "backends/cloud/cloudmanager.h"
+#endif
namespace Common {
+OutSaveFile::OutSaveFile(WriteStream *w): _wrapped(w) {}
+
+OutSaveFile::~OutSaveFile() {}
+
+bool OutSaveFile::err() const { return _wrapped->err(); }
+
+void OutSaveFile::clearErr() { _wrapped->clearErr(); }
+
+void OutSaveFile::finalize() {
+ _wrapped->finalize();
+#ifdef USE_CLOUD
+ CloudMan.syncSaves();
+#endif
+}
+
+bool OutSaveFile::flush() { return _wrapped->flush(); }
+
+uint32 OutSaveFile::write(const void *dataPtr, uint32 dataSize) {
+ return _wrapped->write(dataPtr, dataSize);
+}
+
bool SaveFileManager::copySavefile(const String &oldFilename, const String &newFilename) {
InSaveFile *inFile = 0;
OutSaveFile *outFile = 0;
diff --git a/common/savefile.h b/common/savefile.h
index 38b21c9ddd..d84c9e275a 100644
--- a/common/savefile.h
+++ b/common/savefile.h
@@ -28,6 +28,7 @@
#include "common/stream.h"
#include "common/str-array.h"
#include "common/error.h"
+#include "common/ptr.h"
namespace Common {
@@ -44,8 +45,20 @@ typedef SeekableReadStream InSaveFile;
* That typically means "save games", but also includes things like the
* IQ points in Indy3.
*/
-typedef WriteStream OutSaveFile;
+class OutSaveFile: public WriteStream {
+protected:
+ ScopedPtr<WriteStream> _wrapped;
+public:
+ OutSaveFile(WriteStream *w);
+ virtual ~OutSaveFile();
+
+ virtual bool err() const;
+ virtual void clearErr();
+ virtual void finalize();
+ virtual bool flush();
+ virtual uint32 write(const void *dataPtr, uint32 dataSize);
+};
/**
* The SaveFileManager is serving as a factory for InSaveFile
diff --git a/engines/kyra/saveload_eob.cpp b/engines/kyra/saveload_eob.cpp
index cca8f3a0a4..6fdff0fc80 100644
--- a/engines/kyra/saveload_eob.cpp
+++ b/engines/kyra/saveload_eob.cpp
@@ -328,7 +328,7 @@ Common::Error EoBCoreEngine::saveGameStateIntern(int slot, const char *saveName,
fileName = getSavegameFilename(slot);
}
- Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumbnail);
+ Common::OutSaveFile *out = new Common::OutSaveFile(openSaveForWriting(fileName, saveName, thumbnail));
if (!out)
return _saveFileMan->getError();
@@ -995,7 +995,7 @@ bool EoBCoreEngine::saveAsOriginalSaveFile(int slot) {
return false;
Common::FSNode nf = nd.getChild(_flags.gameID == GI_EOB1 ? "EOBDATA.SAV" : Common::String::format("EOBDATA%d.SAV", slot));
- Common::WriteStream *out = nf.createWriteStream();
+ Common::OutSaveFile *out = new Common::OutSaveFile(nf.createWriteStream());
if (_flags.gameID == GI_EOB2) {
static const char tempStr[20] = "SCUMMVM EXPORT ";
diff --git a/engines/kyra/saveload_hof.cpp b/engines/kyra/saveload_hof.cpp
index e8e76143bd..60ceebd28d 100644
--- a/engines/kyra/saveload_hof.cpp
+++ b/engines/kyra/saveload_hof.cpp
@@ -34,7 +34,7 @@ namespace Kyra {
Common::Error KyraEngine_HoF::saveGameStateIntern(int slot, const char *saveName, const Graphics::Surface *thumb) {
const char *fileName = getSavegameFilename(slot);
- Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumb);
+ Common::OutSaveFile *out = new Common::OutSaveFile(openSaveForWriting(fileName, saveName, thumb));
if (!out)
return _saveFileMan->getError();
diff --git a/engines/kyra/saveload_lok.cpp b/engines/kyra/saveload_lok.cpp
index 1d729d0103..cb2124a537 100644
--- a/engines/kyra/saveload_lok.cpp
+++ b/engines/kyra/saveload_lok.cpp
@@ -241,7 +241,7 @@ Common::Error KyraEngine_LoK::saveGameStateIntern(int slot, const char *saveName
if (shouldQuit())
return Common::kNoError;
- Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumb);
+ Common::OutSaveFile *out = new Common::OutSaveFile(openSaveForWriting(fileName, saveName, thumb));
if (!out)
return _saveFileMan->getError();
diff --git a/engines/kyra/saveload_lol.cpp b/engines/kyra/saveload_lol.cpp
index e02b8fb22c..a5ecd3b248 100644
--- a/engines/kyra/saveload_lol.cpp
+++ b/engines/kyra/saveload_lol.cpp
@@ -335,7 +335,7 @@ Common::Error LoLEngine::loadGameState(int slot) {
Common::Error LoLEngine::saveGameStateIntern(int slot, const char *saveName, const Graphics::Surface *thumbnail) {
const char *fileName = getSavegameFilename(slot);
- Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumbnail);
+ Common::OutSaveFile *out = new Common::OutSaveFile(openSaveForWriting(fileName, saveName, thumbnail));
if (!out)
return _saveFileMan->getError();
diff --git a/engines/kyra/saveload_mr.cpp b/engines/kyra/saveload_mr.cpp
index a938003a07..3c225e6d50 100644
--- a/engines/kyra/saveload_mr.cpp
+++ b/engines/kyra/saveload_mr.cpp
@@ -33,7 +33,7 @@ namespace Kyra {
Common::Error KyraEngine_MR::saveGameStateIntern(int slot, const char *saveName, const Graphics::Surface *thumb) {
const char *fileName = getSavegameFilename(slot);
- Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumb);
+ Common::OutSaveFile *out = new Common::OutSaveFile(openSaveForWriting(fileName, saveName, thumb));
if (!out)
return _saveFileMan->getError();
diff --git a/engines/tsage/stP1kAlM b/engines/tsage/stP1kAlM
new file mode 100644
index 0000000000..dfbb3b9786
--- /dev/null
+++ b/engines/tsage/stP1kAlM
Binary files differ