diff options
author | Willem Jan Palenstijn | 2009-02-27 19:50:22 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2009-02-27 19:50:22 +0000 |
commit | fb8fafaf560b5546858312cd4f552d04b149ab5a (patch) | |
tree | efc1797247c304cd5d40a0d5f9ca917b967aa14a /engines/sci | |
parent | fb552121d234ab200caf8857f007df57085ca7ec (diff) | |
download | scummvm-rg350-fb8fafaf560b5546858312cd4f552d04b149ab5a.tar.gz scummvm-rg350-fb8fafaf560b5546858312cd4f552d04b149ab5a.tar.bz2 scummvm-rg350-fb8fafaf560b5546858312cd4f552d04b149ab5a.zip |
Fix reading corrupted saves.
svn-id: r38934
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/engine/savegame.cfsml | 17 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cpp | 21 |
2 files changed, 30 insertions, 8 deletions
diff --git a/engines/sci/engine/savegame.cfsml b/engines/sci/engine/savegame.cfsml index e59467ed60..58f8f88a36 100644 --- a/engines/sci/engine/savegame.cfsml +++ b/engines/sci/engine/savegame.cfsml @@ -1045,9 +1045,16 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { retval->gfx_state = s->gfx_state; SavegameMetadata *meta = new SavegameMetadata; - memset(meta, 0, sizeof(SavegameMetadata)); - %CFSMLREAD-ATOMIC SavegameMetadata meta FROM fh ERRVAR read_eof; + if (read_eof) { + // TODO: It would be nice to automate this: + meta->savegame_name = NULL; + meta->game_version = NULL; + return false; + } + +%CFSMLREAD-ATOMIC SavegameMetadata meta FROM fh ERRVAR read_eof; + if ((meta->savegame_version < FREESCI_MINIMUM_SAVEGAME_VERSION) || (meta->savegame_version > FREESCI_CURRENT_SAVEGAME_VERSION)) { if (meta->savegame_version < FREESCI_MINIMUM_SAVEGAME_VERSION) @@ -1178,8 +1185,12 @@ bool get_savegame_metadata(Common::SeekableReadStream* stream, SavegameMetadata* %CFSMLREAD-ATOMIC SavegameMetadata meta FROM stream ERRVAR read_eof; - if (read_eof) + if (read_eof) { + // TODO: It would be nice to automate this: + meta->savegame_name = NULL; + meta->game_version = NULL; return false; + } if ((meta->savegame_version < FREESCI_MINIMUM_SAVEGAME_VERSION) || (meta->savegame_version > FREESCI_CURRENT_SAVEGAME_VERSION)) { diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index da8389167f..bea7f688cb 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -5109,7 +5109,13 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { retval->gfx_state = s->gfx_state; SavegameMetadata *meta = new SavegameMetadata; - memset(meta, 0, sizeof(SavegameMetadata)); + + if (read_eof) { + // TODO: It would be nice to automate this: + meta->savegame_name = NULL; + meta->game_version = NULL; + return false; + } // Auto-generated CFSML data reader code #line 762 "engines/sci/engine/savegame.cfsml" @@ -5143,7 +5149,8 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { } } // End of auto-generated CFSML data reader code -#line 1051 "engines/sci/engine/savegame.cfsml" +#line 1057 "engines/sci/engine/savegame.cfsml" + if ((meta->savegame_version < FREESCI_MINIMUM_SAVEGAME_VERSION) || (meta->savegame_version > FREESCI_CURRENT_SAVEGAME_VERSION)) { if (meta->savegame_version < FREESCI_MINIMUM_SAVEGAME_VERSION) @@ -5198,7 +5205,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { } } // End of auto-generated CFSML data reader code -#line 1074 "engines/sci/engine/savegame.cfsml" +#line 1081 "engines/sci/engine/savegame.cfsml" sfx_exit(&s->sound); _gamestate_unfrob(retval); @@ -5336,10 +5343,14 @@ bool get_savegame_metadata(Common::SeekableReadStream* stream, SavegameMetadata* } } // End of auto-generated CFSML data reader code -#line 1180 "engines/sci/engine/savegame.cfsml" +#line 1187 "engines/sci/engine/savegame.cfsml" - if (read_eof) + if (read_eof) { + // TODO: It would be nice to automate this: + meta->savegame_name = NULL; + meta->game_version = NULL; return false; + } if ((meta->savegame_version < FREESCI_MINIMUM_SAVEGAME_VERSION) || (meta->savegame_version > FREESCI_CURRENT_SAVEGAME_VERSION)) { |