aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNicola Mettifogo2009-03-02 08:44:30 +0000
committerNicola Mettifogo2009-03-02 08:44:30 +0000
commitf1044e85b2d75c449ce687fda6b170077a37a454 (patch)
tree921666889ac51aba8b4837a4e8d234e15223853b /engines
parent33a8fe7a7e596b13b05e091c52a0f1a2d5296394 (diff)
downloadscummvm-rg350-f1044e85b2d75c449ce687fda6b170077a37a454.tar.gz
scummvm-rg350-f1044e85b2d75c449ce687fda6b170077a37a454.tar.bz2
scummvm-rg350-f1044e85b2d75c449ce687fda6b170077a37a454.zip
Fixed selection of zone and animation for removal in BRA. This enables the follower animation to follow the main character across location switches.
svn-id: r39065
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/parallaction.cpp72
-rw-r--r--engines/parallaction/parallaction.h13
2 files changed, 51 insertions, 34 deletions
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 38d8b8002e..16a29044dc 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -60,7 +60,7 @@ uint32 _globalFlags = 0;
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,20 +213,6 @@ AnimationPtr Location::findAnimation(const char *name) {
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
@@ -259,7 +245,7 @@ void Parallaction::allocateLocationSlot(const char *name) {
}
-Location::Location() {
+Location::Location(int gameType) : _gameType(gameType) {
cleanup(true);
}
@@ -272,7 +258,6 @@ void Location::cleanup(bool removeAll) {
_endComment.clear();
freeZones(removeAll);
- freeAnimations(removeAll);
_programs.clear();
_commands.clear();
@@ -828,29 +813,52 @@ ZonePtr Location::findZone(const char *name) {
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;
+ }
}
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index 47b530ce10..646af212ae 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -156,12 +156,21 @@ struct Location {
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);