diff options
author | Paul Gilbert | 2016-05-10 22:58:28 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:39:08 -0400 |
commit | 1045fda846dd607546b7f4914850771397fbebb8 (patch) | |
tree | 8db4781afa3635f2d4953a7375fd483ce36d81d4 /engines | |
parent | 33ef893b04bc218a6149b3ff5b6782655767e60f (diff) | |
download | scummvm-rg350-1045fda846dd607546b7f4914850771397fbebb8.tar.gz scummvm-rg350-1045fda846dd607546b7f4914850771397fbebb8.tar.bz2 scummvm-rg350-1045fda846dd607546b7f4914850771397fbebb8.zip |
TITANIC: Variation TTstringNode initialize method
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/true_talk/tt_string_node.cpp | 37 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_string_node.h | 16 |
2 files changed, 53 insertions, 0 deletions
diff --git a/engines/titanic/true_talk/tt_string_node.cpp b/engines/titanic/true_talk/tt_string_node.cpp index b1e2a642e4..da805fa9f1 100644 --- a/engines/titanic/true_talk/tt_string_node.cpp +++ b/engines/titanic/true_talk/tt_string_node.cpp @@ -29,6 +29,10 @@ TTstringNode::TTstringNode() : _pPrior(nullptr), _pNext(nullptr), _field14(0), _mode(0), _field1C(0) { } +TTstringNode::~TTstringNode() { + detach(); +} + void TTstringNode::initialize(int mode) { _mode = mode; _field14 = 0; @@ -41,12 +45,34 @@ void TTstringNode::initialize(int mode) { } } +void TTstringNode::initialize(TTstringNode *oldNode) { + _mode = oldNode->_mode; + _field14 = oldNode->_field14; + + if (_string.isValid()) { + _field1C = 0; + } else { + _field1C = 11; + warning("TTstringNode::initialize has bad subobj"); + } + + delete oldNode; +} + void TTstringNode::addNode(TTstringNode *newNode) { TTstringNode *tail = getTail(); tail->_pNext = newNode; newNode->_pPrior = this; } +void TTstringNode::detach() { + if (_pPrior) + _pPrior->_pNext = _pNext; + + if (_pNext) + _pNext->_pPrior = _pPrior; +} + TTstringNode *TTstringNode::getTail() const { if (_pNext == nullptr) return nullptr; @@ -58,6 +84,17 @@ TTstringNode *TTstringNode::getTail() const { return node; } +TTstringNode *TTstringNode::scan(TTstringNode *start, const TTString &str, int mode) { + for (; start; start = start->_pNext) { + if (start->_mode == mode || (mode == 3 && start->_mode < 3)) { + if (!strcmp(start->_string.c_str(), str.c_str())) + start; + } + } + + return nullptr; +} + /*------------------------------------------------------------------------*/ TTsynonymNode::TTsynonymNode() : TTstringNode() { diff --git a/engines/titanic/true_talk/tt_string_node.h b/engines/titanic/true_talk/tt_string_node.h index e588ea4883..41ce6c5aad 100644 --- a/engines/titanic/true_talk/tt_string_node.h +++ b/engines/titanic/true_talk/tt_string_node.h @@ -38,6 +38,11 @@ protected: * Initializes state for the node */ void initialize(int mode); + + /** + * Initializes state for the node + */ + void initialize(TTstringNode *oldNode); public: TTstringNode *_pPrior; TTstringNode *_pNext; @@ -47,11 +52,22 @@ public: int _field1C; public: TTstringNode(); + virtual ~TTstringNode(); /** * Links the passed node to this node as a linked list */ void addNode(TTstringNode *newNode); + + /** + * Detaches a node from any predecessor and/or successor + */ + void detach(); + + /** + * Scan for a node with a given string + */ + static TTstringNode *scan(TTstringNode *start, const TTString &str, int mode); }; class TTsynonymNode : public TTstringNode { |