TITANIC: Added TTsentenceSubBase setHandlerConcept

This commit is contained in:
Paul Gilbert 2016-05-23 21:37:48 -04:00
parent 938ec867fe
commit d537a25bd7
7 changed files with 125 additions and 51 deletions

View File

@ -53,16 +53,16 @@ private:
CExeResources &_resources;
int _field10;
CScriptHandlerSub1 _sub1;
TTparser _parser;
int _inputCtr;
int _field30;
public:
TTparser _parser;
TTvocab *_vocab;
TTscriptBase *_script;
TTconcept *_concept1P;
TTconcept *_concept2P;
TTconcept *_concept3P;
TTconcept *_concept4P;
int _field30;
public:
TTvocab *_vocab;
TTscriptBase *_script;
public:
CScriptHandler(CTitleEngine *owner, int val1, int val2);
~CScriptHandler();

View File

@ -50,29 +50,21 @@ TTparser::~TTparser() {
delete _currentWordP;
}
void TTparser::loadArray(StringArray &arr, const CString &name) {
Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name);
while (r->pos() < r->size())
arr.push_back(readStringFromStream(r));
delete r;
}
void TTparser::loadArrays() {
Common::SeekableReadStream *r;
r = g_vm->_filesManager->getResource("TEXT/REPLACEMENTS1");
while (r->pos() < r->size())
_replacements1.push_back(readStringFromStream(r));
delete r;
loadArray(_replacements1, "TEXT/REPLACEMENTS1");
loadArray(_replacements2, "TEXT/REPLACEMENTS2");
loadArray(_replacements3, "TEXT/REPLACEMENTS3");
loadArray(_phrases, "TEXT/PHRASES");
loadArray(_pronouns, "TEXT/PRONOUNS");
r = g_vm->_filesManager->getResource("TEXT/REPLACEMENTS2");
while (r->pos() < r->size())
_replacements2.push_back(readStringFromStream(r));
delete r;
r = g_vm->_filesManager->getResource("TEXT/REPLACEMENTS3");
while (r->pos() < r->size())
_replacements3.push_back(readStringFromStream(r));
delete r;
r = g_vm->_filesManager->getResource("TEXT/PHRASES");
while (r->pos() < r->size())
_phrases.push_back(readStringFromStream(r));
delete r;
r = g_vm->_filesManager->getResource("TEXT/NUMBERS");
Common::SeekableReadStream *r = g_vm->_filesManager->getResource("TEXT/NUMBERS");
while (r->pos() < r->size()) {
NumberEntry ne;
ne._text = readStringFromStream(r);
@ -81,7 +73,6 @@ void TTparser::loadArrays() {
_numbers.push_back(ne);
}
delete r;
}
int TTparser::preprocess(TTsentence *sentence) {
@ -490,7 +481,8 @@ int TTparser::findFrames(TTsentence *sentence) {
TTstring *line = sentence->_normalizedLine.copy();
TTstring wordString;
for (;;) {
int status = 0;
for (int ctr = 1; !status; ++ctr) {
// Keep stripping words off the start of the passed input
wordString = line->tokenize(" \n");
if (wordString.empty())
@ -500,17 +492,23 @@ int TTparser::findFrames(TTsentence *sentence) {
TTword *word = _owner->_vocab->getWord(wordString, &word);
sentence->storeVocabHit(srcWord);
if (word) {
// TODO
} else {
if (!word && ctr == 1) {
word = new TTword(wordString, WC_UNKNOWN, 0);
}
for (TTword *currP = word; currP && !status; currP = currP->_nextP)
status = processRequests(currP);
word->deleteSiblings();
delete word;
}
if (!status) {
status = fn1();
}
// TODO
delete line;
return 0;
return status;
}
int TTparser::loadRequests(TTword *word) {
@ -767,10 +765,10 @@ int TTparser::considerRequests(TTword *word) {
} else {
switch (nodeP->_tag) {
case CHECK_COMMAND_FORM:
if (_sentenceSub->_field4 && _sentence->_field2C == 1 &&
!_sentenceSub->_conceptP) {
if (_sentenceSub->_concept1P && _sentence->_field2C == 1 &&
!_sentenceSub->_concept0P) {
concept = new TTconcept(_sentence->_npcScript, ST_NPC_SCRIPT);
_sentenceSub->_conceptP = concept;
_sentenceSub->_concept0P = concept;
_sentenceSub->_field18 = 3;
}
@ -788,7 +786,7 @@ int TTparser::considerRequests(TTword *word) {
break;
case OBJECT_IS_TO:
flag = fn3(&_sentenceSub->_field8, 3);
flag = fn3(&_sentenceSub->_concept2P, 3);
break;
case SEEK_ACTOR:
@ -828,6 +826,11 @@ int TTparser::considerRequests(TTword *word) {
return status;
}
int TTparser::processRequests(TTword *word) {
// TODO
return 0;
}
void TTparser::addToConceptList(TTword *word) {
TTconcept *concept = new TTconcept(word, ST_UNKNOWN_SCRIPT);
addConcept(concept);
@ -851,6 +854,11 @@ int TTparser::addConcept(TTconcept *concept) {
return SS_VALID;
}
int TTparser::fn1() {
// TODO
return 0;
}
int TTparser::fn2(TTword *word) {
switch (word->_id) {
case 600:
@ -873,7 +881,7 @@ int TTparser::fn2(TTword *word) {
}
}
bool TTparser::fn3(int *v, int v2) {
bool TTparser::fn3(TTconcept **v, int v2) {
// TODO
return false;
}

View File

@ -75,6 +75,11 @@ private:
TTconcept *_conceptP;
TTconcept *_currentConceptP;
private:
/**
* Load the data for a given array resource
*/
void loadArray(StringArray &arr, const CString &name);
/**
* Loads the various replacement string data arrays
*/
@ -139,6 +144,7 @@ private:
int loadRequests(TTword *word);
int considerRequests(TTword *word);
int processRequests(TTword *word);
void addToConceptList(TTword *word);
int fn2(TTword *word);
@ -154,7 +160,8 @@ private:
*/
int addConcept(TTconcept *concept);
bool fn3(int *v, int v2);
int fn1();
bool fn3(TTconcept **v, int v2);
public:
CScriptHandler *_owner;
TTsentenceSub *_sentenceSub;
@ -163,6 +170,7 @@ public:
int _field10;
int _field14;
TTword *_currentWordP;
StringArray _pronouns;
public:
TTparser(CScriptHandler *owner);
~TTparser();

View File

@ -21,13 +21,16 @@
*/
#include "titanic/true_talk/tt_sentence.h"
#include "titanic/true_talk/tt_concept.h"
#include "titanic/true_talk/script_handler.h"
#include "titanic/titanic.h"
namespace Titanic {
TTsentenceSubBase::TTsentenceSubBase() : _conceptP(nullptr), _field4(0),
_field8(0), _fieldC(0), _field10(0), _field14(0), _field18(0),
_field1C(0), _nextP(nullptr), _field24(0) {
TTsentenceSubBase::TTsentenceSubBase() : _concept0P(nullptr),
_concept1P(nullptr), _concept2P(nullptr), _concept3P(nullptr),
_concept4P(nullptr), _concept5P(nullptr), _field18(0),
_field1C(0), _nextP(nullptr), _field24(0) {
}
void TTsentenceSubBase::deleteSiblings() {
@ -40,6 +43,60 @@ void TTsentenceSubBase::deleteSiblings() {
_nextP = nullptr;
}
TTconcept **TTsentenceSubBase::setConcept(int conceptIndex, TTconcept *src) {
TTconcept **conceptPP = nullptr;
switch (conceptIndex) {
case 1:
conceptPP = &_concept1P;
break;
case 2:
conceptPP = &_concept2P;
break;
case 3:
conceptPP = &_concept3P;
break;
case 4:
conceptPP = &_concept4P;
break;
case 5:
conceptPP = &_concept5P;
break;
default:
break;
}
bool isPronoun = false;
StringArray &pronouns = g_vm->_scriptHandler->_parser._pronouns;
for (uint idx = 0; idx < pronouns.size() && !isPronoun; ++idx) {
isPronoun = pronouns[idx] == src->getText();
}
CScriptHandler &scrHandler = *g_vm->_exeResources._owner;
if (!isPronoun) {
switch (conceptIndex) {
case 0:
delete scrHandler._concept2P;
scrHandler._concept2P = new TTconcept(*src);
break;
case 1:
delete scrHandler._concept4P;
scrHandler._concept4P = new TTconcept(*src);
break;
case 2:
delete scrHandler._concept1P;
scrHandler._concept1P = new TTconcept(*src);
break;
default:
break;
}
}
return conceptPP;
}
/*------------------------------------------------------------------------*/
TTsentenceSub *TTsentenceSub::addSibling() {

View File

@ -36,12 +36,12 @@ class TTword;
class TTsentenceSubBase {
public:
TTconcept *_conceptP;
int _field4;
int _field8;
int _fieldC;
int _field10;
int _field14;
TTconcept *_concept0P;
TTconcept *_concept1P;
TTconcept *_concept2P;
TTconcept *_concept3P;
TTconcept *_concept4P;
TTconcept *_concept5P;
int _field18;
int _field1C;
TTsentenceSubBase *_nextP;
@ -57,6 +57,8 @@ public:
void set18(int val) { _field18 = val; }
int get18() const { return _field18; }
bool is24() const { return _field24 == 0; }
TTconcept **setConcept(int conceptIndex, TTconcept *src);
};
class TTsentenceSub : public TTsentenceSubBase {

View File

@ -34,7 +34,7 @@ namespace Titanic {
TTvocab::TTvocab(int val): _headP(nullptr), _tailP(nullptr), _word(nullptr),
_fieldC(0), _field10(0), _vocabMode(val) {
_field14 = load("STVOCAB.TXT");
load("STVOCAB.TXT");
}
TTvocab::~TTvocab() {

View File

@ -36,7 +36,6 @@ private:
TTword *_word;
int _fieldC;
int _field10;
int _field14;
int _vocabMode;
private:
/**