diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/cge/btfile.cpp | 6 | ||||
-rw-r--r-- | engines/cge/btfile.h | 2 | ||||
-rw-r--r-- | engines/cge/cfile.cpp | 20 | ||||
-rw-r--r-- | engines/cge/cfile.h | 6 | ||||
-rw-r--r-- | engines/cge/general.cpp | 13 | ||||
-rw-r--r-- | engines/cge/general.h | 10 | ||||
-rw-r--r-- | engines/cge/vol.cpp | 26 | ||||
-rw-r--r-- | engines/cge/vol.h | 2 |
8 files changed, 38 insertions, 47 deletions
diff --git a/engines/cge/btfile.cpp b/engines/cge/btfile.cpp index 449bd6aaad..fd49cd2b12 100644 --- a/engines/cge/btfile.cpp +++ b/engines/cge/btfile.cpp @@ -35,9 +35,9 @@ namespace CGE { -BtFile::BtFile(const char *name, IOMode mode, Crypt *crpt) - : IoHand(name, mode, crpt) { - debugC(1, kCGEDebugFile, "BtFile::BtFile(%s, %d, crpt)", name, mode); +BtFile::BtFile(const char *name, Crypt *crpt) + : IoHand(name, crpt) { + debugC(1, kCGEDebugFile, "BtFile::BtFile(%s, crpt)", name); for (int i = 0; i < kBtLevel; i++) { _buff[i]._page = new BtPage; diff --git a/engines/cge/btfile.h b/engines/cge/btfile.h index 1095324116..19b10c3eed 100644 --- a/engines/cge/btfile.h +++ b/engines/cge/btfile.h @@ -81,7 +81,7 @@ class BtFile : public IoHand { BtPage *getPage(int lev, uint16 pgn); public: - BtFile(const char *name, IOMode mode, Crypt *crpt); + BtFile(const char *name, Crypt *crpt); virtual ~BtFile(); BtKeypack *find(const char *key); BtKeypack *next(); diff --git a/engines/cge/cfile.cpp b/engines/cge/cfile.cpp index f20ab16353..652fecae9a 100644 --- a/engines/cge/cfile.cpp +++ b/engines/cge/cfile.cpp @@ -33,23 +33,23 @@ namespace CGE { -IoBuf::IoBuf(IOMode mode, Crypt *crypt) - : IoHand(mode, crypt), +IoBuf::IoBuf(Crypt *crypt) + : IoHand(crypt), _bufMark(0), _ptr(0), _lim(0) { - debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%d, crypt)", mode); + debugC(1, kCGEDebugFile, "IoBuf::IoBuf(crypt)"); _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); assert(_buff != NULL); } -IoBuf::IoBuf(const char *name, IOMode mode, Crypt *crypt) - : IoHand(name, mode, crypt), +IoBuf::IoBuf(const char *name, Crypt *crypt) + : IoHand(name, crypt), _bufMark(0), _ptr(0), _lim(0) { - debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, %d, crypt)", name, mode); + debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, %d, crypt)", name); _buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize); assert(_buff != NULL); @@ -149,9 +149,9 @@ int IoBuf::read() { uint16 CFile::_maxLineLen = kLineMaxSize; -CFile::CFile(const char *name, IOMode mode, Crypt *crypt) - : IoBuf(name, mode, crypt) { - debugC(1, kCGEDebugFile, "CFile::CFile(%s, %d, crypt)", name, mode); +CFile::CFile(const char *name, Crypt *crypt) + : IoBuf(name, crypt) { + debugC(1, kCGEDebugFile, "CFile::CFile(%s, crypt)", name); } CFile::~CFile() { @@ -160,7 +160,7 @@ CFile::~CFile() { long CFile::mark() { debugC(5, kCGEDebugFile, "CFile::mark()"); - return _bufMark + ((_mode != kModeRead) ? _lim : _ptr); + return _bufMark + _ptr; } long CFile::seek(long pos) { diff --git a/engines/cge/cfile.h b/engines/cge/cfile.h index 39260d2673..f7b45d8ade 100644 --- a/engines/cge/cfile.h +++ b/engines/cge/cfile.h @@ -43,8 +43,8 @@ protected: long _bufMark; virtual void readBuf(); public: - IoBuf(IOMode mode, Crypt *crpt); - IoBuf(const char *name, IOMode mode, Crypt *crpt); + IoBuf(Crypt *crpt); + IoBuf(const char *name, Crypt *crpt); virtual ~IoBuf(); uint16 read(void *buf, uint16 len); uint16 read(uint8 *buf); @@ -55,7 +55,7 @@ public: class CFile : public IoBuf { public: static uint16 _maxLineLen; - CFile(const char *name, IOMode mode, Crypt *crpt); + CFile(const char *name, Crypt *crpt); virtual ~CFile(); long mark(); long seek(long pos); diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index 798749c2bf..a3258e9415 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -202,16 +202,13 @@ char *dwtom(uint32 val, char *str, int radix, int len) { return str; } -IoHand::IoHand(IOMode mode, Crypt *crypt) - : XFile(mode), _crypt(crypt), _seed(kCryptSeed) { +IoHand::IoHand(Crypt *crypt) + : XFile(), _crypt(crypt), _seed(kCryptSeed) { _file = new Common::File(); } -IoHand::IoHand(const char *name, IOMode mode, Crypt *crypt) - : XFile(mode), _crypt(crypt), _seed(kCryptSeed) { - // TODO: Check if WRI and/or UPD modes are needed, and map to a save file - assert(mode == kModeRead); - +IoHand::IoHand(const char *name, Crypt *crypt) + : XFile(), _crypt(crypt), _seed(kCryptSeed) { _file = new Common::File(); _file->open(name); } @@ -222,7 +219,7 @@ IoHand::~IoHand() { } uint16 IoHand::read(void *buf, uint16 len) { - if (_mode == kModeWrite || !_file->isOpen()) + if (!_file->isOpen()) return 0; uint16 bytesRead = _file->read(buf, len); diff --git a/engines/cge/general.h b/engines/cge/general.h index 75a3f3da93..37f492a538 100644 --- a/engines/cge/general.h +++ b/engines/cge/general.h @@ -39,8 +39,6 @@ namespace CGE { #define kCryptSeed 0xA5 -enum IOMode { kModeRead, kModeWrite, kModeUpdate }; - struct Dac { uint8 _r; uint8 _g; @@ -68,11 +66,9 @@ T min(T A, T B) { class XFile { public: - IOMode _mode; uint16 _error; - XFile() : _mode(kModeRead), _error(0) { } - XFile(IOMode mode) : _mode(mode), _error(0) { } + XFile() : _error(0) { } virtual ~XFile() { } virtual uint16 read(void *buf, uint16 len) = 0; virtual long mark() = 0; @@ -93,8 +89,8 @@ protected: uint16 _seed; Crypt *_crypt; public: - IoHand(const char *name, IOMode mode = kModeRead, Crypt crypt = NULL); - IoHand(IOMode mode = kModeRead, Crypt *crypt = NULL); + IoHand(const char *name, Crypt crypt = NULL); + IoHand(Crypt *crypt = NULL); virtual ~IoHand(); static bool exist(const char *name); uint16 read(void *buf, uint16 len); diff --git a/engines/cge/vol.cpp b/engines/cge/vol.cpp index 51dbe4f856..ff0a979b1d 100644 --- a/engines/cge/vol.cpp +++ b/engines/cge/vol.cpp @@ -40,7 +40,7 @@ VFile *VFile::_recent = NULL; /*-----------------------------------------------------------------------*/ -Dat::Dat(): _file(DAT_NAME, kModeRead, CRP) { +Dat::Dat(): _file(DAT_NAME, CRP) { debugC(1, kCGEDebugFile, "Dat::Dat()"); } @@ -50,7 +50,7 @@ void VFile::init() { debugC(1, kCGEDebugFile, "VFile::init()"); _dat = new Dat(); - _cat = new BtFile(CAT_NAME, kModeRead, CRP); + _cat = new BtFile(CAT_NAME, CRP); _recent = NULL; } @@ -59,18 +59,16 @@ void VFile::deinit() { delete _cat; } -VFile::VFile(const char *name, IOMode mode) - : IoBuf(mode, NULL) { - debugC(3, kCGEDebugFile, "VFile::VFile(%s, %d)", name, mode); - - if (mode == kModeRead) { - if (_dat->_file._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(const char *name) + : IoBuf(NULL) { + debugC(3, kCGEDebugFile, "VFile::VFile(%s)", name); + + if (_dat->_file._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() { diff --git a/engines/cge/vol.h b/engines/cge/vol.h index d85faa4f4a..d7184ba064 100644 --- a/engines/cge/vol.h +++ b/engines/cge/vol.h @@ -59,7 +59,7 @@ private: void readBuf(); public: - VFile(const char *name, IOMode mode = kModeRead); + VFile(const char *name); ~VFile(); static void init(); |