aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/cge2/cge2.h6
-rw-r--r--engines/cge2/cge2_main.cpp79
-rw-r--r--engines/cge2/fileio.cpp31
-rw-r--r--engines/cge2/fileio.h9
-rw-r--r--engines/cge2/general.h6
-rw-r--r--engines/cge2/snail.h2
-rw-r--r--engines/cge2/text.cpp2
7 files changed, 68 insertions, 67 deletions
diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h
index b28840817f..be2c129fb5 100644
--- a/engines/cge2/cge2.h
+++ b/engines/cge2/cge2.h
@@ -85,6 +85,12 @@ public:
void caveUp(int cav);
void showBak(int ref);
+ int number(char *s);
+ char *token(char *s);
+ int takeEnum(const char **tab, const char *text);
+ ID ident(const char *s);
+ bool testBool(char *s);
+
const ADGameDescription *_gameDescription;
bool _quitFlag;
diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp
index be503275d1..352c62c6c1 100644
--- a/engines/cge2/cge2_main.cpp
+++ b/engines/cge2/cge2_main.cpp
@@ -36,6 +36,37 @@
namespace CGE2 {
+int CGE2Engine::number(char *s) {
+ int r = atoi(s);
+ char *pp = strchr(s, ':');
+ if (pp)
+ r = (r << 8) + atoi(pp + 1);
+ return r;
+}
+
+char *CGE2Engine::token(char *s) {
+ return strtok(s, " =\t,;/()");
+}
+
+int CGE2Engine::takeEnum(const char **tab, const char *text) {
+ if (text) {
+ for (const char **e = tab; *e; e++) {
+ if (scumm_stricmp(text, *e) == 0) {
+ return e - tab;
+ }
+ }
+ }
+ return -1;
+}
+
+ID CGE2Engine::ident(const char *s) {
+ return ID(takeEnum(EncryptedStream::kIdTab, s));
+}
+
+bool CGE2Engine::testBool(char *s) {
+ return number(s) != 0;
+}
+
void CGE2Engine::badLab(const char *fn) {
error("Misplaced label in %s!", fn);
}
@@ -73,7 +104,7 @@ void CGE2Engine::loadSprite(const char *fname, int ref, int scene, V3D &pos) {
Common::strlcpy(tmpStr, line.c_str(), sizeof(tmpStr));
char *p;
- p = EncryptedStream::token(tmpStr);
+ p = token(tmpStr);
if (*p == '@') {
if (label != kNoByte)
badLab(fname);
@@ -81,7 +112,7 @@ void CGE2Engine::loadSprite(const char *fname, int ref, int scene, V3D &pos) {
continue;
}
- id = EncryptedStream::ident(p);
+ id = ident(p);
switch (id) {
case kIdName: // will be taken in Expand routine
if (label != kNoByte)
@@ -103,26 +134,26 @@ void CGE2Engine::loadSprite(const char *fname, int ref, int scene, V3D &pos) {
case kIdFront:
if (label != kNoByte)
badLab(fname);
- p = EncryptedStream::token(nullptr);
- frnt = EncryptedStream::testBool(p);
+ p = token(nullptr);
+ frnt = testBool(p);
break;
case kIdEast:
if (label != kNoByte)
badLab(fname);
- p = EncryptedStream::token(nullptr);
- east = EncryptedStream::testBool(p);
+ p = token(nullptr);
+ east = testBool(p);
break;
case kIdPortable:
if (label != kNoByte)
badLab(fname);
- p = EncryptedStream::token(nullptr);
- port = EncryptedStream::testBool(p);
+ p = token(nullptr);
+ port = testBool(p);
break;
case kIdTransparent:
if (label != kNoByte)
badLab(fname);
- p = EncryptedStream::token(nullptr);
- tran = EncryptedStream::testBool(p);
+ p = token(nullptr);
+ tran = testBool(p);
break;
default:
if (id >= kIdNear)
@@ -131,7 +162,7 @@ void CGE2Engine::loadSprite(const char *fname, int ref, int scene, V3D &pos) {
case kIdNear:
case kIdMTake:
case kIdFTake:
- if (CommandHandler::com(p) >= 0)
+ if (_commandHandler->com(p) >= 0)
++cnt[section];
else
error("Bad line %d [%s]", sprf.getLineCount(), tmpStr);
@@ -222,39 +253,39 @@ void CGE2Engine::loadScript(const char *fname) {
V3D P;
// sprite ident number
- if ((p = EncryptedStream::token(tmpStr)) == NULL)
+ if ((p = token(tmpStr)) == NULL)
break;
- int SpI = EncryptedStream::number(p);
+ int SpI = number(p);
// sprite file name
char *SpN;
- if ((SpN = EncryptedStream::token(nullptr)) == NULL)
+ if ((SpN = token(nullptr)) == NULL)
break;
// sprite scene
- if ((p = EncryptedStream::token(nullptr)) == NULL)
+ if ((p = token(nullptr)) == NULL)
break;
- int SpA = EncryptedStream::number(p);
+ int SpA = number(p);
// sprite column
- if ((p = EncryptedStream::token(nullptr)) == NULL)
+ if ((p = token(nullptr)) == NULL)
break;
- P._x = EncryptedStream::number(p);
+ P._x = number(p);
// sprite row
- if ((p = EncryptedStream::token(nullptr)) == NULL)
+ if ((p = token(nullptr)) == NULL)
break;
- P._y = EncryptedStream::number(p);
+ P._y = number(p);
// sprite Z pos
- if ((p = EncryptedStream::token(nullptr)) == NULL)
+ if ((p = token(nullptr)) == NULL)
break;
- P._z = EncryptedStream::number(p);
+ P._z = number(p);
// sprite life
- if ((p = EncryptedStream::token(nullptr)) == NULL)
+ if ((p = token(nullptr)) == NULL)
break;
- bool BkG = EncryptedStream::number(p) == 0;
+ bool BkG = number(p) == 0;
ok = true; // no break: OK
diff --git a/engines/cge2/fileio.cpp b/engines/cge2/fileio.cpp
index 6a20b6b561..a9e9563867 100644
--- a/engines/cge2/fileio.cpp
+++ b/engines/cge2/fileio.cpp
@@ -233,37 +233,6 @@ Common::String EncryptedStream::readLine() {
return _readStream->readLine();
}
-int EncryptedStream::number(char *s) {
- int r = atoi(s);
- char *pp = strchr(s, ':');
- if (pp)
- r = (r << 8) + atoi(pp + 1);
- return r;
-}
-
-char *EncryptedStream::token(char *s) {
- return strtok(s, " =\t,;/()");
-}
-
-int EncryptedStream::takeEnum(const char **tab, const char *text) {
- if (text) {
- for (const char **e = tab; *e; e++) {
- if (scumm_stricmp(text, *e) == 0) {
- return e - tab;
- }
- }
- }
- return -1;
-}
-
-ID EncryptedStream::ident(const char *s) {
- return ID(takeEnum(kIdTab, s));
-}
-
-bool EncryptedStream::testBool(char *s) {
- return number(s) != 0;
-}
-
int32 EncryptedStream::size() {
return _readStream->size();
}
diff --git a/engines/cge2/fileio.h b/engines/cge2/fileio.h
index 758d841226..315002268c 100644
--- a/engines/cge2/fileio.h
+++ b/engines/cge2/fileio.h
@@ -112,8 +112,6 @@ private:
const char **_tab;
int _lineCount;
bool _error;
-
- static const char *kIdTab[];
public:
EncryptedStream(CGE2Engine *vm, const char *name);
~EncryptedStream();
@@ -124,12 +122,9 @@ public:
int32 size();
uint32 read(byte *dataPtr, uint32 dataSize);
Common::String readLine();
- static int number(char *s);
- static char *token(char *s);
- static int takeEnum(const char **tab, const char *text);
- static ID ident(const char *s);
- static bool testBool(char *s);
int getLineCount() { return _lineCount; }
+
+ static const char *kIdTab[];
};
} // End of namespace CGE2
diff --git a/engines/cge2/general.h b/engines/cge2/general.h
index 9c89f525ac..62b41a9ebb 100644
--- a/engines/cge2/general.h
+++ b/engines/cge2/general.h
@@ -79,9 +79,9 @@ public:
void setEye(const char *s) {
char *tempStr;
strcpy(tempStr, s);
- _vm->_eye->_x = atoi(EncryptedStream::token(tempStr));
- _vm->_eye->_y = atoi(EncryptedStream::token(tempStr));
- _vm->_eye->_z = atoi(EncryptedStream::token(tempStr));
+ _vm->_eye->_x = atoi(_vm->token(tempStr));
+ _vm->_eye->_y = atoi(_vm->token(tempStr));
+ _vm->_eye->_z = atoi(_vm->token(tempStr));
}
bool operator < (const V2D& p) const { return (x < p.x) && (y < p.y); }
bool operator <= (const V2D& p) const { return (x <= p.x) && (y <= p.y); }
diff --git a/engines/cge2/snail.h b/engines/cge2/snail.h
index c8dea19b02..b364aa92d0 100644
--- a/engines/cge2/snail.h
+++ b/engines/cge2/snail.h
@@ -132,7 +132,7 @@ public:
void insertCommand(CommandType com, int ref, int val, void *ptr);
bool idle();
void reset();
- static int com(const char *com);
+ int com(const char *com);
private:
CGE2Engine *_vm;
bool _turbo;
diff --git a/engines/cge2/text.cpp b/engines/cge2/text.cpp
index de33717c55..2f8e9b4011 100644
--- a/engines/cge2/text.cpp
+++ b/engines/cge2/text.cpp
@@ -107,7 +107,7 @@ void Text::load() {
if (!Common::isDigit(*s))
continue;
- int r = tf.number(s);
+ int r = _vm->number(s);
s += strlen(s);
if (s < tmpStr + n)