Error out on savegame load failure (again).

svn-id: r34953
This commit is contained in:
Johannes Schickel 2008-11-09 13:12:38 +00:00
parent 36de1204e3
commit 85c1d35ae3
9 changed files with 24 additions and 11 deletions

View File

@ -785,7 +785,7 @@ int GUI_HoF::optionsButton(Button *button) {
if (!_loadedSave && _reloadTemporarySave) {
_vm->_unkSceneScreenFlag1 = true;
_vm->loadGameState(999);
_vm->loadGameStateCheck(999);
//_vm->_saveFileMan->removeSavefile(_vm->getSavegameFilename(999));
_vm->_unkSceneScreenFlag1 = false;
}
@ -1195,7 +1195,7 @@ int GUI_HoF::loadMenu(Button *caller) {
} else if (_vm->_gameToLoad >= 0) {
restorePage1(_vm->_screenBuffer);
restorePalette();
_vm->loadGameState(_vm->_gameToLoad);
_vm->loadGameStateCheck(_vm->_gameToLoad);
if (_vm->_gameToLoad == 0) {
_restartGame = true;
for (int i = 0; i < 23; ++i)

View File

@ -658,7 +658,7 @@ int GUI_LoK::loadGameMenu(Button *button) {
} else {
restorePalette();
if (_vm->_gameToLoad != -1)
_vm->loadGameState(_vm->_gameToLoad);
_vm->loadGameStateCheck(_vm->_gameToLoad);
_displayMenu = false;
_menuRestoreScreen = false;
}

View File

@ -1366,7 +1366,7 @@ int GUI_MR::optionsButton(Button *button) {
if (!_loadedSave && _reloadTemporarySave) {
_vm->_unkSceneScreenFlag1 = true;
_vm->loadGameState(999);
_vm->loadGameStateCheck(999);
//_vm->_saveFileMan->removeSavefile(_vm->getSavegameFilename(999));
_vm->_unkSceneScreenFlag1 = false;
}
@ -1408,7 +1408,7 @@ int GUI_MR::loadMenu(Button *caller) {
restorePage1(_vm->_screenBuffer);
restorePalette();
_vm->_menuDirectlyToLoad = false;
_vm->loadGameState(_vm->_gameToLoad);
_vm->loadGameStateCheck(_vm->_gameToLoad);
if (_vm->_gameToLoad == 0) {
_restartGame = true;
_vm->runStartupScript(1, 1);
@ -1425,7 +1425,7 @@ int GUI_MR::loadSecondChance(Button *button) {
_vm->_gameToLoad = 999;
restorePage1(_vm->_screenBuffer);
_vm->loadGameState(_vm->_gameToLoad);
_vm->loadGameStateCheck(_vm->_gameToLoad);
_displayMenu = false;
_loadedSave = true;
return 0;

View File

@ -439,7 +439,7 @@ void KyraEngine_HoF::startup() {
enterNewScene(_mainCharacter.sceneId, _mainCharacter.facing, 0, 0, 1);
saveGameState(0, "New Game", 0);
} else {
loadGameState(_gameToLoad);
loadGameStateCheck(_gameToLoad);
}
_screen->showMouse();

View File

@ -394,7 +394,7 @@ void KyraEngine_LoK::startup() {
saveGameState(0, "New game", 0);
} else {
_screen->setFont(Screen::FID_8_FNT);
loadGameState(_gameToLoad);
loadGameStateCheck(_gameToLoad);
_gameToLoad = -1;
}
}
@ -476,7 +476,7 @@ void KyraEngine_LoK::delay(uint32 amount, bool update, bool isMainLoop) {
int saveLoadSlot = 9 - (event.kbd.keycode - '0') + 990;
if (event.kbd.flags == Common::KBD_CTRL)
loadGameState(saveLoadSlot);
loadGameStateCheck(saveLoadSlot);
else {
char savegameName[14];
sprintf(savegameName, "Quicksave %d", event.kbd.keycode - '0');

View File

@ -690,7 +690,7 @@ void KyraEngine_MR::startup() {
if (_gameToLoad == -1)
enterNewScene(_mainCharacter.sceneId, _mainCharacter.facing, 0, 0, 1);
else
loadGameState(_gameToLoad);
loadGameStateCheck(_gameToLoad);
if (_menuDirectlyToLoad)
(*_mainButtonData[0].buttonCallback)(&_mainButtonData[0]);

View File

@ -306,6 +306,7 @@ protected:
static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *file, bool loadThumbnail, SaveHeader &header);
void loadGameStateCheck(int slot);
virtual Common::Error loadGameState(int slot) = 0;
Common::Error saveGameState(int slot, const char *saveName) { return saveGameState(slot, saveName, 0); }
virtual Common::Error saveGameState(int slot, const char *saveName, const Graphics::Surface *thumbnail) = 0;

View File

@ -185,7 +185,7 @@ int KyraEngine_v2::checkInput(Button *buttonList, bool mainLoop) {
int saveLoadSlot = 9 - (event.kbd.keycode - '0') + 990;
if (event.kbd.flags == Common::KBD_CTRL) {
loadGameState(saveLoadSlot);
loadGameStateCheck(saveLoadSlot);
_eventList.clear();
breakLoop = true;
} else {

View File

@ -251,5 +251,17 @@ void KyraEngine_v1::checkAutosave() {
}
}
void KyraEngine_v1::loadGameStateCheck(int slot) {
if (loadGameState(slot) != Common::kNoError) {
const char *filename = getSavegameFilename(slot);
Common::String errorMessage = "Could not load savegame: '";
errorMessage += filename;
errorMessage += "'";
GUIErrorMessage(errorMessage);
error(errorMessage.c_str());
}
}
} // end of namespace Kyra