From 8c99ff510c2e8a7d4cde30dc6d8b3698fb998907 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 22 May 2016 13:54:29 -0400 Subject: TITANIC: Added TTconcept copyFrom method --- engines/titanic/true_talk/tt_concept.cpp | 29 +++++++++++++++++++++++++++-- engines/titanic/true_talk/tt_concept.h | 9 +++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/titanic/true_talk/tt_concept.cpp b/engines/titanic/true_talk/tt_concept.cpp index 59d53a91ae..8ecaf89289 100644 --- a/engines/titanic/true_talk/tt_concept.cpp +++ b/engines/titanic/true_talk/tt_concept.cpp @@ -77,7 +77,7 @@ TTconcept::TTconcept(TTconcept &src) : if (src._wordP) { _status = initializeWordRef(src._wordP); - copyFrom(src); + initialize(src); } } } @@ -150,7 +150,7 @@ bool TTconcept::compareTo(const char *str) const { _wordP->compareTo(str); } -void TTconcept::copyFrom(TTconcept &src) { +void TTconcept::initialize(TTconcept &src) { _nextP = src._nextP; _field14 = src._field14; _scriptType = src._scriptType; @@ -177,4 +177,29 @@ void TTconcept::copyFrom(TTconcept &src) { _status = src._status; } +void TTconcept::copyFrom(TTconcept *src) { + if (this != src) { + if (src->getStatus()) { + _status = SS_5; + } else { + _string1 = src->_string1; + _string2 = src->_string2; + + if (setStatus()) { + _scriptP = src->_scriptP; + if (src->_wordP) { + _status = initializeWordRef(src->_wordP); + initialize(*src); + } else { + _wordP = nullptr; + initialize(*src); + } + } + } + } + + if (_status) + reset(); +} + } // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_concept.h b/engines/titanic/true_talk/tt_concept.h index d28ac57575..ae956c14f1 100644 --- a/engines/titanic/true_talk/tt_concept.h +++ b/engines/titanic/true_talk/tt_concept.h @@ -69,9 +69,9 @@ private: void reset(); /** - * Copy auxiliary data from the specified source concept + * Initialize inner data for the concept from a given source concept */ - void copyFrom(TTconcept &src); + void initialize(TTconcept &src); public: TTconcept *_nextP; public: @@ -86,6 +86,11 @@ public: */ void deleteSiblings(); + /** + * Copies data from a source concept + */ + void copyFrom(TTconcept *src); + /** * Compares the name of the associated word, if any, * to the passed string -- cgit v1.2.3