diff options
author | Paul Gilbert | 2016-10-28 22:31:06 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-10-28 22:31:06 -0400 |
commit | 2466edc4b8573547817b380d7c660580c38065b5 (patch) | |
tree | 3d2b5c72b237ab62eb2aac24c85fe5f8901828e3 /engines/titanic | |
parent | cf6ae0cd5ece7da5005c5e55378f7f2338c9068c (diff) | |
download | scummvm-rg350-2466edc4b8573547817b380d7c660580c38065b5.tar.gz scummvm-rg350-2466edc4b8573547817b380d7c660580c38065b5.tar.bz2 scummvm-rg350-2466edc4b8573547817b380d7c660580c38065b5.zip |
TITANIC: Fix scanning for rooms in parseView
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/core/game_object.cpp | 3 | ||||
-rw-r--r-- | engines/titanic/core/project_item.cpp | 17 | ||||
-rw-r--r-- | engines/titanic/core/project_item.h | 2 |
3 files changed, 14 insertions, 8 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 1ccf5bae0a..a1b86e3520 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -868,7 +868,8 @@ CViewItem *CGameObject::parseView(const CString &viewString) { if (project) { if (room->getName() != roomName) { // Scan for the correct room - for (room = project->findFirstRoom(); room && room->getName() != roomName; + for (room = project->findFirstRoom(); + room && room->getName() != roomName; room = project->findNextRoom(room)) ; } } diff --git a/engines/titanic/core/project_item.cpp b/engines/titanic/core/project_item.cpp index 65e8645baa..af67f69580 100644 --- a/engines/titanic/core/project_item.cpp +++ b/engines/titanic/core/project_item.cpp @@ -372,15 +372,20 @@ CTreeItem *CProjectItem::findChildInstance(ClassDef *classDef) const { } CRoomItem *CProjectItem::findNextRoom(CRoomItem *priorRoom) const { - return dynamic_cast<CRoomItem *>(findSiblingInstanceOf(CRoomItem::_type, priorRoom)); + return dynamic_cast<CRoomItem *>(findSiblingChildInstanceOf(CRoomItem::_type, priorRoom)); } -CTreeItem *CProjectItem::findSiblingInstanceOf(ClassDef *classDef, CTreeItem *startItem) const { - CTreeItem *treeItem = startItem->getParent()->getNextSibling(); - if (treeItem == nullptr) - return nullptr; +CTreeItem *CProjectItem::findSiblingChildInstanceOf(ClassDef *classDef, CTreeItem *startItem) const { + for (CTreeItem *treeItem = startItem->getParent()->getNextSibling(); + treeItem; treeItem = treeItem->getNextSibling()) { + for (CTreeItem *childItem = treeItem->getFirstChild(); + childItem; childItem = childItem->getNextSibling()) { + if (childItem->isInstanceOf(classDef)) + return childItem; + } + } - return findChildInstance(classDef); + return nullptr; } CDontSaveFileItem *CProjectItem::getDontSaveFileItem() const { diff --git a/engines/titanic/core/project_item.h b/engines/titanic/core/project_item.h index 4d009dd50b..20c4a4377a 100644 --- a/engines/titanic/core/project_item.h +++ b/engines/titanic/core/project_item.h @@ -118,7 +118,7 @@ private: /** * Finds the next sibling occurance of a given class type */ - CTreeItem *findSiblingInstanceOf(ClassDef *classDef, CTreeItem *startItem) const; + CTreeItem *findSiblingChildInstanceOf(ClassDef *classDef, CTreeItem *startItem) const; private: /** * Load project data from the passed file |