aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sky/control.cpp31
-rw-r--r--engines/sky/control.h2
2 files changed, 10 insertions, 23 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;
diff --git a/engines/sky/control.h b/engines/sky/control.h
index 59eda9b4e6..42ada564df 100644
--- a/engines/sky/control.h
+++ b/engines/sky/control.h
@@ -190,7 +190,7 @@ public:
bool loadSaveAllowed();
uint16 _selectedGame;
- uint16 saveGameToFile(bool fromControlPanel);
+ uint16 saveGameToFile(bool fromControlPanel, const char *filename = 0);
void loadDescriptions(Common::StringArray &list);
void saveDescriptions(const Common::StringArray &list);