diff options
author | upthorn | 2012-05-29 12:49:03 -0700 |
---|---|---|
committer | angstsmurf | 2016-10-18 02:09:59 +0200 |
commit | 027bab88fba3187c2fcf2211d0aba5f6cec09a6c (patch) | |
tree | de4a985fc4f72943582c02719bf28729806720c0 /engines/composer | |
parent | 1f1928c9ac41705dcd82416a62d9efde370d8d8a (diff) | |
download | scummvm-rg350-027bab88fba3187c2fcf2211d0aba5f6cec09a6c.tar.gz scummvm-rg350-027bab88fba3187c2fcf2211d0aba5f6cec09a6c.tar.bz2 scummvm-rg350-027bab88fba3187c2fcf2211d0aba5f6cec09a6c.zip |
COMPOSER: Added support for saving/loading in V1 games.
Diffstat (limited to 'engines/composer')
-rw-r--r-- | engines/composer/composer.cpp | 7 | ||||
-rw-r--r-- | engines/composer/composer.h | 3 | ||||
-rw-r--r-- | engines/composer/resource.cpp | 16 | ||||
-rw-r--r-- | engines/composer/resource.h | 11 | ||||
-rw-r--r-- | engines/composer/saveload.cpp | 55 |
5 files changed, 57 insertions, 35 deletions
diff --git a/engines/composer/composer.cpp b/engines/composer/composer.cpp index 73d97e100d..2ef6acc305 100644 --- a/engines/composer/composer.cpp +++ b/engines/composer/composer.cpp @@ -378,7 +378,9 @@ void ComposerEngine::loadLibrary(uint id) { } Common::String filename; - +#ifdef SAVING_ANYWHERE + Common::String oldGroup = _bookGroup; +#endif if (getGameType() == GType_ComposerV1) { if (!id || _bookGroup.empty()) filename = getStringFromConfig("Common", "StartPage"); @@ -412,6 +414,9 @@ void ComposerEngine::loadLibrary(uint id) { Library library; library._id = id; +#ifdef SAVING_ANYWHERE + library._group = oldGroup; +#endif library._archive = new ComposerArchive(); if (!library._archive->openFile(filename)) error("failed to open '%s'", filename.c_str()); diff --git a/engines/composer/composer.h b/engines/composer/composer.h index b570d16229..82457be37b 100644 --- a/engines/composer/composer.h +++ b/engines/composer/composer.h @@ -114,6 +114,9 @@ struct Library { uint _id; Archive *_archive; +#ifdef SAVING_ANYWHERE + Common::String _group; +#endif Common::List<Button> _buttons; Common::List<KeyboardHandler> _keyboardHandlers; }; diff --git a/engines/composer/resource.cpp b/engines/composer/resource.cpp index 063ee9cb14..8192da936b 100644 --- a/engines/composer/resource.cpp +++ b/engines/composer/resource.cpp @@ -263,10 +263,6 @@ Pipe::~Pipe() { void Pipe::nextFrame() { if (_offset == (uint)_stream->size()) return; -#ifdef SAVING_ANYWHERE - _bufferedResources.push_back(_currBufferedResources); -#endif - _currBufferedResources.clear(); _stream->seek(_offset, SEEK_SET); @@ -322,7 +318,11 @@ Common::SeekableReadStream *Pipe::getResource(uint32 tag, uint16 id, bool buffer if (buffering) { _types[tag].erase(id); #ifdef SAVING_ANYWHERE - _currBufferedResources[tag].push_back(id); + bool found = false; + for (Common::List<uint16>::const_iterator i = _bufferedResources[tag].begin(); !found && (i != _bufferedResources[tag].end()); i++) + if ((*i) == id) found = true; + if (!found) + _bufferedResources[tag].push_back(id); #endif } return stream; @@ -344,7 +344,11 @@ Common::SeekableReadStream *Pipe::getResource(uint32 tag, uint16 id, bool buffer if (buffering) { _types[tag].erase(id); #ifdef SAVING_ANYWHERE - _currBufferedResources[tag].push_back(id); + bool found = false; + for (Common::List<uint16>::const_iterator i = _bufferedResources[tag].begin(); !found && (i != _bufferedResources[tag].end()); i++) + if ((*i) == id) found = true; + if (!found) + _bufferedResources[tag].push_back(id); #endif } return new Common::MemoryReadStream(buffer, size, DisposeAfterUse::YES); diff --git a/engines/composer/resource.h b/engines/composer/resource.h index 6383a2fd78..9e297e132a 100644 --- a/engines/composer/resource.h +++ b/engines/composer/resource.h @@ -118,10 +118,10 @@ public: virtual const Common::Array<uint16> *getScripts() { return NULL; } #ifdef SAVING_ANYWHERE uint16 getPipeId() const { return _pipeId; } - uint32 getOffset() const { return _offset; } - void setOffset(uint32 offset) { while (_offset < offset) nextFrame(); } + virtual uint32 getOffset() const { return _offset; } + virtual void setOffset(uint32 offset) { while (_offset < offset) nextFrame(); } typedef Common::HashMap<uint32, Common::List<uint16> > DelMap; - Common::Array<DelMap> _bufferedResources; + DelMap _bufferedResources; #endif protected: @@ -132,7 +132,6 @@ protected: TypeMap _types; #ifdef SAVING_ANYWHERE uint16 _pipeId; - DelMap _currBufferedResources; #endif uint32 _offset; @@ -144,6 +143,10 @@ public: void nextFrame(); const Common::Array<uint16> *getScripts() { return &_scripts; } +#ifdef SAVING_ANYWHERE + uint32 getOffset() const { return _currFrame; } + void setOffset(uint32 offset) { while (_currFrame < offset) nextFrame(); } +#endif protected: uint32 _currFrame, _numFrames; diff --git a/engines/composer/saveload.cpp b/engines/composer/saveload.cpp index c959f38419..ed26616f39 100644 --- a/engines/composer/saveload.cpp +++ b/engines/composer/saveload.cpp @@ -62,7 +62,6 @@ Common::Error ComposerEngine::loadGameState(int slot) { _currentTime += timeDelta; ser.syncAsUint32LE(_lastTime); _lastTime += timeDelta; - ser.syncString(_bookGroup); Common::Array<uint16> libIds; for (Common::List<Library>::iterator i = _libraries.begin(); i != _libraries.end(); i++) libIds.push_back((*i)._id); @@ -72,8 +71,10 @@ Common::Error ComposerEngine::loadGameState(int slot) { for (uint32 i = tmp; i > 0; i--) { uint16 id; ser.syncAsUint16LE(id); + ser.syncString(_bookGroup); loadLibrary(id); } + ser.syncString(_bookGroup); _pendingPageChanges.clear(); ser.syncAsUint32LE(tmp); @@ -106,11 +107,13 @@ Common::Error ComposerEngine::loadGameState(int slot) { ser.syncAsUint32LE(tmp); for (uint32 i = tmp; i > 0; i--) { uint16 id; - uint32 delay; + uint32 pos, delay; + ser.syncAsUint32LE(pos); ser.syncAsUint16LE(id); ser.syncAsUint32LE(delay); OldScript *oTmp = new OldScript(id, getResource(ID_SCRP, id)); oTmp->_currDelay = delay; + oTmp->_stream->seek(pos, SEEK_SET); _oldScripts.push_back(oTmp); } _queuedScripts.clear(); @@ -148,25 +151,29 @@ Common::Error ComposerEngine::loadGameState(int slot) { uint32 offset; ser.syncAsUint16LE(id); ser.syncAsUint32LE(offset); - Common::SeekableReadStream *stream = getResource(ID_ANIM, id); - Pipe *pipe = new Pipe(stream, id); + Pipe *pipe; + Common::SeekableReadStream *stream; + if (getGameType() == GType_ComposerV1) { + stream = getResource(ID_PIPE, id); + pipe = new OldPipe(stream, id); + } else { + stream = getResource(ID_ANIM, id); + pipe = new Pipe(stream, id); + } _pipes.push_front(pipe); _pipeStreams.push_back(stream); + pipe->setOffset(offset); ser.syncAsUint32LE(tmp); for (uint32 j = tmp; j > 0; j--) { + uint32 tag; + ser.syncAsUint32LE(tag); ser.syncAsUint32LE(tmp); for (uint32 k = tmp; k > 0; k--) { - uint32 tag; - ser.syncAsUint32LE(tag); - ser.syncAsUint32LE(tmp); - for (uint32 l = tmp; l > 0; l--) { - ser.syncAsUint16LE(id); + ser.syncAsUint16LE(id); + if (pipe->hasResource(tag, id)) pipe->getResource(tag, id, true); - } } - pipe->nextFrame(); } - pipe->setOffset(offset); } for (Common::List<Animation *>::iterator i = _anims.begin(); i != _anims.end(); i++) { @@ -298,13 +305,15 @@ Common::Error ComposerEngine::saveGameState(int slot, const Common::String &desc ser.syncAsUint32LE(tmp); ser.syncAsUint32LE(_currentTime); ser.syncAsUint32LE(_lastTime); - ser.syncString(_bookGroup); tmp = _libraries.size(); ser.syncAsUint32LE(tmp); for (Common::List<Library>::const_iterator i = _libraries.reverse_begin(); i != _libraries.end(); i--) { uint16 tmp16 = (*i)._id; + Common::String tmps = (*i)._group; ser.syncAsUint16LE(tmp16); + ser.syncString(tmps); } + ser.syncString(_bookGroup); tmp = _pendingPageChanges.size(); ser.syncAsUint32LE(tmp); for (Common::Array<PendingPageChange>::const_iterator i = _pendingPageChanges.begin(); i != _pendingPageChanges.end(); i++) { @@ -328,6 +337,8 @@ Common::Error ComposerEngine::saveGameState(int slot, const Common::String &desc tmp = _oldScripts.size(); ser.syncAsUint32LE(tmp); for (Common::List<OldScript *>::const_iterator i = _oldScripts.begin(); i != _oldScripts.end(); i++) { + tmp = (*i)->_stream->pos(); + ser.syncAsUint32LE(tmp); uint16 tmp16 = (*i)->_id; tmp = (*i)->_currDelay; ser.syncAsUint16LE(tmp16); @@ -363,18 +374,14 @@ Common::Error ComposerEngine::saveGameState(int slot, const Common::String &desc ser.syncAsUint32LE(tmp); tmp = (*i)->_bufferedResources.size(); ser.syncAsUint32LE(tmp); - for (Common::Array<Pipe::DelMap>::const_iterator j = (*i)->_bufferedResources.begin(); j != (*i)->_bufferedResources.end(); j++) { - tmp = (*j).size(); + for (Pipe::DelMap::const_iterator j = (*i)->_bufferedResources.begin(); j != (*i)->_bufferedResources.end(); j++) { + tmp = (*j)._key; + ser.syncAsUint32LE(tmp); + tmp = (*j)._value.size(); ser.syncAsUint32LE(tmp); - for (Pipe::DelMap::const_iterator k = (*j).begin(); k != (*j).end(); k++) { - tmp = (*k)._key; - ser.syncAsUint32LE(tmp); - tmp = (*k)._value.size(); - ser.syncAsUint32LE(tmp); - for (Common::List<uint16>::const_iterator l = (*k)._value.begin(); l != (*k)._value.end(); l++) { - tmp16 = (*l); - ser.syncAsUint16LE(tmp16); - } + for (Common::List<uint16>::const_iterator k = (*j)._value.begin(); k != (*j)._value.end(); k++) { + tmp16 = (*k); + ser.syncAsUint16LE(tmp16); } } } |