aboutsummaryrefslogtreecommitdiff
path: root/engines/mads/game.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2014-04-22 23:00:41 -0400
committerPaul Gilbert2014-04-22 23:00:41 -0400
commit0e9e6cda40ee0bf739e6c7a6320a81307df7c8b9 (patch)
treed69131833413f6bd75ef84e95c64cc54da568e8e /engines/mads/game.cpp
parent3f1a49b567aac10fe8a195f7a2b8e07603470a72 (diff)
downloadscummvm-rg350-0e9e6cda40ee0bf739e6c7a6320a81307df7c8b9.tar.gz
scummvm-rg350-0e9e6cda40ee0bf739e6c7a6320a81307df7c8b9.tar.bz2
scummvm-rg350-0e9e6cda40ee0bf739e6c7a6320a81307df7c8b9.zip
MADS: Beginnings of savegame synchronisation
Diffstat (limited to 'engines/mads/game.cpp')
-rw-r--r--engines/mads/game.cpp34
1 files changed, 25 insertions, 9 deletions
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index d3e3987d4e..3b591d7a9e 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -22,6 +22,7 @@
#include "common/scummsys.h"
#include "common/memstream.h"
+#include "common/serializer.h"
#include "mads/mads.h"
#include "mads/compression.h"
#include "mads/game.h"
@@ -45,7 +46,7 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
_scene(vm), _screenObjects(vm), _player(vm) {
_sectionNumber = _priorSectionNumber = 0;
_difficulty = DIFFICULTY_HARD;
- _saveSlot = -1;
+ _serializer = nullptr;
_statusFlag = 0;
_sectionHandler = nullptr;
_sectionNumber = 1;
@@ -86,7 +87,6 @@ void Game::run() {
case PROTECTION_FAIL:
// Copy protection failed
_scene._nextSceneId = 804;
- _saveSlot = -1;
break;
case PROTECTION_ESCAPE:
// User escaped out of copy protection dialog
@@ -102,7 +102,7 @@ void Game::run() {
// Get the initial starting time for the first scene
_scene._frameStartTime = _vm->_events->getFrameCounter();
- if (_saveSlot == -1 && protectionResult != -1 && protectionResult != -2) {
+ if (_serializer == nullptr && protectionResult != -1 && protectionResult != -2) {
initSection(_sectionNumber);
_statusFlag = true;
@@ -118,11 +118,6 @@ void Game::run() {
if (protectionResult != 1 && protectionResult != 2) {
initialiseGlobals();
-
- if (_saveSlot != -1) {
- warning("TODO: loadGame(\"REX.SAV\", 210)");
- _statusFlag = false;
- }
}
if (_statusFlag)
@@ -131,6 +126,9 @@ void Game::run() {
void Game::gameLoop() {
while (!_vm->shouldQuit() && _statusFlag) {
+ if (_serializer)
+ synchronize(*_serializer, true);
+
setSectionHandler();
_sectionHandler->preLoadSection();
initSection(_sectionNumber);
@@ -248,7 +246,7 @@ void Game::sectionLoop() {
_player.selectSeries();
_player.updateFrame();
- _player._visible3 = _player._visible;
+ _player._beenVisible = _player._visible;
_player._special = _scene.getDepthHighBits(_player._playerPos);
_player._priorTimer = _scene._frameStartTime - _player._ticksAmount;
_player.idle();
@@ -402,4 +400,22 @@ void Game::handleKeypress(const Common::Event &event) {
warning("TODO: handleKeypress - %d", (int)event.kbd.keycode);
}
+void Game::synchronize(Common::Serializer &s, bool phase1) {
+ if (phase1) {
+ s.syncAsUint16LE(_scene._nextSceneId);
+ s.syncAsUint16LE(_scene._priorSceneId);
+
+ if (s.isLoading()) {
+ _sectionNumber = _scene._nextSceneId / 100;
+ _currentSectionNumber = _sectionNumber;
+ }
+ } else {
+ s.syncAsByte(_difficulty);
+
+ _scene.synchronize(s);
+ _objects.synchronize(s);
+ _player.synchronize(s);
+ }
+}
+
} // End of namespace MADS