aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2011-09-11 15:07:56 +0200
committerStrangerke2011-09-11 15:07:56 +0200
commit3b9b89a78bf65db18bdc6d0c3a1268c892d3db2c (patch)
treed08faa34c3730d2bb234386ccf33075e9d297612
parentcdba3ac108940e141901f021da890e2ddbda70f0 (diff)
downloadscummvm-rg350-3b9b89a78bf65db18bdc6d0c3a1268c892d3db2c.tar.gz
scummvm-rg350-3b9b89a78bf65db18bdc6d0c3a1268c892d3db2c.tar.bz2
scummvm-rg350-3b9b89a78bf65db18bdc6d0c3a1268c892d3db2c.zip
CGE: Talk now uses EncryptedStream. Clean up of EncryptedStream
-rw-r--r--engines/cge/fileio.cpp16
-rw-r--r--engines/cge/fileio.h9
-rw-r--r--engines/cge/talk.cpp28
-rw-r--r--engines/cge/talk.h2
-rw-r--r--engines/cge/text.cpp8
5 files changed, 41 insertions, 22 deletions
diff --git a/engines/cge/fileio.cpp b/engines/cge/fileio.cpp
index 87a1ffebac..34c7c6510f 100644
--- a/engines/cge/fileio.cpp
+++ b/engines/cge/fileio.cpp
@@ -398,6 +398,22 @@ EncryptedStream::EncryptedStream(const char *name) {
_readStream = new Common::MemoryReadStream(dataBuffer, kp->_size, DisposeAfterUse::YES);
}
+uint32 EncryptedStream::read(void *dataPtr, uint32 dataSize) {
+ return _readStream->read(dataPtr, dataSize);
+}
+
+bool EncryptedStream::err() {
+ return (_error & _readStream->err());
+}
+
+bool EncryptedStream::eos() {
+ return _readStream->eos();
+}
+
+Common::String EncryptedStream::readLine() {
+ return _readStream->readLine();
+}
+
EncryptedStream::~EncryptedStream() {
}
diff --git a/engines/cge/fileio.h b/engines/cge/fileio.h
index 68b9a26d76..1f0756a276 100644
--- a/engines/cge/fileio.h
+++ b/engines/cge/fileio.h
@@ -148,11 +148,16 @@ public:
};
class EncryptedStream {
-public:
+private:
+ Common::SeekableReadStream *_readStream;
bool _error;
+public:
EncryptedStream(const char *name);
~EncryptedStream();
- Common::SeekableReadStream *_readStream;
+ bool err();
+ bool eos();
+ uint32 read(void *dataPtr, uint32 dataSize);
+ Common::String readLine();
};
extern CFile *_dat;
diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp
index 609a4727c9..8fd425d328 100644
--- a/engines/cge/talk.cpp
+++ b/engines/cge/talk.cpp
@@ -36,9 +36,9 @@ namespace CGE {
Font::Font(const char *name) {
_map = (uint8 *)malloc(kMapSize);
_pos = (uint16 *)malloc(kPosSize * sizeof(uint16));
- _wid = (uint8 *)malloc(kWidSize);
+ _widthArr = (uint8 *)malloc(kWidSize);
- assert((_map != NULL) && (_pos != NULL) && (_wid != NULL));
+ assert((_map != NULL) && (_pos != NULL) && (_widthArr != NULL));
mergeExt(_path, name, kFontExt);
load();
}
@@ -46,22 +46,20 @@ Font::Font(const char *name) {
Font::~Font() {
free(_map);
free(_pos);
- free(_wid);
+ free(_widthArr);
}
void Font::load() {
- VFile f(_path);
- if (f._error)
- return;
+ EncryptedStream f = _path;
+ assert(!f.err());
- f.read(_wid, kWidSize);
- if (f._error)
- return;
+ f.read(_widthArr, kWidSize);
+ assert(!f.err());
uint16 p = 0;
for (uint16 i = 0; i < kPosSize; i++) {
_pos[i] = p;
- p += _wid[i];
+ p += _widthArr[i];
}
f.read(_map, p);
}
@@ -71,7 +69,7 @@ uint16 Font::width(const char *text) {
if (!text)
return 0;
while (*text)
- w += _wid[(unsigned char)*(text++)];
+ w += _widthArr[(unsigned char)*(text++)];
return w;
}
@@ -116,7 +114,7 @@ void Talk::update(const char *text) {
mw = k;
k = 2 * hmarg;
} else
- k += _font->_wid[(unsigned char)*p];
+ k += _font->_widthArr[(unsigned char)*p];
}
if (k > mw)
mw = k;
@@ -132,7 +130,7 @@ void Talk::update(const char *text) {
if (*text == '|' || *text == '\n') {
m = _ts[0]->_m + (ln += kFontHigh + kTextLineSpace) * mw + hmarg;
} else {
- int cw = _font->_wid[(unsigned char)*text];
+ int cw = _font->_widthArr[(unsigned char)*text];
uint8 *f = _font->_map + _font->_pos[(unsigned char)*text];
for (int i = 0; i < cw; i++) {
uint8 *pp = m;
@@ -223,7 +221,7 @@ void Talk::putLine(int line, const char *text) {
uint8 *q = v + size;
while (*text) {
- uint16 cw = _font->_wid[(unsigned char)*text], i;
+ uint16 cw = _font->_widthArr[(unsigned char)*text], i;
uint8 *fp = _font->_map + _font->_pos[(unsigned char)*text];
for (i = 0; i < cw; i++) {
@@ -280,7 +278,7 @@ void InfoLine::update(const char *text) {
uint8 *p = v + 2, * q = p + size;
while (*text) {
- uint16 cw = _font->_wid[(unsigned char)*text];
+ uint16 cw = _font->_widthArr[(unsigned char)*text];
uint8 *fp = _font->_map + _font->_pos[(unsigned char)*text];
for (uint16 i = 0; i < cw; i++) {
diff --git a/engines/cge/talk.h b/engines/cge/talk.h
index 6b06e8009c..23ef9c9c07 100644
--- a/engines/cge/talk.h
+++ b/engines/cge/talk.h
@@ -52,7 +52,7 @@ class Font {
char _path[kPathMax];
void load();
public:
- uint8 *_wid;
+ uint8 *_widthArr;
uint16 *_pos;
uint8 *_map;
Font(const char *name);
diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp
index 7e574a00bc..71bb411f11 100644
--- a/engines/cge/text.cpp
+++ b/engines/cge/text.cpp
@@ -60,14 +60,14 @@ Text::~Text() {
int16 Text::count() {
EncryptedStream tf = _fileName;
- if (tf._error)
+ if (tf.err())
return NULL;
Common::String line;
char tmpStr[kLineMax + 1];
int n, count = 0;
- for (line = tf._readStream->readLine(); !tf._readStream->eos(); line = tf._readStream->readLine()) {
+ for (line = tf.readLine(); !tf.eos(); line = tf.readLine()) {
n = line.size();
char *s;
@@ -94,13 +94,13 @@ void Text::clear() {
void Text::load() {
EncryptedStream tf = _fileName;
- assert(!tf._error);
+ assert(!tf.err());
Common::String line;
char tmpStr[kLineMax + 1];
int idx;
- for (idx = 0, line = tf._readStream->readLine(); !tf._readStream->eos(); line = tf._readStream->readLine()) {
+ for (idx = 0, line = tf.readLine(); !tf.eos(); line = tf.readLine()) {
int n = line.size();
char *s;