From 217bcb847d2a703ecf5fd302127feeac73b3fa3c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 3 Mar 2017 19:19:19 +0100 Subject: [PATCH] - fixed: When the savegame code errors out, some cleanup is required in G_DoSaveGame. --- src/dobjtype.cpp | 3 +-- src/g_game.cpp | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index a2a5a6883..98a893391 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -1398,8 +1398,7 @@ void PPointer::WriteValue(FSerializer &ar, const char *key,const void *addr) con } else { - assert(0 && "Pointer points to a type we don't handle"); - I_Error("Attempt to save pointer to unhandled type"); + I_Error("Attempt to save pointer to unhandled type %s", PointedType->DescriptiveName()); } } diff --git a/src/g_game.cpp b/src/g_game.cpp index b39ee52a8..4391a0571 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -2270,7 +2270,29 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio I_FreezeTime(true); insave = true; - G_SnapshotLevel (); + try + { + G_SnapshotLevel(); + } + catch(CRecoverableError &err) + { + // delete the snapshot. Since the save failed it is broken. + insave = false; + level.info->Snapshot.Clean(); + Printf(PRINT_HIGH, "Save failed\n"); + Printf(PRINT_HIGH, "%s\n", err.GetMessage()); + // The time freeze must be reset if the save fails. + if (cl_waitforsave) + I_FreezeTime(false); + return; + } + catch (...) + { + insave = false; + if (cl_waitforsave) + I_FreezeTime(false); + throw; + } BufferWriter savepic; FSerializer savegameinfo; // this is for displayable info about the savegame