diff options
author | Paul Gilbert | 2007-05-20 07:25:53 +0000 |
---|---|---|
committer | Paul Gilbert | 2007-05-20 07:25:53 +0000 |
commit | 4a40ecb4dfe21c4e52ec5d73183369c365a5a62c (patch) | |
tree | 27edddd0ecc6f54b357b6983d23924b69e2aefdf /engines/lure | |
parent | 8be618fb47bdd413db8b0dc30e67a9443038c944 (diff) | |
download | scummvm-rg350-4a40ecb4dfe21c4e52ec5d73183369c365a5a62c.tar.gz scummvm-rg350-4a40ecb4dfe21c4e52ec5d73183369c365a5a62c.tar.bz2 scummvm-rg350-4a40ecb4dfe21c4e52ec5d73183369c365a5a62c.zip |
Added saving of the room walkable paths
svn-id: r26883
Diffstat (limited to 'engines/lure')
-rw-r--r-- | engines/lure/res.cpp | 3 | ||||
-rw-r--r-- | engines/lure/res_struct.cpp | 23 | ||||
-rw-r--r-- | engines/lure/res_struct.h | 7 |
3 files changed, 32 insertions, 1 deletions
diff --git a/engines/lure/res.cpp b/engines/lure/res.cpp index f52cd8b0d0..5782ccdecb 100644 --- a/engines/lure/res.cpp +++ b/engines/lure/res.cpp @@ -650,6 +650,7 @@ void Resources::saveToStream(Common::WriteStream *stream) _randomActions.saveToStream(stream); _barmanLists.saveToStream(stream); _exitJoins.saveToStream(stream); + _roomData.saveToStream(stream); } void Resources::loadFromStream(Common::ReadStream *stream) { @@ -665,6 +666,8 @@ void Resources::loadFromStream(Common::ReadStream *stream) { _barmanLists.loadFromStream(stream); debugC(ERROR_DETAILED, kLureDebugScripts, "Loading room exit joins"); _exitJoins.loadFromStream(stream); + debugC(ERROR_DETAILED, kLureDebugScripts, "Loading walkable paths"); + _roomData.loadFromStream(stream); debugC(ERROR_DETAILED, kLureDebugScripts, "Finished loading"); } diff --git a/engines/lure/res_struct.cpp b/engines/lure/res_struct.cpp index 06dd33ef72..fa220d719a 100644 --- a/engines/lure/res_struct.cpp +++ b/engines/lure/res_struct.cpp @@ -269,6 +269,29 @@ void RoomPathsData::decompress(RoomPathsDecompressedData &dataOut, int character *pOut-- = 0xffff; } +// Room data class + +void RoomDataList::saveToStream(WriteStream *stream) { + RoomDataList::iterator i; + + for (i = begin(); i != end(); ++i) { + RoomData *rec = *i; + const byte *pathData = rec->paths.data(); + stream->write(pathData, ROOM_PATHS_HEIGHT * ROOM_PATHS_WIDTH); + } +} + +void RoomDataList::loadFromStream(ReadStream *stream) { + RoomDataList::iterator i; + byte data[ROOM_PATHS_HEIGHT * ROOM_PATHS_WIDTH]; + + for (i = begin(); i != end(); ++i) { + RoomData *rec = *i; + stream->read(data, ROOM_PATHS_HEIGHT * ROOM_PATHS_WIDTH); + rec->paths.load(data); + } +} + // Room exit joins class RoomExitJoinData::RoomExitJoinData(RoomExitJoinResource *rec) { diff --git a/engines/lure/res_struct.h b/engines/lure/res_struct.h index b002a2af66..f53f8dd9a0 100644 --- a/engines/lure/res_struct.h +++ b/engines/lure/res_struct.h @@ -310,6 +310,7 @@ public: void load(byte *srcData) { memcpy(_data, srcData, ROOM_PATHS_SIZE); } + const byte *data() { return _data; } bool isOccupied(int x, int y); bool isOccupied(int x, int y, int width); void setOccupied(int x, int y, int width); @@ -339,7 +340,11 @@ public: RoomPathsData paths; }; -typedef ManagedList<RoomData *> RoomDataList; +class RoomDataList: public ManagedList<RoomData *> { +public: + void saveToStream(WriteStream *stream); + void loadFromStream(ReadStream *stream); +}; class RoomExitJoinData { public: |