SCI: Use reference instead of pointer for required out-data in metadata save function

This commit is contained in:
Colin Snover 2017-09-23 01:39:16 -05:00
parent b3c27c2159
commit d17ae077dd
4 changed files with 11 additions and 12 deletions

View File

@ -812,7 +812,7 @@ SaveStateList SciMetaEngine::listSaves(const char *target) const {
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
if (in) {
SavegameMetadata meta;
if (!get_savegame_metadata(in, &meta)) {
if (!get_savegame_metadata(in, meta)) {
// invalid
delete in;
continue;
@ -861,7 +861,7 @@ SaveStateDescriptor SciMetaEngine::querySaveMetaInfos(const char *target, int sl
if (in) {
SavegameMetadata meta;
if (!get_savegame_metadata(in, &meta)) {
if (!get_savegame_metadata(in, meta)) {
// invalid
delete in;

View File

@ -307,7 +307,7 @@ bool fillSavegameDesc(const Common::String &filename, SavegameDesc &desc) {
}
SavegameMetadata meta;
if (!get_savegame_metadata(in.get(), &meta) || meta.name.empty()) {
if (!get_savegame_metadata(in.get(), meta) || meta.name.empty()) {
return false;
}

View File

@ -1395,22 +1395,21 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
s->gameIsRestarting = GAMEISRESTARTING_RESTORE;
}
bool get_savegame_metadata(Common::SeekableReadStream *stream, SavegameMetadata *meta) {
bool get_savegame_metadata(Common::SeekableReadStream *stream, SavegameMetadata &meta) {
assert(stream);
assert(meta);
Common::Serializer ser(stream, 0);
sync_SavegameMetadata(ser, *meta);
Common::Serializer ser(stream, nullptr);
sync_SavegameMetadata(ser, meta);
if (stream->eos())
return false;
if ((meta->version < MINIMUM_SAVEGAME_VERSION) ||
(meta->version > CURRENT_SAVEGAME_VERSION)) {
if (meta->version < MINIMUM_SAVEGAME_VERSION)
if ((meta.version < MINIMUM_SAVEGAME_VERSION) ||
(meta.version > CURRENT_SAVEGAME_VERSION)) {
if (meta.version < MINIMUM_SAVEGAME_VERSION)
warning("Old savegame version detected- can't load");
else
warning("Savegame version is %d- maximum supported is %0d", meta->version, CURRENT_SAVEGAME_VERSION);
warning("Savegame version is %d- maximum supported is %0d", meta.version, CURRENT_SAVEGAME_VERSION);
return false;
}

View File

@ -118,7 +118,7 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *save);
/**
* Read the header from a savegame.
*/
bool get_savegame_metadata(Common::SeekableReadStream* stream, SavegameMetadata* meta);
bool get_savegame_metadata(Common::SeekableReadStream *stream, SavegameMetadata &meta);
} // End of namespace Sci