diff options
| author | Max Horn | 2009-03-24 11:30:52 +0000 |
|---|---|---|
| committer | Max Horn | 2009-03-24 11:30:52 +0000 |
| commit | 47f9b2eb6d2248e41a58c1e60498c829c41a6317 (patch) | |
| tree | fcf9e0d865fe4b729806b4c58a30f8f933829b79 /common | |
| parent | 48d73ff6bf7f3c25ba9060f7d1717cbf044ff53f (diff) | |
| download | scummvm-rg350-47f9b2eb6d2248e41a58c1e60498c829c41a6317.tar.gz scummvm-rg350-47f9b2eb6d2248e41a58c1e60498c829c41a6317.tar.bz2 scummvm-rg350-47f9b2eb6d2248e41a58c1e60498c829c41a6317.zip | |
cleanup
svn-id: r39658
Diffstat (limited to 'common')
| -rw-r--r-- | common/serializer.h | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/common/serializer.h b/common/serializer.h index 3727c277b3..803807814a 100644 --- a/common/serializer.h +++ b/common/serializer.h @@ -33,7 +33,7 @@ namespace Common { #define SYNC_AS(SUFFIX,TYPE,SIZE) \ - template <class T> \ + template <typename T> \ void syncAs ## SUFFIX(T &val) { \ if (_loadStream) \ val = static_cast<T>(_loadStream->read ## SUFFIX()); \ @@ -57,8 +57,29 @@ public: bool isSaving() { return (_saveStream != 0); } bool isLoading() { return (_loadStream != 0); } + /** + * Return the total number of bytes synced so far. + */ uint bytesSynced() const { return _bytesSynced; } + + /** + * Skip a number of bytes in the data stream. + * This is useful to skip obsolete fields in old savestates. + */ + void skip(uint32 size) { + _bytesSynced += size; + if (_loadStream) + _loadStream->skip(size); + else { + while (size--) + _saveStream->writeByte(0); + } + } + + /** + * Sync a block of arbitrary fixed-length data. + */ void syncBytes(byte *buf, uint32 size) { if (_loadStream) _loadStream->read(buf, size); @@ -93,16 +114,6 @@ public: syncBytes((byte *)buf, size); } - void skip(uint32 size) { - _bytesSynced += size; - if (_loadStream) - _loadStream->skip(size); - else { - while (size--) - _saveStream->writeByte(0); - } - } - SYNC_AS(Byte, byte, 1) SYNC_AS(Uint16LE, uint16, 2) |
