mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-21 19:51:49 +00:00
CGE2: Make some static functions non-static.
EncryptedStream -> CGE2Engine Namely: * CGE2Engine::number(char *s) * char *CGE2Engine::token(char *s) * int CGE2Engine::takeEnum(const char **tab, const char *text) * ID CGE2Engine::ident(const char *s) * bool CGE2Engine::testBool(char *s) * int CommandHandler::com(const char *com)
This commit is contained in:
parent
e30296976c
commit
c108a18306
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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); }
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user