aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision
diff options
context:
space:
mode:
Diffstat (limited to 'engines/zvision')
-rw-r--r--engines/zvision/module.mk1
-rw-r--r--engines/zvision/puzzle.cpp46
-rw-r--r--engines/zvision/puzzle.h13
-rw-r--r--engines/zvision/scr_file_handling.cpp11
-rw-r--r--engines/zvision/script_manager.cpp2
-rw-r--r--engines/zvision/script_manager.h9
6 files changed, 15 insertions, 67 deletions
diff --git a/engines/zvision/module.mk b/engines/zvision/module.mk
index f90bb156e6..26cf4ee696 100644
--- a/engines/zvision/module.mk
+++ b/engines/zvision/module.mk
@@ -8,7 +8,6 @@ MODULE_OBJS := \
detection.o \
events.o \
lzss_read_stream.o \
- puzzle.o \
render_manager.o \
render_table.o \
scr_file_handling.o \
diff --git a/engines/zvision/puzzle.cpp b/engines/zvision/puzzle.cpp
deleted file mode 100644
index 8399919399..0000000000
--- a/engines/zvision/puzzle.cpp
+++ /dev/null
@@ -1,46 +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.
-*
-*/
-
-#include "common/scummsys.h"
-
-#include "zvision/actions.h"
-#include "zvision/puzzle.h"
-
-namespace ZVision {
-
-Puzzle::~Puzzle() {
- for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); iter++) {
- delete (*iter);
- }
-}
-
-Puzzle::Puzzle(const Puzzle &other)
- : key(other.key),
- criteriaList(other.criteriaList),
- flags(flags) {
- // We have to clone the ResultActions since they are on the heap
- for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); iter++) {
- resultActions.push_back((*iter)->clone());
- }
-}
-
-} // End of namespace ZVision
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index c73a345c3a..5e060c009a 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -23,19 +23,15 @@
#ifndef ZVISION_PUZZLE_H
#define ZVISION_PUZZLE_H
+
#include "common/list.h"
+#include "common/ptr.h"
namespace ZVision {
class ResultAction;
-class Puzzle {
-public:
- Puzzle() {}
- ~Puzzle();
- Puzzle(const Puzzle &other);
-
-public:
+struct Puzzle {
/** How criteria should be decided */
enum CriteriaOperator {
EQUAL_TO,
@@ -65,11 +61,10 @@ public:
DISABLED = 0x04
};
-public:
uint32 key;
Common::List<Criteria> criteriaList;
// This has to be list of pointers because ResultAction is abstract
- Common::List<ResultAction *> resultActions;
+ Common::List<Common::SharedPtr<ResultAction>> resultActions;
uint flags;
// Used by the ScriptManager to allow unique-ification of _referenceTable
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 0bd28ec4a9..860e77147d 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -134,7 +134,7 @@ bool ScriptManager::parseCriteria(Puzzle::Criteria *criteria, Common::SeekableRe
return true;
}
-void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::List<ResultAction *> &actionList) const {
+void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::List<Common::SharedPtr<ResultAction> > &actionList) const {
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
@@ -143,14 +143,13 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
while (!line.contains('}')) {
// Parse for the action type
if (line.matchString("*:add*", true)) {
- actionList.push_back(new ActionAdd(line));
+ actionList.push_back(Common::SharedPtr<ResultAction>(new ActionAdd(line)));
} else if (line.matchString("*:animplay*", true)) {
- actionList.push_back(new ActionPlayAnimation(line));
+ actionList.push_back(Common::SharedPtr<ResultAction>(new ActionPlayAnimation(line)));
} else if (line.matchString("*:animpreload*", true)) {
- actionList.push_back(new ActionPreloadAnimation(line));
+ actionList.push_back(Common::SharedPtr<ResultAction>(new ActionPreloadAnimation(line)));
} else if (line.matchString("*:animunload*", true)) {
-
-
+ actionList.push_back(Common::SharedPtr<ResultAction>(new ActionUnloadAnimation(line)));
} else if (line.matchString("*:attenuate*", true)) {
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index ad986d6568..540971ad8b 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -112,7 +112,7 @@ void ScriptManager::checkPuzzleCriteria() {
// TODO: Add logic for the different Flags (aka, ONCE_PER_INST)
// criteriaList can be empty. Aka, the puzzle should be executed immediately
if (puzzle->criteriaList.empty() || criteriaMet) {
- for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
+ for (Common::List<Common::SharedPtr<ResultAction> >::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
(*resultIter)->execute(_engine);
}
}
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 07dd3d8586..c43030d62b 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -106,13 +106,14 @@ private:
bool parseCriteria(Puzzle::Criteria *criteria, Common::SeekableReadStream &stream) const;
/**
- * Parses the stream into a Results object
+ * Parses the stream into a ResultAction objects
* Helper method for parsePuzzle.
*
- * @param stream Scr file stream
- * @return Created Results object
+ * @param stream Scr file stream
+ * @param actionList The list where the results will be added
+ * @return Created Results object
*/
- void parseResults(Common::SeekableReadStream &stream, Common::List<ResultAction *> &actionList) const;
+ void parseResults(Common::SeekableReadStream &stream, Common::List<Common::SharedPtr<ResultAction> > &actionList) const;
/**
* Helper method for parsePuzzle. Parses the stream into a bitwise or of the StateFlags enum