mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
GLK: ADVSYS: Save/load fixes
This commit is contained in:
parent
553bb74f8c
commit
919670a565
@ -103,6 +103,9 @@ bool AdvSys::singleAction() {
|
||||
}
|
||||
|
||||
Common::Error AdvSys::readSaveData(Common::SeekableReadStream *rs) {
|
||||
if ((int)rs->size() != _saveSize)
|
||||
return Common::kReadingFailed;
|
||||
|
||||
rs->read(_saveArea, rs->size());
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
@ -190,11 +190,21 @@ Common::Error GlkEngine::loadGameState(int slot) {
|
||||
// so if present we can validate the save is for this game
|
||||
for (QuetzalReader::Iterator it = r.begin(); it != r.end(); ++it) {
|
||||
if ((*it)._id == ID_SCVM) {
|
||||
// Skip over date/time & playtime
|
||||
Common::SeekableReadStream *rs = it.getStream();
|
||||
rs->skip(14);
|
||||
|
||||
byte interpType = rs->readByte();
|
||||
byte language = rs->readByte();
|
||||
Common::String md5 = QuetzalReader::readString(rs);
|
||||
delete rs;
|
||||
|
||||
if (interpType != getInterpreterType() || language != getLanguage() || md5 != getGameMD5())
|
||||
errCode = Common::kReadingFailed;
|
||||
}
|
||||
}
|
||||
|
||||
if (errCode != Common::kNoError) {
|
||||
if (errCode == Common::kNoError) {
|
||||
// Scan for an uncompressed memory chunk
|
||||
errCode = Common::kReadingFailed; // Presume we won't find chunk
|
||||
for (QuetzalReader::Iterator it = r.begin(); it != r.end(); ++it) {
|
||||
@ -202,6 +212,7 @@ Common::Error GlkEngine::loadGameState(int slot) {
|
||||
Common::SeekableReadStream *rs = it.getStream();
|
||||
errCode = readSaveData(rs).getCode();
|
||||
delete rs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -228,7 +239,7 @@ Common::Error GlkEngine::saveGameState(int slot, const Common::String &desc) {
|
||||
errCode = writeGameData(&ws).getCode();
|
||||
}
|
||||
|
||||
if (errCode != Common::kNoError) {
|
||||
if (errCode == Common::kNoError) {
|
||||
w.save(*file, desc);
|
||||
}
|
||||
|
||||
|
@ -45,10 +45,8 @@ bool QuetzalReader::open(Common::SeekableReadStream *stream, uint32 formType) {
|
||||
uint32 size = stream->readUint32BE();
|
||||
uint32 fileFormType = stream->readUint32BE();
|
||||
|
||||
if (formType != ID_IFSF)
|
||||
return false;
|
||||
if ((formType != 0 && fileFormType != formType) ||
|
||||
(formType == 0 && (fileFormType == ID_IFZS || fileFormType == ID_IFSF)))
|
||||
(formType == 0 && fileFormType != ID_IFZS && fileFormType != ID_IFSF))
|
||||
return false;
|
||||
|
||||
if ((int)size > stream->size() || (size & 1) || (size < 4))
|
||||
@ -112,7 +110,6 @@ bool QuetzalReader::getSavegameMetaInfo(Common::SeekableReadStream *rs, SaveStat
|
||||
ssd.setDescription(readString(s));
|
||||
delete s;
|
||||
|
||||
return true;
|
||||
} else if ((*it)._id == ID_SCVM) {
|
||||
Common::SeekableReadStream *s = it.getStream();
|
||||
int year = s->readUint16BE();
|
||||
|
@ -781,7 +781,7 @@ FileStream::FileStream(Streams *streams, frefid_t fref, uint fmode, uint rock, b
|
||||
Common::String fname = fref->_slotNumber == -1 ? fref->_filename : fref->getSaveName();
|
||||
|
||||
if (fmode == filemode_Write || fmode == filemode_ReadWrite || fmode == filemode_WriteAppend) {
|
||||
_outFile = g_system->getSavefileManager()->openForSaving(fname, fref->_slotNumber != -1 && g_vm->getInterpreterType() != INTERPRETER_FROTZ);
|
||||
_outFile = g_system->getSavefileManager()->openForSaving(fname, false);
|
||||
if (!_outFile)
|
||||
error("Could open file for writing - %s", fname.c_str());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user