diff options
author | Eugene Sandulenko | 2016-09-20 13:14:10 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-09-20 19:34:48 +0200 |
commit | ac7eb25ef08de284a1ea06ae4179a40153f4415e (patch) | |
tree | d93b7cdcc475b2c79107b18dd3cdedaac1e2d2c4 /engines/fullpipe | |
parent | ca1eb70fd8760411c0be2eb48449765c15768cb6 (diff) | |
download | scummvm-rg350-ac7eb25ef08de284a1ea06ae4179a40153f4415e.tar.gz scummvm-rg350-ac7eb25ef08de284a1ea06ae4179a40153f4415e.tar.bz2 scummvm-rg350-ac7eb25ef08de284a1ea06ae4179a40153f4415e.zip |
FULLPIPE: Move more stuff to stateloader.cpp
Diffstat (limited to 'engines/fullpipe')
-rw-r--r-- | engines/fullpipe/gameloader.cpp | 54 | ||||
-rw-r--r-- | engines/fullpipe/stateloader.cpp | 55 |
2 files changed, 55 insertions, 54 deletions
diff --git a/engines/fullpipe/gameloader.cpp b/engines/fullpipe/gameloader.cpp index d7e40f9806..57bde97d9d 100644 --- a/engines/fullpipe/gameloader.cpp +++ b/engines/fullpipe/gameloader.cpp @@ -21,7 +21,6 @@ */ #include "fullpipe/fullpipe.h" -#include "graphics/thumbnail.h" #include "fullpipe/gameloader.h" #include "fullpipe/scene.h" @@ -696,59 +695,6 @@ const char *getSavegameFile(int saveGameIdx) { return buffer; } -void parseSavegameHeader(Fullpipe::FullpipeSavegameHeader &header, SaveStateDescriptor &desc) { - int day = (header.date >> 24) & 0xFF; - int month = (header.date >> 16) & 0xFF; - int year = header.date & 0xFFFF; - desc.setSaveDate(year, month, day); - int hour = (header.time >> 8) & 0xFF; - int minutes = header.time & 0xFF; - desc.setSaveTime(hour, minutes); - desc.setPlayTime(header.playtime * 1000); -} - -bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header) { - char saveIdentBuffer[6]; - header.thumbnail = NULL; - - uint oldPos = in->pos(); - - in->seek(4, SEEK_END); - uint headerOffset = in->readUint32LE(); - - in->seek(headerOffset, SEEK_SET); - - // Validate the header Id - in->read(saveIdentBuffer, 6); - if (strcmp(saveIdentBuffer, "SVMCR")) { - // This is wrong header, perhaps it is original savegame. Thus fill out dummy values - header.date = (16 >> 24) | (9 >> 20) | 2016; - header.time = (9 >> 8) | 56; - header.playtime = 1000; - return false; - } - - header.version = in->readByte(); - if (header.version != FULLPIPE_SAVEGAME_VERSION) - return false; - - // Read in the string - header.saveName.clear(); - char ch; - while ((ch = (char)in->readByte()) != '\0') - header.saveName += ch; - - // Get the thumbnail - header.thumbnail = Graphics::loadThumbnail(*in); - - in->seek(oldPos, SEEK_SET); // Rewind the file - - if (!header.thumbnail) - return false; - - return true; -} - void GameLoader::restoreDefPicAniInfos() { for (uint i = 0; i < _sc2array.size(); i++) { if (_sc2array[i]._picAniInfos) { diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp index d5d374f454..9cca85c52d 100644 --- a/engines/fullpipe/stateloader.cpp +++ b/engines/fullpipe/stateloader.cpp @@ -27,6 +27,8 @@ #include "common/list.h" #include "common/memstream.h" +#include "graphics/thumbnail.h" + #include "fullpipe/objects.h" #include "fullpipe/gameloader.h" #include "fullpipe/scene.h" @@ -158,6 +160,59 @@ void GameLoader::readSavegame(const char *fname) { } } +void parseSavegameHeader(Fullpipe::FullpipeSavegameHeader &header, SaveStateDescriptor &desc) { + int day = (header.date >> 24) & 0xFF; + int month = (header.date >> 16) & 0xFF; + int year = header.date & 0xFFFF; + desc.setSaveDate(year, month, day); + int hour = (header.time >> 8) & 0xFF; + int minutes = header.time & 0xFF; + desc.setSaveTime(hour, minutes); + desc.setPlayTime(header.playtime * 1000); +} + +bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header) { + char saveIdentBuffer[6]; + header.thumbnail = NULL; + + uint oldPos = in->pos(); + + in->seek(4, SEEK_END); + uint headerOffset = in->readUint32LE(); + + in->seek(headerOffset, SEEK_SET); + + // Validate the header Id + in->read(saveIdentBuffer, 6); + if (strcmp(saveIdentBuffer, "SVMCR")) { + // This is wrong header, perhaps it is original savegame. Thus fill out dummy values + header.date = (16 >> 24) | (9 >> 20) | 2016; + header.time = (9 >> 8) | 56; + header.playtime = 1000; + return false; + } + + header.version = in->readByte(); + if (header.version != FULLPIPE_SAVEGAME_VERSION) + return false; + + // Read in the string + header.saveName.clear(); + char ch; + while ((ch = (char)in->readByte()) != '\0') + header.saveName += ch; + + // Get the thumbnail + header.thumbnail = Graphics::loadThumbnail(*in); + + in->seek(oldPos, SEEK_SET); // Rewind the file + + if (!header.thumbnail) + return false; + + return true; +} + void GameLoader::addVar(GameVar *var, GameVar *subvar) { if (var && subvar) { int type = var->_varType; |