aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicola Mettifogo2007-03-18 19:35:54 +0000
committerNicola Mettifogo2007-03-18 19:35:54 +0000
commitf14a5c17f2d153c76995d43de02c2c985186f5c5 (patch)
tree14afcbc1afdc0dcf58e0ddaed2571245ec590bd2
parent2c3152ea62d475007eb50abd07397e6074a197a9 (diff)
downloadscummvm-rg350-f14a5c17f2d153c76995d43de02c2c985186f5c5.tar.gz
scummvm-rg350-f14a5c17f2d153c76995d43de02c2c985186f5c5.tar.bz2
scummvm-rg350-f14a5c17f2d153c76995d43de02c2c985186f5c5.zip
- Made global Node's (_zones, _animations, _helperNode) and the functions using them members of the engine.
- Added a constructor for Node svn-id: r26226
-rw-r--r--engines/parallaction/animation.cpp18
-rw-r--r--engines/parallaction/callables.cpp40
-rw-r--r--engines/parallaction/commands.cpp4
-rw-r--r--engines/parallaction/defs.h5
-rw-r--r--engines/parallaction/intro.cpp2
-rw-r--r--engines/parallaction/location.cpp14
-rw-r--r--engines/parallaction/parallaction.h15
-rw-r--r--engines/parallaction/walk.cpp4
-rw-r--r--engines/parallaction/zone.cpp11
-rw-r--r--engines/parallaction/zone.h6
10 files changed, 63 insertions, 56 deletions
diff --git a/engines/parallaction/animation.cpp b/engines/parallaction/animation.cpp
index 53021dfbec..0805917698 100644
--- a/engines/parallaction/animation.cpp
+++ b/engines/parallaction/animation.cpp
@@ -53,7 +53,7 @@ namespace Parallaction {
void wrapLocalVar(LocalVariable *local);
-void sortAnimations();
+
LValue getLValue(Instruction *inst, char *str, LocalVariable *locals, Animation *a);
@@ -61,7 +61,7 @@ LValue getLValue(Instruction *inst, char *str, LocalVariable *locals, Animation
uint16 _numLocals = 0;
char _localNames[10][10];
-Animation *findAnimation(const char *name) {
+Animation *Parallaction::findAnimation(const char *name) {
Animation *v4 = (Animation*)_animations._next;
@@ -166,7 +166,7 @@ void freeScript(Program *program) {
-void freeAnimations() {
+void Parallaction::freeAnimations() {
Animation *v4 = (Animation*)_animations._next;
while (v4) {
freeScript(v4->_program);
@@ -182,7 +182,7 @@ void freeAnimations() {
void jobDisplayAnimations(void *parm, Job *j) {
// printf("jobDisplayAnimations()...\n");
- Animation *v18 = (Animation*)_animations._next;
+ Animation *v18 = (Animation*)_vm->_animations._next;
StaticCnv v14;
uint16 _si = 0;
@@ -226,7 +226,7 @@ void jobDisplayAnimations(void *parm, Job *j) {
void jobEraseAnimations(void *arg_0, Job *j) {
debugC(3, kDebugJobs, "jobEraseAnimations");
- Animation *a = (Animation*)_animations._next;
+ Animation *a = (Animation*)_vm->_animations._next;
for (; a; a=(Animation*)a->_zone._next) {
@@ -457,7 +457,7 @@ LValue getLValue(Instruction *inst, char *str, LocalVariable *locals, Animation
}
if (str[1] == '.') {
- a = findAnimation(&str[2]);
+ a = _vm->findAnimation(&str[2]);
}
if (str[0] == 'X') {
@@ -483,7 +483,7 @@ void jobRunScripts(void *parm, Job *j) {
static uint16 modCounter = 0;
- Animation *a = (Animation*)_animations._next;
+ Animation *a = (Animation*)_vm->_animations._next;
StaticCnv v18;
WalkNode *v4 = NULL;
@@ -634,7 +634,7 @@ label1:
a->_z = a->_zone._top + a->height();
}
- sortAnimations();
+ _vm->sortAnimations();
modCounter++;
return;
@@ -653,7 +653,7 @@ void wrapLocalVar(LocalVariable *local) {
-void sortAnimations() {
+void Parallaction::sortAnimations() {
Node v14;
memset(&v14, 0, sizeof(Node));
diff --git a/engines/parallaction/callables.cpp b/engines/parallaction/callables.cpp
index 570e7796ef..861fe07662 100644
--- a/engines/parallaction/callables.cpp
+++ b/engines/parallaction/callables.cpp
@@ -92,21 +92,21 @@ void _c_moveSarc(void *parm) {
_introSarcData2 = 0;
if (_moveSarcZones[0] == NULL) {
- _moveSarcZones[0] = findZone("sarc1");
- _moveSarcZones[1] = findZone("sarc2");
- _moveSarcZones[2] = findZone("sarc3");
- _moveSarcZones[3] = findZone("sarc4");
- _moveSarcZones[4] = findZone("sarc5");
-
- _moveSarcExaZones[0] = findZone("sarc1exa");
- _moveSarcExaZones[1] = findZone("sarc2exa");
- _moveSarcExaZones[2] = findZone("sarc3exa");
- _moveSarcExaZones[3] = findZone("sarc4exa");
- _moveSarcExaZones[4] = findZone("sarc5exa");
+ _moveSarcZones[0] = _vm->findZone("sarc1");
+ _moveSarcZones[1] = _vm->findZone("sarc2");
+ _moveSarcZones[2] = _vm->findZone("sarc3");
+ _moveSarcZones[3] = _vm->findZone("sarc4");
+ _moveSarcZones[4] = _vm->findZone("sarc5");
+
+ _moveSarcExaZones[0] = _vm->findZone("sarc1exa");
+ _moveSarcExaZones[1] = _vm->findZone("sarc2exa");
+ _moveSarcExaZones[2] = _vm->findZone("sarc3exa");
+ _moveSarcExaZones[3] = _vm->findZone("sarc4exa");
+ _moveSarcExaZones[4] = _vm->findZone("sarc5exa");
}
- a = findAnimation("sposta");
+ a = _vm->findAnimation("sposta");
_moveSarcZone1 = (Zone*)parm;
@@ -147,7 +147,7 @@ void _c_moveSarc(void *parm) {
_moveSarcZones[3]->_left == 134 &&
_moveSarcZones[4]->_left == 167) {
- a = findAnimation("finito");
+ a = _vm->findAnimation("finito");
a->_zone._flags |= (kFlagsActive | kFlagsActing);
_localFlags[_vm->_currentLocationIndex] |= 0x20; // GROSS HACK: activates 'finito' flag in dinoit_museo.loc
@@ -319,17 +319,17 @@ void _c_finito(void *parm) {
_engineFlags |= kEngineQuit;
- freeZones(_zones._next);
- freeNodeList(_zones._next);
- _zones._next = NULL;
+ _vm->freeZones(_vm->_zones._next);
+ freeNodeList(_vm->_zones._next);
+ _vm->_zones._next = NULL;
- freeZones(_animations._next);
- freeNodeList(_animations._next);
- _animations._next = NULL;
+ _vm->freeZones(_vm->_animations._next);
+ freeNodeList(_vm->_animations._next);
+ _vm->_animations._next = NULL;
_engineFlags &= ~kEngineQuit;
- addNode(&_animations, &_vm->_char._ani._zone);
+ addNode(&_vm->_animations, &_vm->_char._ani._zone);
_score = 0;
return;
diff --git a/engines/parallaction/commands.cpp b/engines/parallaction/commands.cpp
index 7c4b1ed105..a6bbebc081 100644
--- a/engines/parallaction/commands.cpp
+++ b/engines/parallaction/commands.cpp
@@ -88,7 +88,7 @@ Command *parseCommands(Script &script) {
case CMD_START: // start
case CMD_STOP: // stop
- cmd->u._animation = findAnimation(_tokens[_si]);
+ cmd->u._animation = _vm->findAnimation(_tokens[_si]);
_si++;
if (cmd->u._animation == NULL) {
strcpy(_forwardedAnimationNames[_numForwards], _tokens[_si-1]);
@@ -103,7 +103,7 @@ Command *parseCommands(Script &script) {
case CMD_CLOSE: // close
case CMD_ON: // on
case CMD_OFF: // off
- cmd->u._zone = findZone(_tokens[_si]);
+ cmd->u._zone = _vm->findZone(_tokens[_si]);
_si++;
break;
diff --git a/engines/parallaction/defs.h b/engines/parallaction/defs.h
index 6f864215b6..990a32bbbc 100644
--- a/engines/parallaction/defs.h
+++ b/engines/parallaction/defs.h
@@ -36,6 +36,11 @@ namespace Parallaction {
struct Node {
Node* _prev;
Node* _next;
+
+ Node() {
+ _prev = NULL;
+ _next = NULL;
+ }
};
struct WalkNode : public Node {
diff --git a/engines/parallaction/intro.cpp b/engines/parallaction/intro.cpp
index 64eed32b91..dfddd70627 100644
--- a/engines/parallaction/intro.cpp
+++ b/engines/parallaction/intro.cpp
@@ -123,7 +123,7 @@ extern Credit _credits[];
void _c_startIntro(void *parm) {
- _rightHandAnim = findAnimation("righthand");
+ _rightHandAnim = _vm->findAnimation("righthand");
_vm->_midiPlayer->play("intro");
_engineFlags |= kEngineMouse;
diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp
index 24e1ab6093..67e38c83c1 100644
--- a/engines/parallaction/location.cpp
+++ b/engines/parallaction/location.cpp
@@ -33,9 +33,9 @@ namespace Parallaction {
void resolveLocationForwards();
void switchBackground(const char* background, const char* mask);
void parseWalkNodes(Script &script, Node *list);
-void freeAnimations();
-Node helperNode = { NULL, NULL };
+
+
void Parallaction::parseLocation(const char *filename) {
// printf("parseLocation(%s)", filename);
@@ -168,7 +168,7 @@ void resolveLocationForwards() {
// printf("# forwards: %i", _numForwards);
for (uint16 _si = 0; _forwardedCommands[_si]; _si++) {
- _forwardedCommands[_si]->u._animation = findAnimation(_forwardedAnimationNames[_si]);
+ _forwardedCommands[_si]->u._animation = _vm->findAnimation(_forwardedAnimationNames[_si]);
_forwardedCommands[_si] = NULL;
}
@@ -177,7 +177,7 @@ void resolveLocationForwards() {
}
-void freeLocation() {
+void Parallaction::freeLocation() {
debugC(7, kDebugLocation, "freeLocation");
uint16 _si = 1;
@@ -194,14 +194,14 @@ void freeLocation() {
debugC(7, kDebugLocation, "freeLocation: walk nodes freed");
helperNode._prev = helperNode._next = NULL;
- freeZones(_zones._next);
+ _vm->freeZones(_zones._next);
freeNodeList(_zones._next);
memcpy(&_zones, &helperNode, sizeof(Node));
debugC(7, kDebugLocation, "freeLocation: zones freed");
helperNode._prev = helperNode._next = NULL;
- freeZones(_animations._next);
- freeAnimations();
+ _vm->freeZones(_animations._next);
+ _vm->freeAnimations();
freeNodeList(_animations._next);
memcpy(&_animations, &helperNode, sizeof(Node));
debugC(7, kDebugLocation, "freeLocation: animations freed");
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index fd7d6d77e5..fec7d90c61 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -162,7 +162,7 @@ Command *parseCommands(Script &script);
void runCommands(Command *list, Zone *z = NULL);
void freeCommands(Command*);
-void freeZones(Node *list);
+
void runDialogue(SpeakData*);
@@ -308,6 +308,14 @@ public:
void resumeJobs();
void runJobs();
+ void freeZones(Node *list);
+ Animation *findAnimation(const char *name);
+ Zone *findZone(const char *name);
+ Zone *hitZone(uint32 type, uint16 x, uint16 y);
+ void freeAnimations();
+ void sortAnimations();
+ void freeLocation();
+
public:
int getGameType() const;
uint32 getFeatures() const;
@@ -339,6 +347,9 @@ public:
Common::Point _mousePos;
+ Node _zones;
+ Node _animations;
+
protected: // data
struct InputData {
@@ -370,6 +381,8 @@ protected: // data
Job _jobs;
+ Node helperNode; // used for freeZones
+
protected: // members
bool detectGame(void);
diff --git a/engines/parallaction/walk.cpp b/engines/parallaction/walk.cpp
index 3529b838e7..710040d184 100644
--- a/engines/parallaction/walk.cpp
+++ b/engines/parallaction/walk.cpp
@@ -414,7 +414,7 @@ uint16 checkDoor() {
}
_engineFlags &= ~kEngineWalking;
- Zone *z = hitZone(kZoneDoor, _vm->_char._ani._zone._left + _vm->_char._ani.width() / 2, _vm->_char._ani._zone._top + _vm->_char._ani.height());
+ Zone *z = _vm->hitZone(kZoneDoor, _vm->_char._ani._zone._left + _vm->_char._ani.width() / 2, _vm->_char._ani._zone._top + _vm->_char._ani.height());
if (z != NULL) {
@@ -432,7 +432,7 @@ uint16 checkDoor() {
}
}
- z = hitZone(kZoneTrap, _vm->_char._ani._zone._left + _vm->_char._ani.width() / 2, _vm->_char._ani._zone._top + _vm->_char._ani.height());
+ z = _vm->hitZone(kZoneTrap, _vm->_char._ani._zone._left + _vm->_char._ani.width() / 2, _vm->_char._ani._zone._top + _vm->_char._ani.height());
if (z != NULL) {
_localFlags[_vm->_currentLocationIndex] |= kFlagsEnter;
diff --git a/engines/parallaction/zone.cpp b/engines/parallaction/zone.cpp
index 7f8ed55544..8790d07eda 100644
--- a/engines/parallaction/zone.cpp
+++ b/engines/parallaction/zone.cpp
@@ -33,12 +33,7 @@ void freeScript(Program*);
void freeDialogue(Dialogue *d);
-Node _zones = { NULL, NULL };
-Node _animations = { NULL, NULL };
-
-extern Node helperNode;
-
-Zone *findZone(const char *name) {
+Zone *Parallaction::findZone(const char *name) {
Zone *v4 = (Zone*)_zones._next;
@@ -120,7 +115,7 @@ void Parallaction::parseZone(Script &script, Node *list, char *name) {
return;
}
-void freeZones(Node *list) {
+void Parallaction::freeZones(Node *list) {
debugC(1, kDebugLocation, "freeZones: kEngineQuit = %i", _engineFlags & kEngineQuit);
Zone *z = (Zone*)list;
@@ -569,7 +564,7 @@ void jobDisplayDroppedItem(void *parm, Job *j) {
-Zone *hitZone(uint32 type, uint16 x, uint16 y) {
+Zone *Parallaction::hitZone(uint32 type, uint16 x, uint16 y) {
// printf("hitZone(%i, %i, %i)", type, x, y);
uint16 _di = y;
diff --git a/engines/parallaction/zone.h b/engines/parallaction/zone.h
index f4e8f6fa1f..775bf0bca8 100644
--- a/engines/parallaction/zone.h
+++ b/engines/parallaction/zone.h
@@ -237,21 +237,15 @@ struct Animation {
}
};
-extern Node _zones;
-extern Node _animations;
-
-Zone *findZone(const char *name);
uint16 runZone(Zone *z);
void dropItem(uint16 v);
int16 pickupItem(Zone *z);
-Zone *hitZone(uint32 type, uint16 x, uint16 y);
uint16 checkDoor();
-Animation *findAnimation(const char *name);
void loadProgram(Animation *, char *filename);