From 15d16b94a722533375b5dba1105d7d2be7db62bb Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 13 Sep 2008 20:22:52 +0000 Subject: SCUMM: Merged class Chunk & FileChunk svn-id: r34517 --- engines/scumm/smush/chunk.cpp | 18 ++++++++++-------- engines/scumm/smush/chunk.h | 29 ++++++++++------------------- engines/scumm/smush/smush_player.cpp | 2 +- engines/scumm/smush/smush_player.h | 2 +- 4 files changed, 22 insertions(+), 29 deletions(-) diff --git a/engines/scumm/smush/chunk.cpp b/engines/scumm/smush/chunk.cpp index 2a797d459b..aa7bb4a9df 100644 --- a/engines/scumm/smush/chunk.cpp +++ b/engines/scumm/smush/chunk.cpp @@ -66,7 +66,8 @@ bool Chunk::seek(int32 delta, int dir) { return true; } -FileChunk::FileChunk(BaseScummFile *data, int offset) { +Chunk::Chunk(BaseScummFile *data, int offset) + : _type(0), _size(0), _curPos(0) { _data = data; _deleteData = false; @@ -77,11 +78,12 @@ FileChunk::FileChunk(BaseScummFile *data, int offset) { _curPos = 0; } -FileChunk::FileChunk(const Common::String &name, int offset) { +Chunk::Chunk(const Common::String &name, int offset) + : _type(0), _size(0), _curPos(0) { _data = new ScummFile(); _deleteData = true; if (!g_scumm->openFile(*_data, name)) - error("FileChunk: Unable to open file %s", name.c_str()); + error("Chunk: Unable to open file %s", name.c_str()); _data->seek(offset, SEEK_SET); _type = _data->readUint32BE(); @@ -91,22 +93,22 @@ FileChunk::FileChunk(const Common::String &name, int offset) { _name = name; } -FileChunk::~FileChunk() { +Chunk::~Chunk() { if (_deleteData) delete _data; } -Chunk *FileChunk::subBlock() { - FileChunk *ptr = new FileChunk(_data, _offset + _curPos); +Chunk *Chunk::subBlock() { + Chunk *ptr = new Chunk(_data, _offset + _curPos); skip(sizeof(Chunk::type) + sizeof(uint32) + ptr->size()); return ptr; } -void FileChunk::reseek() { +void Chunk::reseek() { _data->seek(_offset + _curPos, SEEK_SET); } -uint32 FileChunk::read(void *buffer, uint32 dataSize) { +uint32 Chunk::read(void *buffer, uint32 dataSize) { if (dataSize <= 0 || (_curPos + dataSize) > _size) error("invalid buffer read request"); diff --git a/engines/scumm/smush/chunk.h b/engines/scumm/smush/chunk.h index 76ea56c12c..d1e6413978 100644 --- a/engines/scumm/smush/chunk.h +++ b/engines/scumm/smush/chunk.h @@ -34,7 +34,6 @@ namespace Scumm { class BaseScummFile; -// Common functionality for concrete chunks (FileChunk, MemoryChunk) class Chunk : public Common::SeekableReadStream { public: typedef uint32 type; @@ -45,32 +44,24 @@ protected: uint32 _curPos; Common::String _name; - Chunk() : _type(0), _size(0), _curPos(0) {} + BaseScummFile *_data; + bool _deleteData; + uint32 _offset; + Chunk(BaseScummFile *data, int offset); public: + Chunk(const Common::String &name, int offset = 0); + virtual ~Chunk(); + Chunk::type getType() const { return _type; } + Chunk *subBlock(); + void reseek(); + int32 size() const { return _size; } bool eos() const { return _curPos >= _size; } int32 pos() const { return _curPos; } bool seek(int32 delta, int dir); - - virtual Chunk *subBlock() = 0; - virtual void reseek() = 0; -}; - -class FileChunk : public Chunk { -private: - BaseScummFile *_data; - bool _deleteData; - uint32 _offset; - - FileChunk(BaseScummFile *data, int offset); -public: - FileChunk(const Common::String &name, int offset = 0); - virtual ~FileChunk(); - Chunk *subBlock(); - void reseek(); uint32 read(void *buffer, uint32 size); }; diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp index 9100d95e5d..70359cfcb3 100644 --- a/engines/scumm/smush/smush_player.cpp +++ b/engines/scumm/smush/smush_player.cpp @@ -992,7 +992,7 @@ void SmushPlayer::parseNextFrame() { if (_seekFile.size() > 0) { delete _base; - _base = new FileChunk(_seekFile); + _base = new Chunk(_seekFile); if (_seekPos > 0) { assert(_seekPos > 8); diff --git a/engines/scumm/smush/smush_player.h b/engines/scumm/smush/smush_player.h index 29a2397d58..d725a5539a 100644 --- a/engines/scumm/smush/smush_player.h +++ b/engines/scumm/smush/smush_player.h @@ -51,7 +51,7 @@ private: StringResource *_strings; Codec37Decoder *_codec37; Codec47Decoder *_codec47; - FileChunk *_base; + Chunk *_base; byte *_frameBuffer; byte *_specialBuffer; -- cgit v1.2.3