diff options
author | Paul Gilbert | 2015-01-11 14:21:57 -0500 |
---|---|---|
committer | Paul Gilbert | 2015-01-11 14:21:57 -0500 |
commit | 3b1edcdf36fc7a207a70cb28e7dcf7879ea9b7e5 (patch) | |
tree | 8eabf36d7aeaa2fd790c3f1aa3125b348e708a41 /engines/xeen/scripts.cpp | |
parent | 0b5f79afb7dbf0d2bcf3cb14747f93f348b1aaa5 (diff) | |
download | scummvm-rg350-3b1edcdf36fc7a207a70cb28e7dcf7879ea9b7e5.tar.gz scummvm-rg350-3b1edcdf36fc7a207a70cb28e7dcf7879ea9b7e5.tar.bz2 scummvm-rg350-3b1edcdf36fc7a207a70cb28e7dcf7879ea9b7e5.zip |
XEEN: Implemented code for 'saving' resources to the loaded savefile
Diffstat (limited to 'engines/xeen/scripts.cpp')
-rw-r--r-- | engines/xeen/scripts.cpp | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp index ee804317ec..0a864aa2cb 100644 --- a/engines/xeen/scripts.cpp +++ b/engines/xeen/scripts.cpp @@ -27,27 +27,37 @@ namespace Xeen { MazeEvent::MazeEvent() : _direction(DIR_ALL), _line(-1), _opcode(OP_None) { } -void MazeEvent::synchronize(Common::SeekableReadStream &s) { - int len = s.readByte(); - _position.x = s.readByte(); - _position.y = s.readByte(); - _direction = (Direction)s.readByte(); - _line = s.readByte(); - _opcode = (Opcode)s.readByte(); - - for (int i = 0; i < (len - 5); ++i) - _parameters.push_back(s.readByte()); +void MazeEvent::synchronize(Common::Serializer &s) { + int len = 5 + _parameters.size(); + s.syncAsByte(len); + + s.syncAsByte(_position.x); + s.syncAsByte(_position.y); + s.syncAsByte(_direction); + s.syncAsByte(_line); + s.syncAsByte(_opcode); + + len -= 5; + if (s.isLoading()) + _parameters.resize(len); + for (int i = 0; i < len; ++i) + s.syncAsByte(_parameters[i]); } /*------------------------------------------------------------------------*/ -void MazeEvents::synchronize(Common::SeekableReadStream &s) { +void MazeEvents::synchronize(XeenSerializer &s) { MazeEvent e; - clear(); - while (!s.eos()) { - e.synchronize(s); - push_back(e); + if (s.isLoading()) { + clear(); + while (!s.finished()) { + e.synchronize(s); + push_back(e); + } + } else { + for (uint i = 0; i < size(); ++i) + (*this).operator[](i).synchronize(s); } } |