CGE2: Rework EncryptedStream::readLine().

This commit is contained in:
uruk 2014-05-26 16:30:32 +02:00
parent 43ce991b84
commit 62e36f9279
4 changed files with 14 additions and 11 deletions

View File

@ -116,11 +116,10 @@ void CGE2Engine::loadSprite(const char *fname, int ref, int scene, V3D &pos) {
Common::String line;
for (line = sprf.readLine(); !sprf.eos(); line = sprf.readLine()){
int len = line.size();
Common::strlcpy(tmpStr, line.c_str(), sizeof(tmpStr));
if (len == 0 || *tmpStr == ';')
if (line.size() == 0)
continue;
Common::strlcpy(tmpStr, line.c_str(), sizeof(tmpStr));
char *p;
p = token(tmpStr);
if (*p == '@') {
@ -260,13 +259,14 @@ void CGE2Engine::loadScript(const char *fname) {
Common::String line;
for (line = scrf.readLine(); !scrf.eos(); line = scrf.readLine()) {
if (line.size() == 0)
continue;
char *p;
lcnt++;
Common::strlcpy(tmpStr, line.c_str(), sizeof(tmpStr));
if ((line.size() == 0) || (*tmpStr == ';')) // Comments start with ';' - don't bother with them.
continue;
ok = false; // not OK if break
V3D P;

View File

@ -242,7 +242,10 @@ bool EncryptedStream::seek(int32 offset) {
Common::String EncryptedStream::readLine() {
_lineCount++;
return _readStream->readLine();
Common::String line = _readStream->readLine();
if (!line.empty() && (line[0] == ';' || line[0] == '.' || line[0] == '*'))
line.clear(); // Returns an empty string, if the line is invalid.
return line;
}
int32 EncryptedStream::size() {

View File

@ -105,6 +105,7 @@ public:
bool exist(const char *name);
};
// TODO: Revise the whole class!
class EncryptedStream {
private:
CGE2Engine *_vm;

View File

@ -278,10 +278,9 @@ Sprite *Sprite::expand() {
char tmpStr[kLineMax + 1];
for (line = sprf.readLine(); !sprf.eos(); line = sprf.readLine()){
int len = line.size();
Common::strlcpy(tmpStr, line.c_str(), sizeof(tmpStr));
if (len == 0 || *tmpStr == ';')
if (line.size() == 0)
continue;
Common::strlcpy(tmpStr, line.c_str(), sizeof(tmpStr));
char *p = _vm->token(tmpStr);
if (*p == '@') {