diff options
author | Nicola Mettifogo | 2007-03-19 21:49:41 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2007-03-19 21:49:41 +0000 |
commit | fe5660400fd0a108d7cee4e0c37978154a8ab085 (patch) | |
tree | 16b4ce0e86464c12a23c5edd093929ea1c9e6199 /engines/parallaction | |
parent | 3dd12518cbb75545ed4de029c7cec22ffce32f78 (diff) | |
download | scummvm-rg350-fe5660400fd0a108d7cee4e0c37978154a8ab085.tar.gz scummvm-rg350-fe5660400fd0a108d7cee4e0c37978154a8ab085.tar.bz2 scummvm-rg350-fe5660400fd0a108d7cee4e0c37978154a8ab085.zip |
made Animation a subclass of Zone (finally!)
svn-id: r26244
Diffstat (limited to 'engines/parallaction')
-rw-r--r-- | engines/parallaction/animation.cpp | 126 | ||||
-rw-r--r-- | engines/parallaction/callables.cpp | 14 | ||||
-rw-r--r-- | engines/parallaction/commands.cpp | 2 | ||||
-rw-r--r-- | engines/parallaction/intro.cpp | 12 | ||||
-rw-r--r-- | engines/parallaction/location.cpp | 16 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 10 | ||||
-rw-r--r-- | engines/parallaction/parallaction.h | 16 | ||||
-rw-r--r-- | engines/parallaction/saveload.cpp | 4 | ||||
-rw-r--r-- | engines/parallaction/walk.cpp | 28 | ||||
-rw-r--r-- | engines/parallaction/zone.cpp | 30 | ||||
-rw-r--r-- | engines/parallaction/zone.h | 22 |
11 files changed, 132 insertions, 148 deletions
diff --git a/engines/parallaction/animation.cpp b/engines/parallaction/animation.cpp index dc52066b71..f2c2becfa7 100644 --- a/engines/parallaction/animation.cpp +++ b/engines/parallaction/animation.cpp @@ -66,8 +66,8 @@ Animation *Parallaction::findAnimation(const char *name) { Animation *v4 = (Animation*)_animations._next; while (v4) { - if (!scumm_stricmp(name, v4->_zone._label._text)) return v4; - v4 = (Animation*)v4->_zone._next; + if (!scumm_stricmp(name, v4->_label._text)) return v4; + v4 = (Animation*)v4->_next; } return NULL; @@ -79,10 +79,10 @@ Animation *Parallaction::parseAnimation(Script& script, Node *list, char *name) Animation *vD0 = new Animation; - vD0->_zone._label._text = (char*)malloc(strlen(name)+1); - strcpy(vD0->_zone._label._text, name); + vD0->_label._text = (char*)malloc(strlen(name)+1); + strcpy(vD0->_label._text, name); - addNode(list, &vD0->_zone); + addNode(list, vD0); fillBuffers(script, true); while (scumm_stricmp(_tokens[0], "endanimation")) { @@ -92,22 +92,22 @@ Animation *Parallaction::parseAnimation(Script& script, Node *list, char *name) loadProgram(vD0, _tokens[1]); } if (!scumm_stricmp(_tokens[0], "commands")) { - vD0->_zone._commands = parseCommands(script); + vD0->_commands = parseCommands(script); } if (!scumm_stricmp(_tokens[0], "type")) { if (_tokens[2][0] != '\0') { - vD0->_zone._type = ((4 + searchTable(_tokens[2], const_cast<const char **>(_objectsNames))) << 16) & 0xFFFF0000; + vD0->_type = ((4 + searchTable(_tokens[2], const_cast<const char **>(_objectsNames))) << 16) & 0xFFFF0000; } int16 _si = searchTable(_tokens[1], _zoneTypeNames); if (_si != -1) { - vD0->_zone._type |= 1 << (_si-1); - if (((vD0->_zone._type & 0xFFFF) != kZoneNone) && ((vD0->_zone._type & 0xFFFF) != kZoneCommand)) { - parseZoneTypeBlock(script, &vD0->_zone); + vD0->_type |= 1 << (_si-1); + if (((vD0->_type & 0xFFFF) != kZoneNone) && ((vD0->_type & 0xFFFF) != kZoneCommand)) { + parseZoneTypeBlock(script, vD0); } } } if (!scumm_stricmp(_tokens[0], "label")) { - _vm->_gfx->makeCnvFromString(&vD0->_zone._label._cnv, _tokens[1]); + _vm->_gfx->makeCnvFromString(&vD0->_label._cnv, _tokens[1]); } if (!scumm_stricmp(_tokens[0], "flags")) { uint16 _si = 1; @@ -115,7 +115,7 @@ Animation *Parallaction::parseAnimation(Script& script, Node *list, char *name) do { byte _al = searchTable(_tokens[_si], _zoneFlagNames); _si++; - vD0->_zone._flags |= 1 << (_al - 1); + vD0->_flags |= 1 << (_al - 1); } while (!scumm_stricmp(_tokens[_si++], "|")); } if (!scumm_stricmp(_tokens[0], "file")) { @@ -129,22 +129,22 @@ Animation *Parallaction::parseAnimation(Script& script, Node *list, char *name) vD0->_cnv = _disk->loadFrames(vC8); } if (!scumm_stricmp(_tokens[0], "position")) { - vD0->_zone._left = atoi(_tokens[1]); - vD0->_zone._top = atoi(_tokens[2]); + vD0->_left = atoi(_tokens[1]); + vD0->_top = atoi(_tokens[2]); vD0->_z = atoi(_tokens[3]); } if (!scumm_stricmp(_tokens[0], "moveto")) { - vD0->_zone._moveTo.x = atoi(_tokens[1]); - vD0->_zone._moveTo.y = atoi(_tokens[2]); + vD0->_moveTo.x = atoi(_tokens[1]); + vD0->_moveTo.y = atoi(_tokens[2]); } fillBuffers(script, true); } - vD0->_zone._oldLeft = -1000; - vD0->_zone._oldTop = -1000; + vD0->_oldLeft = -1000; + vD0->_oldTop = -1000; - vD0->_zone._flags |= 0x1000000; + vD0->_flags |= 0x1000000; return vD0; } @@ -169,7 +169,7 @@ void Parallaction::freeAnimations() { freeScript(v4->_program); _vm->_gfx->freeCnv(v4->_cnv); if (v4->_cnv) delete v4->_cnv; - v4 = (Animation*)v4->_zone._next; + v4 = (Animation*)v4->_next; // TODO: delete Animation } @@ -187,32 +187,32 @@ void jobDisplayAnimations(void *parm, Job *j) { uint16 _si = 0; - for ( ; v18; v18 = (Animation*)v18->_zone._next) { + for ( ; v18; v18 = (Animation*)v18->_next) { - if ((v18->_zone._flags & kFlagsActive) && ((v18->_zone._flags & kFlagsRemove) == 0)) { + if ((v18->_flags & kFlagsActive) && ((v18->_flags & kFlagsRemove) == 0)) { v14._width = v18->width(); v14._height = v18->height(); v14._data0 = v18->getFrameData(v18->_frame); // v14._data1 = v18->_cnv->field_8[v18->_frame]; - if (v18->_zone._flags & kFlagsNoMasked) + if (v18->_flags & kFlagsNoMasked) _si = 3; else - _si = _vm->_gfx->queryMask(v18->_zone._top + v18->height()); + _si = _vm->_gfx->queryMask(v18->_top + v18->height()); -// printf("jobDisplayAnimations %s, x: %i, y: %i, w: %i, h: %i\n", v18->_zone._name, v18->_zone._left, v18->_zone._top, v14._width, v14._height); - _vm->_gfx->blitCnv(&v14, v18->_zone._left, v18->_zone._top, _si, Gfx::kBitBack); +// printf("jobDisplayAnimations %s, x: %i, y: %i, w: %i, h: %i\n", v18->_name, v18->_left, v18->_top, v14._width, v14._height); + _vm->_gfx->blitCnv(&v14, v18->_left, v18->_top, _si, Gfx::kBitBack); } - if (((v18->_zone._flags & kFlagsActive) == 0) && (v18->_zone._flags & kFlagsRemove)) { - v18->_zone._flags &= ~kFlagsRemove; - v18->_zone._oldLeft = -1000; + if (((v18->_flags & kFlagsActive) == 0) && (v18->_flags & kFlagsRemove)) { + v18->_flags &= ~kFlagsRemove; + v18->_oldLeft = -1000; } - if ((v18->_zone._flags & kFlagsActive) && (v18->_zone._flags & kFlagsRemove)) { - v18->_zone._flags &= ~kFlagsActive; - v18->_zone._flags |= kFlagsRemove; + if ((v18->_flags & kFlagsActive) && (v18->_flags & kFlagsRemove)) { + v18->_flags &= ~kFlagsActive; + v18->_flags |= kFlagsRemove; } } @@ -228,17 +228,17 @@ void jobEraseAnimations(void *arg_0, Job *j) { Animation *a = (Animation*)_vm->_animations._next; - for (; a; a=(Animation*)a->_zone._next) { + for (; a; a=(Animation*)a->_next) { - if (((a->_zone._flags & kFlagsActive) == 0) && ((a->_zone._flags & kFlagsRemove) == 0)) continue; + if (((a->_flags & kFlagsActive) == 0) && ((a->_flags & kFlagsRemove) == 0)) continue; Common::Rect r(a->width(), a->height()); - r.moveTo(a->_zone._oldLeft, a->_zone._oldTop); + r.moveTo(a->_oldLeft, a->_oldTop); _vm->_gfx->restoreBackground(r); if (arg_0) { - a->_zone._oldLeft = a->_zone._left; - a->_zone._oldTop = a->_zone._top; + a->_oldLeft = a->_left; + a->_oldTop = a->_top; } } @@ -312,7 +312,7 @@ void Parallaction::parseScriptLine(Instruction *inst, Animation *a, LocalVariabl case INST_ON: // on case INST_OFF: // off case INST_START: // start - if (!scumm_stricmp(_tokens[1], a->_zone._label._text)) { + if (!scumm_stricmp(_tokens[1], a->_label._text)) { inst->_opBase._a = a; } else { inst->_opBase._a = findAnimation(_tokens[1]); @@ -324,12 +324,12 @@ void Parallaction::parseScriptLine(Instruction *inst, Animation *a, LocalVariabl break; case INST_X: // x - inst->_opA._pvalue = &a->_zone._left; + inst->_opA._pvalue = &a->_left; inst->_opB = getLValue(inst, _tokens[1], locals, a); break; case INST_Y: // y - inst->_opA._pvalue = &a->_zone._top; + inst->_opA._pvalue = &a->_top; inst->_opB = getLValue(inst, _tokens[1], locals, a); break; @@ -346,10 +346,10 @@ void Parallaction::parseScriptLine(Instruction *inst, Animation *a, LocalVariabl case INST_INC: // inc case INST_DEC: // dec if (!scumm_stricmp(_tokens[1], "X")) { - inst->_opA._pvalue = &a->_zone._left; + inst->_opA._pvalue = &a->_left; } else if (!scumm_stricmp(_tokens[1], "Y")) { - inst->_opA._pvalue = &a->_zone._top; + inst->_opA._pvalue = &a->_top; } else if (!scumm_stricmp(_tokens[1], "Z")) { inst->_opA._pvalue = &a->_z; @@ -380,7 +380,7 @@ void Parallaction::parseScriptLine(Instruction *inst, Animation *a, LocalVariabl break; case INST_PUT: // put - if (!scumm_stricmp(_tokens[1], a->_zone._label._text)) { + if (!scumm_stricmp(_tokens[1], a->_label._text)) { inst->_opBase._a = a; } else { inst->_opBase._a = findAnimation(_tokens[1]); @@ -459,10 +459,10 @@ LValue getLValue(Instruction *inst, char *str, LocalVariable *locals, Animation } if (str[0] == 'X') { - v._pvalue = &a->_zone._left; + v._pvalue = &a->_left; } else if (str[0] == 'Y') { - v._pvalue = &a->_zone._top; + v._pvalue = &a->_top; } else if (str[0] == 'Z') { v._pvalue = &a->_z; @@ -486,17 +486,17 @@ void jobRunScripts(void *parm, Job *j) { StaticCnv v18; WalkNode *v4 = NULL; - if (a->_zone._flags & kFlagsCharacter) a->_z = a->_zone._top + a->height(); - for ( ; a; a = (Animation*)a->_zone._next) { + if (a->_flags & kFlagsCharacter) a->_z = a->_top + a->height(); + for ( ; a; a = (Animation*)a->_next) { - if ((a->_zone._flags & kFlagsActing) == 0) continue; + if ((a->_flags & kFlagsActing) == 0) continue; Instruction *inst = a->_program->_ip; -// printf("Animation: %s, flags: %x\n", a->_zone._name, a->_zone._flags); +// printf("Animation: %s, flags: %x\n", a->_name, a->_flags); - while ((inst->_index != INST_SHOW) && (a->_zone._flags & kFlagsActing)) { + while ((inst->_index != INST_SHOW) && (a->_flags & kFlagsActing)) { - debugC(1, kDebugJobs, "Animation: %s, instruction: %s", a->_zone._label._text, inst->_index == INST_END ? "end" : _instructionNames[inst->_index - 1]); + debugC(1, kDebugJobs, "Animation: %s, instruction: %s", a->_label._text, inst->_index == INST_END ? "end" : _instructionNames[inst->_index - 1]); switch (inst->_index) { case INST_ENDLOOP: // endloop @@ -506,19 +506,19 @@ void jobRunScripts(void *parm, Job *j) { break; case INST_OFF: {// off - inst->_opBase._a->_zone._flags |= kFlagsRemove; + inst->_opBase._a->_flags |= kFlagsRemove; // v1C = inst->_opBase; } break; case INST_ON: // on - inst->_opBase._a->_zone._flags |= kFlagsActive; - inst->_opBase._a->_zone._flags &= ~kFlagsRemove; + inst->_opBase._a->_flags |= kFlagsActive; + inst->_opBase._a->_flags &= ~kFlagsRemove; break; case INST_START: // start // v1C = inst->_opBase; - inst->_opBase._a->_zone._flags |= (kFlagsActing | kFlagsActive); + inst->_opBase._a->_flags |= (kFlagsActing | kFlagsActive); break; case INST_LOOP: // loop @@ -584,9 +584,9 @@ void jobRunScripts(void *parm, Job *j) { break; case INST_END: // exit - if ((a->_zone._flags & kFlagsLooping) == 0) { - a->_zone._flags &= ~kFlagsActing; - runCommands(a->_zone._commands, (Zone*)&a->_zone); + if ((a->_flags & kFlagsLooping) == 0) { + a->_flags &= ~kFlagsActing; + runCommands(a->_commands, a); } a->_program->_ip = (Instruction*)a->_program->_next; goto label1; @@ -628,8 +628,8 @@ void jobRunScripts(void *parm, Job *j) { a->_program->_ip = (Instruction*)inst->_next; label1: - if (a->_zone._flags & kFlagsCharacter) - a->_z = a->_zone._top + a->height(); + if (a->_flags & kFlagsCharacter) + a->_z = a->_top + a->height(); } _vm->sortAnimations(); @@ -655,7 +655,7 @@ void Parallaction::sortAnimations() { Node v14; memset(&v14, 0, sizeof(Node)); - _vm->_char._ani._z = _vm->_char._ani.height() + _vm->_char._ani._zone._top; + _vm->_char._ani._z = _vm->_char._ani.height() + _vm->_char._ani._top; Animation *vC = (Animation*)_animations._next; Node *v8; @@ -669,9 +669,9 @@ void Parallaction::sortAnimations() { v8 = v8->_next; } - v4 = (Animation*)vC->_zone._next; + v4 = (Animation*)vC->_next; - addNode(v8, &vC->_zone); + addNode(v8, vC); vC = v4; } diff --git a/engines/parallaction/callables.cpp b/engines/parallaction/callables.cpp index 861fe07662..f7ab236453 100644 --- a/engines/parallaction/callables.cpp +++ b/engines/parallaction/callables.cpp @@ -122,15 +122,15 @@ void _c_moveSarc(void *parm) { _introSarcData3 = _moveSarcZone1->_left; if (_introSarcData1 > 0) { - a->_zone._left = _introSarcData1 / 2; + a->_left = _introSarcData1 / 2; } else { - a->_zone._left = -_introSarcData1 / 2; + a->_left = -_introSarcData1 / 2; } if (_introSarcData1 > 0) { - a->_zone._top = 2; + a->_top = 2; } else { - a->_zone._top = -2; + a->_top = -2; } return; @@ -149,7 +149,7 @@ void _c_moveSarc(void *parm) { a = _vm->findAnimation("finito"); - a->_zone._flags |= (kFlagsActive | kFlagsActing); + a->_flags |= (kFlagsActive | kFlagsActing); _localFlags[_vm->_currentLocationIndex] |= 0x20; // GROSS HACK: activates 'finito' flag in dinoit_museo.loc } @@ -312,7 +312,7 @@ void _c_finito(void *parm) { _vm->_menu->selectCharacter(); } - removeNode(&_vm->_char._ani._zone); + removeNode(&_vm->_char._ani); _vm->_locationNames[0][0] = '\0'; _vm->_numLocations = 0; _commandFlags = 0; @@ -329,7 +329,7 @@ void _c_finito(void *parm) { _engineFlags &= ~kEngineQuit; - addNode(&_vm->_animations, &_vm->_char._ani._zone); + addNode(&_vm->_animations, &_vm->_char._ani); _score = 0; return; diff --git a/engines/parallaction/commands.cpp b/engines/parallaction/commands.cpp index 0c0ca1b36a..b01e081b62 100644 --- a/engines/parallaction/commands.cpp +++ b/engines/parallaction/commands.cpp @@ -327,7 +327,7 @@ void runCommands(Command *list, Zone *z) { break; case CMD_MOVE: { // move - if ((_vm->_char._ani._zone._flags & kFlagsRemove) || (_vm->_char._ani._zone._flags & kFlagsActive) == 0) { + if ((_vm->_char._ani._flags & kFlagsRemove) || (_vm->_char._ani._flags & kFlagsActive) == 0) { continue; } diff --git a/engines/parallaction/intro.cpp b/engines/parallaction/intro.cpp index dfddd70627..eec52673a3 100644 --- a/engines/parallaction/intro.cpp +++ b/engines/parallaction/intro.cpp @@ -313,8 +313,8 @@ void _c_sketch(void *parm) { introFunc1(_1, _2, _3, _4); - _rightHandAnim->_zone._left = _rightHandPositions[index*2]; - _rightHandAnim->_zone._top = _rightHandPositions[index*2+1] - 20; + _rightHandAnim->_left = _rightHandPositions[index*2]; + _rightHandAnim->_top = _rightHandPositions[index*2+1] - 20; index++; @@ -327,10 +327,10 @@ void _c_sketch(void *parm) { void _c_shade(void *parm) { Common::Rect r( - _rightHandAnim->_zone._left - 36, - _rightHandAnim->_zone._top - 36, - _rightHandAnim->_zone._left, - _rightHandAnim->_zone._top + _rightHandAnim->_left - 36, + _rightHandAnim->_top - 36, + _rightHandAnim->_left, + _rightHandAnim->_top ); _vm->_gfx->maskClearRectangle(r); diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp index 3b98cf2b32..f595fc7b20 100644 --- a/engines/parallaction/location.cpp +++ b/engines/parallaction/location.cpp @@ -92,8 +92,8 @@ void Parallaction::parseLocation(const char *filename) { switchBackground(_location._name, mask); if (_tokens[2][0] != '\0') { - _vm->_char._ani._zone._left = atoi(_tokens[2]); - _vm->_char._ani._zone._top = atoi(_tokens[3]); + _vm->_char._ani._left = atoi(_tokens[2]); + _vm->_char._ani._top = atoi(_tokens[3]); } if (_tokens[4][0] != '\0') { @@ -343,7 +343,7 @@ void Parallaction::changeLocation(char *location) { debugC(2, kDebugLocation, "changeLocation: changed cursor"); } - removeNode(&_vm->_char._ani._zone); + removeNode(&_vm->_char._ani); debugC(2, kDebugLocation, "changeLocation: removed character from the animation list"); freeLocation(); @@ -376,7 +376,7 @@ void Parallaction::changeLocation(char *location) { } } - addNode(&_animations, &_vm->_char._ani._zone); + addNode(&_animations, &_vm->_char._ani); debugC(2, kDebugLocation, "changeLocation: new character added to the animation list"); strcpy(_saveData1, list[0].c_str()); @@ -385,13 +385,13 @@ void Parallaction::changeLocation(char *location) { _gfx->copyScreen(Gfx::kBitBack, Gfx::kBit2); debugC(1, kDebugLocation, "changeLocation: new location '%s' parsed", _saveData1); - _vm->_char._ani._zone._oldLeft = -1000; - _vm->_char._ani._zone._oldTop = -1000; + _vm->_char._ani._oldLeft = -1000; + _vm->_char._ani._oldTop = -1000; _vm->_char._ani.field_50 = 0; if (_location._startPosition.x != -1000) { - _vm->_char._ani._zone._left = _location._startPosition.x; - _vm->_char._ani._zone._top = _location._startPosition.y; + _vm->_char._ani._left = _location._startPosition.x; + _vm->_char._ani._top = _location._startPosition.y; _vm->_char._ani._frame = _location._startFrame; _location._startPosition.y = -1000; _location._startPosition.x = -1000; diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 58d0f0a99c..5fc12a0820 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -216,7 +216,7 @@ int Parallaction::init() { initInventory(); - addNode(&_animations, &_vm->_char._ani._zone); + addNode(&_animations, &_vm->_char._ani); _gfx = new Gfx(this); int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI); @@ -261,8 +261,8 @@ void Parallaction::initGame() { parseLocation(_location._name); if (_location._startPosition.x != -1000) { - _vm->_char._ani._zone._left = _location._startPosition.x; - _vm->_char._ani._zone._top = _location._startPosition.y; + _vm->_char._ani._left = _location._startPosition.x; + _vm->_char._ani._top = _location._startPosition.y; _vm->_char._ani._frame = _location._startFrame; _location._startPosition.y = -1000; _location._startPosition.x = -1000; @@ -504,8 +504,8 @@ void Parallaction::processInput(InputData *data) { debugC(2, kDebugInput, "processInput: kEvWalk"); _hoverZone = NULL; changeCursor(kCursorArrow); - if (_vm->_char._ani._zone._flags & kFlagsRemove) break; - if ((_vm->_char._ani._zone._flags & kFlagsActive) == 0) break; + if (_vm->_char._ani._flags & kFlagsRemove) break; + if ((_vm->_char._ani._flags & kFlagsActive) == 0) break; v4 = buildWalkPath(data->_mousePos.x, data->_mousePos.y); addJob(&jobWalk, v4, kPriority19); _engineFlags |= kEngineWalking; // inhibits processing of input until walking is over diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 5d260673f9..0a6f7d674e 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -257,16 +257,16 @@ struct Character { _objs = NULL; // _objs._count = 0; - _ani._zone._left = 150; - _ani._zone._top = 100; + _ani._left = 150; + _ani._top = 100; _ani._z = 10; - _ani._zone._oldLeft = -1000; - _ani._zone._oldTop = -1000; + _ani._oldLeft = -1000; + _ani._oldTop = -1000; _ani._frame = 0; - _ani._zone._flags = kFlagsActive | kFlagsNoName; - _ani._zone._type = kZoneYou; - _ani._zone._label._cnv._data0 = NULL; - _ani._zone._label._text = strdup("yourself"); + _ani._flags = kFlagsActive | kFlagsNoName; + _ani._type = kZoneYou; + _ani._label._cnv._data0 = NULL; + _ani._label._text = strdup("yourself"); _normalFrames = NULL; _miniFrames = NULL; diff --git a/engines/parallaction/saveload.cpp b/engines/parallaction/saveload.cpp index 1d3f3169ad..2677c6c132 100644 --- a/engines/parallaction/saveload.cpp +++ b/engines/parallaction/saveload.cpp @@ -179,9 +179,9 @@ void Parallaction::doSaveGame(uint16 slot, const char* name) { sprintf(s, "%s\n", _saveData1); f->writeString(s); - sprintf(s, "%d\n", _vm->_char._ani._zone._left); + sprintf(s, "%d\n", _vm->_char._ani._left); f->writeString(s); - sprintf(s, "%d\n", _vm->_char._ani._zone._top); + sprintf(s, "%d\n", _vm->_char._ani._top); f->writeString(s); sprintf(s, "%d\n", _score); f->writeString(s); diff --git a/engines/parallaction/walk.cpp b/engines/parallaction/walk.cpp index ef17775327..0c36c1190f 100644 --- a/engines/parallaction/walk.cpp +++ b/engines/parallaction/walk.cpp @@ -142,8 +142,8 @@ WalkNode *buildWalkPath(uint16 x, uint16 y) { v48 = &v58; - Common::Point v20(_vm->_char._ani._zone._left, _vm->_char._ani._zone._top); - Common::Point v8(_si - _vm->_char._ani._zone._left, _di - _vm->_char._ani._zone._top); + Common::Point v20(_vm->_char._ani._left, _vm->_char._ani._top); + Common::Point v8(_si - _vm->_char._ani._left, _di - _vm->_char._ani._top); v34 = v30 = dotProduct(v8, v8); // square distance from current position and target @@ -235,8 +235,8 @@ uint16 walkFunc1(int16 x, int16 y, WalkNode *Node) { Common::Point v4(0, 0); Common::Point foot( - _vm->_char._ani._zone._left + _vm->_char._ani.width()/2, - _vm->_char._ani._zone._top + _vm->_char._ani.height() + _vm->_char._ani._left + _vm->_char._ani.width()/2, + _vm->_char._ani._top + _vm->_char._ani.height() ); Common::Point v8(foot); @@ -285,13 +285,13 @@ uint16 walkFunc1(int16 x, int16 y, WalkNode *Node) { void jobWalk(void *parm, Job *j) { WalkNode *node = (WalkNode*)parm; - int16 _si = _vm->_char._ani._zone._left; - int16 _di = _vm->_char._ani._zone._top; + int16 _si = _vm->_char._ani._left; + int16 _di = _vm->_char._ani._top; // debugC(1, kDebugWalk, "jobWalk to (%i, %i)", node->_x + _vm->_char._ani.width() / 2, node->_y + _vm->_char._ani.height()); - _vm->_char._ani._zone._oldLeft = _si; - _vm->_char._ani._zone._oldTop = _di; + _vm->_char._ani._oldLeft = _si; + _vm->_char._ani._oldTop = _di; if ((node->_x == _si) && (node->_y == _di)) { if (node->_next == NULL) { @@ -314,7 +314,7 @@ void jobWalk(void *parm, Job *j) { node = (WalkNode*)tmp; } - Common::Point dist(node->_x - _vm->_char._ani._zone._left, node->_y - _vm->_char._ani._zone._top); + Common::Point dist(node->_x - _vm->_char._ani._left, node->_y - _vm->_char._ani._top); if (dist.x < 0) dist.x = -dist.x; @@ -378,10 +378,10 @@ void jobWalk(void *parm, Job *j) { } // printf("hitZone: %i, %i\n", _si, _di); - _vm->_char._ani._zone._left = _si; - _vm->_char._ani._zone._top = _di; + _vm->_char._ani._left = _si; + _vm->_char._ani._top = _di; - if ((_si == _vm->_char._ani._zone._oldLeft) && (_di == _vm->_char._ani._zone._oldTop)) { + if ((_si == _vm->_char._ani._oldLeft) && (_di == _vm->_char._ani._oldTop)) { j->_finished = 1; checkDoor(); @@ -406,7 +406,7 @@ uint16 checkDoor() { } _engineFlags &= ~kEngineWalking; - Zone *z = _vm->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._left + _vm->_char._ani.width() / 2, _vm->_char._ani._top + _vm->_char._ani.height()); if (z != NULL) { @@ -424,7 +424,7 @@ uint16 checkDoor() { } } - z = _vm->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._left + _vm->_char._ani.width() / 2, _vm->_char._ani._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 b81edaa56f..48e01d8af7 100644 --- a/engines/parallaction/zone.cpp +++ b/engines/parallaction/zone.cpp @@ -42,8 +42,7 @@ Zone *Parallaction::findZone(const char *name) { v4 = (Zone*)v4->_next; } - Animation *a = findAnimation(name); - return (a == NULL ? NULL : &a->_zone); + return findAnimation(name); } @@ -602,13 +601,13 @@ Zone *Parallaction::hitZone(uint32 type, uint16 x, uint16 y) { if (z->_left != -1) continue; - if (_si < _vm->_char._ani._zone._left) + if (_si < _vm->_char._ani._left) continue; - if (_si > (_vm->_char._ani._zone._left + _vm->_char._ani.width())) + if (_si > (_vm->_char._ani._left + _vm->_char._ani.width())) continue; - if (_di < _vm->_char._ani._zone._top) + if (_di < _vm->_char._ani._top) continue; - if (_di > (_vm->_char._ani._zone._top + _vm->_char._ani.height())) + if (_di > (_vm->_char._ani._top + _vm->_char._ani.height())) continue; } @@ -626,20 +625,19 @@ Zone *Parallaction::hitZone(uint32 type, uint16 x, uint16 y) { Animation *a = (Animation*)_animations._next; int16 _a, _b, _c, _d, _e, _f; - for (; a; a = (Animation*)a->_zone._next) { -// printf("Animation name: %s", a->_zone._name); + for (; a; a = (Animation*)a->_next) { - _a = (a->_zone._flags & kFlagsActive) ? 1 : 0; // _a: active Animation - _e = ((_si >= a->_zone._left + a->width()) || (_si <= a->_zone._left)) ? 0 : 1; // _e: horizontal range - _f = ((_di >= a->_zone._top + a->height()) || (_di <= a->_zone._top)) ? 0 : 1; // _f: vertical range + _a = (a->_flags & kFlagsActive) ? 1 : 0; // _a: active Animation + _e = ((_si >= a->_left + a->width()) || (_si <= a->_left)) ? 0 : 1; // _e: horizontal range + _f = ((_di >= a->_top + a->height()) || (_di <= a->_top)) ? 0 : 1; // _f: vertical range - _b = ((type != 0) || (a->_zone._type == kZoneYou)) ? 0 : 1; // _b: (no type specified) AND (Animation is not the character) - _c = (a->_zone._type & 0xFFFF0000) ? 0 : 1; // _c: Animation is not an object - _d = ((a->_zone._type & 0xFFFF0000) != type) ? 0 : 1; // _d: Animation is an object of the same type + _b = ((type != 0) || (a->_type == kZoneYou)) ? 0 : 1; // _b: (no type specified) AND (Animation is not the character) + _c = (a->_type & 0xFFFF0000) ? 0 : 1; // _c: Animation is not an object + _d = ((a->_type & 0xFFFF0000) != type) ? 0 : 1; // _d: Animation is an object of the same type - if ((_a != 0 && _e != 0 && _f != 0) && ((_b != 0 && _c != 0) || (a->_zone._type == type) || (_d != 0))) { + if ((_a != 0 && _e != 0 && _f != 0) && ((_b != 0 && _c != 0) || (a->_type == type) || (_d != 0))) { - return &a->_zone; + return a; } diff --git a/engines/parallaction/zone.h b/engines/parallaction/zone.h index 1fc3cdb016..3c6e708c5b 100644 --- a/engines/parallaction/zone.h +++ b/engines/parallaction/zone.h @@ -184,14 +184,10 @@ struct Label { }; struct Zone : public Node { - int16 _left; int16 _top; int16 _right; int16 _bottom; - int16 _oldLeft; - int16 _oldTop; - uint32 _type; uint32 _flags; Label _label; @@ -203,7 +199,6 @@ struct Zone : public Node { Zone() { _left = _top = _right = _bottom = 0; - _oldLeft = _oldTop = 0; _type = 0; _flags = 0; @@ -298,8 +293,9 @@ struct Program : public Node { -struct Animation { - Zone _zone; +struct Animation : public Zone { + int16 _oldLeft; + int16 _oldTop; Program *_program; Cnv *_cnv; int16 _frame; @@ -313,18 +309,8 @@ struct Animation { uint16 field_5E; // unused Animation() { - - // FIXME: temporary hack until Animation become a subclass of Zone - _zone._left = _zone._top = _zone._right = _zone._bottom = 0; - _zone._oldLeft = _zone._oldTop = 0; - - _zone._type = 0; - _zone._flags = 0; - _zone._commands = NULL; - + _oldLeft = _oldTop = 0; _cnv = NULL; - - _program = NULL; _frame = 0; _z = 0; |