[Scummvm-cvs-logs] scummvm master -> 5d8bbc2f48a5c736fbeeb42b31b3fa6e453cc5e1

Strangerke Strangerke at scummvm.org
Tue Sep 13 00:12:18 CEST 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
5d8bbc2f48 CGE: Remove IoBuf and CFile


Commit: 5d8bbc2f48a5c736fbeeb42b31b3fa6e453cc5e1
    https://github.com/scummvm/scummvm/commit/5d8bbc2f48a5c736fbeeb42b31b3fa6e453cc5e1
Author: Strangerke (strangerke at scummvm.org)
Date: 2011-09-12T15:07:00-07:00

Commit Message:
CGE: Remove IoBuf and CFile

Changed paths:
    engines/cge/cge.cpp
    engines/cge/cge_main.cpp
    engines/cge/fileio.cpp
    engines/cge/fileio.h



diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp
index ade3071..a5967da 100644
--- a/engines/cge/cge.cpp
+++ b/engines/cge/cge.cpp
@@ -79,7 +79,7 @@ void CGEEngine::init() {
 	_miniShp = NULL;
 	_miniShpList = NULL;
 	_sprite = NULL;
-	_dat = new CFile(kDatName, XCrypt);
+	_dat = new IoHand(kDatName, XCrypt);
 	_cat = new BtFile(kCatName, XCrypt);
 
 	// Create debugger console
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index e56fad5..e35e5c6 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -72,7 +72,7 @@ Snail *_snail_;
 
 Fx *_fx;
 Sound *_sound;
-CFile *_dat;
+IoHand *_dat;
 BtFile *_cat;
 
 // 0.75 - 17II95  - full sound support
diff --git a/engines/cge/fileio.cpp b/engines/cge/fileio.cpp
index 888437c..5c63d41 100644
--- a/engines/cge/fileio.cpp
+++ b/engines/cge/fileio.cpp
@@ -79,152 +79,6 @@ long IoHand::size() {
 }
 
 /*-----------------------------------------------------------------------
- * IoBuf
- *-----------------------------------------------------------------------*/
-IoBuf::IoBuf(Crypt *crypt)
-	: IoHand(crypt),
-	  _bufMark(0),
-	  _ptr(0),
-	  _lim(0) {
-	debugC(1, kCGEDebugFile, "IoBuf::IoBuf(crypt)");
-
-	_buff = (uint8 *)malloc(sizeof(uint8) * kBufferSize);
-	assert(_buff != NULL);
-}
-
-IoBuf::IoBuf(const char *name, Crypt *crypt)
-	: IoHand(name, crypt),
-	  _bufMark(0),
-	  _ptr(0),
-	  _lim(0) {
-	debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, crypt)", name);
-
-	_buff = (uint8 *)malloc(sizeof(uint8) * kBufferSize);
-	assert(_buff != NULL);
-}
-
-IoBuf::~IoBuf() {
-	debugC(6, kCGEDebugFile, "IoBuf::~IoBuf()");
-	free(_buff);
-}
-
-void IoBuf::readBuf() {
-	debugC(4, kCGEDebugFile, "IoBuf::readBuf()");
-
-	_bufMark = IoHand::mark();
-	_lim = IoHand::read(_buff, kBufferSize);
-	_ptr = 0;
-}
-
-uint16 IoBuf::read(void *buf, uint16 len) {
-	debugC(4, kCGEDebugFile, "IoBuf::read(buf, %d)", len);
-
-	uint16 total = 0;
-	while (len) {
-		if (_ptr >= _lim)
-			readBuf();
-		uint16 n = _lim - _ptr;
-		if (n) {
-			if (len < n)
-				n = len;
-			memcpy(buf, _buff + _ptr, n);
-			buf = (uint8 *)buf + n;
-			len -= n;
-			total += n;
-			_ptr += n;
-		} else
-			break;
-	}
-	return total;
-}
-
-uint16 IoBuf::read(uint8 *buf) {
-	debugC(3, kCGEDebugFile, "IoBuf::read(buf)");
-
-	uint16 total = 0;
-
-	while (total < kLineMaxSize - 2) {
-		if (_ptr >= _lim)
-			readBuf();
-		uint8 *p = _buff + _ptr;
-		uint16 n = _lim - _ptr;
-		if (n) {
-			if (total + n >= kLineMaxSize - 2)
-				n = kLineMaxSize - 2 - total;
-			uint8 *eol = (uint8 *) memchr(p, '\r', n);
-			if (eol)
-				n = (uint16)(eol - p);
-			uint8 *eof = (uint8 *) memchr(p, '\32', n);
-			if (eof) { // end-of-file
-				n = (uint16)(eof - p);
-				_ptr = (uint16)(eof - _buff);
-			}
-			if (n)
-				memcpy(buf, p, n);
-			buf += n;
-			total += n;
-			if (eof)
-				break;
-			_ptr += n;
-			if (eol) {
-				_ptr++;
-				*(buf++) = '\n';
-				total++;
-				if (_ptr >= _lim)
-					readBuf();
-				if (_ptr < _lim)
-					if (_buff[_ptr] == '\n')
-						++_ptr;
-				break;
-			}
-		} else
-			break;
-	}
-	*buf = '\0';
-	return total;
-}
-
-int IoBuf::read() {
-	debugC(1, kCGEDebugFile, "IoBuf::read()");
-
-	if (_ptr >= _lim) {
-		readBuf();
-		if (_lim == 0)
-			return -1;
-	}
-	return _buff[_ptr++];
-}
-
-/*-----------------------------------------------------------------------
- * CFile
- *-----------------------------------------------------------------------*/
-CFile::CFile(const char *name, Crypt *crypt) : IoBuf(name, crypt) {
-	debugC(1, kCGEDebugFile, "CFile::CFile(%s, crypt)", name);
-}
-
-CFile::~CFile() {
-}
-
-long CFile::mark() {
-	debugC(5, kCGEDebugFile, "CFile::mark()");
-
-	return _bufMark + _ptr;
-}
-
-long CFile::seek(long pos) {
-	debugC(1, kCGEDebugFile, "CFile::seek(%ld)", pos);
-
-	if (pos >= _bufMark && pos < _bufMark + _lim) {
-		_ptr = (uint16)(pos - _bufMark);
-		return pos;
-	} else {
-		_lim = 0;
-		_ptr = 0;
-		return _bufMark = IoHand::seek(pos);
-	}
-}
-
-/*-----------------------------------------------------------------------
  * BtPage
  *-----------------------------------------------------------------------*/
 void BtPage::read(Common::ReadStream &s) {
diff --git a/engines/cge/fileio.h b/engines/cge/fileio.h
index 8e5779c..bc4fd0a 100644
--- a/engines/cge/fileio.h
+++ b/engines/cge/fileio.h
@@ -78,31 +78,6 @@ public:
 	long seek(long pos);
 };
 
-class IoBuf : public IoHand {
-protected:
-	uint8 *_buff;
-	uint16 _ptr;
-	uint16 _lim;
-	long _bufMark;
-	virtual void readBuf();
-public:
-	IoBuf(Crypt *crpt);
-	IoBuf(const char *name, Crypt *crpt);
-	virtual ~IoBuf();
-	uint16 read(void *buf, uint16 len);
-	uint16 read(uint8 *buf);
-	int read();
-};
-
-
-class CFile : public IoBuf {
-public:
-	CFile(const char *name, Crypt *crpt);
-	virtual ~CFile();
-	long mark();
-	long seek(long pos);
-};
-
 struct BtPage {
 	Header _header;
 	union {
@@ -148,7 +123,7 @@ public:
 	Common::String readLine();
 };
 
-extern CFile *_dat;
+extern IoHand *_dat;
 extern BtFile *_cat;
 
 } // End of namespace CGE






More information about the Scummvm-git-logs mailing list