Skip to content

Commit

Permalink
TITANIC: Revert field renamings in CScriptHandler
Browse files Browse the repository at this point in the history
I initially thought the four concept fields could be given a relevant name
for actor, object, and verb, but on further analysis, it looks like what
fields go in which concept slot depends on the kind of sentence. I haven't
been able to find any consistency, so I'm reverting them back to being
called _concept1P through _concept4P
  • Loading branch information
dreammaster committed Jan 28, 2017
1 parent 4353fd8 commit 4b1762d
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 84 deletions.
54 changes: 27 additions & 27 deletions engines/titanic/true_talk/script_handler.cpp
Expand Up @@ -32,8 +32,8 @@ namespace Titanic {
/*------------------------------------------------------------------------*/

CScriptHandler::CScriptHandler(CTitleEngine *owner, int val1, int val2) :
_owner(owner), _script(owner->_script), _parser(this), _inputCtr(0), _conceptObject(nullptr),
_conceptActor(nullptr), _conceptUnused(nullptr), _conceptVerb(nullptr) {
_owner(owner), _script(owner->_script), _parser(this), _inputCtr(0), _concept1P(nullptr),
_concept2P(nullptr), _concept3P(nullptr), _concept4P(nullptr) {
g_vm->_scriptHandler = this;
g_vm->_script = _script;
g_vm->_exeResources.reset(this, val1, val2);
Expand All @@ -42,10 +42,10 @@ CScriptHandler::CScriptHandler(CTitleEngine *owner, int val1, int val2) :

CScriptHandler::~CScriptHandler() {
delete _vocab;
delete _conceptObject;
delete _conceptActor;
delete _conceptUnused;
delete _conceptVerb;
delete _concept1P;
delete _concept2P;
delete _concept3P;
delete _concept4P;
}

ScriptChangedResult CScriptHandler::scriptChanged(TTroomScript *roomScript, TTnpcScript *npcScript, uint dialogueId) {
Expand All @@ -59,14 +59,14 @@ ScriptChangedResult CScriptHandler::scriptChanged(TTroomScript *roomScript, TTnp
result = npcScript->notifyScript(roomScript, dialogueId);

if (dialogueId == 3 || dialogueId == 4) {
delete _conceptObject;
delete _conceptActor;
delete _conceptUnused;
delete _conceptVerb;
_conceptObject = nullptr;
_conceptActor = nullptr;
_conceptUnused = nullptr;
_conceptVerb = nullptr;
delete _concept1P;
delete _concept2P;
delete _concept3P;
delete _concept4P;
_concept1P = nullptr;
_concept2P = nullptr;
_concept3P = nullptr;
_concept4P = nullptr;
}

++_inputCtr;
Expand Down Expand Up @@ -115,30 +115,30 @@ int CScriptHandler::setResponse(TTscriptBase *script, TTresponse *response) {
return _owner->setResponse(script, response);
}

void CScriptHandler::setActorObject(const TTstring *str) {
setActor(str);
setObject(str);
void CScriptHandler::handleWord(const TTstring *str) {
handleWord1(str);
handleWord2(str);
}

void CScriptHandler::setActor(const TTstring *str) {
if (_conceptActor)
delete _conceptActor;
_conceptActor = nullptr;
void CScriptHandler::handleWord1(const TTstring *str) {
if (_concept2P)
delete _concept2P;
_concept2P = nullptr;

if (str) {
TTword word(*str, WC_UNKNOWN, 0);
_conceptActor = new TTconcept(&word);
_concept2P = new TTconcept(&word);
}
}

void CScriptHandler::setObject(const TTstring *str) {
if (_conceptObject)
delete _conceptObject;
_conceptObject = nullptr;
void CScriptHandler::handleWord2(const TTstring *str) {
if (_concept1P)
delete _concept1P;
_concept1P = nullptr;

if (str) {
TTword word(*str, WC_UNKNOWN, 0);
_conceptObject = new TTconcept(&word);
_concept1P = new TTconcept(&word);
}
}

Expand Down
28 changes: 7 additions & 21 deletions engines/titanic/true_talk/script_handler.h
Expand Up @@ -39,23 +39,16 @@ class CScriptHandler {
CTitleEngine *_owner;
int _inputCtr;
private:
/**
* Sets the text for the actor concept
*/
void setActor(const TTstring *str);

/**
* Sets the text for the onject concept
*/
void setObject(const TTstring *str);
void handleWord1(const TTstring *str);
void handleWord2(const TTstring *str);
public:
TTparser _parser;
TTvocab *_vocab;
TTscriptBase *_script;
TTconcept *_conceptObject;
TTconcept *_conceptActor;
TTconcept *_conceptUnused;
TTconcept *_conceptVerb;
TTconcept *_concept1P;
TTconcept *_concept2P;
TTconcept *_concept3P;
TTconcept *_concept4P;
public:
CScriptHandler(CTitleEngine *owner, int val1, int val2);
~CScriptHandler();
Expand All @@ -66,10 +59,6 @@ class CScriptHandler {
ScriptChangedResult scriptChanged(TTroomScript *roomScript,
TTnpcScript *npcScript, uint dialogueId);

/**
* Main processing and handling for text lines entered into the
* Conversation tab of the PET
*/
int processInput(TTroomScript *roomScript, TTnpcScript *npcScript,
const TTstring &line);

Expand All @@ -88,10 +77,7 @@ class CScriptHandler {
*/
int setResponse(TTscriptBase *script, TTresponse *response);

/**
* Sets the concepts for both actor and object to the specified text
*/
void setActorObject(const TTstring *str);
void handleWord(const TTstring *str);
};

} // End of namespace Titanic
Expand Down
12 changes: 6 additions & 6 deletions engines/titanic/true_talk/tt_concept_node.cpp
Expand Up @@ -79,18 +79,18 @@ TTconcept **TTconceptNode::setConcept(int conceptIndex, TTconcept *src) {
if (!isPronoun) {
switch (conceptIndex) {
case 0:
delete scrHandler._conceptActor;
scrHandler._conceptActor = new TTconcept(*src);
delete scrHandler._concept2P;
scrHandler._concept2P = new TTconcept(*src);
break;

case 1:
delete scrHandler._conceptVerb;
scrHandler._conceptVerb = new TTconcept(*src);
delete scrHandler._concept4P;
scrHandler._concept4P = new TTconcept(*src);
break;

case 2:
delete scrHandler._conceptObject;
scrHandler._conceptObject = new TTconcept(*src);
delete scrHandler._concept1P;
scrHandler._concept1P = new TTconcept(*src);
break;

default:
Expand Down
4 changes: 2 additions & 2 deletions engines/titanic/true_talk/tt_npc_script.cpp
Expand Up @@ -262,12 +262,12 @@ bool TTnpcScript::handleWord(uint id) const {
const TTwordEntry &we = _words[idx];
if (we._id == id) {
TTstring str(we._text);
g_vm->_scriptHandler->setActorObject(&str);
g_vm->_scriptHandler->handleWord(&str);
return true;
}
}

g_vm->_scriptHandler->setActorObject(nullptr);
g_vm->_scriptHandler->handleWord(nullptr);
return true;
}

Expand Down
30 changes: 15 additions & 15 deletions engines/titanic/true_talk/tt_parser.cpp
Expand Up @@ -765,13 +765,13 @@ int TTparser::considerRequests(TTword *word) {
case SEEK_ACTOR:
case MKTAG('S', 'A', 'C', 'T'):
if (!_sentenceConcept->_concept0P) {
flag = applyConcepts(5, 0);
flag = filterConcepts(5, 0);
} else if (_sentenceConcept->_concept0P->compareTo("?") &&
_sentenceConcept->_concept1P->isWordId(113) &&
word->_wordClass == WC_THING) {
TTconcept *oldConcept = _sentenceConcept->_concept0P;
_sentenceConcept->_concept0P = nullptr;
flag = applyConcepts(5, 2);
flag = filterConcepts(5, 2);
if (flag)
delete oldConcept;
} else {
Expand All @@ -783,11 +783,11 @@ int TTparser::considerRequests(TTword *word) {
if (_sentenceConcept->_concept2P && _sentenceConcept->_concept2P->compareTo(word)) {
flag = true;
} else if (!_sentenceConcept->_concept2P) {
if (applyConcepts(5, 2) && _sentenceConcept->_concept2P->checkWordId1())
if (filterConcepts(5, 2) && _sentenceConcept->_concept2P->checkWordId1())
addNode(SEEK_OBJECT);
} else if (word->_wordClass == WC_THING && _sentence->fn2(2, TTstring("?"), _sentenceConcept)) {
TTconcept *oldConcept = _sentenceConcept->_concept2P;
flag = applyConcepts(5, 2);
flag = filterConcepts(5, 2);
_sentenceConcept->_concept2P->_field20 = oldConcept->get20();
if (flag)
delete oldConcept;
Expand All @@ -807,7 +807,7 @@ int TTparser::considerRequests(TTword *word) {

if (!status && !_sentenceConcept->_concept4P && _sentenceConcept->_concept0P) {
TTconcept *oldConcept = _sentenceConcept->_concept2P;
flag = applyConcepts(5, 2);
flag = filterConcepts(5, 2);
_sentenceConcept->_concept2P->_field20 = oldConcept->get20();
if (flag)
delete oldConcept;
Expand All @@ -824,7 +824,7 @@ int TTparser::considerRequests(TTword *word) {
_sentenceConcept->_concept3P = _sentenceConcept->_concept2P;
_sentenceConcept->_concept2P = nullptr;

flag = applyConcepts(5, 2);
flag = filterConcepts(5, 2);
if (!flag) {
status = _sentenceConcept->createConcept(0, 2, word);
}
Expand All @@ -833,17 +833,17 @@ int TTparser::considerRequests(TTword *word) {

case SEEK_TO:
if (!_sentenceConcept->_concept3P) {
if (!applyConcepts(8, 3))
flag = applyConcepts(3, 3);
if (!filterConcepts(8, 3))
flag = filterConcepts(3, 3);
} else {
flag = true;
}
break;

case SEEK_FROM:
if (!_sentenceConcept->_concept4P) {
if (!applyConcepts(8, 4))
flag = applyConcepts(3, 3);
if (!filterConcepts(8, 4))
flag = filterConcepts(3, 3);
} else {
flag = true;
}
Expand Down Expand Up @@ -906,14 +906,14 @@ int TTparser::considerRequests(TTword *word) {
_sentenceConcept->_concept5P->findByWordId(904)) {
TTconcept *oldConcept = _sentenceConcept->_concept5P;
_sentenceConcept->_concept5P = nullptr;
flag = applyConcepts(9, 5);
flag = filterConcepts(9, 5);
if (flag)
delete oldConcept;
} else {
flag = true;
}
} else {
flag = applyConcepts(9, 5);
flag = filterConcepts(9, 5);
if (!flag && word->_wordClass == WC_ADVERB) {
status = _sentenceConcept->createConcept(1, 5, word);
flag = true;
Expand Down Expand Up @@ -1471,7 +1471,7 @@ int TTparser::checkForAction() {
if (!_sentenceConcept->_concept0P && !_sentenceConcept->_concept1P &&
!_sentenceConcept->_concept2P && !_sentenceConcept->_concept5P && !flag) {
if (_conceptP)
applyConcepts(5, 2);
filterConcepts(5, 2);

if (!_sentenceConcept->_concept2P && _sentence->_category == 1)
_sentence->_category = 0;
Expand Down Expand Up @@ -1508,7 +1508,7 @@ int TTparser::checkForAction() {
} else if (!_sentenceConcept->_concept0P && !_sentenceConcept->_concept1P &&
!_sentenceConcept->_concept2P && !_sentenceConcept->_concept5P) {
if (_conceptP)
applyConcepts(5, 2);
filterConcepts(5, 2);

if (!_sentenceConcept->_concept2P && _sentence->_category == 1)
_sentence->_category = 0;
Expand Down Expand Up @@ -1597,7 +1597,7 @@ bool TTparser::checkConcept2(TTconcept *concept, int conceptMode) {
return false;
}

int TTparser::applyConcepts(int conceptMode, int conceptIndex) {
int TTparser::filterConcepts(int conceptMode, int conceptIndex) {
int result = 0;

for (TTconcept *currP = _conceptP; currP && !result; currP = currP->_nextP) {
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/true_talk/tt_parser.h
Expand Up @@ -174,7 +174,7 @@ class TTparser {
int checkForAction();
int fn2(TTword *word);
bool checkConcept2(TTconcept *concept, int conceptMode);
int applyConcepts(int conceptMode, int conceptIndex);
int filterConcepts(int conceptMode, int conceptIndex);
bool resetConcept(TTconcept **conceptPP, int conceptIndex);
public:
CScriptHandler *_owner;
Expand Down
24 changes: 12 additions & 12 deletions engines/titanic/true_talk/tt_sentence.cpp
Expand Up @@ -195,33 +195,33 @@ bool TTsentence::fn2(int slotIndex, const TTstring &str, const TTconceptNode *no
return true;
}

if (slotIndex == 1 && g_vm->_exeResources._owner->_conceptVerb) {
if (str == g_vm->_exeResources._owner->_conceptVerb->getText() &&
if (slotIndex == 1 && g_vm->_exeResources._owner->_concept4P) {
if (str == g_vm->_exeResources._owner->_concept4P->getText() &&
conceptText == "do")
goto exit;
}

if (g_vm->_exeResources._owner->_conceptActor && (slotIndex == 0 ||
if (g_vm->_exeResources._owner->_concept2P && (slotIndex == 0 ||
slotIndex == 3 || slotIndex == 4)) {
if (str == g_vm->_exeResources._owner->_conceptActor->getText() &&
if (str == g_vm->_exeResources._owner->_concept2P->getText() &&
(conceptText == "it" || conceptText == "he" || conceptText == "she" ||
conceptText == "him" || conceptText == "her" || conceptText == "them" ||
conceptText == "they"))
goto exit;
}

if (g_vm->_exeResources._owner->_conceptObject && (slotIndex == 0 ||
if (g_vm->_exeResources._owner->_concept1P && (slotIndex == 0 ||
slotIndex == 2 || slotIndex == 3 || slotIndex == 4 || slotIndex == 5)) {
if (str == g_vm->_exeResources._owner->_conceptObject->getText() &&
if (str == g_vm->_exeResources._owner->_concept1P->getText() &&
(conceptText == "it" || conceptText == "that" || conceptText == "he" ||
conceptText == "she" || conceptText == "him" || conceptText == "her" ||
conceptText == "them" || conceptText == "they" || conceptText == "those" ||
conceptText == "1" || conceptText == "thing"))
goto exit;
}

if (g_vm->_exeResources._owner->_conceptObject && (slotIndex == 0 || slotIndex == 2)) {
if (conceptText == "?" && str == g_vm->_exeResources._owner->_conceptObject->getText()) {
if (g_vm->_exeResources._owner->_concept1P && (slotIndex == 0 || slotIndex == 2)) {
if (conceptText == "?" && str == g_vm->_exeResources._owner->_concept1P->getText()) {
delete concept;
concept = getFrameSlot(5, node);
conceptText = concept->getText();
Expand Down Expand Up @@ -307,12 +307,12 @@ bool TTsentence::localWord(const char *str) const {
CScriptHandler &scriptHandler = *g_vm->_exeResources._owner;
bool foundMatch = false;

if (scriptHandler._conceptObject) {
TTstring s = scriptHandler._conceptObject->getText();
if (scriptHandler._concept1P) {
TTstring s = scriptHandler._concept1P->getText();
if (s == str)
foundMatch = true;
} else if (scriptHandler._conceptActor) {
TTstring s = scriptHandler._conceptActor->getText();
} else if (scriptHandler._concept2P) {
TTstring s = scriptHandler._concept2P->getText();
if (s == str)
foundMatch = true;
}
Expand Down

0 comments on commit 4b1762d

Please sign in to comment.