diff options
author | Paul Gilbert | 2017-08-07 21:10:24 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-08-07 21:10:24 -0400 |
commit | aef786fcc3b93670ce980f37d44fea48955d9d3a (patch) | |
tree | fc9bba6f5123b20730eb3188660a1f5a3f15d9bc /engines/titanic/core | |
parent | e685973cac056f8df0b4b02ed7bd143e05767a0c (diff) | |
download | scummvm-rg350-aef786fcc3b93670ce980f37d44fea48955d9d3a.tar.gz scummvm-rg350-aef786fcc3b93670ce980f37d44fea48955d9d3a.tar.bz2 scummvm-rg350-aef786fcc3b93670ce980f37d44fea48955d9d3a.zip |
TITANIC: Hook in the original game's secret cheat room
You can either use a special Ctrl-C key combination, or use the
'cheat' command in the debugger
Diffstat (limited to 'engines/titanic/core')
-rw-r--r-- | engines/titanic/core/game_object.cpp | 52 | ||||
-rw-r--r-- | engines/titanic/core/project_item.cpp | 56 | ||||
-rw-r--r-- | engines/titanic/core/project_item.h | 7 |
3 files changed, 64 insertions, 51 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 27af509618..ab91a6decc 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -883,57 +883,7 @@ void CGameObject::gotoView(const CString &viewName, const CString &clipName) { } CViewItem *CGameObject::parseView(const CString &viewString) { - int firstIndex = viewString.indexOf('.'); - int lastIndex = viewString.lastIndexOf('.'); - CString roomName, nodeName, viewName; - - if (firstIndex == -1) { - roomName = viewString; - } else { - roomName = viewString.left(firstIndex); - - if (lastIndex > firstIndex) { - nodeName = viewString.mid(firstIndex + 1, lastIndex - firstIndex - 1); - viewName = viewString.mid(lastIndex + 1); - } else { - nodeName = viewString.mid(firstIndex + 1); - } - } - - CGameManager *gameManager = getGameManager(); - if (!gameManager) - return nullptr; - - CRoomItem *room = gameManager->getRoom(); - CProjectItem *project = room->getRoot(); - - // Ensure we have the specified room - if (project) { - if (room->getName().compareToIgnoreCase(roomName)) { - // Scan for the correct room - for (room = project->findFirstRoom(); - room && room->getName().compareToIgnoreCase(roomName); - room = project->findNextRoom(room)) ; - } - } - if (!room) - return nullptr; - - // Find the designated node within the room - CNodeItem *node = dynamic_cast<CNodeItem *>(room->findChildInstanceOf(CNodeItem::_type)); - while (node && node->getName().compareToIgnoreCase(nodeName)) - node = dynamic_cast<CNodeItem *>(room->findNextInstanceOf(CNodeItem::_type, node)); - if (!node) - return nullptr; - - CViewItem *view = dynamic_cast<CViewItem *>(node->findChildInstanceOf(CViewItem::_type)); - while (view && view->getName().compareToIgnoreCase(viewName)) - view = dynamic_cast<CViewItem *>(node->findNextInstanceOf(CViewItem::_type, view)); - if (!view) - return nullptr; - - // Find the view, so return it - return view; + return getRoot()->parseView(viewString); } CString CGameObject::getViewFullName() const { diff --git a/engines/titanic/core/project_item.cpp b/engines/titanic/core/project_item.cpp index fa902e6ab7..13bcdfc4b4 100644 --- a/engines/titanic/core/project_item.cpp +++ b/engines/titanic/core/project_item.cpp @@ -569,4 +569,60 @@ Graphics::Surface *CProjectItem::createThumbnail() { return thumb; } +CViewItem *CProjectItem::parseView(const CString &viewString) { + int firstIndex = viewString.indexOf('.'); + int lastIndex = viewString.lastIndexOf('.'); + CString roomName, nodeName, viewName; + + if (firstIndex == -1) { + roomName = viewString; + } + else { + roomName = viewString.left(firstIndex); + + if (lastIndex > firstIndex) { + nodeName = viewString.mid(firstIndex + 1, lastIndex - firstIndex - 1); + viewName = viewString.mid(lastIndex + 1); + } + else { + nodeName = viewString.mid(firstIndex + 1); + } + } + + CGameManager *gameManager = getGameManager(); + if (!gameManager) + return nullptr; + + CRoomItem *room = gameManager->getRoom(); + CProjectItem *project = room->getRoot(); + + // Ensure we have the specified room + if (project) { + if (room->getName().compareToIgnoreCase(roomName)) { + // Scan for the correct room + for (room = project->findFirstRoom(); + room && room->getName().compareToIgnoreCase(roomName); + room = project->findNextRoom(room)); + } + } + if (!room) + return nullptr; + + // Find the designated node within the room + CNodeItem *node = dynamic_cast<CNodeItem *>(room->findChildInstanceOf(CNodeItem::_type)); + while (node && node->getName().compareToIgnoreCase(nodeName)) + node = dynamic_cast<CNodeItem *>(room->findNextInstanceOf(CNodeItem::_type, node)); + if (!node) + return nullptr; + + CViewItem *view = dynamic_cast<CViewItem *>(node->findChildInstanceOf(CViewItem::_type)); + while (view && view->getName().compareToIgnoreCase(viewName)) + view = dynamic_cast<CViewItem *>(node->findNextInstanceOf(CViewItem::_type, view)); + if (!view) + return nullptr; + + // Find the view, so return it + return view; +} + } // End of namespace Titanic diff --git a/engines/titanic/core/project_item.h b/engines/titanic/core/project_item.h index 71a84f7e00..4a87e64e2e 100644 --- a/engines/titanic/core/project_item.h +++ b/engines/titanic/core/project_item.h @@ -235,6 +235,13 @@ public: * Finds a view */ CViewItem *findView(int roomNumber, int nodeNumber, int viewNumber); + + /** + * Parses a view into it's components of room, node, and view, + * and locates the designated view + */ + CViewItem *parseView(const CString &viewString); + }; } // End of namespace Titanic |