diff options
author | Paul Gilbert | 2007-05-07 12:10:32 +0000 |
---|---|---|
committer | Paul Gilbert | 2007-05-07 12:10:32 +0000 |
commit | d2e56f7b666f2733ca21d6f74182f8e3ce1536cb (patch) | |
tree | cd3affb540525abb5d35e6e6c6a793b2d4b88035 /engines/lure | |
parent | e2c40aaee6282a8d4db82776242c41f1ff6b016c (diff) | |
download | scummvm-rg350-d2e56f7b666f2733ca21d6f74182f8e3ce1536cb.tar.gz scummvm-rg350-d2e56f7b666f2733ca21d6f74182f8e3ce1536cb.tar.bz2 scummvm-rg350-d2e56f7b666f2733ca21d6f74182f8e3ce1536cb.zip |
Added saving of room exit join data in savefiles
svn-id: r26776
Diffstat (limited to 'engines/lure')
-rw-r--r-- | engines/lure/res.cpp | 3 | ||||
-rw-r--r-- | engines/lure/res_struct.cpp | 48 | ||||
-rw-r--r-- | engines/lure/res_struct.h | 6 |
3 files changed, 51 insertions, 6 deletions
diff --git a/engines/lure/res.cpp b/engines/lure/res.cpp index c6517a3970..f52cd8b0d0 100644 --- a/engines/lure/res.cpp +++ b/engines/lure/res.cpp @@ -649,6 +649,7 @@ void Resources::saveToStream(Common::WriteStream *stream) _fieldList.saveToStream(stream); _randomActions.saveToStream(stream); _barmanLists.saveToStream(stream); + _exitJoins.saveToStream(stream); } void Resources::loadFromStream(Common::ReadStream *stream) { @@ -662,6 +663,8 @@ void Resources::loadFromStream(Common::ReadStream *stream) { _randomActions.loadFromStream(stream); debugC(ERROR_DETAILED, kLureDebugScripts, "Loading barman lists"); _barmanLists.loadFromStream(stream); + debugC(ERROR_DETAILED, kLureDebugScripts, "Loading room exit joins"); + _exitJoins.loadFromStream(stream); debugC(ERROR_DETAILED, kLureDebugScripts, "Finished loading"); } diff --git a/engines/lure/res_struct.cpp b/engines/lure/res_struct.cpp index e1cf32811a..06dd33ef72 100644 --- a/engines/lure/res_struct.cpp +++ b/engines/lure/res_struct.cpp @@ -211,14 +211,14 @@ void RoomPathsData::decompress(RoomPathsDecompressedData &dataOut, int character uint16 *pOut = &dataOut[DECODED_PATHS_WIDTH * DECODED_PATHS_HEIGHT - 1]; byte v; int paddingCtr; - int charWidth = (characterWidth - 1) >> 3; + int charWidth = characterWidth >> 3; int charCtr = 0; bool charState = false; // Handle padding for last row, including left/right edge padding, as // well as the right column of the second row for (paddingCtr = 0; paddingCtr < (DECODED_PATHS_WIDTH + 1); ++paddingCtr) - *pOut-- = 0; + *pOut-- = 0xffff; for (int y = 0; y < ROOM_PATHS_HEIGHT; ++y) { charState = false; @@ -258,15 +258,15 @@ void RoomPathsData::decompress(RoomPathsDecompressedData &dataOut, int character } // Store 2 words to allow off-screen row-start/prior row end - *pOut-- = 0; - *pOut-- = 0; + *pOut-- = 0xffff; + *pOut-- = 0xffff; charState = false; } // Handle padding for final top row - no need for end column, as end of prior // row provided padding for it for (paddingCtr = 0; paddingCtr < (ROOM_PATHS_WIDTH + 1); ++paddingCtr) - *pOut-- = 0; + *pOut-- = 0xffff; } // Room exit joins class @@ -285,6 +285,44 @@ RoomExitJoinData::RoomExitJoinData(RoomExitJoinResource *rec) { blocked = rec->blocked; } +void RoomExitJoinList::saveToStream(WriteStream *stream) { + for (RoomExitJoinList::iterator i = begin(); i != end(); ++i) { + RoomExitJoinData *rec = *i; + stream->writeUint16LE(rec->hotspot1Id); + stream->writeUint16LE(rec->hotspot2Id); + stream->writeByte(rec->h1CurrentFrame); + stream->writeByte(rec->h1DestFrame); + stream->writeByte(rec->h2CurrentFrame); + stream->writeByte(rec->h2DestFrame); + stream->writeByte(rec->blocked); + } + + // Write end of list marker + stream->writeUint16LE(0xffff); +} + +void RoomExitJoinList::loadFromStream(ReadStream *stream) { + for (RoomExitJoinList::iterator i = begin(); i != end(); ++i) { + RoomExitJoinData *rec = *i; + + uint16 hotspot1Id = stream->readUint16LE(); + if (hotspot1Id == 0xffff) error("Invalid room exit join list"); + uint16 hotspot2Id = stream->readUint16LE(); + + if ((rec->hotspot1Id != hotspot1Id) || (rec->hotspot2Id != hotspot2Id)) + break; + + rec->h1CurrentFrame = stream->readByte(); + rec->h1DestFrame = stream->readByte(); + rec->h2CurrentFrame = stream->readByte(); + rec->h2DestFrame = stream->readByte(); + rec->blocked = stream->readByte(); + } + + // Read final end of list marker + stream->readUint16LE(); +} + // Hotspot action record HotspotActionData::HotspotActionData(HotspotActionResource *rec) { diff --git a/engines/lure/res_struct.h b/engines/lure/res_struct.h index c49de0fee2..b002a2af66 100644 --- a/engines/lure/res_struct.h +++ b/engines/lure/res_struct.h @@ -359,7 +359,11 @@ public: uint32 unknown; }; -typedef ManagedList<RoomExitJoinData *> RoomExitJoinList; +class RoomExitJoinList: public ManagedList<RoomExitJoinData *> { +public: + void saveToStream(WriteStream *stream); + void loadFromStream(ReadStream *stream); +}; class HotspotActionData { public: |