Skip to content

Commit

Permalink
TITANIC: Properly initialize NPC scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Nov 13, 2016
1 parent 923a484 commit c6a24d1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
12 changes: 6 additions & 6 deletions engines/titanic/true_talk/tt_concept.cpp
Expand Up @@ -28,15 +28,16 @@
namespace Titanic {

TTconcept::TTconcept() : _string1(" "), _string2(" "),
_scriptP(nullptr), _wordP(nullptr) {
_scriptP(nullptr), _wordP(nullptr), _status(SS_VALID) {
if (setStatus())
setScriptType(ST_UNKNOWN_SCRIPT);
else
reset();
}

TTconcept::TTconcept(TTscriptBase *script, ScriptType scriptType) :
_string1(" "), _string2(" "), _wordP(nullptr), _scriptP(nullptr) {
_string1(" "), _string2(" "), _wordP(nullptr), _scriptP(nullptr),
_status(SS_VALID) {
if (!script->getStatus()) {
setScriptType(scriptType);
_scriptP = script;
Expand All @@ -50,8 +51,8 @@ TTconcept::TTconcept(TTscriptBase *script, ScriptType scriptType) :
}

TTconcept::TTconcept(TTword *word, ScriptType scriptType) :
_string1(" "), _string2(" "), _wordP(nullptr), _scriptP(nullptr) {

_string1(" "), _string2(" "), _wordP(nullptr), _scriptP(nullptr),
_status(SS_VALID) {
if (!word || !setStatus() || word->getStatus()) {
_status = SS_5;
} else {
Expand All @@ -66,8 +67,7 @@ TTconcept::TTconcept(TTword *word, ScriptType scriptType) :

TTconcept::TTconcept(TTconcept &src) :
_string1(src._string1), _string2(src._string2),
_wordP(nullptr), _scriptP(nullptr) {

_wordP(nullptr), _scriptP(nullptr), _status(SS_VALID) {
if (src.getStatus()) {
_status = SS_5;
} else {
Expand Down
14 changes: 9 additions & 5 deletions engines/titanic/true_talk/tt_script_base.cpp
Expand Up @@ -33,7 +33,7 @@ TTscriptBase::TTscriptBase(int scriptId, const char *charClass, int state,
_field20(0), _field24(0), _field28(0), _field2C(0),
_field30(0), _state(0), _hist2P(nullptr), _field3C(0),
_respHeadP(nullptr), _respTailP(nullptr), _oldResponseP(nullptr) {
if (!isValid()) {
if (isValid()) {
if (!v7 || !getStatus()) {
_id = scriptId;
_field20 = v3;
Expand All @@ -43,7 +43,7 @@ TTscriptBase::TTscriptBase(int scriptId, const char *charClass, int state,
_field30 = v7;
_state = state;
} else {
_status = 5;
_status = SS_5;
}
}

Expand All @@ -65,9 +65,13 @@ TTscriptBase::~TTscriptBase() {
}

bool TTscriptBase::isValid() {
bool result = !_charName.isValid() && !_charClass.isValid();
_status = result ? 0 : 11;
return result;
if (!_charName.empty() && !_charClass.empty()) {
_status = SS_VALID;
return true;
} else {
_status = SS_11;
return false;
}
}

void TTscriptBase::reset() {
Expand Down
1 change: 1 addition & 0 deletions engines/titanic/true_talk/tt_word.cpp
Expand Up @@ -43,6 +43,7 @@ TTword::TTword(const TTword *src) {
_id = src->_id;
_tag = src->_tag;
_synP = nullptr;
_status = SS_VALID;

TTsynonym *priorSyn = nullptr;
for (TTsynonym *synP = _synP; synP && !_status;) {
Expand Down

0 comments on commit c6a24d1

Please sign in to comment.