From 925f41b9c4055d39498c61c8f22388176ee25cce Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 20 Jun 2013 17:21:37 -0400 Subject: FULLPIPE: Made MfcArchive work with both files and archives --- engines/fullpipe/scene.cpp | 7 +++++-- engines/fullpipe/utils.cpp | 10 +++++++--- engines/fullpipe/utils.h | 12 ++++++++++-- 3 files changed, 22 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp index 96ca7c05e6..887647d347 100644 --- a/engines/fullpipe/scene.cpp +++ b/engines/fullpipe/scene.cpp @@ -92,19 +92,22 @@ void SceneTag::loadScene() { _scene = new Scene(); - //_scene->load(*file); + MfcArchive archive(file); + + _scene->load(archive); delete file; free(fname); free(archname); - } Scene::Scene() { } bool Scene::load(MfcArchive &file) { + debug(0, "Scene::load"); + return true; } diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 26c03ceeea..468d03b6f9 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -30,12 +30,14 @@ namespace Fullpipe { bool CObject::loadFile(const char *fname) { - MfcArchive file; + Common::File file; if (!file.open(fname)) return false; - return load(file); + MfcArchive archive(&file); + + return load(archive); } bool CObList::load(MfcArchive &file) { @@ -201,7 +203,7 @@ static CObject *createObject(int objectId) { return 0; } -MfcArchive::MfcArchive() { +MfcArchive::MfcArchive(Common::SeekableReadStream *stream) { for (int i = 0; classMap[i].name; i++) { _classMap[classMap[i].name] = classMap[i].id; } @@ -209,6 +211,8 @@ MfcArchive::MfcArchive() { _lastIndex = 1; _level = 0; + _stream = stream; + _objectMap.push_back(0); _objectIdMap.push_back(kNullObject); } diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h index 409c5ded1a..b349fc305d 100644 --- a/engines/fullpipe/utils.h +++ b/engines/fullpipe/utils.h @@ -33,7 +33,7 @@ class CObject; typedef Common::HashMap ClassMap; -class MfcArchive : public Common::File { +class MfcArchive : public Common::SeekableReadStream { ClassMap _classMap; Common::Array _objectMap; Common::Array _objectIdMap; @@ -41,8 +41,10 @@ class MfcArchive : public Common::File { int _lastIndex; int _level; + Common::SeekableReadStream *_stream; + public: - MfcArchive(); + MfcArchive(Common::SeekableReadStream *file); char *readPascalString(bool twoByte = false); int readCount(); @@ -53,6 +55,12 @@ class MfcArchive : public Common::File { void incLevel() { _level++; } void decLevel() { _level--; } int getLevel() { return _level; } + + virtual bool eos() const { return _stream->eos(); } + virtual uint32 read(void *dataPtr, uint32 dataSize) { return _stream->read(dataPtr, dataSize); } + virtual int32 pos() const { return _stream->pos(); } + virtual int32 size() const { return _stream->size(); } + virtual bool seek(int32 offset, int whence = SEEK_SET) { return _stream->seek(offset, whence); } }; class CObject { -- cgit v1.2.3