TITANIC: Added TTconcept deleteSiblings

This commit is contained in:
Paul Gilbert 2016-05-22 11:26:01 -04:00
parent bcfebf8f0f
commit 1ffb8ff92b
4 changed files with 24 additions and 3 deletions

View File

@ -97,6 +97,15 @@ TTconcept::~TTconcept() {
g_vm->_exeResources._owner->setParserConcept(this, nullptr);
}
void TTconcept::deleteSiblings() {
for (TTconcept *currP = _nextP, *nextP; currP; currP = nextP) {
nextP = currP->_nextP;
delete currP;
}
_nextP = nullptr;
}
bool TTconcept::setStatus() {
if (_string1.isValid() && _string2.isValid()) {
_status = SS_VALID;

View File

@ -81,6 +81,11 @@ public:
TTconcept(TTconcept &src);
~TTconcept();
/**
* Destroys any attached sibling concepts to the given concept
*/
void deleteSiblings();
/**
* Compares the name of the associated word, if any,
* to the passed string

View File

@ -31,8 +31,8 @@
namespace Titanic {
TTparser::TTparser(CScriptHandler *owner) : _owner(owner), _sentenceSub(nullptr),
_sentence(nullptr), _fieldC(0), _field10(0), _field14(0), _field18(0),
_nodesP(nullptr), _conceptP(nullptr) {
_sentence(nullptr), _fieldC(0), _field10(0), _field14(0),
_currentWordP(nullptr), _nodesP(nullptr), _conceptP(nullptr) {
loadArrays();
}
@ -41,6 +41,13 @@ TTparser::~TTparser() {
_nodesP->deleteSiblings();
delete _nodesP;
}
if (_conceptP) {
_conceptP->deleteSiblings();
delete _conceptP;
}
delete _currentWordP;
}
void TTparser::loadArrays() {

View File

@ -162,7 +162,7 @@ public:
int _fieldC;
int _field10;
int _field14;
int _field18;
TTword *_currentWordP;
public:
TTparser(CScriptHandler *owner);
~TTparser();