diff options
author | richiesams | 2013-07-29 21:43:49 -0500 |
---|---|---|
committer | richiesams | 2013-08-04 13:32:49 -0500 |
commit | 7d58ebf2819562893df2f07b916c9712d5b7413f (patch) | |
tree | 6dcead96ff83ac8d66f599bd4420a5d1ebac69ee /engines/zvision | |
parent | 93c6670f6f80b98dd05df09d710b3c683cfd1173 (diff) | |
download | scummvm-rg350-7d58ebf2819562893df2f07b916c9712d5b7413f.tar.gz scummvm-rg350-7d58ebf2819562893df2f07b916c9712d5b7413f.tar.bz2 scummvm-rg350-7d58ebf2819562893df2f07b916c9712d5b7413f.zip |
ZVISION: Convert Puzzle to a class
It needed a copy constructor and destructor to handle the heap memory ResultActions
Diffstat (limited to 'engines/zvision')
-rw-r--r-- | engines/zvision/puzzle.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h index 06c228d367..08d8a5cfd7 100644 --- a/engines/zvision/puzzle.h +++ b/engines/zvision/puzzle.h @@ -58,7 +58,27 @@ enum StateFlags { DISABLED = 0x04 }; -struct Puzzle { +class Puzzle { +public: + ~Puzzle() { + for (Common::List<ResultAction *>::iterator iter = resultActions.begin(); iter != resultActions.end(); iter++) { + delete (*iter); + } + } + + Puzzle() {} + + // Copy constructor + 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()); + } + } + uint32 key; Common::List<Criteria> criteriaList; // This has to be list of pointers because ResultAction is abstract |