diff options
author | Willem Jan Palenstijn | 2012-02-13 21:23:47 +0100 |
---|---|---|
committer | Willem Jan Palenstijn | 2012-02-13 21:31:41 +0100 |
commit | 54ede63fcc5046f8fec7b59e64b66780fd7a73b5 (patch) | |
tree | 901144347c2ed0a73417a3f40271957063bfea36 /engines/sky/control.cpp | |
parent | 87e85e17cbe95821899bee76d978924760d76f89 (diff) | |
download | scummvm-rg350-54ede63fcc5046f8fec7b59e64b66780fd7a73b5.tar.gz scummvm-rg350-54ede63fcc5046f8fec7b59e64b66780fd7a73b5.tar.bz2 scummvm-rg350-54ede63fcc5046f8fec7b59e64b66780fd7a73b5.zip |
BASS: Reduce code duplication in autosave code
Diffstat (limited to 'engines/sky/control.cpp')
-rw-r--r-- | engines/sky/control.cpp | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/engines/sky/control.cpp b/engines/sky/control.cpp index fd2f2b92d3..a40e77d1cb 100644 --- a/engines/sky/control.cpp +++ b/engines/sky/control.cpp @@ -1094,36 +1094,23 @@ void Control::doAutoSave() { strcpy(fName, "SKY-VM-CD.ASD"); else sprintf(fName, "SKY-VM%03d.ASD", SkyEngine::_systemVars.gameVersion); - Common::OutSaveFile *outf; - - outf = _saveFileMan->openForSaving(fName); - if (outf == NULL) { - displayMessage(0, "Unable to create autosave file '%s'. (%s)", fName, _saveFileMan->popErrorDesc().c_str()); - return; - } - - _savedCharSet = _skyText->giveCurrentCharSet(); - _savedMouse = _skyMouse->giveCurrentMouseType(); - - uint8 *saveData = (uint8 *)malloc(0x20000); - uint32 fSize = prepareSaveData(saveData); - outf->write(saveData, fSize); - outf->finalize(); + uint16 res = saveGameToFile(false, fName); - if (outf->err()) - displayMessage(0, "Unable to write autosave file '%s'. Disk full? (%s)", fName, _saveFileMan->popErrorDesc().c_str()); + if (res != GAME_SAVED) + displayMessage(0, "Unable to perform autosave to '%s'. (%s)", fName, _saveFileMan->popErrorDesc().c_str()); - delete outf; - free(saveData); } -uint16 Control::saveGameToFile(bool fromControlPanel) { +uint16 Control::saveGameToFile(bool fromControlPanel, const char *filename) { char fName[20]; - sprintf(fName,"SKY-VM.%03d", _selectedGame); + if (!filename) { + sprintf(fName,"SKY-VM.%03d", _selectedGame); + filename = fName; + } Common::OutSaveFile *outf; - outf = _saveFileMan->openForSaving(fName); + outf = _saveFileMan->openForSaving(filename); if (outf == NULL) return NO_DISK_SPACE; |