- fixed: saving game to read-only file was erroneously reported as succeeded

This commit is contained in:
alexey.lysiuk 2019-08-29 14:34:02 +03:00
parent 554eb1c813
commit 49b790a8f6

View file

@ -2324,28 +2324,38 @@ void G_DoSaveGame (bool okForQuicksave, bool forceQuicksave, FString filename, c
G_WriteSnapshots (savegame_filenames, savegame_content);
WriteZip(filename, savegame_filenames, savegame_content);
bool succeeded = false;
if (WriteZip(filename, savegame_filenames, savegame_content))
{
// Check whether the file is ok by trying to open it.
FResourceFile *test = FResourceFile::OpenResourceFile(filename, true);
if (test != nullptr)
{
delete test;
succeeded = true;
}
}
if (succeeded)
{
savegameManager.NotifyNewSave(filename, description, okForQuicksave, forceQuicksave);
BackupSaveName = filename;
if (longsavemessages) Printf("%s (%s)\n", GStrings("GGSAVED"), filename.GetChars());
else Printf("%s\n", GStrings("GGSAVED"));
}
else
{
Printf(PRINT_HIGH, "%s\n", GStrings("TXT_SAVEFAILED"));
}
savegameManager.NotifyNewSave (filename, description, okForQuicksave, forceQuicksave);
// delete the JSON buffers we created just above. Everything else will
// either still be needed or taken care of automatically.
savegame_content[1].Clean();
savegame_content[2].Clean();
// Check whether the file is ok by trying to open it.
FResourceFile *test = FResourceFile::OpenResourceFile(filename, true);
if (test != nullptr)
{
delete test;
if (longsavemessages) Printf ("%s (%s)\n", GStrings("GGSAVED"), filename.GetChars());
else Printf ("%s\n", GStrings("GGSAVED"));
}
else Printf(PRINT_HIGH, "%s\n", GStrings("TXT_SAVEFAILED"));
BackupSaveName = filename;
// We don't need the snapshot any longer.
level.info->Snapshot.Clean();