[Scummvm-cvs-logs] SF.net SVN: scummvm: [31415] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sun Apr 6 07:40:03 CEST 2008


Revision: 31415
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31415&view=rev
Author:   peres001
Date:     2008-04-05 22:40:02 -0700 (Sat, 05 Apr 2008)

Log Message:
-----------
Replaced custom ManagedList with Common::SharedPtr.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/callables_ns.cpp
    scummvm/trunk/engines/parallaction/debug.cpp
    scummvm/trunk/engines/parallaction/disk.h
    scummvm/trunk/engines/parallaction/exec_br.cpp
    scummvm/trunk/engines/parallaction/exec_ns.cpp
    scummvm/trunk/engines/parallaction/graphics.h
    scummvm/trunk/engines/parallaction/objects.cpp
    scummvm/trunk/engines/parallaction/objects.h
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_br.cpp
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp
    scummvm/trunk/engines/parallaction/parser.h
    scummvm/trunk/engines/parallaction/parser_br.cpp
    scummvm/trunk/engines/parallaction/parser_ns.cpp
    scummvm/trunk/engines/parallaction/saveload.cpp
    scummvm/trunk/engines/parallaction/sound.h
    scummvm/trunk/engines/parallaction/walk.cpp
    scummvm/trunk/engines/parallaction/walk.h

Removed Paths:
-------------
    scummvm/trunk/engines/parallaction/defs.h

Modified: scummvm/trunk/engines/parallaction/callables_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables_ns.cpp	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/callables_ns.cpp	2008-04-06 05:40:02 UTC (rev 31415)
@@ -40,9 +40,9 @@
 	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 *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_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 @@
 
 		a = findAnimation("sposta");
 
-		_moveSarcZone1 = (Zone*)parm;
+		_moveSarcZone1 = *(ZonePtr*)parm;
 
 		for (uint16 _si = 0; _si < 5; _si++) {
 			if (_moveSarcZones[_si] == _moveSarcZone1) {

Modified: scummvm/trunk/engines/parallaction/debug.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/debug.cpp	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/debug.cpp	2008-04-06 05:40:02 UTC (rev 31415)
@@ -156,7 +156,7 @@
 				"| 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 @@
 				"| 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 @@
 				"| # | 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");

Deleted: scummvm/trunk/engines/parallaction/defs.h
===================================================================
--- scummvm/trunk/engines/parallaction/defs.h	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/defs.h	2008-04-06 05:40:02 UTC (rev 31415)
@@ -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
-
-
-
-
-
-

Modified: scummvm/trunk/engines/parallaction/disk.h
===================================================================
--- scummvm/trunk/engines/parallaction/disk.h	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/disk.h	2008-04-06 05:40:02 UTC (rev 31415)
@@ -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"
 

Modified: scummvm/trunk/engines/parallaction/exec_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_br.cpp	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/exec_br.cpp	2008-04-06 05:40:02 UTC (rev 31415)
@@ -123,7 +123,7 @@
 
 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(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(call) {
-	callFunction(_cmdRunCtxt.cmd->u._callable, _cmdRunCtxt.z);
+	callFunction(_cmdRunCtxt.cmd->u._callable, &_cmdRunCtxt.z);
 }
 
 
@@ -316,8 +316,8 @@
 
 
 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(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(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(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(inc) {
-	Instruction *inst = *_instRunCtxt.inst;
+	InstructionPtr inst = *_instRunCtxt.inst;
 
 	int16 rvalue = inst->_opB.getRValue();
 
@@ -432,7 +432,7 @@
 
 
 DECLARE_INSTRUCTION_OPCODE(color) {
-	Instruction *inst = *_instRunCtxt.inst;
+	InstructionPtr inst = *_instRunCtxt.inst;
 
 	int16 entry = inst->_opB.getRValue();
 
@@ -456,7 +456,7 @@
 }
 
 DECLARE_INSTRUCTION_OPCODE(text) {
-	Instruction *inst = (*_instRunCtxt.inst);
+	InstructionPtr inst = (*_instRunCtxt.inst);
 	setupSubtitles(inst->_text, inst->_text2, inst->_y);
 }
 

Modified: scummvm/trunk/engines/parallaction/exec_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/exec_ns.cpp	2008-04-06 05:40:02 UTC (rev 31415)
@@ -61,7 +61,7 @@
 
 
 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(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(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(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(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(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(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(call) {
-	callFunction(_cmdRunCtxt.cmd->u._callable, _cmdRunCtxt.z);
+	callFunction(_cmdRunCtxt.cmd->u._callable, &_cmdRunCtxt.z);
 }
 
 
@@ -325,7 +325,7 @@
 
 	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 @@
 
 	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 @@
 			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 @@
 			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 @@
 }
 
 
-void Parallaction::runCommands(CommandList& list, Zone *z) {
+void Parallaction::runCommands(CommandList& list, ZonePtr z) {
 	if (list.size() == 0)
 		return;
 
@@ -433,7 +433,7 @@
 	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 @@
 
 
 
-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 @@
 //
 //	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 @@
 //	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 @@
 
 
 
-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 @@
 	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 @@
 
 			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 @@
 	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 @@
 
 	}
 
-	return NULL;
+	return nullZonePtr;
 }
 
 

Modified: scummvm/trunk/engines/parallaction/graphics.h
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.h	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/graphics.h	2008-04-06 05:40:02 UTC (rev 31415)
@@ -26,15 +26,14 @@
 #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 @@
 
 
 
+

Modified: scummvm/trunk/engines/parallaction/objects.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/objects.cpp	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/objects.cpp	2008-04-06 05:40:02 UTC (rev 31415)
@@ -30,6 +30,9 @@
 namespace Parallaction {
 
 
+ZonePtr nullZonePtr;
+AnimationPtr nullAnimationPtr;
+InstructionPtr nullInstructionPtr;
 
 Command::Command() {
 	_id = 0;
@@ -126,7 +129,6 @@
 	// BRA specific
 	_index = 0;
 	_linkedName = 0;
-	_linkedAnim = 0;
 }
 
 Zone::~Zone() {
@@ -230,8 +232,6 @@
 	_flags = 0;
 
 	// common
-	_a = 0;
-	_z = 0;
 	_immediate = 0;
 
 	// BRA specific

Modified: scummvm/trunk/engines/parallaction/objects.h
===================================================================
--- scummvm/trunk/engines/parallaction/objects.h	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/objects.h	2008-04-06 05:40:02 UTC (rev 31415)
@@ -27,9 +27,8 @@
 #define PARALLACTION_ZONE_H
 
 #include "common/list.h"
+#include "common/ptr.h"
 
-#include "parallaction/defs.h"
-
 #include "parallaction/graphics.h"
 
 
@@ -43,6 +42,19 @@
 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 @@
 	kFlagsTestTrue		= 2
 };
 
+
+
 struct CommandData {
 	uint32			_flags;
-	Zone*			_zone;
+	ZonePtr			_zone;
 	char*			_string;
 	uint16			_callable;
 	uint16			_object;
@@ -133,7 +147,8 @@
 	~Command();
 };
 
-typedef ManagedList<Command*> CommandList;
+typedef Common::SharedPtr<Command> CommandPtr;
+typedef Common::List<CommandPtr> CommandList;
 
 
 #define NUM_QUESTIONS		20
@@ -278,7 +293,7 @@
 	// BRA specific
 	uint			_index;
 	char			*_linkedName;
-	Animation		*_linkedAnim;
+	AnimationPtr	_linkedAnim;
 
 	Zone();
 	virtual ~Zone();
@@ -289,8 +304,6 @@
 	virtual uint16 height() const;
 };
 
-typedef Zone* ZonePointer;
-typedef ManagedList<ZonePointer> ZoneList;
 
 struct LocalVariable {
 	int16		_value;
@@ -336,15 +349,14 @@
 	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 @@
 };
 
 struct Program {
-	Animation		*_anim;
+	AnimationPtr	_anim;
 
 	LocalVariable	*_locals;
 
@@ -390,7 +402,8 @@
 	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 @@
 	byte* getFrameData(uint32 index) const;
 };
 
-typedef Animation* AnimationPointer;
-typedef ManagedList<AnimationPointer> AnimationList;
-
-
 class Table {
 
 protected:

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2008-04-06 05:40:02 UTC (rev 31415)
@@ -130,7 +130,6 @@
 	_location._endComment = NULL;
 
 	_pathBuffer = 0;
-	_activeZone = 0;
 
 	_screenSize = _screenWidth * _screenHeight;
 
@@ -140,8 +139,6 @@
 
 	initInventory();	// needs to be pushed into subclass
 
-	_hoverZone = NULL;
-
 	_gfx = new Gfx(this);
 
 	_debugger = new Debugger(this);
@@ -288,7 +285,7 @@
 	case kEvAction:
 		debugC(2, kDebugInput, "processInput: kEvAction");
 		_procCurrentHoverItem = -1;
-		_hoverZone = NULL;
+		_hoverZone = nullZonePtr;
 		pauseJobs();
 		runZone(data->_zone);
 		resumeJobs();
@@ -296,7 +293,7 @@
 
 	case kEvOpenInventory:
 		_procCurrentHoverItem = -1;
-		_hoverZone = NULL;
+		_hoverZone = nullZonePtr;
 		_gfx->setFloatingLabel(0);
 		if (hitZone(kZoneYou, _mousePos.x, _mousePos.y) == 0) {
 			setArrowCursor();
@@ -319,7 +316,7 @@
 
 	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 @@
 		break;
 
 	case kEvSaveGame:
-		_hoverZone = NULL;
+		_hoverZone = nullZonePtr;
 		saveGame();
 		setArrowCursor();
 		break;
 
 	case kEvLoadGame:
-		_hoverZone = NULL;
+		_hoverZone = nullZonePtr;
 		loadGame();
 		setArrowCursor();
 		break;
@@ -440,25 +437,25 @@
 	}
 
 	// 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 @@
 		}
 
 		_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 @@
 
 
 
-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 @@
 
 
 
-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 @@
 
 		// 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::_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 @@
 	delete _head;
 	delete _objs;
 
-	_ani.gfxobj = NULL;
+	_ani->gfxobj = NULL;
 	_talk = NULL;
 	_head = NULL;
 	_objs = NULL;

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2008-04-06 05:40:02 UTC (rev 31415)
@@ -33,14 +33,15 @@
 
 #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;
 
 namespace Parallaction {
@@ -200,7 +201,7 @@
 	Parallaction	*_vm;
 
 
-	Animation		_ani;
+	AnimationPtr	_ani;
 	Frames			*_head;
 	Frames			*_talk;
 	Frames			*_objs;
@@ -319,15 +320,15 @@
 	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 @@
 	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 @@
 		p = _mousePos;
 	}
 
-	Zone			*_activeZone;
+	ZonePtr			_activeZone;
 
 	ZoneList		_zones;
 	AnimationList	_animations;
@@ -423,7 +424,7 @@
 		uint16			_event;
 		Common::Point	_mousePos;
 		int16		_inventoryIndex;
-		Zone*		_zone;
+		ZonePtr		_zone;
 		Label*			_label;
 	};
 
@@ -446,7 +447,7 @@
 	bool		_hasLocationSound;
 	char		_locationSound[50];
 
-	Zone		*_hoverZone;
+	ZonePtr		_hoverZone;
 
 
 protected:		// members
@@ -480,7 +481,7 @@
 
 	void		freeCharacter();
 
-	int16		pickupItem(Zone *z);
+	int16		pickupItem(ZonePtr &z);
 
 public:
 	virtual	void callFunction(uint index, void* parm) { }
@@ -490,7 +491,7 @@
 
 	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 @@
 
 		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 @@
 	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 @@
 	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 @@
 
 	struct CommandForwardReference {
 		char		name[20];
-		Command*	cmd;
+		CommandPtr	cmd;
 	} _forwardedCommands[MAX_FORWARDS];
 	uint		_numForwardedCommands;
 
@@ -773,13 +774,13 @@
 
 	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 @@
 	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 @@
 	int			_subtitleY;
 	int			_subtitle[2];
 
-	Zone		*_activeZone2;
+	ZonePtr		_activeZone2;
 
 	int32		_counters[32];
 

Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp	2008-04-06 05:40:02 UTC (rev 31415)
@@ -64,8 +64,6 @@
 
 	_soundMan = new DummySoundMan(this);
 
-	_activeZone2 = 0;
-
 	initResources();
 	initFonts();
 	initCursors();
@@ -192,17 +190,17 @@
 }
 
 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);
 	}
 }

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2008-04-06 05:40:02 UTC (rev 31415)
@@ -137,7 +137,7 @@
 	initOpcodes();
 	initParsers();
 
-	_animations.push_front(&_char._ani);
+	_animations.push_front(_char._ani);
 
 	Parallaction::init();
 
@@ -153,7 +153,7 @@
 	delete _instructionNames;
 	delete _locationStmt;
 
-	_animations.remove(&_char._ani);
+	_animations.remove(_char._ani);
 
 }
 
@@ -278,8 +278,8 @@
 
 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 @@
 	_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 @@
 		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 @@
 	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 @@
 	_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 @@
 	_engineFlags &= ~kEngineQuit;
 
 	// main character animation is restored
-	_animations.push_front(&_char._ani);
+	_animations.push_front(_char._ani);
 	_score = 0;
 
 	return;

Modified: scummvm/trunk/engines/parallaction/parser.h
===================================================================
--- scummvm/trunk/engines/parallaction/parser.h	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/parser.h	2008-04-06 05:40:02 UTC (rev 31415)
@@ -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 @@
 
 #endif
 
+

Modified: scummvm/trunk/engines/parallaction/parser_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser_br.cpp	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/parser_br.cpp	2008-04-06 05:40:02 UTC (rev 31415)
@@ -130,14 +130,14 @@
 	// 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(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 @@
 		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);

Modified: scummvm/trunk/engines/parallaction/parser_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parser_ns.cpp	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/parser_ns.cpp	2008-04-06 05:40:02 UTC (rev 31415)
@@ -179,26 +179,24 @@
 	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 @@
 	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 @@
 		return;
 	}
 
-	Animation *a;
+	AnimationPtr a;
 	if (str[1] == '.') {
 		a = findAnimation(&str[2]);
 	} else {
@@ -445,7 +443,7 @@
 		return;
 	}
 
-	Animation *a;
+	AnimationPtr a;
 	if (str[1] == '.') {
 		a = findAnimation(&str[2]);
 	} else {
@@ -501,7 +499,7 @@
 	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 @@
 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::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 @@
 	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 @@
 
 		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 @@
 		return;
 	}
 
-	Zone *z = new Zone;
+	ZonePtr z(new Zone);
 
 	strncpy(z->_name, name, ZONENAME_LENGTH);
 
@@ -1284,7 +1282,7 @@
 
 
 
-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::parseExamineData(Script &script, Zone *z) {
+void Parallaction_ns::parseExamineData(Script &script, ZonePtr &z) {
 
 	ExamineData *data = new ExamineData;
 
@@ -1336,7 +1334,7 @@
 }
 
 
-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::parseMergeData(Script &script, Zone *z) {
+void Parallaction_ns::parseMergeData(Script &script, ZonePtr &z) {
 
 	MergeData *data = new MergeData;
 
@@ -1403,7 +1401,7 @@
 
 }
 
-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::parseSpeakData(Script &script, Zone *z) {
+void Parallaction_ns::parseSpeakData(Script &script, ZonePtr &z) {
 
 	SpeakData *data = new SpeakData;
 
@@ -1445,7 +1443,7 @@
 }
 
 
-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) {

Modified: scummvm/trunk/engines/parallaction/saveload.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/saveload.cpp	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/saveload.cpp	2008-04-06 05:40:02 UTC (rev 31415)
@@ -207,9 +207,9 @@
 
 	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);

Modified: scummvm/trunk/engines/parallaction/sound.h
===================================================================
--- scummvm/trunk/engines/parallaction/sound.h	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/sound.h	2008-04-06 05:40:02 UTC (rev 31415)
@@ -34,7 +34,7 @@
 #include "sound/mixer.h"
 #include "sound/mididrv.h"
 
-#include "parallaction/defs.h"
+#define PATH_LEN 200
 
 class MidiParser;
 

Modified: scummvm/trunk/engines/parallaction/walk.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/walk.cpp	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/walk.cpp	2008-04-06 05:40:02 UTC (rev 31415)
@@ -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 @@
 		(*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 @@
 	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 @@
 	printNodes(_list, "complete");
 #endif
 
-	delete v44;
 	return _list;
 }
 
@@ -210,7 +208,7 @@
 //	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 @@
 	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 @@
 	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 @@
 
 	// 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 @@
 
 	if (_currentLocationIndex != _doorData1) {
 		_doorData1 = _currentLocationIndex;
-		_zoneTrap = NULL;
+		_zoneTrap = nullZonePtr;
 	}
 
 	_engineFlags &= ~kEngineWalking;
@@ -337,16 +335,16 @@
 	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 @@
 	_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 @@
 
 	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 @@
 
 	_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 @@
 	p.y = _y;
 }
 
-PathBuilder::PathBuilder(Animation *anim) : _anim(anim), _list(0) {
+PathBuilder::PathBuilder(AnimationPtr &anim) : _anim(anim), _list(0) {
 }
 
 

Modified: scummvm/trunk/engines/parallaction/walk.h
===================================================================
--- scummvm/trunk/engines/parallaction/walk.h	2008-04-05 23:30:12 UTC (rev 31414)
+++ scummvm/trunk/engines/parallaction/walk.h	2008-04-06 05:40:02 UTC (rev 31415)
@@ -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 @@
 	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);
 
 };


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list