diff options
author | Einar Johan Trøan Sømåen | 2012-07-25 03:33:24 +0200 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2012-07-25 03:34:38 +0200 |
commit | 28759d7aa3b3b6ef9e01a806fe277ca83d7ee30d (patch) | |
tree | ab51d6afa992a780cadfe55c5f6d04ac9ceaa739 /engines | |
parent | b05b6210b73d47461de9392c4936a5cb4dde57e1 (diff) | |
download | scummvm-rg350-28759d7aa3b3b6ef9e01a806fe277ca83d7ee30d.tar.gz scummvm-rg350-28759d7aa3b3b6ef9e01a806fe277ca83d7ee30d.tar.bz2 scummvm-rg350-28759d7aa3b3b6ef9e01a806fe277ca83d7ee30d.zip |
WINTERMUTE: Move SaveGame-file-saving handling over to BasePersistenceManager
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wintermute/base/base_file_manager.cpp | 21 | ||||
-rw-r--r-- | engines/wintermute/base/base_file_manager.h | 3 | ||||
-rw-r--r-- | engines/wintermute/base/base_persistence_manager.cpp | 16 | ||||
-rw-r--r-- | engines/wintermute/base/base_persistence_manager.h | 2 |
4 files changed, 15 insertions, 27 deletions
diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 2661081528..156aff61fe 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -112,27 +112,6 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz return buffer;
}
-Common::SeekableReadStream *BaseFileManager::loadSaveGame(const Common::String &filename) {
- Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan();
- Common::InSaveFile *file = saveMan->openForLoading(filename);
- return file;
-}
-
-//////////////////////////////////////////////////////////////////////////
-bool BaseFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) {
- // TODO
- warning("Implement SaveFile");
-
- Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan();
- Common::OutSaveFile *file = saveMan->openForSaving(filename);
- file->write(prefixBuffer, prefixSize);
- file->write(buffer, bufferSize);
- file->finalize();
- delete file;
-
- return STATUS_OK;
-}
-
//////////////////////////////////////////////////////////////////////////
bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) {
if (!path.exists())
diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 89d1e5b46b..e3c20378bb 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -43,13 +43,10 @@ public: bool closeFile(Common::SeekableReadStream *File);
bool hasFile(const Common::String &filename);
Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true);
- Common::SeekableReadStream *loadSaveGame(const Common::String &filename);
byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true);
BaseFileManager(BaseGame *inGame = NULL);
virtual ~BaseFileManager();
- // Used only by BasePersistenceManager
- bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0);
// Used only for detection
bool registerPackages(const Common::FSList &fslist);
private:
diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index bcdb93a93e..5f8a2114c1 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -359,8 +359,20 @@ bool BasePersistenceManager::initLoad(const char *filename) { //////////////////////////////////////////////////////////////////////////
-bool BasePersistenceManager::saveFile(const char *filename) {
- return _gameRef->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), _gameRef->_compressedSavegames, _richBuffer, _richBufferSize);
+bool BasePersistenceManager::saveFile(const Common::String &filename) {
+ byte *prefixBuffer = _richBuffer;
+ uint32 prefixSize = _richBufferSize;
+ byte *buffer = ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData();
+ uint32 bufferSize = ((Common::MemoryWriteStreamDynamic *)_saveStream)->size();
+
+ Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan();
+ Common::OutSaveFile *file = saveMan->openForSaving(filename);
+ file->write(prefixBuffer, prefixSize);
+ file->write(buffer, bufferSize);
+ bool retVal = !file->err();
+ file->finalize();
+ delete file;
+ return retVal;
}
diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index a59f797668..78d3230c47 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -47,7 +47,7 @@ public: char *_savedDescription;
Common::String _savePrefix;
Common::String _savedName;
- bool saveFile(const char *filename);
+ bool saveFile(const Common::String &filename);
uint32 getDWORD();
void putDWORD(uint32 val);
char *getString();
|