diff options
author | D G Turner | 2011-12-08 14:27:28 +0000 |
---|---|---|
committer | D G Turner | 2011-12-08 14:27:28 +0000 |
commit | 111f5806766a322de7f18da89dd0e72aa7cdc609 (patch) | |
tree | 0a94610a5ce7ab2953308723db5b0fa2b3b80319 | |
parent | d3a187c298decc7b8e0125a3cdc46162f65ea3bb (diff) | |
download | scummvm-rg350-111f5806766a322de7f18da89dd0e72aa7cdc609.tar.gz scummvm-rg350-111f5806766a322de7f18da89dd0e72aa7cdc609.tar.bz2 scummvm-rg350-111f5806766a322de7f18da89dd0e72aa7cdc609.zip |
TINSEL: Replace usage of 'goto'.
-rw-r--r-- | engines/tinsel/saveload.cpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/engines/tinsel/saveload.cpp b/engines/tinsel/saveload.cpp index a0801d8247..8664cd5f15 100644 --- a/engines/tinsel/saveload.cpp +++ b/engines/tinsel/saveload.cpp @@ -486,6 +486,16 @@ static bool DoRestore() { return !failed; } +static void SaveFailure(Common::OutSaveFile *f) { + if (f) { + delete f; + _vm->getSaveFileMan()->removeSavefile(SaveSceneName); + SaveSceneName = NULL; // Invalidate save name + } + GUI::MessageDialog dialog(_("Failed to save game state to file.")); + dialog.runModal(); +} + /** * DoSave */ @@ -524,8 +534,10 @@ static void DoSave() { f = _vm->getSaveFileMan()->openForSaving(SaveSceneName); Common::Serializer s(0, f); - if (f == NULL) - goto save_failure; + if (f == NULL) { + SaveFailure(f); + return; + } // Write out a savegame header SaveGameHeader hdr; @@ -536,29 +548,22 @@ static void DoSave() { hdr.desc[SG_DESC_LEN - 1] = 0; g_system->getTimeAndDate(hdr.dateTime); if (!syncSaveGameHeader(s, hdr) || f->err()) { - goto save_failure; + SaveFailure(f); + return; } DoSync(s); // Write out the special Id for Discworld savegames f->writeUint32LE(0xFEEDFACE); - if (f->err()) - goto save_failure; + if (f->err()) { + SaveFailure(f); + return; + } f->finalize(); delete f; SaveSceneName = NULL; // Invalidate save name - return; - -save_failure: - if (f) { - delete f; - _vm->getSaveFileMan()->removeSavefile(SaveSceneName); - SaveSceneName = NULL; // Invalidate save name - } - GUI::MessageDialog dialog(_("Failed to save game state to file.")); - dialog.runModal(); } /** |