aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/core
diff options
context:
space:
mode:
authorPaul Gilbert2016-07-20 19:03:30 -0400
committerPaul Gilbert2016-07-20 19:03:30 -0400
commit543434aa78fd46a73ba169a773259cf71451e0c5 (patch)
treec72e537e390518c85ad387e4e0a4bc8c64bbced3 /engines/titanic/core
parent1102203396b8e924991fd0dc9990004b5d7f2e63 (diff)
downloadscummvm-rg350-543434aa78fd46a73ba169a773259cf71451e0c5.tar.gz
scummvm-rg350-543434aa78fd46a73ba169a773259cf71451e0c5.tar.bz2
scummvm-rg350-543434aa78fd46a73ba169a773259cf71451e0c5.zip
TITANIC: Fix destroying previous game project when loading savegame
Diffstat (limited to 'engines/titanic/core')
-rw-r--r--engines/titanic/core/tree_item.cpp12
-rw-r--r--engines/titanic/core/tree_item.h5
2 files changed, 9 insertions, 8 deletions
diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp
index de3d87e0d3..5fcd74bbd7 100644
--- a/engines/titanic/core/tree_item.cpp
+++ b/engines/titanic/core/tree_item.cpp
@@ -213,16 +213,16 @@ void CTreeItem::moveUnder(CTreeItem *newParent) {
}
void CTreeItem::destroyAll() {
- destroyOthers();
+ destroyChildren();
detach();
delete this;
}
-int CTreeItem::destroyOthers() {
+int CTreeItem::destroyChildren() {
if (!_firstChild)
return 0;
- CTreeItem *item = this, *child, *nextSibling;
+ CTreeItem *item = _firstChild, *child, *nextSibling;
int total = 0;
do {
@@ -230,9 +230,9 @@ int CTreeItem::destroyOthers() {
nextSibling = item->_nextSibling;
if (child)
- total += child->destroyOthers();
- child->detach();
- delete child;
+ total += item->destroyChildren();
+ item->detach();
+ delete item;
++total;
} while ((item = nextSibling) != nullptr);
diff --git a/engines/titanic/core/tree_item.h b/engines/titanic/core/tree_item.h
index 49a3fa7a65..46d7996f0f 100644
--- a/engines/titanic/core/tree_item.h
+++ b/engines/titanic/core/tree_item.h
@@ -233,9 +233,10 @@ public:
void destroyAll();
/**
- * Destroys all tree items around the given one
+ * Destroys all child tree items under this one.
+ * @returns Total number of tree items recursively removed
*/
- int destroyOthers();
+ int destroyChildren();
/**
* Detach the tree item from any other associated tree items