aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mads/game.cpp1
-rw-r--r--engines/mads/globals.cpp23
-rw-r--r--engines/mads/globals.h10
-rw-r--r--engines/mads/nebular/game_nebular.cpp8
-rw-r--r--engines/mads/nebular/game_nebular.h2
-rw-r--r--engines/mads/nebular/globals_nebular.cpp2
-rw-r--r--engines/mads/scene.cpp1
-rw-r--r--engines/mads/user_interface.cpp8
-rw-r--r--engines/mads/user_interface.h5
9 files changed, 55 insertions, 5 deletions
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 3b591d7a9e..462c6401a9 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -408,6 +408,7 @@ void Game::synchronize(Common::Serializer &s, bool phase1) {
if (s.isLoading()) {
_sectionNumber = _scene._nextSceneId / 100;
_currentSectionNumber = _sectionNumber;
+ _scene._frameStartTime = _vm->_events->getFrameCounter();
}
} else {
s.syncAsByte(_difficulty);
diff --git a/engines/mads/globals.cpp b/engines/mads/globals.cpp
index 68a2cf1970..de15ba9595 100644
--- a/engines/mads/globals.cpp
+++ b/engines/mads/globals.cpp
@@ -26,8 +26,27 @@
namespace MADS {
void Globals::reset() {
- for (uint i = 0; i < _flags.size(); ++i)
- _flags[i] = 0;
+ for (uint i = 0; i < _data.size(); ++i)
+ _data[i] = 0;
+}
+
+void Globals::synchronize(Common::Serializer &s) {
+ int count = 0;
+ int16 v;
+ s.syncAsUint16LE(count);
+
+ if (s.isSaving()) {
+ for (int idx = 0; idx < count; ++idx) {
+ v = _data[idx];
+ s.syncAsSint16LE(v);
+ }
+ } else {
+ _data.clear();
+ for (int idx = 0; idx < count; ++idx) {
+ s.syncAsSint16LE(v);
+ _data.push_back(v);
+ }
+ }
}
diff --git a/engines/mads/globals.h b/engines/mads/globals.h
index ea327b0045..fa7a630f7f 100644
--- a/engines/mads/globals.h
+++ b/engines/mads/globals.h
@@ -25,24 +25,30 @@
#include "common/scummsys.h"
#include "common/array.h"
+#include "common/serializer.h"
namespace MADS {
class Globals {
protected:
- Common::Array<int16> _flags;
+ Common::Array<int16> _data;
public:
Globals() {}
/**
* Square brackets operator for accessing flags
*/
- int16 &operator[](int idx) { return _flags[idx]; }
+ int16 &operator[](int idx) { return _data[idx]; }
/*
* Resets all the globals to empty
*/
void reset();
+
+ /**
+ * Synchronize the globals data
+ */
+ void synchronize(Common::Serializer &s);
};
} // End of namespace MADS
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 23c8b3cdd6..34eb6f140c 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -744,6 +744,14 @@ void GameNebular::step() {
}
}
+void GameNebular::synchronize(Common::Serializer &s, bool phase1) {
+ Game::synchronize(s, phase1);
+
+ if (!phase1) {
+ _globals.synchronize(s);
+ }
+}
+
} // End of namespace Nebular
} // End of namespace MADS
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 7d64e3e49f..0e2d564236 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -73,6 +73,8 @@ public:
virtual void unhandledAction();
virtual void step();
+
+ virtual void synchronize(Common::Serializer &s, bool phase1);
};
diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index 3e9a9f7e2f..a8b7cdce72 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -30,7 +30,7 @@ namespace Nebular {
NebularGlobals::NebularGlobals(): Globals() {
// Initialize lists
- _flags.resize(210);
+ _data.resize(210);
_spriteIndexes.resize(30);
_sequenceIndexes.resize(30);
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 239a91c585..24218479ce 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -684,6 +684,7 @@ void Scene::freeAnimation() {
void Scene::synchronize(Common::Serializer &s) {
_action._activeAction.synchronize(s);
_rails.synchronize(s);
+ _userInterface.synchronize(s);
}
} // End of namespace MADS
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 493804c923..9a63ac32ad 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -1079,4 +1079,12 @@ void UserInterface::scrollInventory() {
_vm->_game->_screenObjects._v8332A = 0;
}
+void UserInterface::synchronize(Common::Serializer &s) {
+ InventoryObjects &invObjects = _vm->_game->_objects;
+
+ if (s.isLoading()) {
+ _selectedInvIndex = invObjects._inventoryList.empty() ? -1 : 0;
+ }
+}
+
} // End of namespace MADS
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index baae269c4f..1e07681a6f 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -293,6 +293,11 @@ public:
* Add a msesage to the list of conversation items to select from
*/
void addConversationMessage(int vocabId, const Common::String &msg);
+
+ /**
+ * Synchronize the data
+ */
+ void synchronize(Common::Serializer &s);
};
} // End of namespace MADS