aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2016-05-20 07:18:39 -0400
committerPaul Gilbert2016-07-15 19:13:33 -0400
commit4d3ca910b7ba193eb118852380c2727747ed9eb6 (patch)
tree73ab00e3bbc2f4f178ab528b947ab2b311f89f88 /engines
parent378c96736a4ce86d6812886f7c06a3c6484b9de9 (diff)
downloadscummvm-rg350-4d3ca910b7ba193eb118852380c2727747ed9eb6.tar.gz
scummvm-rg350-4d3ca910b7ba193eb118852380c2727747ed9eb6.tar.bz2
scummvm-rg350-4d3ca910b7ba193eb118852380c2727747ed9eb6.zip
TITANIC: Added TTnode methods
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/true_talk/tt_node.cpp17
-rw-r--r--engines/titanic/true_talk/tt_node.h11
2 files changed, 28 insertions, 0 deletions
diff --git a/engines/titanic/true_talk/tt_node.cpp b/engines/titanic/true_talk/tt_node.cpp
index 22695ad379..c72dfd3e51 100644
--- a/engines/titanic/true_talk/tt_node.cpp
+++ b/engines/titanic/true_talk/tt_node.cpp
@@ -38,6 +38,12 @@ void TTnode::addNode(TTnode *newNode) {
newNode->_priorP = this;
}
+void TTnode::addToHead(TTnode *newNode) {
+ TTnode *head = getHead();
+ head->_priorP = newNode;
+ newNode->_nextP = head;
+}
+
void TTnode::detach() {
if (_priorP)
_priorP->_nextP = _nextP;
@@ -58,6 +64,17 @@ void TTnode::deleteSiblings() {
}
}
+TTnode *TTnode::getHead() {
+ if (_priorP == nullptr)
+ return this;
+
+ TTnode *node = _priorP;
+ while (node->_priorP)
+ node = node->_priorP;
+
+ return node;
+}
+
TTnode *TTnode::getTail() {
if (_nextP == nullptr)
return this;
diff --git a/engines/titanic/true_talk/tt_node.h b/engines/titanic/true_talk/tt_node.h
index f8d1bc6766..8faebae18f 100644
--- a/engines/titanic/true_talk/tt_node.h
+++ b/engines/titanic/true_talk/tt_node.h
@@ -39,6 +39,12 @@ public:
void addNode(TTnode *newNode);
/**
+ * Adds a new node at the beginning of the linked list
+ */
+ void addToHead(TTnode *newNode);
+
+
+ /**
* Detaches a node from any predecessor and/or successor
*/
void detach();
@@ -49,6 +55,11 @@ public:
void deleteSiblings();
/**
+ * Returns the first node at the beginning of a linked list of nodes
+ */
+ TTnode *getHead();
+
+ /**
* Returns the final node at the end of the linked list of nodes
*/
TTnode *getTail();