aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/true_talk
diff options
context:
space:
mode:
Diffstat (limited to 'engines/titanic/true_talk')
-rw-r--r--engines/titanic/true_talk/tt_parser.cpp15
-rw-r--r--engines/titanic/true_talk/tt_parser.h5
2 files changed, 13 insertions, 7 deletions
diff --git a/engines/titanic/true_talk/tt_parser.cpp b/engines/titanic/true_talk/tt_parser.cpp
index 6b69c903e4..4abe9e52b1 100644
--- a/engines/titanic/true_talk/tt_parser.cpp
+++ b/engines/titanic/true_talk/tt_parser.cpp
@@ -41,17 +41,24 @@ TTparser::TTparser(CScriptHandler *owner) : _owner(owner), _sentenceConcept(null
}
TTparser::~TTparser() {
+ clear();
+}
+
+void TTparser::clear() {
if (_nodesP) {
_nodesP->deleteSiblings();
delete _nodesP;
+ _nodesP = nullptr;
}
if (_conceptP) {
_conceptP->deleteSiblings();
delete _conceptP;
+ _conceptP = nullptr;
}
delete _currentWordP;
+ _currentWordP = nullptr;
}
void TTparser::loadArray(StringArray &arr, const CString &name) {
@@ -531,13 +538,7 @@ int TTparser::findFrames(TTsentence *sentence) {
if (status <= 1) {
status = checkForAction();
- }
-
- if (_nodesP) {
- // This shouldn't ever happen
- warning("Parser had left-over processing nodes");
- while (_nodesP)
- removeNode(_nodesP);
+ clear();
}
delete line;
diff --git a/engines/titanic/true_talk/tt_parser.h b/engines/titanic/true_talk/tt_parser.h
index d39cf50c33..5930ea239a 100644
--- a/engines/titanic/true_talk/tt_parser.h
+++ b/engines/titanic/true_talk/tt_parser.h
@@ -77,6 +77,11 @@ private:
TTconcept *_currentConceptP;
private:
/**
+ * Clear the parser
+ */
+ void clear();
+
+ /**
* Load the data for a given array resource
*/
void loadArray(StringArray &arr, const CString &name);