diff options
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); } } |