From 4410c75599def09cfbb181268f5a894f1aa11b44 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 11 May 2016 21:47:47 -0400 Subject: TITANIC: Rename STVocab to TTvocab to match original --- engines/titanic/module.mk | 2 +- engines/titanic/true_talk/script_handler.cpp | 2 +- engines/titanic/true_talk/script_handler.h | 4 +- engines/titanic/true_talk/st_vocab.cpp | 171 --------------------------- engines/titanic/true_talk/st_vocab.h | 63 ---------- engines/titanic/true_talk/tt_vocab.cpp | 171 +++++++++++++++++++++++++++ engines/titanic/true_talk/tt_vocab.h | 63 ++++++++++ 7 files changed, 238 insertions(+), 238 deletions(-) delete mode 100644 engines/titanic/true_talk/st_vocab.cpp delete mode 100644 engines/titanic/true_talk/st_vocab.h create mode 100644 engines/titanic/true_talk/tt_vocab.cpp create mode 100644 engines/titanic/true_talk/tt_vocab.h diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index 47da6d4230..cac64a57c2 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -459,7 +459,6 @@ MODULE_OBJS := \ true_talk/succubus_script.o \ true_talk/title_engine.o \ true_talk/script_handler.o \ - true_talk/st_vocab.o \ true_talk/true_talk_manager.o \ true_talk/tt_script_base.o \ true_talk/tt_room_script.o \ @@ -470,6 +469,7 @@ MODULE_OBJS := \ true_talk/tt_synonym.o \ true_talk/tt_talker.o \ true_talk/tt_title_script.o \ + true_talk/tt_vocab.o \ true_talk/tt_word.o # This module can be built as a plugin diff --git a/engines/titanic/true_talk/script_handler.cpp b/engines/titanic/true_talk/script_handler.cpp index d19c08aa0e..d050c0492e 100644 --- a/engines/titanic/true_talk/script_handler.cpp +++ b/engines/titanic/true_talk/script_handler.cpp @@ -34,7 +34,7 @@ CScriptHandler::CScriptHandler(CTitleEngine *owner, int val1, int val2) : g_vm->_scriptHandler = this; g_vm->_script = _script; g_vm->_exeResources.reset(this, val1, val2); - _vocab = new STVocab(val2); + _vocab = new TTvocab(val2); } CScriptHandler::~CScriptHandler() { diff --git a/engines/titanic/true_talk/script_handler.h b/engines/titanic/true_talk/script_handler.h index 8449a72282..80532a7dda 100644 --- a/engines/titanic/true_talk/script_handler.h +++ b/engines/titanic/true_talk/script_handler.h @@ -26,7 +26,7 @@ #include "titanic/true_talk/tt_npc_script.h" #include "titanic/true_talk/tt_room_script.h" #include "titanic/true_talk/tt_string.h" -#include "titanic/true_talk/st_vocab.h" +#include "titanic/true_talk/tt_vocab.h" #include "titanic/support/exe_resources.h" namespace Titanic { @@ -64,7 +64,7 @@ class CScriptHandler { private: CTitleEngine *_owner; TTScriptBase *_script; - STVocab *_vocab; + TTvocab *_vocab; CExeResources &_resources; int _field10; CScriptHandlerSub1 _sub1; diff --git a/engines/titanic/true_talk/st_vocab.cpp b/engines/titanic/true_talk/st_vocab.cpp deleted file mode 100644 index 8ea2b53871..0000000000 --- a/engines/titanic/true_talk/st_vocab.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "common/file.h" -#include "titanic/true_talk/st_vocab.h" -#include "titanic/titanic.h" - -namespace Titanic { - -STVocab::STVocab(int val): _pHead(nullptr), _pTail(nullptr), _word(nullptr), - _fieldC(0), _field10(0), _field18(val) { - _field14 = load("STVOCAB.TXT"); -} - -STVocab::~STVocab() { - if (_pHead) { - _pHead->deleteSiblings(); - delete _pHead; - _pHead = _pTail = nullptr; - } -} - -int STVocab::load(const CString &name) { - SimpleFile *file = g_vm->_exeResources._owner->openResource(name); - int result = 0; - bool skipFlag; - - while (!result && !file->eos()) { - skipFlag = false; - int mode = file->readNumber(); - TTString space(" "); - - switch (mode) { - case 0: { - if (_word) - result = _word->readSyn(file); - skipFlag = true; - break; - } - - case 1: { - TTword2 *word = new TTword2(space, 0, 0, 0, 0); - result = word->load(file); - _word = word; - break; - } - - case 2: { - TTword3 *word = new TTword3(space, 0, 0, 0, 0, 0, 0); - result = word->load(file); - _word = word; - break; - } - - case 3: - case 9: { - TTword1 *word = new TTword1(space, 0, 0, 0); - result = word->load(file, mode); - _word = word; - break; - } - - case 4: - case 5: - case 7: { - TTword *word = new TTword(space, 0, 0); - result = word->load(file, mode); - _word = word; - break; - } - - case 8: { - TTword4 *word = new TTword4(space, 0, 0, 0, 0); - result = word->load(file); - _word = word; - break; - } - - case 6: { - TTword5 *word = new TTword5(space, 0, 0, 0, 0); - result = word->load(file); - _word = word; - break; - } - - default: - result = 4; - break; - } - - if (!skipFlag && _word) { - if (result) { - // Something wrong occurred, so delete word - delete _word; - _word = nullptr; - } else { - // Add the word to the master vocab list - addWord(_word); - } - } - } - - // Close resource and return result - delete file; - return result; -} - -void STVocab::addWord(TTword *word) { - TTword *existingWord = findWord(word->_string); - - if (existingWord) { - if (word->_synP) { - // Move over the synonym - existingWord->appendNode(word->_synP); - word->_synP = nullptr; - } - - _word = nullptr; - if (word) - delete word; - } else if (_pTail) { - _pTail->_pNext = word; - _pTail = word; - } else { - if (!_pHead) - _pHead = word; - - _pTail = word; - } -} - -TTword *STVocab::findWord(const TTString &str) { - TTsynonym *tempNode = new TTsynonym(); - bool flag = false; - TTword *word = _pHead; - - while (word && !flag) { - if (_field18 != 3 || strcmp(word->c_str(), str)) { - if (word->scanCopy(str, tempNode, _field18)) - flag = true; - else - word = word->_pNext; - } else { - flag = true; - } - } - - delete tempNode; - return word; -} - -} // End of namespace Titanic diff --git a/engines/titanic/true_talk/st_vocab.h b/engines/titanic/true_talk/st_vocab.h deleted file mode 100644 index 6a86825ef7..0000000000 --- a/engines/titanic/true_talk/st_vocab.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef TITANIC_ST_VOCAB_H -#define TITANIC_ST_VOCAB_H - -#include "titanic/support/string.h" -#include "titanic/true_talk/tt_string.h" -#include "titanic/true_talk/tt_word.h" - -namespace Titanic { - -class STVocab { -private: - TTword *_pHead; - TTword *_pTail; - TTword *_word; - int _fieldC; - int _field10; - int _field14; - int _field18; -private: - /** - * Load the vocab data - */ - int load(const CString &name); - - /** - * Adds a specified word to the vocab list - */ - void addWord(TTword *word); - - /** - * Scans the vocab list for an existing word match - */ - TTword *findWord(const TTString &str); -public: - STVocab(int val); - ~STVocab(); -}; - -} // End of namespace Titanic - -#endif /* TITANIC_ST_VOCAB_H */ diff --git a/engines/titanic/true_talk/tt_vocab.cpp b/engines/titanic/true_talk/tt_vocab.cpp new file mode 100644 index 0000000000..1bfd3dfde3 --- /dev/null +++ b/engines/titanic/true_talk/tt_vocab.cpp @@ -0,0 +1,171 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/file.h" +#include "titanic/true_talk/tt_vocab.h" +#include "titanic/titanic.h" + +namespace Titanic { + +TTvocab::TTvocab(int val): _pHead(nullptr), _pTail(nullptr), _word(nullptr), + _fieldC(0), _field10(0), _field18(val) { + _field14 = load("STVOCAB.TXT"); +} + +TTvocab::~TTvocab() { + if (_pHead) { + _pHead->deleteSiblings(); + delete _pHead; + _pHead = _pTail = nullptr; + } +} + +int TTvocab::load(const CString &name) { + SimpleFile *file = g_vm->_exeResources._owner->openResource(name); + int result = 0; + bool skipFlag; + + while (!result && !file->eos()) { + skipFlag = false; + int mode = file->readNumber(); + TTString space(" "); + + switch (mode) { + case 0: { + if (_word) + result = _word->readSyn(file); + skipFlag = true; + break; + } + + case 1: { + TTword2 *word = new TTword2(space, 0, 0, 0, 0); + result = word->load(file); + _word = word; + break; + } + + case 2: { + TTword3 *word = new TTword3(space, 0, 0, 0, 0, 0, 0); + result = word->load(file); + _word = word; + break; + } + + case 3: + case 9: { + TTword1 *word = new TTword1(space, 0, 0, 0); + result = word->load(file, mode); + _word = word; + break; + } + + case 4: + case 5: + case 7: { + TTword *word = new TTword(space, 0, 0); + result = word->load(file, mode); + _word = word; + break; + } + + case 8: { + TTword4 *word = new TTword4(space, 0, 0, 0, 0); + result = word->load(file); + _word = word; + break; + } + + case 6: { + TTword5 *word = new TTword5(space, 0, 0, 0, 0); + result = word->load(file); + _word = word; + break; + } + + default: + result = 4; + break; + } + + if (!skipFlag && _word) { + if (result) { + // Something wrong occurred, so delete word + delete _word; + _word = nullptr; + } else { + // Add the word to the master vocab list + addWord(_word); + } + } + } + + // Close resource and return result + delete file; + return result; +} + +void TTvocab::addWord(TTword *word) { + TTword *existingWord = findWord(word->_string); + + if (existingWord) { + if (word->_synP) { + // Move over the synonym + existingWord->appendNode(word->_synP); + word->_synP = nullptr; + } + + _word = nullptr; + if (word) + delete word; + } else if (_pTail) { + _pTail->_pNext = word; + _pTail = word; + } else { + if (!_pHead) + _pHead = word; + + _pTail = word; + } +} + +TTword *TTvocab::findWord(const TTString &str) { + TTsynonym *tempNode = new TTsynonym(); + bool flag = false; + TTword *word = _pHead; + + while (word && !flag) { + if (_field18 != 3 || strcmp(word->c_str(), str)) { + if (word->scanCopy(str, tempNode, _field18)) + flag = true; + else + word = word->_pNext; + } else { + flag = true; + } + } + + delete tempNode; + return word; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_vocab.h b/engines/titanic/true_talk/tt_vocab.h new file mode 100644 index 0000000000..d4dbda0029 --- /dev/null +++ b/engines/titanic/true_talk/tt_vocab.h @@ -0,0 +1,63 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ST_VOCAB_H +#define TITANIC_ST_VOCAB_H + +#include "titanic/support/string.h" +#include "titanic/true_talk/tt_string.h" +#include "titanic/true_talk/tt_word.h" + +namespace Titanic { + +class TTvocab { +private: + TTword *_pHead; + TTword *_pTail; + TTword *_word; + int _fieldC; + int _field10; + int _field14; + int _field18; +private: + /** + * Load the vocab data + */ + int load(const CString &name); + + /** + * Adds a specified word to the vocab list + */ + void addWord(TTword *word); + + /** + * Scans the vocab list for an existing word match + */ + TTword *findWord(const TTString &str); +public: + TTvocab(int val); + ~TTvocab(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ST_VOCAB_H */ -- cgit v1.2.3