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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Mon Mar 2 09:44:30 CET 2009


Revision: 39065
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39065&view=rev
Author:   peres001
Date:     2009-03-02 08:44:30 +0000 (Mon, 02 Mar 2009)

Log Message:
-----------
Fixed selection of zone and animation for removal in BRA. This enables the follower animation to follow the main character across location switches.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2009-03-02 08:36:42 UTC (rev 39064)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2009-03-02 08:44:30 UTC (rev 39065)
@@ -60,7 +60,7 @@
 
 
 Parallaction::Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gameDesc) :
-	Engine(syst), _gameDescription(gameDesc), _char(this) {
+	Engine(syst), _gameDescription(gameDesc), _char(this), _location(getGameType()) {
 
 	_vm = this;
 	Common::addDebugChannel(kDebugDialogue, "dialogue", "Dialogues debug level");
@@ -213,21 +213,7 @@
 	return AnimationPtr();
 }
 
-void Location::freeAnimations(bool removeAll) {
-	AnimationList::iterator it = _animations.begin();
-	while (it != _animations.end()) {
-		AnimationPtr a = *it;
-		if (!removeAll && ((a->_flags & kFlagsSelfuse) || (ACTIONTYPE(a) == kZoneMerge))) {
-			++it;
-		} else {
-			a->_commands.clear();	// See comment for freeZones(), about circular references.
-			it = _animations.erase(it);
-		}
-	}
-}
 
-
-
 void Parallaction::allocateLocationSlot(const char *name) {
 	// WORKAROUND: the original code erroneously incremented
 	// _currentLocationIndex, thus producing inconsistent
@@ -259,7 +245,7 @@
 }
 
 
-Location::Location() {
+Location::Location(int gameType) : _gameType(gameType) {
 	cleanup(true);
 }
 
@@ -272,7 +258,6 @@
 	_endComment.clear();
 
 	freeZones(removeAll);
-	freeAnimations(removeAll);
 
 	_programs.clear();
 	_commands.clear();
@@ -828,29 +813,52 @@
 	return findAnimation(name);
 }
 
+bool Location::keepZone_ns(ZonePtr z) {
+	return (z->getY() == -1) || (z->getX() == -2);
+}
 
-void Location::freeZones(bool removeAll) {
-	debugC(2, kDebugExec, "freeZones: removeAll = %i", removeAll);
+bool Location::keepAnimation_ns(AnimationPtr a) {
+	return false;
+}
 
-	ZoneList::iterator it = _zones.begin();
+bool Location::keepZone_br(ZonePtr z) {
+	return (z->_flags & kFlagsSelfuse) || (ACTIONTYPE(z) == kZoneMerge);
+}
 
-	while ( it != _zones.end() ) {
+bool Location::keepAnimation_br(AnimationPtr a) {
+	return keepZone_br(a);
+}
 
-		// 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.
-		ZonePtr z = *it;
-		if (((z->getY() == -1) || (z->getX() == -2)) && (!removeAll)) {
-			debugC(2, kDebugExec, "freeZones preserving zone '%s'", z->_name);
-			it++;
+
+template <class T>
+void Location::freeList(Common::List<T> &list, bool removeAll, Common::MemFunc1<bool, T, Location> filter) {
+	typedef typename Common::List<T>::iterator iterator;
+	iterator it = list.begin();
+	while (it != list.end()) {
+		T z = *it;
+		if (!removeAll && filter(this, z)) {
+			++it;
 		} else {
-			(*it)->_commands.clear();	// Since commands may reference zones, and both commands and zones are kept stored into
-										// SharedPtr's, we need to kill commands explicitly to destroy any potential circular
-										// reference.
-			it = _zones.erase(it);
+			z->_commands.clear();
+			it = list.erase(it);
 		}
 	}
+}
 
-	return;
+void Location::freeZones(bool removeAll) {
+	debugC(2, kDebugExec, "freeZones: removeAll = %i", removeAll);
+
+	switch (_gameType) {
+	case GType_Nippon:
+		freeList(_zones, removeAll, Common::mem_fun(&Location::keepZone_ns));
+		freeList(_animations, removeAll, Common::mem_fun(&Location::keepAnimation_ns));
+		break;
+
+	case GType_BRA:
+		freeList(_zones, removeAll, Common::mem_fun(&Location::keepZone_br));
+		freeList(_animations, removeAll, Common::mem_fun(&Location::keepAnimation_br));
+		break;
+	}
 }
 
 

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2009-03-02 08:36:42 UTC (rev 39064)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2009-03-02 08:44:30 UTC (rev 39065)
@@ -156,12 +156,21 @@
 	Common::Point	_followerStartPosition;
 	uint16			_followerStartFrame;
 
+
 protected:
-	void freeAnimations(bool removeAll);
+	int			_gameType;
 	void freeZones(bool removeAll);
 
+	bool keepZone_br(ZonePtr z);
+	bool keepZone_ns(ZonePtr z);
+	bool keepAnimation_ns(AnimationPtr a);
+	bool keepAnimation_br(AnimationPtr a);
+
+	template <class T>
+	void freeList(Common::List<T> &list, bool removeAll, Common::MemFunc1<bool, T, Location> filter);
+
 public:
-	Location();
+	Location(int gameType);
 	~Location();
 
 	AnimationPtr findAnimation(const char *name);


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