diff options
-rw-r--r-- | engines/mads/game.cpp | 21 | ||||
-rw-r--r-- | engines/mads/game.h | 2 | ||||
-rw-r--r-- | engines/mads/globals.cpp | 4 | ||||
-rw-r--r-- | engines/mads/mads.cpp | 8 | ||||
-rw-r--r-- | engines/mads/nebular/game_nebular.cpp | 2 | ||||
-rw-r--r-- | engines/mads/player.cpp | 3 |
6 files changed, 22 insertions, 18 deletions
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp index a63fec424e..862ecf9a54 100644 --- a/engines/mads/game.cpp +++ b/engines/mads/game.cpp @@ -273,6 +273,7 @@ void Game::sectionLoop() { Common::Serializer s(_saveFile, nullptr); synchronize(s, false); delete _saveFile; + _saveFile = nullptr; } // Set player data @@ -464,14 +465,6 @@ void Game::synchronize(Common::Serializer &s, bool phase1) { _visitedScenes.synchronize(s); _player.synchronize(s); _screenObjects.synchronize(s); - - if (s.isLoading()) { - _scene._userInterface._selectedInvIndex = -1; - _currentSectionNumber = -2; - _scene._currentSceneId = -2; - _sectionNumber = _scene._nextSceneId / 100; - _scene._frameStartTime = _vm->_events->getFrameCounter(); - } } else { // Load scene specific data for the loaded scene _scene._sceneLogic->synchronize(s); @@ -494,8 +487,18 @@ void Game::loadGame(int slotNumber) { delete header._thumbnail; } - // Load the initial data such as what scene needs to be loaded up + // Load most of the savegame data with the exception of scene specific info synchronize(s, true); + + // Set up section/scene and other initial states for post-load + _scene._userInterface._selectedInvIndex = -1; + _currentSectionNumber = -2; + _scene._currentSceneId = -2; + _sectionNumber = _scene._nextSceneId / 100; + _scene._frameStartTime = _vm->_events->getFrameCounter(); + + _player._spritesLoaded = false; + _player._spritesChanged = true; } void Game::saveGame(int slotNumber, const Common::String &saveName) { diff --git a/engines/mads/game.h b/engines/mads/game.h index 5ae670df76..358a266e09 100644 --- a/engines/mads/game.h +++ b/engines/mads/game.h @@ -87,7 +87,6 @@ protected: bool _quoteEmergency; bool _vocabEmergency; bool _anyEmergency; - int _loadGameSlot; int _lastSave; Common::String _saveName; Common::InSaveFile *_saveFile; @@ -149,6 +148,7 @@ public: Common::String _aaName; int _winStatus; int _widepipeCtr; + int _loadGameSlot; public: virtual ~Game(); diff --git a/engines/mads/globals.cpp b/engines/mads/globals.cpp index de15ba9595..2343dd9c68 100644 --- a/engines/mads/globals.cpp +++ b/engines/mads/globals.cpp @@ -31,9 +31,9 @@ void Globals::reset() { } void Globals::synchronize(Common::Serializer &s) { - int count = 0; - int16 v; + int count = _data.size(); s.syncAsUint16LE(count); + int16 v; if (s.isSaving()) { for (int idx = 0; idx < count; ++idx) { diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp index a099f5904e..9587efa443 100644 --- a/engines/mads/mads.cpp +++ b/engines/mads/mads.cpp @@ -124,13 +124,13 @@ int MADSEngine::hypotenuse(int xv, int yv) { bool MADSEngine::canLoadGameStateCurrently() { return !_game->_winStatus && !_game->globals()[5] && _dialogs->_pendingDialog == DIALOG_NONE - && _events->_cursorId == CURSOR_ARROW; + && _events->_cursorId != CURSOR_WAIT; } bool MADSEngine::canSaveGameStateCurrently() { return !_game->_winStatus && !_game->globals()[5] && _dialogs->_pendingDialog == DIALOG_NONE - && _events->_cursorId == CURSOR_ARROW; + && _events->_cursorId != CURSOR_WAIT; } /** @@ -142,7 +142,9 @@ Common::String MADSEngine::generateSaveName(int slot) { } Common::Error MADSEngine::loadGameState(int slot) { - _game->loadGame(slot); + _game->_loadGameSlot = slot; + _game->_scene._currentSceneId = -1; + _game->_currentSectionNumber = -1; return Common::kNoError; } diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp index ce3f0869cd..546fdbea7c 100644 --- a/engines/mads/nebular/game_nebular.cpp +++ b/engines/mads/nebular/game_nebular.cpp @@ -748,7 +748,7 @@ void GameNebular::step() { void GameNebular::synchronize(Common::Serializer &s, bool phase1) { Game::synchronize(s, phase1); - if (!phase1) { + if (phase1) { _globals.synchronize(s); s.syncAsByte(_storyMode); s.syncAsByte(_difficulty); diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp index 0c9a496144..20d54902dd 100644 --- a/engines/mads/player.cpp +++ b/engines/mads/player.cpp @@ -690,6 +690,7 @@ void Player::releasePlayerSprites() { } while (--spriteEnd >= _spritesStart); } + _numSprites = 0; _spritesLoaded = false; _spritesChanged = true; } @@ -722,7 +723,6 @@ void Player::synchronize(Common::Serializer &s) { s.syncAsByte(_visible); s.syncAsByte(_priorVisible); - s.syncAsSint16LE(_spritesStart); for (int i = 0; i < 8; ++i) s.syncAsByte(_spriteSetsPresent[i]); @@ -751,7 +751,6 @@ void Player::synchronize(Common::Serializer &s) { s.syncAsUint16LE(_frameCount); synchronizeString(s, _spritesPrefix); s.syncAsUint32LE(_priorTimer); - s.syncAsSint16LE(_numSprites); s.syncAsByte(_loadsFirst); s.syncAsByte(_loadedFirst); s.syncAsByte(_spritesLoaded); |