diff options
author | richiesams | 2013-09-03 23:58:25 -0500 |
---|---|---|
committer | richiesams | 2013-09-04 00:16:45 -0500 |
commit | 644af30df572f4965d63e1dba77c574a1d5ad69a (patch) | |
tree | f5b6cad145668f96b2a93b1ae0f633c7500dd263 /engines | |
parent | ac578bf9b7b9c58dbaad58c874517b7af45dfa3f (diff) | |
download | scummvm-rg350-644af30df572f4965d63e1dba77c574a1d5ad69a.tar.gz scummvm-rg350-644af30df572f4965d63e1dba77c574a1d5ad69a.tar.bz2 scummvm-rg350-644af30df572f4965d63e1dba77c574a1d5ad69a.zip |
ZVISION: Create ScriptManager state table serialization methods
Diffstat (limited to 'engines')
-rw-r--r-- | engines/zvision/script_manager.cpp | 24 | ||||
-rw-r--r-- | engines/zvision/script_manager.h | 2 |
2 files changed, 26 insertions, 0 deletions
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index 6330e206be..25cbc6d285 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -25,11 +25,13 @@ #include "common/algorithm.h" #include "common/hashmap.h" #include "common/debug.h" +#include "common/stream.h" #include "zvision/zvision.h" #include "zvision/script_manager.h" #include "zvision/render_manager.h" #include "zvision/cursor_manager.h" +#include "zvision/save_manager.h" #include "zvision/actions.h" #include "zvision/action_node.h" #include "zvision/utility.h" @@ -336,6 +338,28 @@ void ScriptManager::changeLocation(char world, char room, char node, char view, _currentLocation.offset = offset; } +void ScriptManager::serializeStateTable(Common::WriteStream *stream) { + // Write the number of state value entries + stream->writeUint32LE(_globalState.size()); + + for (Common::HashMap<uint32, uint32>::iterator iter = _globalState.begin(); iter != _globalState.end(); iter++) { + // Write out the key/value pair + stream->writeUint32LE((*iter)._key); + stream->writeUint32LE((*iter)._value); + } +} + +void ScriptManager::deserializeStateTable(Common::SeekableReadStream *stream) { + // Read the number of key/value pairs + uint32 numberOfPairs = stream->readUint32LE(); + + for (uint32 i = 0; i < numberOfPairs; i++) { + uint32 key = stream->readUint32LE(); + uint32 value = stream->readUint32LE(); + setStateValue(key, value); + } +} + Location ScriptManager::getCurrentLocation() const { Location location = _currentLocation; location.offset = _engine->getRenderManager()->getCurrentBackgroundOffset(); diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 96123a8468..c5377504a8 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -110,6 +110,8 @@ public: void changeLocation(char world, char room, char node, char view, uint32 offset); + void serializeStateTable(Common::WriteStream *stream); + void deserializeStateTable(Common::SeekableReadStream *stream); Location getCurrentLocation() const; private: |