diff options
Diffstat (limited to 'engines/parallaction')
-rw-r--r-- | engines/parallaction/callables_ns.cpp | 16 | ||||
-rw-r--r-- | engines/parallaction/debug.cpp | 6 | ||||
-rw-r--r-- | engines/parallaction/defs.h | 75 | ||||
-rw-r--r-- | engines/parallaction/disk.h | 3 | ||||
-rw-r--r-- | engines/parallaction/exec_br.cpp | 24 | ||||
-rw-r--r-- | engines/parallaction/exec_ns.cpp | 56 | ||||
-rw-r--r-- | engines/parallaction/graphics.h | 4 | ||||
-rw-r--r-- | engines/parallaction/objects.cpp | 6 | ||||
-rw-r--r-- | engines/parallaction/objects.h | 41 | ||||
-rw-r--r-- | engines/parallaction/parallaction.cpp | 69 | ||||
-rw-r--r-- | engines/parallaction/parallaction.h | 77 | ||||
-rw-r--r-- | engines/parallaction/parallaction_br.cpp | 8 | ||||
-rw-r--r-- | engines/parallaction/parallaction_ns.cpp | 32 | ||||
-rw-r--r-- | engines/parallaction/parser.h | 3 | ||||
-rw-r--r-- | engines/parallaction/parser_br.cpp | 14 | ||||
-rw-r--r-- | engines/parallaction/parser_ns.cpp | 56 | ||||
-rw-r--r-- | engines/parallaction/saveload.cpp | 4 | ||||
-rw-r--r-- | engines/parallaction/sound.h | 2 | ||||
-rw-r--r-- | engines/parallaction/walk.cpp | 48 | ||||
-rw-r--r-- | engines/parallaction/walk.h | 14 |
20 files changed, 243 insertions, 315 deletions
diff --git a/engines/parallaction/callables_ns.cpp b/engines/parallaction/callables_ns.cpp index 6563262e24..72b5de28f4 100644 --- a/engines/parallaction/callables_ns.cpp +++ b/engines/parallaction/callables_ns.cpp @@ -40,9 +40,9 @@ namespace Parallaction { game callables data members */ -static Zone *_moveSarcZone0 = NULL; +static ZonePtr _moveSarcZone0; static int16 _introSarcData1 = 0; -static Zone *_moveSarcZone1 = NULL; +static ZonePtr _moveSarcZone1; // part completion messages static const char *endMsg0[] = {"COMPLIMENTI!", "BRAVO!", "CONGRATULATIONS!", "PRIMA!"}; @@ -56,14 +56,14 @@ static const char *endMsg6[] = {"DELL' AVVENTURA", "DE L'AVENTURE", "OF THIS ADV static const char *endMsg7[] = {"ED ORA IL GRAN FINALE ", "ET MAINTENANT LE GRAND FINAL", "NOW THE GREAT FINAL", "UND YETZT DER GROSSE SCHLUSS!"}; static uint16 num_foglie = 0; -static Zone *_moveSarcZones[5]; -static Zone *_moveSarcExaZones[5]; +static ZonePtr _moveSarcZones[5]; +static ZonePtr _moveSarcExaZones[5]; /* intro callables data members */ -static Animation *_rightHandAnim; +static AnimationPtr _rightHandAnim; static uint16 _rightHandPositions[684] = { 0x0064, 0x0046, 0x006c, 0x0046, 0x0074, 0x0046, 0x007c, 0x0046, @@ -215,12 +215,12 @@ void Parallaction_ns::_c_fade(void *parm) { void Parallaction_ns::_c_moveSarc(void *parm) { - Animation *a; + AnimationPtr a; if (_introSarcData2 != 0) { _introSarcData2 = 0; - if (_moveSarcZones[0] == NULL) { + if (!_moveSarcZones[0]) { _moveSarcZones[0] = findZone("sarc1"); _moveSarcZones[1] = findZone("sarc2"); @@ -238,7 +238,7 @@ void Parallaction_ns::_c_moveSarc(void *parm) { a = findAnimation("sposta"); - _moveSarcZone1 = (Zone*)parm; + _moveSarcZone1 = *(ZonePtr*)parm; for (uint16 _si = 0; _si < 5; _si++) { if (_moveSarcZones[_si] == _moveSarcZone1) { diff --git a/engines/parallaction/debug.cpp b/engines/parallaction/debug.cpp index 4930987af0..c88cc63575 100644 --- a/engines/parallaction/debug.cpp +++ b/engines/parallaction/debug.cpp @@ -156,7 +156,7 @@ bool Debugger::Cmd_Zones(int argc, const char **argv) { "| name | l | t | r | b | type | flag |\n" "+--------------------+---+---+---+---+--------+--------+\n"); for ( ; b != e; b++) { - Zone *z = *b; + ZonePtr z = *b; DebugPrintf("|%-20s|%3i|%3i|%3i|%3i|%8x|%8x|\n", z->_name, z->_left, z->_top, z->_right, z->_bottom, z->_type, z->_flags ); } DebugPrintf("+--------------------+---+---+---+---+--------+--------+\n"); @@ -174,7 +174,7 @@ bool Debugger::Cmd_Animations(int argc, const char **argv) { "| name | x | y | z | f | type | flag | \n" "+--------------------+---+---+---+---+--------+--------+\n"); for ( ; b != e; b++) { - Animation *a = *b; + AnimationPtr a = *b; DebugPrintf("|%-20s|%3i|%3i|%3i|%3i|%8x|%8x|\n", a->_name, a->_left, a->_top, a->_z, a->_frame, a->_type, a->_flags ); } DebugPrintf("+--------------------+---+---+---+---+--------+--------+\n"); @@ -230,7 +230,7 @@ bool Debugger::Cmd_Programs(int argc, const char** argv) { "| # | bound animation | status |\n" "+---+--------------------+----------+\n"); for ( ; b != e; b++, i++) { - Program *p = *b; + ProgramPtr p = *b; DebugPrintf("|%3i|%-20s|%-10s|\n", i, p->_anim->_name, status[p->_status] ); } DebugPrintf("+---+--------------------+---------+\n"); diff --git a/engines/parallaction/defs.h b/engines/parallaction/defs.h deleted file mode 100644 index 42c7ad22e4..0000000000 --- a/engines/parallaction/defs.h +++ /dev/null @@ -1,75 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#ifndef PARALLACTION_DEFS_H -#define PARALLACTION_DEFS_H - -#include "common/list.h" -#include "common/rect.h" - -namespace Parallaction { - -#define PATH_LEN 200 - -template <class T> -class ManagedList : public Common::List<T> { - -public: - - typedef typename Common::List<T> Common_List; - typedef typename Common::List<T>::iterator iterator; - - ~ManagedList() { - clear(); - } - - void clear() { - erase(Common_List::begin(), Common_List::end()); - } - - iterator erase(iterator pos) { - if (pos != Common_List::end()) - delete *pos; - return Common_List::erase(pos); - } - - iterator erase(iterator first, iterator last) { - for (iterator it = first; it != last; it++) - delete *it; - return Common_List::erase(first, last); - } - -}; - -} // namespace Parallaction - - -#endif - - - - - - diff --git a/engines/parallaction/disk.h b/engines/parallaction/disk.h index 6dbf6150df..7c24655033 100644 --- a/engines/parallaction/disk.h +++ b/engines/parallaction/disk.h @@ -26,7 +26,8 @@ #ifndef PARALLACTION_DISK_H #define PARALLACTION_DISK_H -#include "parallaction/defs.h" +#define PATH_LEN 200 + #include "common/file.h" #include "graphics/surface.h" diff --git a/engines/parallaction/exec_br.cpp b/engines/parallaction/exec_br.cpp index 874d9d97a2..6aeb090ad9 100644 --- a/engines/parallaction/exec_br.cpp +++ b/engines/parallaction/exec_br.cpp @@ -123,7 +123,7 @@ DECLARE_COMMAND_OPCODE(close) { DECLARE_COMMAND_OPCODE(on) { CommandData *data = &_cmdRunCtxt.cmd->u; - Zone *z = data->_zone; + ZonePtr z = data->_zone; if (z) { z->_flags |= kFlagsActive; @@ -138,7 +138,7 @@ DECLARE_COMMAND_OPCODE(on) { DECLARE_COMMAND_OPCODE(off) { CommandData *data = &_cmdRunCtxt.cmd->u; - Zone *z = data->_zone; + ZonePtr z = data->_zone; if (z) { z->_flags |= kFlagsRemove; @@ -151,7 +151,7 @@ DECLARE_COMMAND_OPCODE(off) { DECLARE_COMMAND_OPCODE(call) { - callFunction(_cmdRunCtxt.cmd->u._callable, _cmdRunCtxt.z); + callFunction(_cmdRunCtxt.cmd->u._callable, &_cmdRunCtxt.z); } @@ -316,8 +316,8 @@ DECLARE_COMMAND_OPCODE(offsave) { DECLARE_INSTRUCTION_OPCODE(on) { - Instruction *inst = *_instRunCtxt.inst; - Zone *z = inst->_z; + InstructionPtr inst = *_instRunCtxt.inst; + ZonePtr z = inst->_z; if (z) { z->_flags |= kFlagsActive; @@ -331,8 +331,8 @@ DECLARE_INSTRUCTION_OPCODE(on) { DECLARE_INSTRUCTION_OPCODE(off) { - Instruction *inst = *_instRunCtxt.inst; - Zone *z = inst->_z; + InstructionPtr inst = *_instRunCtxt.inst; + ZonePtr z = inst->_z; if (z) { z->_flags |= kFlagsRemove; @@ -345,7 +345,7 @@ DECLARE_INSTRUCTION_OPCODE(off) { DECLARE_INSTRUCTION_OPCODE(set) { - Instruction *inst = *_instRunCtxt.inst; + InstructionPtr inst = *_instRunCtxt.inst; int16 rvalue = inst->_opB.getRValue(); int16* lvalue = inst->_opA.getLValue(); @@ -356,7 +356,7 @@ DECLARE_INSTRUCTION_OPCODE(set) { DECLARE_INSTRUCTION_OPCODE(loop) { - Instruction *inst = *_instRunCtxt.inst; + InstructionPtr inst = *_instRunCtxt.inst; _instRunCtxt.program->_loopCounter = inst->_opB.getRValue(); _instRunCtxt.program->_loopStart = _instRunCtxt.inst; @@ -364,7 +364,7 @@ DECLARE_INSTRUCTION_OPCODE(loop) { DECLARE_INSTRUCTION_OPCODE(inc) { - Instruction *inst = *_instRunCtxt.inst; + InstructionPtr inst = *_instRunCtxt.inst; int16 rvalue = inst->_opB.getRValue(); @@ -432,7 +432,7 @@ DECLARE_INSTRUCTION_OPCODE(move) { DECLARE_INSTRUCTION_OPCODE(color) { - Instruction *inst = *_instRunCtxt.inst; + InstructionPtr inst = *_instRunCtxt.inst; int16 entry = inst->_opB.getRValue(); @@ -456,7 +456,7 @@ DECLARE_INSTRUCTION_OPCODE(print) { } DECLARE_INSTRUCTION_OPCODE(text) { - Instruction *inst = (*_instRunCtxt.inst); + InstructionPtr inst = (*_instRunCtxt.inst); setupSubtitles(inst->_text, inst->_text2, inst->_y); } diff --git a/engines/parallaction/exec_ns.cpp b/engines/parallaction/exec_ns.cpp index 821d058ac9..c383920f18 100644 --- a/engines/parallaction/exec_ns.cpp +++ b/engines/parallaction/exec_ns.cpp @@ -61,7 +61,7 @@ typedef OpcodeImpl<Parallaction_ns> OpcodeV1; DECLARE_INSTRUCTION_OPCODE(on) { - Instruction *inst = *_instRunCtxt.inst; + InstructionPtr inst = *_instRunCtxt.inst; inst->_a->_flags |= kFlagsActive; inst->_a->_flags &= ~kFlagsRemove; @@ -74,7 +74,7 @@ DECLARE_INSTRUCTION_OPCODE(off) { DECLARE_INSTRUCTION_OPCODE(loop) { - Instruction *inst = *_instRunCtxt.inst; + InstructionPtr inst = *_instRunCtxt.inst; _instRunCtxt.program->_loopCounter = inst->_opB.getRValue(); _instRunCtxt.program->_loopStart = _instRunCtxt.inst; @@ -88,7 +88,7 @@ DECLARE_INSTRUCTION_OPCODE(endloop) { } DECLARE_INSTRUCTION_OPCODE(inc) { - Instruction *inst = *_instRunCtxt.inst; + InstructionPtr inst = *_instRunCtxt.inst; int16 _si = inst->_opB.getRValue(); if (inst->_flags & kInstMod) { // mod @@ -114,7 +114,7 @@ DECLARE_INSTRUCTION_OPCODE(inc) { DECLARE_INSTRUCTION_OPCODE(set) { - Instruction *inst = *_instRunCtxt.inst; + InstructionPtr inst = *_instRunCtxt.inst; int16 _si = inst->_opB.getRValue(); int16 *lvalue = inst->_opA.getLValue(); @@ -125,7 +125,7 @@ DECLARE_INSTRUCTION_OPCODE(set) { DECLARE_INSTRUCTION_OPCODE(put) { - Instruction *inst = *_instRunCtxt.inst; + InstructionPtr inst = *_instRunCtxt.inst; Graphics::Surface v18; v18.w = inst->_a->width(); v18.h = inst->_a->height(); @@ -168,7 +168,7 @@ DECLARE_INSTRUCTION_OPCODE(sound) { DECLARE_INSTRUCTION_OPCODE(move) { - Instruction *inst = (*_instRunCtxt.inst); + InstructionPtr inst = (*_instRunCtxt.inst); int16 x = inst->_opA.getRValue(); int16 y = inst->_opB.getRValue(); @@ -262,14 +262,14 @@ DECLARE_COMMAND_OPCODE(close) { DECLARE_COMMAND_OPCODE(on) { - Zone *z = _cmdRunCtxt.cmd->u._zone; + ZonePtr z = _cmdRunCtxt.cmd->u._zone; // WORKAROUND: the original DOS-based engine didn't check u->_zone before dereferencing // the pointer to get structure members, thus leading to crashes in systems with memory // protection. // As a side note, the overwritten address is the 5th entry in the DOS interrupt table // (print screen handler): this suggests that a system would hang when the print screen // key is pressed after playing Nippon Safes, provided that this code path is taken. - if (z != NULL) { + if (z) { z->_flags &= ~kFlagsRemove; z->_flags |= kFlagsActive; if ((z->_type & 0xFFFF) == kZoneGet) { @@ -285,7 +285,7 @@ DECLARE_COMMAND_OPCODE(off) { DECLARE_COMMAND_OPCODE(call) { - callFunction(_cmdRunCtxt.cmd->u._callable, _cmdRunCtxt.z); + callFunction(_cmdRunCtxt.cmd->u._callable, &_cmdRunCtxt.z); } @@ -325,7 +325,7 @@ void Parallaction_ns::drawAnimations() { for (AnimationList::iterator it = _animations.begin(); it != _animations.end(); it++) { - Animation *v18 = *it; + AnimationPtr v18 = *it; GfxObj *obj = v18->gfxobj; if ((v18->_flags & kFlagsActive) && ((v18->_flags & kFlagsRemove) == 0)) { @@ -376,7 +376,7 @@ void Parallaction_ns::runScripts() { for (ProgramList::iterator it = _programs.begin(); it != _programs.end(); it++) { - Animation *a = (*it)->_anim; + AnimationPtr a = (*it)->_anim; if (a->_flags & kFlagsCharacter) a->_z = a->_top + a->height(); @@ -392,7 +392,7 @@ void Parallaction_ns::runScripts() { debugC(9, kDebugExec, "Animation: %s, instruction: %s", a->_name, _instructionNamesRes[(*inst)->_index - 1]); _instRunCtxt.inst = inst; - _instRunCtxt.anim = a; + _instRunCtxt.anim = AnimationPtr(a); _instRunCtxt.program = *it; _instRunCtxt.modCounter = modCounter; _instRunCtxt.suspend = false; @@ -414,9 +414,9 @@ label1: a->_z = a->_top + a->height(); } - _char._ani._z = _char._ani.height() + _char._ani._top; - if (_char._ani.gfxobj) { - _char._ani.gfxobj->z = _char._ani._z; + _char._ani->_z = _char._ani->height() + _char._ani->_top; + if (_char._ani->gfxobj) { + _char._ani->gfxobj->z = _char._ani->_z; } modCounter++; @@ -424,7 +424,7 @@ label1: } -void Parallaction::runCommands(CommandList& list, Zone *z) { +void Parallaction::runCommands(CommandList& list, ZonePtr z) { if (list.size() == 0) return; @@ -433,7 +433,7 @@ void Parallaction::runCommands(CommandList& list, Zone *z) { CommandList::iterator it = list.begin(); for ( ; it != list.end(); it++) { - Command *cmd = *it; + CommandPtr cmd = *it; uint32 v8 = _localFlags[_currentLocationIndex]; if (_engineFlags & kEngineQuit) @@ -496,7 +496,7 @@ void Parallaction::displayComment(ExamineData *data) { -uint16 Parallaction::runZone(Zone *z) { +uint16 Parallaction::runZone(ZonePtr& z) { debugC(3, kDebugExec, "runZone (%s)", z->_name); uint16 subtype = z->_type & 0xFFFF; @@ -542,7 +542,7 @@ uint16 Parallaction::runZone(Zone *z) { // // ZONE TYPE: DOOR // -void Parallaction::updateDoor(Zone *z) { +void Parallaction::updateDoor(ZonePtr& z) { if (z->u.door->gfxobj) { uint frame = (z->_flags & kFlagsClosed ? 0 : 1); @@ -559,7 +559,7 @@ void Parallaction::updateDoor(Zone *z) { // ZONE TYPE: GET // -int16 Parallaction::pickupItem(Zone *z) { +int16 Parallaction::pickupItem(ZonePtr &z) { int r = addInventoryItem(z->u.get->_icon); if (r != -1) { _gfx->showGfxObj(z->u.get->gfxobj, false); @@ -570,7 +570,7 @@ int16 Parallaction::pickupItem(Zone *z) { -Zone *Parallaction::hitZone(uint32 type, uint16 x, uint16 y) { +ZonePtr Parallaction::hitZone(uint32 type, uint16 x, uint16 y) { // printf("hitZone(%i, %i, %i)", type, x, y); uint16 _di = y; @@ -579,7 +579,7 @@ Zone *Parallaction::hitZone(uint32 type, uint16 x, uint16 y) { for (ZoneList::iterator it = _zones.begin(); it != _zones.end(); it++) { // printf("Zone name: %s", z->_name); - Zone *z = *it; + ZonePtr z = *it; if (z->_flags & kFlagsRemove) continue; @@ -614,13 +614,13 @@ Zone *Parallaction::hitZone(uint32 type, uint16 x, uint16 y) { if (z->_left != -1) continue; - if (_si < _char._ani._left) + if (_si < _char._ani->_left) continue; - if (_si > (_char._ani._left + _char._ani.width())) + if (_si > (_char._ani->_left + _char._ani->width())) continue; - if (_di < _char._ani._top) + if (_di < _char._ani->_top) continue; - if (_di > (_char._ani._top + _char._ani.height())) + if (_di > (_char._ani->_top + _char._ani->height())) continue; } @@ -639,7 +639,7 @@ Zone *Parallaction::hitZone(uint32 type, uint16 x, uint16 y) { int16 _a, _b, _c, _d, _e, _f; for (AnimationList::iterator ait = _animations.begin(); ait != _animations.end(); ait++) { - Animation *a = *ait; + AnimationPtr a = *ait; _a = (a->_flags & kFlagsActive) ? 1 : 0; // _a: active Animation _e = ((_si >= a->_left + a->width()) || (_si <= a->_left)) ? 0 : 1; // _e: horizontal range @@ -657,7 +657,7 @@ Zone *Parallaction::hitZone(uint32 type, uint16 x, uint16 y) { } - return NULL; + return nullZonePtr; } diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index 13c756e0c1..8f1c14aef0 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -26,14 +26,13 @@ #ifndef PARALLACTION_GRAPHICS_H #define PARALLACTION_GRAPHICS_H +#include "common/list.h" #include "common/rect.h" #include "common/hash-str.h" #include "common/stream.h" #include "graphics/surface.h" -#include "parallaction/defs.h" - namespace Parallaction { @@ -609,3 +608,4 @@ protected: + diff --git a/engines/parallaction/objects.cpp b/engines/parallaction/objects.cpp index 58dd305b9a..0491c5c3c7 100644 --- a/engines/parallaction/objects.cpp +++ b/engines/parallaction/objects.cpp @@ -30,6 +30,9 @@ namespace Parallaction { +ZonePtr nullZonePtr; +AnimationPtr nullAnimationPtr; +InstructionPtr nullInstructionPtr; Command::Command() { _id = 0; @@ -126,7 +129,6 @@ Zone::Zone() { // BRA specific _index = 0; _linkedName = 0; - _linkedAnim = 0; } Zone::~Zone() { @@ -230,8 +232,6 @@ Instruction::Instruction() { _flags = 0; // common - _a = 0; - _z = 0; _immediate = 0; // BRA specific diff --git a/engines/parallaction/objects.h b/engines/parallaction/objects.h index d1ad943625..eb7a1445b3 100644 --- a/engines/parallaction/objects.h +++ b/engines/parallaction/objects.h @@ -27,8 +27,7 @@ #define PARALLACTION_ZONE_H #include "common/list.h" - -#include "parallaction/defs.h" +#include "common/ptr.h" #include "parallaction/graphics.h" @@ -43,6 +42,19 @@ struct Answer; struct Instruction; struct Program; +typedef Common::SharedPtr<Zone> ZonePtr; +typedef Common::List<ZonePtr> ZoneList; +extern ZonePtr nullZonePtr; + +typedef Common::SharedPtr<Animation> AnimationPtr; +typedef Common::List<AnimationPtr> AnimationList; +extern AnimationPtr nullAnimationPtr; + +typedef Common::SharedPtr<Instruction> InstructionPtr; +typedef Common::List<InstructionPtr> InstructionList; +extern InstructionPtr nullInstructionPtr; + + enum ZoneTypes { kZoneExamine = 1, // zone displays comment if activated kZoneDoor = 2, // zone activated on click (after some walk if needed) @@ -91,9 +103,11 @@ enum CommandFlags { kFlagsTestTrue = 2 }; + + struct CommandData { uint32 _flags; - Zone* _zone; + ZonePtr _zone; char* _string; uint16 _callable; uint16 _object; @@ -133,7 +147,8 @@ struct Command { ~Command(); }; -typedef ManagedList<Command*> CommandList; +typedef Common::SharedPtr<Command> CommandPtr; +typedef Common::List<CommandPtr> CommandList; #define NUM_QUESTIONS 20 @@ -278,7 +293,7 @@ struct Zone { // BRA specific uint _index; char *_linkedName; - Animation *_linkedAnim; + AnimationPtr _linkedAnim; Zone(); virtual ~Zone(); @@ -289,8 +304,6 @@ struct Zone { virtual uint16 height() const; }; -typedef Zone* ZonePointer; -typedef ManagedList<ZonePointer> ZoneList; struct LocalVariable { int16 _value; @@ -336,15 +349,14 @@ enum InstructionFlags { kInstUnk20 = 0x20 }; -typedef ManagedList<Instruction*> InstructionList; struct Instruction { uint32 _index; uint32 _flags; // common - Animation *_a; - Zone *_z; + AnimationPtr _a; + ZonePtr _z; int16 _immediate; ScriptVar _opA; ScriptVar _opB; @@ -369,7 +381,7 @@ enum { }; struct Program { - Animation *_anim; + AnimationPtr _anim; LocalVariable *_locals; @@ -390,7 +402,8 @@ struct Program { int16 addLocal(const char *name, int16 value = 0, int16 min = -10000, int16 max = 10000); }; -typedef ManagedList<Program*> ProgramList; +typedef Common::SharedPtr<Program> ProgramPtr; +typedef Common::List<ProgramPtr> ProgramList; struct Animation : public Zone { @@ -415,10 +428,6 @@ struct Animation : public Zone { byte* getFrameData(uint32 index) const; }; -typedef Animation* AnimationPointer; -typedef ManagedList<AnimationPointer> AnimationList; - - class Table { protected: diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 9f70fa1805..9a70956f8b 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -130,7 +130,6 @@ int Parallaction::init() { _location._endComment = NULL; _pathBuffer = 0; - _activeZone = 0; _screenSize = _screenWidth * _screenHeight; @@ -140,8 +139,6 @@ int Parallaction::init() { initInventory(); // needs to be pushed into subclass - _hoverZone = NULL; - _gfx = new Gfx(this); _debugger = new Debugger(this); @@ -288,7 +285,7 @@ void Parallaction::processInput(InputData *data) { case kEvAction: debugC(2, kDebugInput, "processInput: kEvAction"); _procCurrentHoverItem = -1; - _hoverZone = NULL; + _hoverZone = nullZonePtr; pauseJobs(); runZone(data->_zone); resumeJobs(); @@ -296,7 +293,7 @@ void Parallaction::processInput(InputData *data) { case kEvOpenInventory: _procCurrentHoverItem = -1; - _hoverZone = NULL; + _hoverZone = nullZonePtr; _gfx->setFloatingLabel(0); if (hitZone(kZoneYou, _mousePos.x, _mousePos.y) == 0) { setArrowCursor(); @@ -319,7 +316,7 @@ void Parallaction::processInput(InputData *data) { case kEvWalk: debugC(2, kDebugInput, "processInput: kEvWalk"); - _hoverZone = NULL; + _hoverZone = nullZonePtr; setArrowCursor(); _char.scheduleWalk(data->_mousePos.x, data->_mousePos.y); break; @@ -329,13 +326,13 @@ void Parallaction::processInput(InputData *data) { break; case kEvSaveGame: - _hoverZone = NULL; + _hoverZone = nullZonePtr; saveGame(); setArrowCursor(); break; case kEvLoadGame: - _hoverZone = NULL; + _hoverZone = nullZonePtr; loadGame(); setArrowCursor(); break; @@ -440,25 +437,25 @@ bool Parallaction::translateGameInput() { } // test if mouse is hovering on an interactive zone for the currently selected inventory item - Zone *z = hitZone(_activeItem._id, _mousePos.x, _mousePos.y); + ZonePtr z = hitZone(_activeItem._id, _mousePos.x, _mousePos.y); - if (((_mouseButtons == kMouseLeftUp) && (_activeItem._id == 0) && ((_engineFlags & kEngineWalking) == 0)) && ((z == NULL) || ((z->_type & 0xFFFF) != kZoneCommand))) { + if (((_mouseButtons == kMouseLeftUp) && (_activeItem._id == 0) && ((_engineFlags & kEngineWalking) == 0)) && ((!z) || ((z->_type & 0xFFFF) != kZoneCommand))) { _input._event = kEvWalk; return true; } - if ((z != _hoverZone) && (_hoverZone != NULL)) { - _hoverZone = NULL; + if ((z != _hoverZone) && (_hoverZone)) { + _hoverZone = nullZonePtr; _input._event = kEvExitZone; return true; } - if (z == NULL) { + if (!z) { _input._event = kEvNone; return true; } - if ((_hoverZone == NULL) && ((z->_flags & kFlagsNoName) == 0)) { + if ((!_hoverZone) && ((z->_flags & kFlagsNoName) == 0)) { _hoverZone = z; _input._event = kEvEnterZone; _input._label = z->_label; @@ -512,9 +509,9 @@ bool Parallaction::translateInventoryInput() { } _engineFlags &= ~kEngineDragging; - Zone *z = hitZone(kZoneMerge, _activeItem._index, getInventoryItemIndex(_input._inventoryIndex)); + ZonePtr z = hitZone(kZoneMerge, _activeItem._index, getInventoryItemIndex(_input._inventoryIndex)); - if (z != NULL) { + if (z) { dropItem(z->u.merge->_obj1); dropItem(z->u.merge->_obj2); addInventoryItem(z->u.merge->_obj3); @@ -623,12 +620,12 @@ void Parallaction::parseStatement() { -Animation *Parallaction::findAnimation(const char *name) { +AnimationPtr& Parallaction::findAnimation(const char *name) { for (AnimationList::iterator it = _animations.begin(); it != _animations.end(); it++) if (!scumm_stricmp((*it)->_name, name)) return *it; - return NULL; + return nullAnimationPtr; } void Parallaction::freeAnimations() { @@ -773,7 +770,7 @@ void Parallaction::doLocationEnterTransition() { -Zone *Parallaction::findZone(const char *name) { +ZonePtr Parallaction::findZone(const char *name) { for (ZoneList::iterator it = _zones.begin(); it != _zones.end(); it++) { if (!scumm_stricmp((*it)->_name, name)) return *it; @@ -792,7 +789,7 @@ void Parallaction::freeZones() { // NOTE : this condition has been relaxed compared to the original, to allow the engine // to retain special - needed - zones that were lost across location switches. - Zone* z = *it; + ZonePtr z = *it; if (((z->_top == -1) || (z->_left == -2)) && ((_engineFlags & kEngineQuit) == 0)) { debugC(2, kDebugExec, "freeZones preserving zone '%s'", z->_name); it++; @@ -810,36 +807,36 @@ const char Character::_suffixTras[] = "tras"; const char Character::_empty[] = "\0"; -Character::Character(Parallaction *vm) : _vm(vm), _builder(&_ani) { +Character::Character(Parallaction *vm) : _vm(vm), _ani(new Animation), _builder(_ani) { _talk = NULL; _head = NULL; _objs = NULL; _dummy = false; - _ani._left = 150; - _ani._top = 100; - _ani._z = 10; - _ani._oldPos.x = -1000; - _ani._oldPos.y = -1000; - _ani._frame = 0; - _ani._flags = kFlagsActive | kFlagsNoName; - _ani._type = kZoneYou; - strncpy(_ani._name, "yourself", ZONENAME_LENGTH); + _ani->_left = 150; + _ani->_top = 100; + _ani->_z = 10; + _ani->_oldPos.x = -1000; + _ani->_oldPos.y = -1000; + _ani->_frame = 0; + _ani->_flags = kFlagsActive | kFlagsNoName; + _ani->_type = kZoneYou; + strncpy(_ani->_name, "yourself", ZONENAME_LENGTH); } void Character::getFoot(Common::Point &foot) { - foot.x = _ani._left + _ani.width() / 2; - foot.y = _ani._top + _ani.height(); + foot.x = _ani->_left + _ani->width() / 2; + foot.y = _ani->_top + _ani->height(); } void Character::setFoot(const Common::Point &foot) { - _ani._left = foot.x - _ani.width() / 2; - _ani._top = foot.y - _ani.height(); + _ani->_left = foot.x - _ani->width() / 2; + _ani->_top = foot.y - _ani->height(); } void Character::scheduleWalk(int16 x, int16 y) { - if ((_ani._flags & kFlagsRemove) || (_ani._flags & kFlagsActive) == 0) { + if ((_ani->_flags & kFlagsRemove) || (_ani->_flags & kFlagsActive) == 0) { return; } @@ -853,7 +850,7 @@ void Character::free() { delete _head; delete _objs; - _ani.gfxobj = NULL; + _ani->gfxobj = NULL; _talk = NULL; _head = NULL; _objs = NULL; diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index dfc83f04c1..1376692c82 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -33,13 +33,14 @@ #include "engines/engine.h" -#include "parallaction/defs.h" #include "parallaction/inventory.h" #include "parallaction/parser.h" #include "parallaction/objects.h" #include "parallaction/disk.h" #include "parallaction/walk.h" +#define PATH_LEN 200 + extern OSystem *g_system; @@ -200,7 +201,7 @@ struct Character { Parallaction *_vm; - Animation _ani; + AnimationPtr _ani; Frames *_head; Frames *_talk; Frames *_objs; @@ -319,15 +320,15 @@ public: OpcodeSet _commandOpcodes; struct { - Command *cmd; - Zone *z; + CommandPtr cmd; + ZonePtr z; } _cmdRunCtxt; OpcodeSet _instructionOpcodes; struct { - Animation *anim; - Program *program; + AnimationPtr anim; + ProgramPtr program; InstructionList::iterator inst; uint16 modCounter; bool suspend; @@ -340,19 +341,19 @@ public: void resumeJobs(); void finalizeWalk(WalkNodeList *list); - int16 selectWalkFrame(const Common::Point& pos, const WalkNode* from); - void clipMove(Common::Point& pos, const WalkNode* from); + int16 selectWalkFrame(const Common::Point& pos, const WalkNodePtr& from); + void clipMove(Common::Point& pos, const WalkNodePtr& from); - Zone *findZone(const char *name); - Zone *hitZone(uint32 type, uint16 x, uint16 y); - uint16 runZone(Zone*); + ZonePtr findZone(const char *name); + ZonePtr hitZone(uint32 type, uint16 x, uint16 y); + uint16 runZone(ZonePtr& z); void freeZones(); void runDialogue(SpeakData*); - void runCommands(CommandList& list, Zone *z = NULL); + void runCommands(CommandList& list, ZonePtr z = nullZonePtr); - Animation *findAnimation(const char *name); + AnimationPtr &findAnimation(const char *name); void freeAnimations(); void setBackground(const char *background, const char *mask, const char *path); @@ -402,7 +403,7 @@ public: p = _mousePos; } - Zone *_activeZone; + ZonePtr _activeZone; ZoneList _zones; AnimationList _animations; @@ -423,7 +424,7 @@ protected: // data uint16 _event; Common::Point _mousePos; int16 _inventoryIndex; - Zone* _zone; + ZonePtr _zone; Label* _label; }; @@ -446,7 +447,7 @@ protected: // data bool _hasLocationSound; char _locationSound[50]; - Zone *_hoverZone; + ZonePtr _hoverZone; protected: // members @@ -480,7 +481,7 @@ protected: // members void freeCharacter(); - int16 pickupItem(Zone *z); + int16 pickupItem(ZonePtr &z); public: virtual void callFunction(uint index, void* parm) { } @@ -490,7 +491,7 @@ public: virtual void parseLocation(const char* name) = 0; - void updateDoor(Zone *z); + void updateDoor(ZonePtr &z); virtual void runScripts() = 0; virtual void walk() = 0; @@ -676,12 +677,12 @@ protected: const char *filename; Script *script; - Zone *z; - Animation *a; + ZonePtr z; + AnimationPtr a; int nextToken; CommandList *list; bool endcommands; - Command *cmd; + CommandPtr cmd; // BRA specific int numZones; @@ -733,12 +734,12 @@ protected: DECLARE_UNQUALIFIED_COMMAND_PARSER(move); DECLARE_UNQUALIFIED_COMMAND_PARSER(endcommands); - virtual void parseGetData(Script &script, Zone *z); - virtual void parseExamineData(Script &script, Zone *z); - virtual void parseDoorData(Script &script, Zone *z); - virtual void parseMergeData(Script &script, Zone *z); - virtual void parseHearData(Script &script, Zone *z); - virtual void parseSpeakData(Script &script, Zone *z); + virtual void parseGetData(Script &script, ZonePtr& z); + virtual void parseExamineData(Script &script, ZonePtr& z); + virtual void parseDoorData(Script &script, ZonePtr& z); + virtual void parseMergeData(Script &script, ZonePtr& z); + virtual void parseHearData(Script &script, ZonePtr& z); + virtual void parseSpeakData(Script &script, ZonePtr& z); void parseLocation(const char *filename); char *parseComment(Script &script); @@ -749,12 +750,12 @@ protected: Question *parseQuestion(Script &script); void parseZone(Script &script, ZoneList &list, char *name); - void parseZoneTypeBlock(Script &script, Zone *z); + void parseZoneTypeBlock(Script &script, ZonePtr z); void parseWalkNodes(Script& script, WalkNodeList &list); - Animation *parseAnimation(Script &script, AnimationList &list, char *name); + void parseAnimation(Script &script, AnimationList &list, char *name); void parseCommands(Script &script, CommandList&); void parseCommandFlags(); - void saveCommandForward(const char *name, Command* cmd); + void saveCommandForward(const char *name, CommandPtr &cmd); void resolveCommandForwards(); void createCommand(uint id); void addCommand(); @@ -763,7 +764,7 @@ protected: struct CommandForwardReference { char name[20]; - Command* cmd; + CommandPtr cmd; } _forwardedCommands[MAX_FORWARDS]; uint _numForwardedCommands; @@ -773,13 +774,13 @@ protected: struct { bool end; - Animation *a; - Instruction *inst; + AnimationPtr a; + InstructionPtr inst; LocalVariable *locals; - Program *program; + ProgramPtr program; // BRA specific - Instruction *openIf; + InstructionPtr openIf; } _instParseCtxt; DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(defLocal); @@ -798,8 +799,8 @@ protected: DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(null); DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(endscript); - void parseInstruction(Program *program); - void loadProgram(Animation *a, const char *filename); + void parseInstruction(ProgramPtr &program); + void loadProgram(AnimationPtr &a, const char *filename); void parseLValue(ScriptVar &var, const char *str); virtual void parseRValue(ScriptVar &var, const char *str); void wrapLocalVar(LocalVariable *local); @@ -889,7 +890,7 @@ public: int _subtitleY; int _subtitle[2]; - Zone *_activeZone2; + ZonePtr _activeZone2; int32 _counters[32]; diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp index 089d38ce81..93174c9d47 100644 --- a/engines/parallaction/parallaction_br.cpp +++ b/engines/parallaction/parallaction_br.cpp @@ -64,8 +64,6 @@ int Parallaction_br::init() { _soundMan = new DummySoundMan(this); - _activeZone2 = 0; - initResources(); initFonts(); initCursors(); @@ -192,17 +190,17 @@ void Parallaction_br::startPart() { } void Parallaction_br::runPendingZones() { - Zone *z; + ZonePtr z; if (_activeZone) { z = _activeZone; // speak Zone or sound - _activeZone = NULL; + _activeZone = nullZonePtr; // runZone(z); // FIXME: BRA doesn't handle sound yet } if (_activeZone2) { z = _activeZone2; // speak Zone or sound - _activeZone2 = NULL; + _activeZone2 = nullZonePtr; runZone(z); } } diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp index a0af2107e3..573306e525 100644 --- a/engines/parallaction/parallaction_ns.cpp +++ b/engines/parallaction/parallaction_ns.cpp @@ -137,7 +137,7 @@ int Parallaction_ns::init() { initOpcodes(); initParsers(); - _animations.push_front(&_char._ani); + _animations.push_front(_char._ani); Parallaction::init(); @@ -153,7 +153,7 @@ Parallaction_ns::~Parallaction_ns() { delete _instructionNames; delete _locationStmt; - _animations.remove(&_char._ani); + _animations.remove(_char._ani); } @@ -278,8 +278,8 @@ void Parallaction_ns::showSlide(const char *name) { void Parallaction_ns::runPendingZones() { if (_activeZone) { - Zone *z = _activeZone; // speak Zone or sound - _activeZone = NULL; + ZonePtr z = _activeZone; // speak Zone or sound + _activeZone = nullZonePtr; runZone(z); } } @@ -295,12 +295,12 @@ void Parallaction_ns::changeLocation(char *location) { _gfx->setFloatingLabel(0); _gfx->freeLabels(); - _hoverZone = NULL; + _hoverZone = nullZonePtr; if (_engineFlags & kEngineBlockInput) { setArrowCursor(); } - _animations.remove(&_char._ani); + _animations.remove(_char._ani); freeLocation(); @@ -320,19 +320,19 @@ void Parallaction_ns::changeLocation(char *location) { changeCharacter(locname.character()); } - _animations.push_front(&_char._ani); + _animations.push_front(_char._ani); strcpy(_saveData1, locname.location()); parseLocation(_saveData1); - _char._ani._oldPos.x = -1000; - _char._ani._oldPos.y = -1000; + _char._ani->_oldPos.x = -1000; + _char._ani->_oldPos.y = -1000; - _char._ani.field_50 = 0; + _char._ani->field_50 = 0; if (_location._startPosition.x != -1000) { - _char._ani._left = _location._startPosition.x; - _char._ani._top = _location._startPosition.y; - _char._ani._frame = _location._startFrame; + _char._ani->_left = _location._startPosition.x; + _char._ani->_top = _location._startPosition.y; + _char._ani->_frame = _location._startFrame; _location._startPosition.y = -1000; _location._startPosition.x = -1000; } @@ -376,7 +376,7 @@ void Parallaction_ns::changeCharacter(const char *name) { freeCharacter(); Common::String oldArchive = _disk->selectArchive((getFeatures() & GF_DEMO) ? "disk0" : "disk1"); - _char._ani.gfxobj = _gfx->loadAnim(_char.getFullName()); + _char._ani->gfxobj = _gfx->loadAnim(_char.getFullName()); if (!_char.dummy()) { if (getPlatform() == Common::kPlatformAmiga) { @@ -414,7 +414,7 @@ void Parallaction_ns::cleanupGame() { _engineFlags &= ~kEngineTransformedDonna; // this code saves main character animation from being removed from the following code - _animations.remove(&_char._ani); + _animations.remove(_char._ani); _numLocations = 0; _commandFlags = 0; @@ -431,7 +431,7 @@ void Parallaction_ns::cleanupGame() { _engineFlags &= ~kEngineQuit; // main character animation is restored - _animations.push_front(&_char._ani); + _animations.push_front(_char._ani); _score = 0; return; diff --git a/engines/parallaction/parser.h b/engines/parallaction/parser.h index f19e4fc905..f2a2a0c4b6 100644 --- a/engines/parallaction/parser.h +++ b/engines/parallaction/parser.h @@ -28,8 +28,6 @@ #include "common/stream.h" -#include "parallaction/defs.h" - namespace Parallaction { char *parseNextToken(char *s, char *tok, uint16 count, const char *brk, bool ignoreQuotes = false); @@ -64,3 +62,4 @@ public: #endif + diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp index 4e75b09355..1968b008eb 100644 --- a/engines/parallaction/parser_br.cpp +++ b/engines/parallaction/parser_br.cpp @@ -130,14 +130,14 @@ DECLARE_LOCATION_PARSER(location) { // TODO: handle background horizontal flip (via a context parameter) if (_tokens[nextToken][0] != '\0') { - _char._ani._left = atoi(_tokens[nextToken]); + _char._ani->_left = atoi(_tokens[nextToken]); nextToken++; - _char._ani._top = atoi(_tokens[nextToken]); + _char._ani->_top = atoi(_tokens[nextToken]); nextToken++; } if (_tokens[nextToken][0] != '\0') { - _char._ani._frame = atoi(_tokens[nextToken]); + _char._ani->_frame = atoi(_tokens[nextToken]); } } @@ -695,11 +695,11 @@ DECLARE_INSTRUCTION_PARSER(if_op) { DECLARE_INSTRUCTION_PARSER(endif) { debugC(7, kDebugParser, "INSTRUCTION_PARSER(endif) "); - if (_instParseCtxt.openIf == 0) + if (!_instParseCtxt.openIf) error("unexpected 'endif'"); // _instParseCtxt.openIf->_endif = _instParseCtxt.inst; - _instParseCtxt.openIf = NULL; + _instParseCtxt.openIf = nullInstructionPtr; } @@ -716,14 +716,14 @@ void Parallaction_br::parseRValue(ScriptVar &v, const char *str) { return; } - Animation *a; + AnimationPtr a; if (str[1] == '.') { a = findAnimation(&str[2]); if (!a) { error("unknown animation '%s' in script", &str[2]); } } else - a = _instParseCtxt.a; + a = AnimationPtr(_instParseCtxt.a); if (str[0] == 'X') { v.setField(&a->_left); diff --git a/engines/parallaction/parser_ns.cpp b/engines/parallaction/parser_ns.cpp index 319a32eb0d..8ed4709bd0 100644 --- a/engines/parallaction/parser_ns.cpp +++ b/engines/parallaction/parser_ns.cpp @@ -179,26 +179,24 @@ DECLARE_ANIM_PARSER(endanimation) { popParserTables(); } -Animation *Parallaction_ns::parseAnimation(Script& script, AnimationList &list, char *name) { +void Parallaction_ns::parseAnimation(Script& script, AnimationList &list, char *name) { debugC(5, kDebugParser, "parseAnimation(name: %s)", name); - Animation *a = new Animation; + AnimationPtr a(new Animation); strncpy(a->_name, name, ZONENAME_LENGTH); - list.push_front(a); + list.push_front(AnimationPtr(a)); _locParseCtxt.a = a; _locParseCtxt.script = &script; pushParserTables(&_locationAnimParsers, _locationAnimStmt); - - return a; } -void Parallaction_ns::parseInstruction(Program *program) { +void Parallaction_ns::parseInstruction(ProgramPtr &program) { - Instruction *inst = new Instruction; + InstructionPtr inst(new Instruction); if (_tokens[0][1] == '.') { _tokens[0][1] = '\0'; @@ -221,14 +219,14 @@ void Parallaction_ns::parseInstruction(Program *program) { return; } -void Parallaction_ns::loadProgram(Animation *a, const char *filename) { +void Parallaction_ns::loadProgram(AnimationPtr &a, const char *filename) { debugC(1, kDebugParser, "loadProgram(Animation: %s, script: %s)", a->_name, filename); Script *script = _disk->loadScript(filename); - Program *program = new Program; + ProgramPtr program(new Program); program->_anim = a; - _instParseCtxt.openIf = NULL; + _instParseCtxt.openIf = nullInstructionPtr; _instParseCtxt.end = false; _instParseCtxt.program = program; @@ -415,7 +413,7 @@ void Parallaction_ns::parseRValue(ScriptVar &v, const char *str) { return; } - Animation *a; + AnimationPtr a; if (str[1] == '.') { a = findAnimation(&str[2]); } else { @@ -445,7 +443,7 @@ void Parallaction_ns::parseLValue(ScriptVar &v, const char *str) { return; } - Animation *a; + AnimationPtr a; if (str[1] == '.') { a = findAnimation(&str[2]); } else { @@ -501,7 +499,7 @@ DECLARE_COMMAND_PARSER(zone) { createCommand(_lookup); _locParseCtxt.cmd->u._zone = findZone(_tokens[_locParseCtxt.nextToken]); - if (_locParseCtxt.cmd->u._zone == NULL) { + if (!_locParseCtxt.cmd->u._zone) { saveCommandForward(_tokens[_locParseCtxt.nextToken], _locParseCtxt.cmd); } _locParseCtxt.nextToken++; @@ -584,7 +582,7 @@ DECLARE_COMMAND_PARSER(endcommands) { void Parallaction_ns::parseCommandFlags() { int _si = _locParseCtxt.nextToken; - Command *cmd = _locParseCtxt.cmd; + CommandPtr cmd = _locParseCtxt.cmd; if (!scumm_stricmp(_tokens[_si], "flags")) { _si++; @@ -650,12 +648,12 @@ void Parallaction_ns::addCommand() { void Parallaction_ns::createCommand(uint id) { _locParseCtxt.nextToken = 1; - _locParseCtxt.cmd = new Command; + _locParseCtxt.cmd = CommandPtr(new Command); _locParseCtxt.cmd->_id = id; } -void Parallaction_ns::saveCommandForward(const char *name, Command* cmd) { +void Parallaction_ns::saveCommandForward(const char *name, CommandPtr &cmd) { assert(_numForwardedCommands < MAX_FORWARDS); strcpy(_forwardedCommands[_numForwardedCommands].name, name); @@ -858,12 +856,12 @@ DECLARE_LOCATION_PARSER(location) { switchBackground(_location._name, mask); if (_tokens[2][0] != '\0') { - _char._ani._left = atoi(_tokens[2]); - _char._ani._top = atoi(_tokens[3]); + _char._ani->_left = atoi(_tokens[2]); + _char._ani->_top = atoi(_tokens[3]); } if (_tokens[4][0] != '\0') { - _char._ani._frame = atoi(_tokens[4]); + _char._ani->_frame = atoi(_tokens[4]); } } @@ -1023,10 +1021,10 @@ void Parallaction_ns::parseWalkNodes(Script& script, WalkNodeList &list) { if (!scumm_stricmp(_tokens[0], "COORD")) { - WalkNode *v4 = new WalkNode( + WalkNodePtr v4(new WalkNode( atoi(_tokens[1]), atoi(_tokens[2]) - ); + )); list.push_front(v4); } @@ -1267,7 +1265,7 @@ void Parallaction_ns::parseZone(Script &script, ZoneList &list, char *name) { return; } - Zone *z = new Zone; + ZonePtr z(new Zone); strncpy(z->_name, name, ZONENAME_LENGTH); @@ -1284,7 +1282,7 @@ void Parallaction_ns::parseZone(Script &script, ZoneList &list, char *name) { -void Parallaction_ns::parseGetData(Script &script, Zone *z) { +void Parallaction_ns::parseGetData(Script &script, ZonePtr &z) { GetData *data = new GetData; @@ -1315,7 +1313,7 @@ void Parallaction_ns::parseGetData(Script &script, Zone *z) { } -void Parallaction_ns::parseExamineData(Script &script, Zone *z) { +void Parallaction_ns::parseExamineData(Script &script, ZonePtr &z) { ExamineData *data = new ExamineData; @@ -1336,7 +1334,7 @@ void Parallaction_ns::parseExamineData(Script &script, Zone *z) { } -void Parallaction_ns::parseDoorData(Script &script, Zone *z) { +void Parallaction_ns::parseDoorData(Script &script, ZonePtr &z) { DoorData *data = new DoorData; @@ -1380,7 +1378,7 @@ void Parallaction_ns::parseDoorData(Script &script, Zone *z) { } -void Parallaction_ns::parseMergeData(Script &script, Zone *z) { +void Parallaction_ns::parseMergeData(Script &script, ZonePtr &z) { MergeData *data = new MergeData; @@ -1403,7 +1401,7 @@ void Parallaction_ns::parseMergeData(Script &script, Zone *z) { } -void Parallaction_ns::parseHearData(Script &script, Zone *z) { +void Parallaction_ns::parseHearData(Script &script, ZonePtr &z) { HearData *data = new HearData; @@ -1424,7 +1422,7 @@ void Parallaction_ns::parseHearData(Script &script, Zone *z) { } -void Parallaction_ns::parseSpeakData(Script &script, Zone *z) { +void Parallaction_ns::parseSpeakData(Script &script, ZonePtr &z) { SpeakData *data = new SpeakData; @@ -1445,7 +1443,7 @@ void Parallaction_ns::parseSpeakData(Script &script, Zone *z) { } -void Parallaction_ns::parseZoneTypeBlock(Script &script, Zone *z) { +void Parallaction_ns::parseZoneTypeBlock(Script &script, ZonePtr z) { debugC(7, kDebugParser, "parseZoneTypeBlock(name: %s, type: %x)", z->_name, z->_type); switch (z->_type & 0xFFFF) { diff --git a/engines/parallaction/saveload.cpp b/engines/parallaction/saveload.cpp index 7c27b9b633..002295315d 100644 --- a/engines/parallaction/saveload.cpp +++ b/engines/parallaction/saveload.cpp @@ -207,9 +207,9 @@ void Parallaction_ns::doSaveGame(uint16 slot, const char* name) { sprintf(s, "%s\n", _saveData1); f->writeString(s); - sprintf(s, "%d\n", _char._ani._left); + sprintf(s, "%d\n", _char._ani->_left); f->writeString(s); - sprintf(s, "%d\n", _char._ani._top); + sprintf(s, "%d\n", _char._ani->_top); f->writeString(s); sprintf(s, "%d\n", _score); f->writeString(s); diff --git a/engines/parallaction/sound.h b/engines/parallaction/sound.h index 8842558ae9..e8360d47b8 100644 --- a/engines/parallaction/sound.h +++ b/engines/parallaction/sound.h @@ -34,7 +34,7 @@ #include "sound/mixer.h" #include "sound/mididrv.h" -#include "parallaction/defs.h" +#define PATH_LEN 200 class MidiParser; diff --git a/engines/parallaction/walk.cpp b/engines/parallaction/walk.cpp index 4f8453c509..e10a5785f5 100644 --- a/engines/parallaction/walk.cpp +++ b/engines/parallaction/walk.cpp @@ -28,7 +28,7 @@ namespace Parallaction { static uint16 _doorData1 = 1000; -static Zone *_zoneTrap = NULL; +static ZonePtr _zoneTrap; static uint16 walkData1 = 0; static uint16 walkData2 = 0; // next walk frame @@ -129,7 +129,7 @@ uint32 PathBuilder::buildSubPath(const Common::Point& pos, const Common::Point& (*nearest)->getPoint(v20); v34 = v30 = v20.sqrDist(stop); - _subPath.push_back(new WalkNode(**nearest)); + _subPath.push_back(WalkNodePtr(new WalkNode(**nearest))); } return v34; @@ -154,14 +154,13 @@ WalkNodeList *PathBuilder::buildPath(uint16 x, uint16 y) { correctPathPoint(to); debugC(1, kDebugWalk, "found closest path point at (%i, %i)", to.x, to.y); - WalkNode *v48 = new WalkNode(to.x, to.y); - WalkNode *v44 = new WalkNode(*v48); + WalkNodePtr v48(new WalkNode(to.x, to.y)); + WalkNodePtr v44 = v48; uint16 v38 = walkFunc1(to.x, to.y, v44); if (v38 == 1) { // destination directly reachable debugC(1, kDebugWalk, "direct move to (%i, %i)", to.x, to.y); - delete v44; _list = new WalkNodeList; _list->push_back(v48); @@ -198,7 +197,6 @@ WalkNodeList *PathBuilder::buildPath(uint16 x, uint16 y) { printNodes(_list, "complete"); #endif - delete v44; return _list; } @@ -210,7 +208,7 @@ WalkNodeList *PathBuilder::buildPath(uint16 x, uint16 y) { // 1 : Point reachable in a straight line // other values: square distance to target (point not reachable in a straight line) // -uint16 PathBuilder::walkFunc1(int16 x, int16 y, WalkNode *Node) { +uint16 PathBuilder::walkFunc1(int16 x, int16 y, WalkNodePtr &Node) { Common::Point arg(x, y); @@ -261,7 +259,7 @@ uint16 PathBuilder::walkFunc1(int16 x, int16 y, WalkNode *Node) { return 1; } -void Parallaction::clipMove(Common::Point& pos, const WalkNode* from) { +void Parallaction::clipMove(Common::Point& pos, const WalkNodePtr& from) { if ((pos.x < from->_x) && (pos.x < _pathBuffer->w) && (_pathBuffer->getValue(pos.x + 2, pos.y) != 0)) { pos.x = (pos.x + 2 < from->_x) ? pos.x + 2 : from->_x; @@ -282,7 +280,7 @@ void Parallaction::clipMove(Common::Point& pos, const WalkNode* from) { return; } -int16 Parallaction::selectWalkFrame(const Common::Point& pos, const WalkNode* from) { +int16 Parallaction::selectWalkFrame(const Common::Point& pos, const WalkNodePtr& from) { Common::Point dist(from->_x - pos.x, from->_y - pos.y); @@ -295,7 +293,7 @@ int16 Parallaction::selectWalkFrame(const Common::Point& pos, const WalkNode* fr // walk frame selection int16 v16; - if (_char._ani.getFrameNum() == 20) { + if (_char._ani->getFrameNum() == 20) { if (dist.x > dist.y) { walkData2 = (from->_x > pos.x) ? 0 : 7; @@ -329,7 +327,7 @@ uint16 Parallaction::checkDoor() { if (_currentLocationIndex != _doorData1) { _doorData1 = _currentLocationIndex; - _zoneTrap = NULL; + _zoneTrap = nullZonePtr; } _engineFlags &= ~kEngineWalking; @@ -337,16 +335,16 @@ uint16 Parallaction::checkDoor() { Common::Point foot; _char.getFoot(foot); - Zone *z = hitZone(kZoneDoor, foot.x, foot.y); + ZonePtr z = hitZone(kZoneDoor, foot.x, foot.y); - if (z != NULL) { + if (z) { if ((z->_flags & kFlagsClosed) == 0) { _location._startPosition = z->u.door->_startPos; _location._startFrame = z->u.door->_startFrame; scheduleLocationSwitch(z->u.door->_location); - _zoneTrap = NULL; + _zoneTrap = nullZonePtr; } else { runCommands(z->_commands, z); @@ -356,23 +354,23 @@ uint16 Parallaction::checkDoor() { _char.getFoot(foot); z = hitZone(kZoneTrap, foot.x, foot.y); - if (z != NULL) { + if (z) { _localFlags[_currentLocationIndex] |= kFlagsEnter; runCommands(z->_commands, z); _localFlags[_currentLocationIndex] &= ~kFlagsEnter; _zoneTrap = z; } else - if (_zoneTrap != NULL) { + if (_zoneTrap) { _localFlags[_currentLocationIndex] |= kFlagsExit; runCommands(_zoneTrap->_commands, _zoneTrap); _localFlags[_currentLocationIndex] &= ~kFlagsExit; - _zoneTrap = NULL; + _zoneTrap = nullZonePtr; } // printf("done\n"); - _char._ani._frame = walkData2; - return _char._ani._frame; + _char._ani->_frame = walkData2; + return _char._ani->_frame; } @@ -388,8 +386,8 @@ void Parallaction_ns::walk() { WalkNodeList *list = _char._walkPath; - _char._ani._oldPos.x = _char._ani._left; - _char._ani._oldPos.y = _char._ani._top; + _char._ani->_oldPos.x = _char._ani->_left; + _char._ani->_oldPos.y = _char._ani->_top; Common::Point pos; _char.getFoot(pos); @@ -416,14 +414,14 @@ void Parallaction_ns::walk() { _char.setFoot(pos); - Common::Point newpos(_char._ani._left, _char._ani._top); + Common::Point newpos(_char._ani->_left, _char._ani->_top); - if (newpos == _char._ani._oldPos) { + if (newpos == _char._ani->_oldPos) { debugC(1, kDebugWalk, "walk was blocked by an unforeseen obstacle"); // j->_finished = 1; finalizeWalk(list); } else { - _char._ani._frame = v16 + walkData2 + 1; + _char._ani->_frame = v16 + walkData2 + 1; } return; @@ -444,7 +442,7 @@ void WalkNode::getPoint(Common::Point &p) const { p.y = _y; } -PathBuilder::PathBuilder(Animation *anim) : _anim(anim), _list(0) { +PathBuilder::PathBuilder(AnimationPtr &anim) : _anim(anim), _list(0) { } diff --git a/engines/parallaction/walk.h b/engines/parallaction/walk.h index 1b03aa6334..f4684cb822 100644 --- a/engines/parallaction/walk.h +++ b/engines/parallaction/walk.h @@ -26,7 +26,8 @@ #ifndef PARALLACTION_WALK_H #define PARALLACTION_WALK_H -#include "parallaction/defs.h" +#include "common/ptr.h" +#include "common/list.h" namespace Parallaction { @@ -44,22 +45,23 @@ public: void getPoint(Common::Point &p) const; }; -typedef ManagedList<WalkNode*> WalkNodeList; +typedef Common::SharedPtr<WalkNode> WalkNodePtr; +typedef Common::List<WalkNodePtr> WalkNodeList; class PathBuilder { - Animation *_anim; + AnimationPtr _anim; WalkNodeList *_list; - Common::List<WalkNode*> _subPath; + WalkNodeList _subPath; void correctPathPoint(Common::Point &to); uint32 buildSubPath(const Common::Point& pos, const Common::Point& stop); - uint16 walkFunc1(int16 x, int16 y, WalkNode *Node); + uint16 walkFunc1(int16 x, int16 y, WalkNodePtr& Node); public: - PathBuilder(Animation *anim); + PathBuilder(AnimationPtr &anim); WalkNodeList* buildPath(uint16 x, uint16 y); }; |