MADS: Further synchronization implementation
This commit is contained in:
parent
ee1a33946f
commit
c1a90cdda1
9 changed files with 55 additions and 5 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -73,6 +73,8 @@ public:
|
|||
virtual void unhandledAction();
|
||||
|
||||
virtual void step();
|
||||
|
||||
virtual void synchronize(Common::Serializer &s, bool phase1);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Nebular {
|
|||
|
||||
NebularGlobals::NebularGlobals(): Globals() {
|
||||
// Initialize lists
|
||||
_flags.resize(210);
|
||||
_data.resize(210);
|
||||
_spriteIndexes.resize(30);
|
||||
_sequenceIndexes.resize(30);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue