From 5da19b674d3b9d24517a266e369728f3b5c2957a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 17 May 2016 17:54:59 -0400 Subject: TITANIC: Changed TTinput to TTsentence to match original --- engines/titanic/module.mk | 2 +- engines/titanic/true_talk/script_handler.cpp | 12 ++--- engines/titanic/true_talk/tt_hist.cpp | 4 +- engines/titanic/true_talk/tt_hist.h | 8 +-- engines/titanic/true_talk/tt_input.cpp | 47 ---------------- engines/titanic/true_talk/tt_input.h | 80 ---------------------------- engines/titanic/true_talk/tt_parser.cpp | 52 +++++++++--------- engines/titanic/true_talk/tt_parser.h | 8 +-- engines/titanic/true_talk/tt_script_base.cpp | 4 +- engines/titanic/true_talk/tt_script_base.h | 4 +- engines/titanic/true_talk/tt_sentence.cpp | 47 ++++++++++++++++ engines/titanic/true_talk/tt_sentence.h | 80 ++++++++++++++++++++++++++++ 12 files changed, 174 insertions(+), 174 deletions(-) delete mode 100644 engines/titanic/true_talk/tt_input.cpp delete mode 100644 engines/titanic/true_talk/tt_input.h create mode 100644 engines/titanic/true_talk/tt_sentence.cpp create mode 100644 engines/titanic/true_talk/tt_sentence.h (limited to 'engines/titanic') diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index 7972fa1c4f..9e10577758 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -463,7 +463,6 @@ MODULE_OBJS := \ true_talk/tt_action.o \ true_talk/tt_adj.o \ true_talk/tt_hist.o \ - true_talk/tt_input.o \ true_talk/tt_major_word.o \ true_talk/tt_npc_script.o \ true_talk/tt_parser.o \ @@ -472,6 +471,7 @@ MODULE_OBJS := \ true_talk/tt_room_script.o \ true_talk/tt_script_base.o \ true_talk/tt_scripts.o \ + true_talk/tt_sentence.o \ true_talk/tt_string.o \ true_talk/tt_string_node.o \ true_talk/tt_synonym.o \ diff --git a/engines/titanic/true_talk/script_handler.cpp b/engines/titanic/true_talk/script_handler.cpp index 0b600f9be0..ab5b97122d 100644 --- a/engines/titanic/true_talk/script_handler.cpp +++ b/engines/titanic/true_talk/script_handler.cpp @@ -21,7 +21,7 @@ */ #include "titanic/true_talk/script_handler.h" -#include "titanic/true_talk/tt_input.h" +#include "titanic/true_talk/tt_sentence.h" #include "titanic/titanic.h" namespace Titanic { @@ -63,15 +63,15 @@ int CScriptHandler::processInput(TTroomScript *roomScript, TTnpcScript *npcScrip if (!roomScript || !line.isValid()) return SS_5; - TTinput *input = new TTinput(_inputCtr++, line, this, roomScript, npcScript); - _parser.preprocess(input); - roomScript->preprocess(input); - npcScript->preprocess(input); + TTsentence *sentence = new TTsentence(_inputCtr++, line, this, roomScript, npcScript); + _parser.preprocess(sentence); + roomScript->preprocess(sentence); + npcScript->preprocess(sentence); warning("TODO: CScriptHandler::processInput"); // TODO - delete input; + delete sentence; return SS_VALID; } diff --git a/engines/titanic/true_talk/tt_hist.cpp b/engines/titanic/true_talk/tt_hist.cpp index 8c9aeb3684..e0f6cb88b6 100644 --- a/engines/titanic/true_talk/tt_hist.cpp +++ b/engines/titanic/true_talk/tt_hist.cpp @@ -21,11 +21,11 @@ */ #include "titanic/true_talk/tt_hist.h" -#include "titanic/true_talk/tt_input.h" +#include "titanic/true_talk/tt_sentence.h" namespace Titanic { -TThist::TThist(TTinput *input) { +TThist::TThist(TTsentence *sentence) { // TODO } diff --git a/engines/titanic/true_talk/tt_hist.h b/engines/titanic/true_talk/tt_hist.h index f910e6eb5a..7ba0032a4d 100644 --- a/engines/titanic/true_talk/tt_hist.h +++ b/engines/titanic/true_talk/tt_hist.h @@ -25,19 +25,19 @@ namespace Titanic { -class TTinput; +class TTsentence; class TThist { protected: int _field0; - TTinput *_input; + TTsentence *_input; public: - TThist(TTinput *input); + TThist(TTsentence *sentence); }; class TTscriptHist : public TThist { public: - TTscriptHist(TTinput *input) : TThist(input) {} + TTscriptHist(TTsentence *sentence) : TThist(sentence) {} }; } // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_input.cpp b/engines/titanic/true_talk/tt_input.cpp deleted file mode 100644 index 102f86fc27..0000000000 --- a/engines/titanic/true_talk/tt_input.cpp +++ /dev/null @@ -1,47 +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 "titanic/true_talk/tt_input.h" -#include "titanic/true_talk/script_handler.h" - -namespace Titanic { - -TTinputSubBase::TTinputSubBase() : _field0(0), _field4(0), _field8(0), - _fieldC(0), _field10(0), _field14(0), _field18(0), _field1C(0), - _field20(0), _field24(0) { -} - -/*------------------------------------------------------------------------*/ - -TTinput::TTinput(int inputCtr, const TTstring &line, CScriptHandler *owner, - TTroomScript *roomScript, TTnpcScript *npcScript) : - _owner(owner), _field2C(1), _inputCtr(inputCtr), _field34(0), - _field38(0), _initialLine(line), _field4C(0), _roomScript(roomScript), - _npcScript(npcScript), _field58(0), _field5C(0) { - _status = _initialLine.isValid() && _normalizedLine.isValid() ? SS_11: SS_VALID; -} - -void TTinput::set38(int val) { - _field38 = val; -} - -} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_input.h b/engines/titanic/true_talk/tt_input.h deleted file mode 100644 index e378e9b3ab..0000000000 --- a/engines/titanic/true_talk/tt_input.h +++ /dev/null @@ -1,80 +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_TT_INPUT_H -#define TITANIC_TT_INPUT_H - -#include "titanic/true_talk/tt_npc_script.h" -#include "titanic/true_talk/tt_room_script.h" -#include "titanic/true_talk/tt_string.h" - -namespace Titanic { - -class CScriptHandler; - -class TTinputSubBase { -public: - int _field0; - int _field4; - int _field8; - int _fieldC; - int _field10; - int _field14; - int _field18; - int _field1C; - int _field20; - int _field24; -public: - TTinputSubBase(); -}; - -class TTinputSub : public TTinputSubBase { -public: -}; - -class TTinput { -private: - CScriptHandler *_owner; - TTinputSub _sub; - int _field2C; - int _inputCtr; - int _field34; - int _field38; - int _field4C; - TTroomScript *_roomScript; - TTnpcScript *_npcScript; - int _field58; - int _field5C; - int _status; -public: - TTstring _initialLine; - TTstring _normalizedLine; -public: - TTinput(int inputCtr, const TTstring &line, CScriptHandler *owner, - TTroomScript *roomScript, TTnpcScript *npcScript); - - void set38(int v); -}; - -} // End of namespace Titanic - -#endif /* TITANIC_TT_INPUT_H */ diff --git a/engines/titanic/true_talk/tt_parser.cpp b/engines/titanic/true_talk/tt_parser.cpp index 66cb57bcd4..a965c70394 100644 --- a/engines/titanic/true_talk/tt_parser.cpp +++ b/engines/titanic/true_talk/tt_parser.cpp @@ -22,13 +22,13 @@ #include "titanic/true_talk/tt_parser.h" #include "titanic/true_talk/script_handler.h" -#include "titanic/true_talk/tt_input.h" +#include "titanic/true_talk/tt_sentence.h" #include "titanic/titanic.h" namespace Titanic { TTparser::TTparser(CScriptHandler *owner) : _owner(owner), _field4(0), - _input(nullptr), _fieldC(0), _field10(0), _field14(0), _field18(0) { + _sentence(nullptr), _fieldC(0), _field10(0), _field14(0), _field18(0) { loadArrays(); } @@ -66,34 +66,34 @@ void TTparser::loadArrays() { } -int TTparser::preprocess(TTinput *input) { - _input = input; - if (normalize(input)) +int TTparser::preprocess(TTsentence *sentence) { + _sentence = sentence; + if (normalize(sentence)) return 0; // Scan for and replace common slang and contractions with verbose versions - searchAndReplace(input->_normalizedLine, _replacements1); - searchAndReplace(input->_normalizedLine, _replacements2); + searchAndReplace(sentence->_normalizedLine, _replacements1); + searchAndReplace(sentence->_normalizedLine, _replacements2); // Check entire normalized line against common phrases to replace for (uint idx = 0; idx < _phrases.size(); idx += 2) { - if (!_phrases[idx].compareTo(input->_normalizedLine)) - input->_normalizedLine = _phrases[idx + 1]; + if (!_phrases[idx].compareTo(sentence->_normalizedLine)) + sentence->_normalizedLine = _phrases[idx + 1]; } // Do a further search and replace of roman numerals to decimal - searchAndReplace(input->_normalizedLine, _replacements3); + searchAndReplace(sentence->_normalizedLine, _replacements3); // Replace any roman numerals, spelled out words, etc. with decimal numbers CTrueTalkManager::_v1 = -1000; int idx = 0; do { - idx = replaceNumbers(input->_normalizedLine, idx); + idx = replaceNumbers(sentence->_normalizedLine, idx); } while (idx >= 0); - if (CTrueTalkManager::_v1 == -1000 && !input->_normalizedLine.empty()) { + if (CTrueTalkManager::_v1 == -1000 && !sentence->_normalizedLine.empty()) { // Scan the text for any numeric digits - for (const char *strP = input->_normalizedLine.c_str(); *strP; ++strP) { + for (const char *strP = sentence->_normalizedLine.c_str(); *strP; ++strP) { if (Common::isDigit(*strP)) { // Found digit, so convert it and any following ones CTrueTalkManager::_v1 = atoi(strP); @@ -105,9 +105,9 @@ int TTparser::preprocess(TTinput *input) { return 0; } -int TTparser::normalize(TTinput *input) { +int TTparser::normalize(TTsentence *sentence) { TTstring *destLine = new TTstring(); - const TTstring &srcLine = input->_initialLine; + const TTstring &srcLine = sentence->_initialLine; int srcSize = srcLine.size(); int savedIndex = 0; int counter1 = 0; @@ -124,7 +124,7 @@ int TTparser::normalize(TTinput *input) { (*destLine) += toupper(c); } else if (Common::isDigit(c)) { if (c == '0' && isEmoticon(srcLine, index)) { - input->set38(10); + sentence->set38(10); } else { // Iterate through all the digits of the number (*destLine) += c; @@ -135,7 +135,7 @@ int TTparser::normalize(TTinput *input) { bool flag = false; switch (c) { case '!': - input->set38(3); + sentence->set38(3); break; case '\'': @@ -144,13 +144,13 @@ int TTparser::normalize(TTinput *input) { break; case '.': - input->set38(1); + sentence->set38(1); break; case ':': commandVal = isEmoticon(srcLine, index); if (commandVal) { - input->set38(commandVal); + sentence->set38(commandVal); index += 2; } else { flag = true; @@ -160,10 +160,10 @@ int TTparser::normalize(TTinput *input) { case ';': commandVal = isEmoticon(srcLine, index); if (commandVal == 6) { - input->set38(7); + sentence->set38(7); index += 2; } else if (commandVal != 0) { - input->set38(commandVal); + sentence->set38(commandVal); index += 2; } break; @@ -172,7 +172,7 @@ int TTparser::normalize(TTinput *input) { ++index; commandVal = isEmoticon(srcLine, index); if (commandVal == 6) { - input->set38(12); + sentence->set38(12); } else { --index; flag = true; @@ -183,7 +183,7 @@ int TTparser::normalize(TTinput *input) { ++index; commandVal = isEmoticon(srcLine, index); if (commandVal == 6 || commandVal == 9) { - input->set38(11); + sentence->set38(11); } else { --index; flag = true; @@ -191,7 +191,7 @@ int TTparser::normalize(TTinput *input) { break; case '?': - input->set38(2); + sentence->set38(2); break; default: @@ -207,14 +207,14 @@ int TTparser::normalize(TTinput *input) { } if (counter1 >= 4) - input->set38(4); + sentence->set38(4); // Remove any trailing spaces while (destLine->hasSuffix(" ")) destLine->deleteLastChar(); // Copy out the normalized line - input->_normalizedLine = *destLine; + sentence->_normalizedLine = *destLine; delete destLine; return 0; diff --git a/engines/titanic/true_talk/tt_parser.h b/engines/titanic/true_talk/tt_parser.h index 4dbc4d4c48..da63336783 100644 --- a/engines/titanic/true_talk/tt_parser.h +++ b/engines/titanic/true_talk/tt_parser.h @@ -23,7 +23,7 @@ #ifndef TITANIC_TT_PARSER_H #define TITANIC_TT_PARSER_H -#include "titanic/true_talk/tt_input.h" +#include "titanic/true_talk/tt_sentence.h" #include "titanic/true_talk/tt_string.h" namespace Titanic { @@ -60,7 +60,7 @@ private: * Normalizes a passed input, taking care of things like removing extra * spaces and lowercasing everything */ - int normalize(TTinput *input); + int normalize(TTsentence *sentence); /** * Submethod called by normalize to handle expanding contacted word pairs @@ -115,7 +115,7 @@ private: public: CScriptHandler *_owner; int _field4; - TTinput *_input; + TTsentence *_sentence; int _fieldC; int _field10; int _field14; @@ -127,7 +127,7 @@ public: * Preprocesses the passed input text, to handle things like lowercasing * all the words, and replcaing common slang with their full equivalents */ - int preprocess(TTinput *input); + int preprocess(TTsentence *sentence); }; } // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_script_base.cpp b/engines/titanic/true_talk/tt_script_base.cpp index 092e5bb6ea..16783dec0f 100644 --- a/engines/titanic/true_talk/tt_script_base.cpp +++ b/engines/titanic/true_talk/tt_script_base.cpp @@ -73,9 +73,9 @@ void TTscriptBase::reset() { _field48 = 0; } -int TTscriptBase::preprocess(TTinput *input) { +int TTscriptBase::preprocess(TTsentence *sentence) { delete _hist; - _hist = new TTscriptHist(input); + _hist = new TTscriptHist(sentence); return _hist ? SS_VALID : SS_7; } diff --git a/engines/titanic/true_talk/tt_script_base.h b/engines/titanic/true_talk/tt_script_base.h index f55d06c799..9bcb33467d 100644 --- a/engines/titanic/true_talk/tt_script_base.h +++ b/engines/titanic/true_talk/tt_script_base.h @@ -32,7 +32,7 @@ enum ScriptChangedResult { SCR_1 = 1, SCR_2 = 2, SCR_3 = 3, SCR_4 = 4, SCR_5 = 5 }; -class TTinput; +class TTsentence; class TTscriptBase { private: @@ -65,7 +65,7 @@ public: /** * Gets passed a newly created input wrapper during conversation text processing */ - int preprocess(TTinput *input); + int preprocess(TTsentence *sentence); virtual void proc2(int v); diff --git a/engines/titanic/true_talk/tt_sentence.cpp b/engines/titanic/true_talk/tt_sentence.cpp new file mode 100644 index 0000000000..e5968bd35a --- /dev/null +++ b/engines/titanic/true_talk/tt_sentence.cpp @@ -0,0 +1,47 @@ +/* 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 "titanic/true_talk/tt_sentence.h" +#include "titanic/true_talk/script_handler.h" + +namespace Titanic { + +TTsentenceSubBase::TTsentenceSubBase() : _field0(0), _field4(0), _field8(0), + _fieldC(0), _field10(0), _field14(0), _field18(0), _field1C(0), + _field20(0), _field24(0) { +} + +/*------------------------------------------------------------------------*/ + +TTsentence::TTsentence(int inputCtr, const TTstring &line, CScriptHandler *owner, + TTroomScript *roomScript, TTnpcScript *npcScript) : + _owner(owner), _field2C(1), _inputCtr(inputCtr), _field34(0), + _field38(0), _initialLine(line), _field4C(0), _roomScript(roomScript), + _npcScript(npcScript), _field58(0), _field5C(0) { + _status = _initialLine.isValid() && _normalizedLine.isValid() ? SS_11: SS_VALID; +} + +void TTsentence::set38(int val) { + _field38 = val; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_sentence.h b/engines/titanic/true_talk/tt_sentence.h new file mode 100644 index 0000000000..94d7bfc8d9 --- /dev/null +++ b/engines/titanic/true_talk/tt_sentence.h @@ -0,0 +1,80 @@ +/* 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_TT_SENTENCE_H +#define TITANIC_TT_SENTENCE_H + +#include "titanic/true_talk/tt_npc_script.h" +#include "titanic/true_talk/tt_room_script.h" +#include "titanic/true_talk/tt_string.h" + +namespace Titanic { + +class CScriptHandler; + +class TTsentenceSubBase { +public: + int _field0; + int _field4; + int _field8; + int _fieldC; + int _field10; + int _field14; + int _field18; + int _field1C; + int _field20; + int _field24; +public: + TTsentenceSubBase(); +}; + +class TTsentenceSub : public TTsentenceSubBase { +public: +}; + +class TTsentence { +private: + CScriptHandler *_owner; + TTsentenceSub _sub; + int _field2C; + int _inputCtr; + int _field34; + int _field38; + int _field4C; + TTroomScript *_roomScript; + TTnpcScript *_npcScript; + int _field58; + int _field5C; + int _status; +public: + TTstring _initialLine; + TTstring _normalizedLine; +public: + TTsentence(int inputCtr, const TTstring &line, CScriptHandler *owner, + TTroomScript *roomScript, TTnpcScript *npcScript); + + void set38(int v); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_SENTENCE_H */ -- cgit v1.2.3