- 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 committed by drfrag
parent f27afdb0d2
commit 338e599de8

View file

@ -2306,28 +2306,38 @@ void G_DoSaveGame (bool okForQuicksave, bool forceQuicksave, FString filename, c
G_WriteSnapshots (savegame_filenames, savegame_content);
WriteZip(filename, savegame_filenames, savegame_content);
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();
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;
if (longsavemessages) Printf ("%s (%s)\n", GStrings("GGSAVED"), filename.GetChars());
else Printf ("%s\n", GStrings("GGSAVED"));
succeeded = true;
}
}
else Printf(PRINT_HIGH, "%s\n", GStrings("TXT_SAVEFAILED"));
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"));
}
// 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();
// We don't need the snapshot any longer.
level.info->Snapshot.Clean();