Ticket #4771: kyra-recover_from_invalid_savegame_slot.patch
File kyra-recover_from_invalid_savegame_slot.patch, 5.5 KB (added by , 14 years ago) |
---|
-
engines/kyra/kyra_hof.cpp
438 438 runStartScript(1, 0); 439 439 loadNPCScript(); 440 440 441 if (_gameToLoad == -1) { 441 // Try loading a saved game and fallback to normal game init if it fails 442 if (_gameToLoad == -1 || (_gameToLoad != -1 && !loadGameStateCheck(_gameToLoad))) { 442 443 snd_playWanderScoreViaMap(52, 1); 443 444 enterNewScene(_mainCharacter.sceneId, _mainCharacter.facing, 0, 0, 1); 444 445 saveGameState(0, "New Game", 0); 445 } else { 446 loadGameStateCheck(_gameToLoad); 447 } 446 } 448 447 449 448 _screen->showMouse(); 450 449 -
engines/kyra/kyra_lok.cpp
409 409 error("Could not load \"_NPC.EMC\" script"); 410 410 411 411 snd_playTheme(1, -1); 412 if (_gameToLoad == -1) { 413 enterNewScene(_currentCharacter->sceneId, _currentCharacter->facing, 0, 0, 1); 414 if (_abortIntroFlag && _skipIntroFlag && saveFileLoadable(0)) { 415 _menuDirectlyToLoad = true; 416 _screen->setMouseCursor(1, 1, _shapes[0]); 417 _screen->showMouse(); 418 _gui->buttonMenuCallback(0); 419 _menuDirectlyToLoad = false; 420 } else if (!shouldQuit()) { 421 saveGameState(0, "New game", 0); 412 413 // Try loading a saved game and fall back to normal path if it fails 414 if (_gameToLoad != -1) { 415 Screen::FontId previousFont = _screen->setFont(_flags.lang == Common::JA_JPN ? Screen::FID_SJIS_FNT : Screen::FID_8_FNT); 416 417 if (loadGameStateCheck(_gameToLoad)) { 418 _gameToLoad = -1; 419 return; 422 420 } 423 } else { 424 _screen->setFont(_flags.lang == Common::JA_JPN ? Screen::FID_SJIS_FNT : Screen::FID_8_FNT);425 loadGameStateCheck(_gameToLoad);421 422 // Restore screen font and continue 423 _screen->setFont(previousFont); 426 424 _gameToLoad = -1; 427 425 } 426 427 enterNewScene(_currentCharacter->sceneId, _currentCharacter->facing, 0, 0, 1); 428 if (_abortIntroFlag && _skipIntroFlag && saveFileLoadable(0)) { 429 _menuDirectlyToLoad = true; 430 _screen->setMouseCursor(1, 1, _shapes[0]); 431 _screen->showMouse(); 432 _gui->buttonMenuCallback(0); 433 _menuDirectlyToLoad = false; 434 } else if (!shouldQuit()) { 435 saveGameState(0, "New game", 0); 436 } 428 437 } 429 438 430 439 void KyraEngine_LoK::mainLoop() { -
engines/kyra/kyra_mr.cpp
658 658 saveGameState(0, "New Game", 0); 659 659 _soundDigital->beginFadeOut(_musicSoundChannel, 60); 660 660 delayWithTicks(60); 661 if (_gameToLoad == -1) 661 662 // Try loading a saved game and fall back to normal scene if it fails 663 if (_gameToLoad == -1 || (_gameToLoad != -1 && loadGameStateCheck(_gameToLoad))) 662 664 enterNewScene(_mainCharacter.sceneId, _mainCharacter.facing, 0, 0, 1); 663 else664 loadGameStateCheck(_gameToLoad);665 665 666 666 if (_menuDirectlyToLoad) 667 667 (*_mainButtonData[0].buttonCallback)(&_mainButtonData[0]); -
engines/kyra/kyra_v1.cpp
266 266 int saveLoadSlot = 9 - (event.kbd.keycode - Common::KEYCODE_0) + 990; 267 267 268 268 if (event.kbd.flags == Common::KBD_CTRL) { 269 loadGameStateCheck(saveLoadSlot); 270 _eventList.clear(); 271 breakLoop = true; 269 if (loadGameStateCheck(saveLoadSlot)) { 270 _eventList.clear(); 271 breakLoop = true; 272 } 272 273 } else { 273 274 char savegameName[14]; 274 275 sprintf(savegameName, "Quicksave %d", event.kbd.keycode - Common::KEYCODE_0); -
engines/kyra/kyra_v1.h
409 409 410 410 static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *file, bool loadThumbnail, SaveHeader &header); 411 411 412 voidloadGameStateCheck(int slot);412 bool loadGameStateCheck(int slot); 413 413 virtual Common::Error loadGameState(int slot) = 0; 414 414 Common::Error saveGameState(int slot, const char *saveName) { return saveGameState(slot, saveName, 0); } 415 415 virtual Common::Error saveGameState(int slot, const char *saveName, const Graphics::Surface *thumbnail) = 0; -
engines/kyra/saveload.cpp
256 256 } 257 257 } 258 258 259 void KyraEngine_v1::loadGameStateCheck(int slot) { 260 if (loadGameState(slot) != Common::kNoError) { 259 bool KyraEngine_v1::loadGameStateCheck(int slot) { 260 Common::Error ret = loadGameState(slot); 261 262 if (ret != Common::kNoError) { 261 263 const char *filename = getSavegameFilename(slot); 262 264 Common::String errorMessage = "Could not load savegame: '"; 263 265 errorMessage += filename; 264 266 errorMessage += "'"; 265 267 266 268 GUIErrorMessage(errorMessage); 269 270 // In case the file does not exist, we get a reading failed error and we can recover from it 271 if (ret == Common::kReadingFailed) { 272 warning("%s", errorMessage.c_str()); 273 return false; 274 } 275 276 // The loading failed and the engine is in an unknown state, so we throw an error 267 277 error("%s", errorMessage.c_str()); 278 return false; 268 279 } 280 281 return true; 269 282 } 270 283 271 284 } // End of namespace Kyra