mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-21 09:21:08 +00:00
ZVISION: Create ScriptManager state table serialization methods
This commit is contained in:
parent
ac578bf9b7
commit
644af30df5
@ -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();
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user