diff options
author | Eugene Sandulenko | 2016-09-20 19:34:22 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-09-20 19:34:48 +0200 |
commit | 4b93ebedf1a9f3258e38b60b2a233cb764eb0b7a (patch) | |
tree | e0a5f415f0b0da04ffbf37e84a0bc78256028ec6 /engines/fullpipe | |
parent | cf4452388cc4104072801b2a0c74bdef03d419d5 (diff) | |
download | scummvm-rg350-4b93ebedf1a9f3258e38b60b2a233cb764eb0b7a.tar.gz scummvm-rg350-4b93ebedf1a9f3258e38b60b2a233cb764eb0b7a.tar.bz2 scummvm-rg350-4b93ebedf1a9f3258e38b60b2a233cb764eb0b7a.zip |
FULLPIPE: Correctly fill out dummy header on reading failure
Diffstat (limited to 'engines/fullpipe')
-rw-r--r-- | engines/fullpipe/stateloader.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp index a12233187a..4df97636d1 100644 --- a/engines/fullpipe/stateloader.cpp +++ b/engines/fullpipe/stateloader.cpp @@ -173,6 +173,13 @@ void parseSavegameHeader(Fullpipe::FullpipeSavegameHeader &header, SaveStateDesc desc.setDescription(header.saveName); } +void fillDummyHeader(Fullpipe::FullpipeSavegameHeader &header) { + // This is wrong header, perhaps it is original savegame. Thus fill out dummy values + header.date = (20 << 24) | (9 << 16) | 2016; + header.time = (9 << 8) | 56; + header.playtime = 1000; +} + bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header) { header.thumbnail = NULL; @@ -188,6 +195,7 @@ bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header) // Sanity check if (headerOffset >= in->pos() || headerOffset == 0) { in->seek(oldPos, SEEK_SET); // Rewind the file + fillDummyHeader(header); return false; } @@ -197,16 +205,17 @@ bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header) // Validate the header Id if (strcmp(header.id, "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; + in->seek(oldPos, SEEK_SET); // Rewind the file + fillDummyHeader(header); return false; } header.version = in->readByte(); - if (header.version != FULLPIPE_SAVEGAME_VERSION) + if (header.version != FULLPIPE_SAVEGAME_VERSION) { + in->seek(oldPos, SEEK_SET); // Rewind the file + fillDummyHeader(header); return false; + } header.date = in->readUint32LE(); header.time = in->readUint16LE(); |