diff options
author | Bendegúz Nagy | 2016-08-20 13:25:29 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | ca267da97c14268f8c650d7dac727182062129d0 (patch) | |
tree | e6d0e6fe09481332a481587446e5bc30ba299dd9 /engines | |
parent | d85970b4e47d05db625eccd04646514d47b8e5fe (diff) | |
download | scummvm-rg350-ca267da97c14268f8c650d7dac727182062129d0.tar.gz scummvm-rg350-ca267da97c14268f8c650d7dac727182062129d0.tar.bz2 scummvm-rg350-ca267da97c14268f8c650d7dac727182062129d0.zip |
DM: Add file error checking for save game
Diffstat (limited to 'engines')
-rw-r--r-- | engines/dm/dm.h | 2 | ||||
-rw-r--r-- | engines/dm/loadsave.cpp | 14 |
2 files changed, 11 insertions, 5 deletions
diff --git a/engines/dm/dm.h b/engines/dm/dm.h index d90943b764..edc54c17b3 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -209,7 +209,7 @@ class DMEngine : public Engine { void initArrays(); Common::String getSavefileName(uint16 slot); void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName); - void writeCompleteSaveFile(int16 slot, Common::String &desc, int16 saveAndPlayChoice); + bool writeCompleteSaveFile(int16 slot, Common::String &desc, int16 saveAndPlayChoice); void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance public: explicit DMEngine(OSystem *syst, const ADGameDescription *gameDesc); diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp index 02f1a8088e..a84a0b6624 100644 --- a/engines/dm/loadsave.cpp +++ b/engines/dm/loadsave.cpp @@ -240,7 +240,10 @@ void DMEngine::f433_processCommand140_saveGame() { _championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load -= champHandObjWeight; } - writeCompleteSaveFile(saveSlot, saveDescription, saveAndPlayChoice); + if (!writeCompleteSaveFile(saveSlot, saveDescription, saveAndPlayChoice)) { + _dialog->f427_dialogDraw(nullptr, "Unable to open file for saving", "OK", nullptr, nullptr, nullptr, false, false, false); + _dialog->f424_dialogGetChoice(1, k0_DIALOG_SET_VIEWPORT, 0, k0_DIALOG_CHOICE_NONE); + } if (!_championMan->_g415_leaderEmptyHanded) { _championMan->_gK71_champions[_championMan->_g411_leaderIndex]._load += champHandObjWeight; @@ -296,13 +299,14 @@ void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::Strin out->writeUint32BE(playTime); } -void DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescription, int16 saveAndPlayChoice) { +bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescription, int16 saveAndPlayChoice) { Common::String savefileName = getSavefileName(saveSlot); Common::SaveFileManager *saveFileManager = _system->getSavefileManager(); Common::OutSaveFile *file = saveFileManager->openForSaving(savefileName); - if (!file) - return; // TODO: silent fail + if (!file) { + return false; + } writeSaveGameHeader(file, saveDescription); @@ -409,6 +413,8 @@ void DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip file->flush(); file->finalize(); delete file; + + return true; } bool readSaveGameHeader(Common::InSaveFile* in, SaveGameHeader* header) { |