aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruruk2014-07-09 11:33:02 +0200
committeruruk2014-07-09 11:33:02 +0200
commit5a1383343fb645b5fbd80060da81253b2443bf28 (patch)
tree465a5fbddecf55e10df39da836e31bd1b34ff18f
parent45da1e7c741a1906b60ad3d55a9e0087fd9a4a3e (diff)
downloadscummvm-rg350-5a1383343fb645b5fbd80060da81253b2443bf28.tar.gz
scummvm-rg350-5a1383343fb645b5fbd80060da81253b2443bf28.tar.bz2
scummvm-rg350-5a1383343fb645b5fbd80060da81253b2443bf28.zip
CGE2: Rework number().
-rw-r--r--engines/cge2/cge2_main.cpp29
-rw-r--r--engines/cge2/hero.cpp28
-rw-r--r--engines/cge2/talk.cpp14
-rw-r--r--engines/cge2/vga13h.cpp28
4 files changed, 29 insertions, 70 deletions
diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp
index b7dcf65b33..a46767b433 100644
--- a/engines/cge2/cge2_main.cpp
+++ b/engines/cge2/cge2_main.cpp
@@ -112,7 +112,10 @@ void System::tick() {
}
}
-int CGE2Engine::number(char *s) { // TODO: Rework it later to include the preceding token() call!
+int CGE2Engine::number(char *str) {
+ char *s = token(str);
+ if (s == nullptr)
+ error("Wrong input for CGE2Engine::number()");
int r = atoi(s);
char *pp = strchr(s, ':');
if (pp)
@@ -335,9 +338,7 @@ void CGE2Engine::loadScript(const char *fname) {
V3D P;
// sprite ident number
- if ((p = token(tmpStr)) == nullptr)
- break;
- int SpI = number(p);
+ int SpI = number(tmpStr);
// sprite file name
char *SpN;
@@ -345,29 +346,19 @@ void CGE2Engine::loadScript(const char *fname) {
break;
// sprite scene
- if ((p = token(nullptr)) == nullptr)
- break;
- int SpA = number(p);
+ int SpA = number(nullptr);
// sprite column
- if ((p = token(nullptr)) == nullptr)
- break;
- P._x = number(p);
+ P._x = number(nullptr);
// sprite row
- if ((p = token(nullptr)) == nullptr)
- break;
- P._y = number(p);
+ P._y = number(nullptr);
// sprite Z pos
- if ((p = token(nullptr)) == nullptr)
- break;
- P._z = number(p);
+ P._z = number(nullptr);
// sprite life
- if ((p = token(nullptr)) == nullptr)
- break;
- bool BkG = number(p) == 0;
+ bool BkG = number(nullptr) == 0;
ok = true; // no break: OK
diff --git a/engines/cge2/hero.cpp b/engines/cge2/hero.cpp
index 65138cd791..6281e4dd5e 100644
--- a/engines/cge2/hero.cpp
+++ b/engines/cge2/hero.cpp
@@ -134,12 +134,8 @@ Sprite *Hero::expand() { // It's very similar to Sprite's expand, but doesn't bo
if (_actionCtrl[section]._cnt) {
CommandHandler::Command *c = &_ext->_actions[section][cnt[section]++];
c->_commandType = CommandType(id);
- if ((p = _vm->token(nullptr)) == nullptr)
- error("Unexpected end of file! %s", fname);
- c->_ref = _vm->number(p);
- if ((p = _vm->token(nullptr)) == nullptr)
- error("Unexpected end of file! %s", fname);
- c->_val = _vm->number(p);
+ c->_ref = _vm->number(nullptr);
+ c->_val = _vm->number(nullptr);
c->_spritePtr = nullptr;
}
break;
@@ -148,9 +144,7 @@ Sprite *Hero::expand() { // It's very similar to Sprite's expand, but doesn't bo
s->_now = atoi(p);
if (s->_now > maxnow)
maxnow = s->_now;
- if ((p = _vm->token(nullptr)) == nullptr)
- break;
- s->_next = _vm->number(p);
+ s->_next = _vm->number(nullptr);
switch (s->_next) {
case 0xFF:
s->_next = seqcnt;
@@ -161,18 +155,10 @@ Sprite *Hero::expand() { // It's very similar to Sprite's expand, but doesn't bo
}
if (s->_next > maxnxt)
maxnxt = s->_next;
- if ((p = _vm->token(nullptr)) == nullptr)
- error("Unexpected end of file! %s", fname);
- s->_dx = _vm->number(p);
- if ((p = _vm->token(nullptr)) == nullptr)
- error("Unexpected end of file! %s", fname);
- s->_dy = _vm->number(p);
- if ((p = _vm->token(nullptr)) == nullptr)
- error("Unexpected end of file! %s", fname);
- s->_dz = _vm->number(p);
- if ((p = _vm->token(nullptr)) == nullptr)
- error("Unexpected end of file! %s", fname);
- s->_dly = _vm->number(p);
+ s->_dx = _vm->number(nullptr);
+ s->_dy = _vm->number(nullptr);
+ s->_dz = _vm->number(nullptr);
+ s->_dly = _vm->number(nullptr);
break;
case kIdPhase:
for (int i = 0; i < kDimMax; i++) {
diff --git a/engines/cge2/talk.cpp b/engines/cge2/talk.cpp
index eda812333c..fd1c140e04 100644
--- a/engines/cge2/talk.cpp
+++ b/engines/cge2/talk.cpp
@@ -87,15 +87,11 @@ void Font::load() {
char *token;
- if ((token = _vm->token(tmpStr)) == nullptr)
- error("Wrong line! (%d) in %s", colorFile.getLineCount(), path);
- _colorSet[n][0] = _vm->number(token);
-
- for (int i = 1; i < 4; i++) {
- if ((token = _vm->token(nullptr)) == nullptr)
- error("Wrong line! (%d) in %s", colorFile.getLineCount(), path);
- _colorSet[n][i] = _vm->number(token);
- }
+
+ _colorSet[n][0] = _vm->number(tmpStr);
+
+ for (int i = 1; i < 4; i++)
+ _colorSet[n][i] = _vm->number(nullptr);
n++;
}
diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp
index a53a1160b8..069c2672ae 100644
--- a/engines/cge2/vga13h.cpp
+++ b/engines/cge2/vga13h.cpp
@@ -353,12 +353,8 @@ Sprite *Sprite::expand() {
CommandHandler::Command *c = &_ext->_actions[section][cnt[section]++];
c->_commandType = CommandType(id);
c->_lab = label;
- if ((p = _vm->token(nullptr)) == nullptr)
- error("Unexpected end of file! %s", fname);
- c->_ref = _vm->number(p);
- if ((p = _vm->token(nullptr)) == nullptr)
- error("Unexpected end of file! %s", fname);
- c->_val = _vm->number(p);
+ c->_ref = _vm->number(nullptr);
+ c->_val = _vm->number(nullptr);
c->_spritePtr = nullptr;
}
break;
@@ -367,9 +363,7 @@ Sprite *Sprite::expand() {
s->_now = atoi(p);
if (s->_now > maxnow)
maxnow = s->_now;
- if ((p = _vm->token(nullptr)) == nullptr)
- break;
- s->_next = _vm->number(p);
+ s->_next = _vm->number(nullptr);
switch (s->_next) {
case 0xFF:
s->_next = seqcnt;
@@ -380,18 +374,10 @@ Sprite *Sprite::expand() {
}
if (s->_next > maxnxt)
maxnxt = s->_next;
- if ((p = _vm->token(nullptr)) == nullptr)
- error("Unexpected end of file! %s", fname);
- s->_dx = _vm->number(p);
- if ((p = _vm->token(nullptr)) == nullptr)
- error("Unexpected end of file! %s", fname);
- s->_dy = _vm->number(p);
- if ((p = _vm->token(nullptr)) == nullptr)
- error("Unexpected end of file! %s", fname);
- s->_dz = _vm->number(p);
- if ((p = _vm->token(nullptr)) == nullptr)
- error("Unexpected end of file! %s", fname);
- s->_dly = _vm->number(p);
+ s->_dx = _vm->number(nullptr);
+ s->_dy = _vm->number(nullptr);
+ s->_dz = _vm->number(nullptr);
+ s->_dly = _vm->number(nullptr);
break;
case kIdPhase: {
shplist[shpcnt] = Bitmap(_vm, p);