Permalink
Browse files

STARTREK: Implement save loading from launcher

  • Loading branch information...
Drenn1 authored and sev- committed Jul 26, 2018
1 parent 23b3782 commit ae6c86bc7a9c1d493208227dfa744b866cda10da
Showing with 37 additions and 17 deletions.
  1. +4 −3 engines/startrek/saveload.cpp
  2. +32 −13 engines/startrek/startrek.cpp
  3. +1 −1 engines/startrek/startrek.h
@@ -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);
}
}
@@ -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) {
@@ -234,7 +234,7 @@ class StarTrekEngine : public ::Engine {
Angle atan2(int32 deltaX, int32 deltaZ);

// Game modes
Common::Error runGameMode(int mode);
Common::Error runGameMode(int mode, bool resume);

// Away missions
void initAwayMission();

0 comments on commit ae6c86b

Please sign in to comment.