[Scummvm-cvs-logs] SF.net SVN: scummvm: [26410] scummvm/trunk/engines/parallaction
peres001 at users.sourceforge.net
peres001 at users.sourceforge.net
Sat Apr 7 19:18:17 CEST 2007
Revision: 26410
http://scummvm.svn.sourceforge.net/scummvm/?rev=26410&view=rev
Author: peres001
Date: 2007-04-07 10:18:16 -0700 (Sat, 07 Apr 2007)
Log Message:
-----------
Added new ManagedList class to handle Instruction and Command lists. The same class will be used to hold Zone, Animation and WalkNode lists.
Modified Paths:
--------------
scummvm/trunk/engines/parallaction/animation.cpp
scummvm/trunk/engines/parallaction/commands.cpp
scummvm/trunk/engines/parallaction/commands.h
scummvm/trunk/engines/parallaction/defs.h
scummvm/trunk/engines/parallaction/dialogue.cpp
scummvm/trunk/engines/parallaction/location.cpp
scummvm/trunk/engines/parallaction/parallaction.h
scummvm/trunk/engines/parallaction/zone.cpp
scummvm/trunk/engines/parallaction/zone.h
Modified: scummvm/trunk/engines/parallaction/animation.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/animation.cpp 2007-04-07 16:40:27 UTC (rev 26409)
+++ scummvm/trunk/engines/parallaction/animation.cpp 2007-04-07 17:18:16 UTC (rev 26410)
@@ -704,12 +704,6 @@
Program::~Program() {
delete[] _locals;
-
- InstructionList::iterator it = _instructions.begin();
- for (; it != _instructions.end(); it++)
- delete *it;
-
- _instructions.clear();
}
Modified: scummvm/trunk/engines/parallaction/commands.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/commands.cpp 2007-04-07 16:40:27 UTC (rev 26409)
+++ scummvm/trunk/engines/parallaction/commands.cpp 2007-04-07 17:18:16 UTC (rev 26410)
@@ -189,22 +189,6 @@
}
-void Parallaction::freeCommands(CommandList &list) {
-
- CommandList::iterator it = list.begin();
-
- while ( it != list.end() ) {
- delete *it;
- it++;
- }
-
- list.clear();
-
- return;
-}
-
-
-
void Parallaction::runCommands(CommandList& list, Zone *z) {
debugC(1, kDebugLocation, "runCommands");
Modified: scummvm/trunk/engines/parallaction/commands.h
===================================================================
--- scummvm/trunk/engines/parallaction/commands.h 2007-04-07 16:40:27 UTC (rev 26409)
+++ scummvm/trunk/engines/parallaction/commands.h 2007-04-07 17:18:16 UTC (rev 26410)
@@ -73,6 +73,9 @@
~Command();
};
+//typedef Common::List<Command*> CommandList;
+typedef ManagedList<Command*> CommandList;
+
} // namespace Parallaction
#endif
Modified: scummvm/trunk/engines/parallaction/defs.h
===================================================================
--- scummvm/trunk/engines/parallaction/defs.h 2007-04-07 16:40:27 UTC (rev 26409)
+++ scummvm/trunk/engines/parallaction/defs.h 2007-04-07 17:18:16 UTC (rev 26410)
@@ -23,6 +23,9 @@
#ifndef PARALLACTION_DEFS_H
#define PARALLACTION_DEFS_H
+#include "common/stdafx.h"
+#include "common/list.h"
+
namespace Parallaction {
// TODO (LIST): this struct won't be used anymore as soon as List<> is enforced throughout the code.
@@ -40,7 +43,34 @@
}
};
+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) {
+ return erase(pos, pos);
+ }
+
+ iterator erase(iterator first, iterator last) {
+ for (iterator it = first; it != last; it++)
+ delete *it;
+ return Common_List::erase(first, last);
+ }
+
+};
+
} // namespace Parallaction
Modified: scummvm/trunk/engines/parallaction/dialogue.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/dialogue.cpp 2007-04-07 16:40:27 UTC (rev 26409)
+++ scummvm/trunk/engines/parallaction/dialogue.cpp 2007-04-07 17:18:16 UTC (rev 26410)
@@ -497,8 +497,6 @@
if (_mood & 0x10)
delete _following._question;
- _vm->freeCommands(_commands);
-
if (_text)
free(_text);
Modified: scummvm/trunk/engines/parallaction/location.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/location.cpp 2007-04-07 16:40:27 UTC (rev 26409)
+++ scummvm/trunk/engines/parallaction/location.cpp 2007-04-07 17:18:16 UTC (rev 26410)
@@ -219,11 +219,10 @@
_location._comment = NULL;
debugC(7, kDebugLocation, "freeLocation: comments freed");
- // TODO (LIST): this should be _location._commands.clear();
- freeCommands(_location._commands);
+ _location._commands.clear();
debugC(7, kDebugLocation, "freeLocation: commands freed");
- freeCommands(_location._aCommands);
+ _location._aCommands.clear();
debugC(7, kDebugLocation, "freeLocation: acommands freed");
return;
Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h 2007-04-07 16:40:27 UTC (rev 26409)
+++ scummvm/trunk/engines/parallaction/parallaction.h 2007-04-07 17:18:16 UTC (rev 26410)
@@ -319,7 +319,6 @@
void runDialogue(SpeakData*);
void runCommands(CommandList& list, Zone *z = NULL);
- void freeCommands(CommandList& list); // to be phased out soon
Animation *findAnimation(const char *name);
void sortAnimations();
Modified: scummvm/trunk/engines/parallaction/zone.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/zone.cpp 2007-04-07 16:40:27 UTC (rev 26409)
+++ scummvm/trunk/engines/parallaction/zone.cpp 2007-04-07 17:18:16 UTC (rev 26410)
@@ -650,7 +650,6 @@
free(_label._text);
_label._text = NULL;
_vm->_gfx->freeStaticCnv(&_label._cnv);
- _vm->freeCommands(_commands);
}
Modified: scummvm/trunk/engines/parallaction/zone.h
===================================================================
--- scummvm/trunk/engines/parallaction/zone.h 2007-04-07 16:40:27 UTC (rev 26409)
+++ scummvm/trunk/engines/parallaction/zone.h 2007-04-07 17:18:16 UTC (rev 26410)
@@ -26,6 +26,7 @@
#include "common/list.h"
#include "parallaction/defs.h"
+#include "parallaction/commands.h"
#include "parallaction/graphics.h"
@@ -68,8 +69,6 @@
struct Command;
struct Question;
-typedef Common::List<Command*> CommandList;
-
struct Answer {
char* _text;
uint16 _mood;
@@ -263,7 +262,8 @@
}
};
-typedef Common::List<Instruction*> InstructionList;
+//typedef Common::List<Instruction*> InstructionList;
+typedef ManagedList<Instruction*> InstructionList;
struct Program {
LocalVariable *_locals;
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