diff options
author | Alexander Tkachev | 2016-07-27 18:06:39 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-07-27 18:06:39 +0600 |
commit | a4f02c73837ef46f620872d8297cdc6cbf5119dc (patch) | |
tree | f26e31de78388c2a43d956c2b7a113c706a38c11 | |
parent | 35883517994efbcef9b5eb429b3888235745dea8 (diff) | |
download | scummvm-rg350-a4f02c73837ef46f620872d8297cdc6cbf5119dc.tar.gz scummvm-rg350-a4f02c73837ef46f620872d8297cdc6cbf5119dc.tar.bz2 scummvm-rg350-a4f02c73837ef46f620872d8297cdc6cbf5119dc.zip |
WAGE: Move some code in saveGame()
Now flags, version, description and thumbnail are added in the end of
the file, thus making saves compatible with original ones.
-rw-r--r-- | engines/wage/saveload.cpp | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/engines/wage/saveload.cpp b/engines/wage/saveload.cpp index a204757543..bc9a443aa0 100644 --- a/engines/wage/saveload.cpp +++ b/engines/wage/saveload.cpp @@ -66,12 +66,16 @@ #define SAVEGAME_CURRENT_VERSION 1 // -// Version 0 (ScummVM): first ScummVM version +// Original saves format is supported. +// ScummVM adds flags, description and thumbnail +// in the end of the file (shouldn't make saves incompatible). +// +// Version 0 (original/ScummVM): first ScummVM version // namespace Wage { -static const uint32 AGIflag = MKTAG('W', 'A', 'G', 'E'); +static const uint32 WAGEflag = MKTAG('W', 'A', 'G', 'E'); //TODO: make sure these are calculated right: (we add flag, description, etc) #define VARS_INDEX 0x005E @@ -109,23 +113,6 @@ int WageEngine::saveGame(const Common::String &fileName, const Common::String &d debug(9, "Successfully opened %s for writing", fileName.c_str()); } - out->writeUint32BE(AGIflag); - - // Write description of saved game, limited to WAGE_SAVEDGAME_DESCRIPTION_LEN characters + terminating NUL - const int WAGE_SAVEDGAME_DESCRIPTION_LEN = 127; - char description[WAGE_SAVEDGAME_DESCRIPTION_LEN + 1]; - - memset(description, 0, sizeof(description)); - strncpy(description, descriptionString.c_str(), WAGE_SAVEDGAME_DESCRIPTION_LEN); - assert(WAGE_SAVEDGAME_DESCRIPTION_LEN + 1 == 128); // safety - out->write(description, 128); - - out->writeByte(SAVEGAME_CURRENT_VERSION); - debug(9, "Writing save game version (%d)", SAVEGAME_CURRENT_VERSION); - - // Thumbnail - Graphics::saveThumbnail(*out); - // Counters out->writeSint16LE(_world->_scenes.size()); //numScenes out->writeSint16LE(_world->_chrs.size()); //numChars @@ -280,6 +267,30 @@ int WageEngine::saveGame(const Common::String &fileName, const Common::String &d out->writeSint16LE(obj->_numberOfUses); } + // the following is appended by ScummVM + out->writeUint32BE(WAGEflag); + + // Write description of saved game, limited to WAGE_SAVEDGAME_DESCRIPTION_LEN characters + terminating NUL + const int WAGE_SAVEDGAME_DESCRIPTION_LEN = 127; + char description[WAGE_SAVEDGAME_DESCRIPTION_LEN + 1]; + + memset(description, 0, sizeof(description)); + strncpy(description, descriptionString.c_str(), WAGE_SAVEDGAME_DESCRIPTION_LEN); + assert(WAGE_SAVEDGAME_DESCRIPTION_LEN + 1 == 128); // safety + out->write(description, 128); + + out->writeByte(SAVEGAME_CURRENT_VERSION); + debug(9, "Writing save game version (%d)", SAVEGAME_CURRENT_VERSION); + + // Thumbnail + Graphics::saveThumbnail(*out); + + // this one to make checking easier: + // it couldn't be added to the beginning + // and we won't be able to find it in the middle, + // so these would be the last 4 bytes of the file + out->writeUint32BE(WAGEflag); + out->finalize(); if (out->err()) { warning("Can't write file '%s'. (Disk full?)", fileName.c_str()); |