CGE: Talk now uses EncryptedStream. Clean up of EncryptedStream
This commit is contained in:
parent
cdba3ac108
commit
3b9b89a78b
5 changed files with 41 additions and 22 deletions
|
@ -398,6 +398,22 @@ EncryptedStream::EncryptedStream(const char *name) {
|
||||||
_readStream = new Common::MemoryReadStream(dataBuffer, kp->_size, DisposeAfterUse::YES);
|
_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() {
|
EncryptedStream::~EncryptedStream() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,11 +148,16 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
class EncryptedStream {
|
class EncryptedStream {
|
||||||
public:
|
private:
|
||||||
|
Common::SeekableReadStream *_readStream;
|
||||||
bool _error;
|
bool _error;
|
||||||
|
public:
|
||||||
EncryptedStream(const char *name);
|
EncryptedStream(const char *name);
|
||||||
~EncryptedStream();
|
~EncryptedStream();
|
||||||
Common::SeekableReadStream *_readStream;
|
bool err();
|
||||||
|
bool eos();
|
||||||
|
uint32 read(void *dataPtr, uint32 dataSize);
|
||||||
|
Common::String readLine();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CFile *_dat;
|
extern CFile *_dat;
|
||||||
|
|
|
@ -36,9 +36,9 @@ namespace CGE {
|
||||||
Font::Font(const char *name) {
|
Font::Font(const char *name) {
|
||||||
_map = (uint8 *)malloc(kMapSize);
|
_map = (uint8 *)malloc(kMapSize);
|
||||||
_pos = (uint16 *)malloc(kPosSize * sizeof(uint16));
|
_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);
|
mergeExt(_path, name, kFontExt);
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
@ -46,22 +46,20 @@ Font::Font(const char *name) {
|
||||||
Font::~Font() {
|
Font::~Font() {
|
||||||
free(_map);
|
free(_map);
|
||||||
free(_pos);
|
free(_pos);
|
||||||
free(_wid);
|
free(_widthArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Font::load() {
|
void Font::load() {
|
||||||
VFile f(_path);
|
EncryptedStream f = _path;
|
||||||
if (f._error)
|
assert(!f.err());
|
||||||
return;
|
|
||||||
|
|
||||||
f.read(_wid, kWidSize);
|
f.read(_widthArr, kWidSize);
|
||||||
if (f._error)
|
assert(!f.err());
|
||||||
return;
|
|
||||||
|
|
||||||
uint16 p = 0;
|
uint16 p = 0;
|
||||||
for (uint16 i = 0; i < kPosSize; i++) {
|
for (uint16 i = 0; i < kPosSize; i++) {
|
||||||
_pos[i] = p;
|
_pos[i] = p;
|
||||||
p += _wid[i];
|
p += _widthArr[i];
|
||||||
}
|
}
|
||||||
f.read(_map, p);
|
f.read(_map, p);
|
||||||
}
|
}
|
||||||
|
@ -71,7 +69,7 @@ uint16 Font::width(const char *text) {
|
||||||
if (!text)
|
if (!text)
|
||||||
return 0;
|
return 0;
|
||||||
while (*text)
|
while (*text)
|
||||||
w += _wid[(unsigned char)*(text++)];
|
w += _widthArr[(unsigned char)*(text++)];
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +114,7 @@ void Talk::update(const char *text) {
|
||||||
mw = k;
|
mw = k;
|
||||||
k = 2 * hmarg;
|
k = 2 * hmarg;
|
||||||
} else
|
} else
|
||||||
k += _font->_wid[(unsigned char)*p];
|
k += _font->_widthArr[(unsigned char)*p];
|
||||||
}
|
}
|
||||||
if (k > mw)
|
if (k > mw)
|
||||||
mw = k;
|
mw = k;
|
||||||
|
@ -132,7 +130,7 @@ void Talk::update(const char *text) {
|
||||||
if (*text == '|' || *text == '\n') {
|
if (*text == '|' || *text == '\n') {
|
||||||
m = _ts[0]->_m + (ln += kFontHigh + kTextLineSpace) * mw + hmarg;
|
m = _ts[0]->_m + (ln += kFontHigh + kTextLineSpace) * mw + hmarg;
|
||||||
} else {
|
} else {
|
||||||
int cw = _font->_wid[(unsigned char)*text];
|
int cw = _font->_widthArr[(unsigned char)*text];
|
||||||
uint8 *f = _font->_map + _font->_pos[(unsigned char)*text];
|
uint8 *f = _font->_map + _font->_pos[(unsigned char)*text];
|
||||||
for (int i = 0; i < cw; i++) {
|
for (int i = 0; i < cw; i++) {
|
||||||
uint8 *pp = m;
|
uint8 *pp = m;
|
||||||
|
@ -223,7 +221,7 @@ void Talk::putLine(int line, const char *text) {
|
||||||
uint8 *q = v + size;
|
uint8 *q = v + size;
|
||||||
|
|
||||||
while (*text) {
|
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];
|
uint8 *fp = _font->_map + _font->_pos[(unsigned char)*text];
|
||||||
|
|
||||||
for (i = 0; i < cw; i++) {
|
for (i = 0; i < cw; i++) {
|
||||||
|
@ -280,7 +278,7 @@ void InfoLine::update(const char *text) {
|
||||||
uint8 *p = v + 2, * q = p + size;
|
uint8 *p = v + 2, * q = p + size;
|
||||||
|
|
||||||
while (*text) {
|
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];
|
uint8 *fp = _font->_map + _font->_pos[(unsigned char)*text];
|
||||||
|
|
||||||
for (uint16 i = 0; i < cw; i++) {
|
for (uint16 i = 0; i < cw; i++) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ class Font {
|
||||||
char _path[kPathMax];
|
char _path[kPathMax];
|
||||||
void load();
|
void load();
|
||||||
public:
|
public:
|
||||||
uint8 *_wid;
|
uint8 *_widthArr;
|
||||||
uint16 *_pos;
|
uint16 *_pos;
|
||||||
uint8 *_map;
|
uint8 *_map;
|
||||||
Font(const char *name);
|
Font(const char *name);
|
||||||
|
|
|
@ -60,14 +60,14 @@ Text::~Text() {
|
||||||
|
|
||||||
int16 Text::count() {
|
int16 Text::count() {
|
||||||
EncryptedStream tf = _fileName;
|
EncryptedStream tf = _fileName;
|
||||||
if (tf._error)
|
if (tf.err())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
Common::String line;
|
Common::String line;
|
||||||
char tmpStr[kLineMax + 1];
|
char tmpStr[kLineMax + 1];
|
||||||
int n, count = 0;
|
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();
|
n = line.size();
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
|
@ -94,13 +94,13 @@ void Text::clear() {
|
||||||
|
|
||||||
void Text::load() {
|
void Text::load() {
|
||||||
EncryptedStream tf = _fileName;
|
EncryptedStream tf = _fileName;
|
||||||
assert(!tf._error);
|
assert(!tf.err());
|
||||||
|
|
||||||
Common::String line;
|
Common::String line;
|
||||||
char tmpStr[kLineMax + 1];
|
char tmpStr[kLineMax + 1];
|
||||||
int idx;
|
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();
|
int n = line.size();
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue