mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-10 04:43:26 +00:00
TITANIC: More properly handle parser clearing after sentence processing
The original actually freed the parser entirely from within findFrames, and then recreated it each time a sentence is parsed. Since this is nasty, and in ScummVM _parser isn't dynamically created, I settled on adding a clear command to completely clear the parser instead.
This commit is contained in:
parent
d39d4b9d4b
commit
0094b4225c
@ -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;
|
||||
|
@ -76,6 +76,11 @@ private:
|
||||
TTconcept *_conceptP;
|
||||
TTconcept *_currentConceptP;
|
||||
private:
|
||||
/**
|
||||
* Clear the parser
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Load the data for a given array resource
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user