From ac7eb25ef08de284a1ea06ae4179a40153f4415e Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 20 Sep 2016 13:14:10 +0200 Subject: FULLPIPE: Move more stuff to stateloader.cpp --- engines/fullpipe/gameloader.cpp | 54 --------------------------------------- engines/fullpipe/stateloader.cpp | 55 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 54 deletions(-) (limited to 'engines/fullpipe') 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; -- cgit v1.2.3