diff options
author | Matthew Stewart | 2018-07-26 18:22:58 -0400 |
---|---|---|
committer | Eugene Sandulenko | 2018-08-09 08:37:30 +0200 |
commit | ae6c86bc7a9c1d493208227dfa744b866cda10da (patch) | |
tree | 1df5e8f0f333ccc329d5bdd245e318a50d5ee790 | |
parent | 23b3782b5217e3d08b84c6abce0821e01071c3f7 (diff) | |
download | scummvm-rg350-ae6c86bc7a9c1d493208227dfa744b866cda10da.tar.gz scummvm-rg350-ae6c86bc7a9c1d493208227dfa744b866cda10da.tar.bz2 scummvm-rg350-ae6c86bc7a9c1d493208227dfa744b866cda10da.zip |
STARTREK: Implement save loading from launcher
-rw-r--r-- | engines/startrek/saveload.cpp | 7 | ||||
-rw-r--r-- | engines/startrek/startrek.cpp | 45 | ||||
-rw-r--r-- | engines/startrek/startrek.h | 2 |
3 files changed, 37 insertions, 17 deletions
diff --git a/engines/startrek/saveload.cpp b/engines/startrek/saveload.cpp index f42d2f128b..bb24587bb2 100644 --- a/engines/startrek/saveload.cpp +++ b/engines/startrek/saveload.cpp @@ -184,14 +184,15 @@ bool StarTrekEngine::saveOrLoadGameData(Common::SeekableReadStream *in, Common:: ser.syncAsUint16LE(_gameMode); // TODO: sub_1d8eb (save) / sub_1d958 (load) (probably bridge / space combat state) - ser.syncString(_sound->_loadedMidiFilename); + Common::String midiFilename = _sound->_loadedMidiFilename; + ser.syncString(midiFilename); ser.syncAsSint16LE(_sound->_loopingMidiTrack); if (ser.isLoading()) { - if (_sound->_loadedMidiFilename.empty()) + if (midiFilename.empty()) _sound->clearAllMidiSlots(); else { - _sound->loadMusicFile(_sound->_loadedMidiFilename); + _sound->loadMusicFile(midiFilename); _sound->playMidiMusicTracks(_sound->_loopingMidiTrack, _sound->_loopingMidiTrack); } } diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp index f5835d2adb..2086b36e97 100644 --- a/engines/startrek/startrek.cpp +++ b/engines/startrek/startrek.cpp @@ -119,27 +119,46 @@ Common::Error StarTrekEngine::run() { initGraphics(SCREEN_WIDTH, SCREEN_HEIGHT, &format); initializeEventsAndMouse(); - _frameIndex = 0; - playIntro(); - debug("DONE"); + bool shouldPlayIntro = false; + bool loadedSave = false; + + if (ConfMan.hasKey("save_slot")) { + if (!loadGame(ConfMan.getInt("save_slot"))) + error("Failed to load savegame %d", ConfMan.getInt("save_slot")); + shouldPlayIntro = false; + loadedSave = true; + _roomIndexToLoad = -1; + } + + if (!loadedSave) { + if (shouldPlayIntro) { + _frameIndex = 0; + playIntro(); + } - _frameIndex = 0; + _frameIndex = 0; - _gameMode = -1; - _lastGameMode = -1; + _gameMode = -1; + _lastGameMode = -1; + } - runGameMode(GAMEMODE_AWAYMISSION); + if (loadedSave) + runGameMode(_gameMode, true); + else + runGameMode(GAMEMODE_AWAYMISSION, false); return Common::kNoError; } -Common::Error StarTrekEngine::runGameMode(int mode) { - _gameMode = mode; +Common::Error StarTrekEngine::runGameMode(int mode, bool resume) { + if (!resume) { // Only run this if not just resuming from a savefile + _gameMode = mode; - _sound->stopAllVocSounds(); + _sound->stopAllVocSounds(); - _resetGameMode = true; - if (_gameMode == GAMEMODE_START) - _gameMode = GAMEMODE_BRIDGE; + _resetGameMode = true; + if (_gameMode == GAMEMODE_START) + _gameMode = GAMEMODE_BRIDGE; + } while (true) { if (_resetGameMode) { diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h index 6f98db2b64..ef2ddf195b 100644 --- a/engines/startrek/startrek.h +++ b/engines/startrek/startrek.h @@ -234,7 +234,7 @@ public: Angle atan2(int32 deltaX, int32 deltaZ); // Game modes - Common::Error runGameMode(int mode); + Common::Error runGameMode(int mode, bool resume); // Away missions void initAwayMission(); |