BASS: Fix savegame corruption

When using the GMM or autosaves, _savedMouse and _savedCharSet were
never set. See bug #3487117.
This commit is contained in:
Willem Jan Palenstijn 2012-02-13 21:28:32 +01:00
parent c7a5d31f05
commit 87e85e17cb
3 changed files with 15 additions and 4 deletions

View File

@ -535,7 +535,7 @@ uint16 Control::handleClick(ConResource *pButton) {
return saveRestorePanel(true); // texts can be edited
case SAVE_A_GAME:
animClick(pButton);
return saveGameToFile();
return saveGameToFile(true);
case RESTORE_A_GAME:
animClick(pButton);
return restoreGameFromFile(false);
@ -1101,6 +1101,10 @@ void Control::doAutoSave() {
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);
@ -1114,7 +1118,7 @@ void Control::doAutoSave() {
free(saveData);
}
uint16 Control::saveGameToFile() {
uint16 Control::saveGameToFile(bool fromControlPanel) {
char fName[20];
sprintf(fName,"SKY-VM.%03d", _selectedGame);
@ -1123,6 +1127,13 @@ uint16 Control::saveGameToFile() {
if (outf == NULL)
return NO_DISK_SPACE;
if (!fromControlPanel) {
// These variables are usually set when entering the control panel,
// but not when using the GMM.
_savedCharSet = _skyText->giveCurrentCharSet();
_savedMouse = _skyMouse->giveCurrentMouseType();
}
uint8 *saveData = (uint8 *)malloc(0x20000);
uint32 fSize = prepareSaveData(saveData);

View File

@ -190,7 +190,7 @@ public:
bool loadSaveAllowed();
uint16 _selectedGame;
uint16 saveGameToFile();
uint16 saveGameToFile(bool fromControlPanel);
void loadDescriptions(Common::StringArray &list);
void saveDescriptions(const Common::StringArray &list);

View File

@ -286,7 +286,7 @@ Common::Error SkyEngine::saveGameState(int slot, const Common::String &desc) {
// Set the save slot and save the game
_skyControl->_selectedGame = slot - 1;
if (_skyControl->saveGameToFile() != GAME_SAVED)
if (_skyControl->saveGameToFile(false) != GAME_SAVED)
return Common::kWritePermissionDenied;
// Load current save game descriptions