From cc9a5ec8abe9b9660177e70cfdbc6fce8b6dfbbf Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 11 Sep 2011 23:57:55 +0200 Subject: CGE: Remove VFile class --- engines/cge/bitmap.cpp | 24 ++++++++++++----------- engines/cge/bitmap.h | 2 +- engines/cge/fileio.cpp | 52 ++++---------------------------------------------- engines/cge/fileio.h | 16 +--------------- 4 files changed, 19 insertions(+), 75 deletions(-) (limited to 'engines/cge') diff --git a/engines/cge/bitmap.cpp b/engines/cge/bitmap.cpp index 3d2ca70868..c54ba09245 100644 --- a/engines/cge/bitmap.cpp +++ b/engines/cge/bitmap.cpp @@ -50,8 +50,10 @@ Bitmap::Bitmap(const char *fname) : _m(NULL), _v(NULL), _map(0) { forceExt(pat, fname, ".VBM"); if (_cat->exist(pat)) { - VFile file(pat); - if ((file._error == 0) && (!loadVBM(&file))) + EncryptedStream file(pat); + if (file.err()) + error("Unable to find VBM [%s]", fname); + if (!loadVBM(&file)) error("Bad VBM [%s]", fname); } else { error("Bad VBM [%s]", fname); @@ -341,27 +343,27 @@ bool Bitmap::solidAt(int16 x, int16 y) { } } -bool Bitmap::loadVBM(VFile *f) { +bool Bitmap::loadVBM(EncryptedStream *f) { debugC(5, kCGEDebugBitmap, "Bitmap::loadVBM(f)"); uint16 p = 0, n = 0; - if (f->_error == 0) + if (!f->err()) f->read((uint8 *)&p, sizeof(p)); p = FROM_LE_16(p); - if (f->_error == 0) + if (!f->err()) f->read((uint8 *)&n, sizeof(n)); n = FROM_LE_16(n); - if (f->_error == 0) + if (!f->err()) f->read((uint8 *)&_w, sizeof(_w)); _w = FROM_LE_16(_w); - if (f->_error == 0) + if (!f->err()) f->read((uint8 *)&_h, sizeof(_h)); _h = FROM_LE_16(_h); - if (f->_error == 0) { + if (!f->err()) { if (p) { if (_pal) { // Read in the palette @@ -375,17 +377,17 @@ bool Bitmap::loadVBM(VFile *f) { _pal[idx]._b = *(srcP + 2); } } else - f->seek(f->mark() + kPalSize); + f->seek(f->pos() + kPalSize); } } if ((_v = new uint8[n]) == NULL) return false; - if (f->_error == 0) + if (!f->err()) f->read(_v, n); _b = (HideDesc *)(_v + n - _h * sizeof(HideDesc)); - return (f->_error == 0); + return (!f->err()); } } // End of namespace CGE diff --git a/engines/cge/bitmap.h b/engines/cge/bitmap.h index fbaeead31e..bc37591399 100644 --- a/engines/cge/bitmap.h +++ b/engines/cge/bitmap.h @@ -50,7 +50,7 @@ struct HideDesc { #include "common/pack-end.h" class Bitmap { - bool loadVBM(VFile *f); + bool loadVBM(EncryptedStream *f); public: static Dac *_pal; uint16 _w; diff --git a/engines/cge/fileio.cpp b/engines/cge/fileio.cpp index 024ea77693..888437c18c 100644 --- a/engines/cge/fileio.cpp +++ b/engines/cge/fileio.cpp @@ -330,54 +330,6 @@ bool BtFile::exist(const char *name) { return scumm_stricmp(find(name)->_key, name) == 0; } -/*----------------------------------------------------------------------- - * VFile - *-----------------------------------------------------------------------*/ -VFile::VFile(const char *name) : IoBuf(NULL) { - debugC(3, kCGEDebugFile, "VFile::VFile(%s)", name); - - if (_dat->_error || _cat->_error) - error("Bad volume data"); - BtKeypack *kp = _cat->find(name); - if (scumm_stricmp(kp->_key, name) != 0) - _error = 1; - _endMark = (_bufMark = _begMark = kp->_mark) + kp->_size; -} - -VFile::~VFile() { -} - -void VFile::readBuf() { - debugC(3, kCGEDebugFile, "VFile::readBuf()"); - - _dat->seek(_bufMark + _lim); - _bufMark = _dat->mark(); - long n = _endMark - _bufMark; - if (n > kBufferSize) - n = kBufferSize; - _lim = _dat->read(_buff, (uint16) n); - _ptr = 0; -} - -long VFile::mark() { - debugC(5, kCGEDebugFile, "VFile::mark()"); - - return (_bufMark + _ptr) - _begMark; -} - -long VFile::size() { - debugC(1, kCGEDebugFile, "VFile::size()"); - - return _endMark - _begMark; -} - -long VFile::seek(long pos) { - debugC(1, kCGEDebugFile, "VFile::seek(%ld)", pos); - - _lim = 0; - return (_bufMark = _begMark + pos); -} - /*----------------------------------------------------------------------- * EncryptedStream *-----------------------------------------------------------------------*/ @@ -422,6 +374,10 @@ int32 EncryptedStream::size() { return _readStream->size(); } +int32 EncryptedStream::pos() { + return _readStream->pos(); +} + EncryptedStream::~EncryptedStream() { } diff --git a/engines/cge/fileio.h b/engines/cge/fileio.h index f6f0a98d54..8e5779cbab 100644 --- a/engines/cge/fileio.h +++ b/engines/cge/fileio.h @@ -132,21 +132,6 @@ public: bool exist(const char *name); }; -class VFile : public IoBuf { -private: - long _begMark; - long _endMark; - - void readBuf(); -public: - VFile(const char *name); - ~VFile(); - - long mark(); - long size(); - long seek(long pos); -}; - class EncryptedStream { private: Common::SeekableReadStream *_readStream; @@ -157,6 +142,7 @@ public: bool err(); bool eos(); bool seek(int32 offset); + int32 pos(); int32 size(); uint32 read(void *dataPtr, uint32 dataSize); Common::String readLine(); -- cgit v1.2.3