diff options
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/game/chicken_dispensor.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/sound/music_room_instrument.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/star_control/base_stars.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/star_control/camera_auto_mover.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/star_control/frect.h | 2 | ||||
-rw-r--r-- | engines/titanic/star_control/star_camera.h | 2 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/star_control/star_crosshairs.h | 8 | ||||
-rw-r--r-- | engines/titanic/star_control/star_field.h | 6 | ||||
-rw-r--r-- | engines/titanic/star_control/star_view.h | 6 | ||||
-rw-r--r-- | engines/titanic/star_control/unmarked_camera_mover.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/star_control/viewport.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/support/avi_surface.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/titanic.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_talker.h | 2 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_vocab.cpp | 1170 |
16 files changed, 608 insertions, 608 deletions
diff --git a/engines/titanic/game/chicken_dispensor.cpp b/engines/titanic/game/chicken_dispensor.cpp index 8d16289647..ced0c78ef1 100644 --- a/engines/titanic/game/chicken_dispensor.cpp +++ b/engines/titanic/game/chicken_dispensor.cpp @@ -106,7 +106,7 @@ bool CChickenDispensor::StatusChangeMsg(CStatusChangeMsg *msg) { bool CChickenDispensor::MovieEndMsg(CMovieEndMsg *msg) { int movieFrame = msg->_endFrame; - + if (movieFrame == 16) { // Dispensed a chicken _cursorId = CURSOR_HAND; diff --git a/engines/titanic/sound/music_room_instrument.cpp b/engines/titanic/sound/music_room_instrument.cpp index 882325c08a..99ead2f8eb 100644 --- a/engines/titanic/sound/music_room_instrument.cpp +++ b/engines/titanic/sound/music_room_instrument.cpp @@ -77,7 +77,7 @@ CMusicRoomInstrument::CMusicRoomInstrument(CProjectItem *project, CSoundManager _gameObjects[0] = static_cast<CGameObject *>(_project->findByName("Tubular Bells")); _insStartTime = 0.4; break; - + case MV_SNAKE: _gameObjects[0] = static_cast<CGameObject *>(_project->findByName("Snake_Hammer")); _gameObjects[1] = static_cast<CGameObject *>(_project->findByName("Snake_Glass")); diff --git a/engines/titanic/star_control/base_stars.cpp b/engines/titanic/star_control/base_stars.cpp index 0fcf8a964f..00206b1a9d 100644 --- a/engines/titanic/star_control/base_stars.cpp +++ b/engines/titanic/star_control/base_stars.cpp @@ -462,7 +462,7 @@ void CBaseStars::draw4(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarClos + vector._z * pose._row3._z + pose._vector._z; if (tempZ <= minVal) continue; - + tempY = vector._x * pose._row1._y + vector._y * pose._row2._y + vector._z * pose._row3._y + pose._vector._y; tempX = vector._x * pose._row1._x + vector._y * pose._row2._x + vector._z * pose._row3._x + pose._vector._x; total2 = tempY * tempY + tempX * tempX + tempZ * tempZ; diff --git a/engines/titanic/star_control/camera_auto_mover.cpp b/engines/titanic/star_control/camera_auto_mover.cpp index 71f7de85b2..d8808653eb 100644 --- a/engines/titanic/star_control/camera_auto_mover.cpp +++ b/engines/titanic/star_control/camera_auto_mover.cpp @@ -78,7 +78,7 @@ void CCameraAutoMover::calcSpeeds(int val1, int val2, float distance) { _field40 = nMoverTransitions-1; _field48 = nMoverTransitions-1; _field3C = (double)val2 * _field38; - + // Calculate the speeds for a graduated movement between stars double base = 0.0, total = 0.0, power = 4.0, baseInc = 0.03125; for (int idx = nMoverTransitions - 1; idx >= 0; --idx) { @@ -86,7 +86,7 @@ void CCameraAutoMover::calcSpeeds(int val1, int val2, float distance) { total += _speeds[idx]; base += baseInc; } - + for (int idx = 0; idx < nMoverTransitions; ++idx) { _speeds[idx] = _speeds[idx] * _field3C / total; } diff --git a/engines/titanic/star_control/frect.h b/engines/titanic/star_control/frect.h index 654c578cfd..d792eb69b4 100644 --- a/engines/titanic/star_control/frect.h +++ b/engines/titanic/star_control/frect.h @@ -41,7 +41,7 @@ public: * Returns true if the rects equal */ bool operator==(const FRect &p) const; - + /** * Returns true if the rects are not equal */ diff --git a/engines/titanic/star_control/star_camera.h b/engines/titanic/star_control/star_camera.h index f2d27212fe..9d0c954765 100644 --- a/engines/titanic/star_control/star_camera.h +++ b/engines/titanic/star_control/star_camera.h @@ -234,7 +234,7 @@ public: * Lock in the first matched star marker */ bool lockMarker1(FVector v1, FVector v2, FVector v3); - + /** * Lock in the second matched star marker */ diff --git a/engines/titanic/star_control/star_control.cpp b/engines/titanic/star_control/star_control.cpp index 8464262b31..7922a2f7f2 100644 --- a/engines/titanic/star_control/star_control.cpp +++ b/engines/titanic/star_control/star_control.cpp @@ -241,7 +241,7 @@ void CStarControl::doAction(StarControlAction action) { pet->starsSetReference(); break; } - + case STAR_FADE_IN: _view.fn3(true); break; diff --git a/engines/titanic/star_control/star_crosshairs.h b/engines/titanic/star_control/star_crosshairs.h index d60541c205..3d060fd91d 100644 --- a/engines/titanic/star_control/star_crosshairs.h +++ b/engines/titanic/star_control/star_crosshairs.h @@ -80,12 +80,12 @@ public: bool fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarCamera *camera); void fn2(CVideoSurface *surface, CStarField *starField, CStarMarkers *markers); - + /** * Increments the index for the number of matches */ void incMatches(); - + /** * Draw the crosshairs for a given star */ @@ -101,12 +101,12 @@ public: * Erase crosshairs for the most recently selected star */ void eraseCurrent(CSurfaceArea *surfaceArea); - + /** * Draw crosshairs at the given position */ void drawAt(const FPoint &pt, CSurfaceArea *surfaceArea); - + /** * Returns the position of the most recently selected star */ diff --git a/engines/titanic/star_control/star_field.h b/engines/titanic/star_control/star_field.h index bd3f8aecb6..3b1c3db2b5 100644 --- a/engines/titanic/star_control/star_field.h +++ b/engines/titanic/star_control/star_field.h @@ -78,17 +78,17 @@ public: void set2(int val); int get54() const; void set54(int val); - + /** * Gets the current display mode */ StarMode getMode() const; - + /** * Sets the display mode */ void setMode(StarMode mode); - + /** * Toggles whether the big box is visible */ diff --git a/engines/titanic/star_control/star_view.h b/engines/titanic/star_control/star_view.h index 553195b0c7..241efbcde5 100644 --- a/engines/titanic/star_control/star_view.h +++ b/engines/titanic/star_control/star_view.h @@ -148,14 +148,14 @@ public: * Toggles between starfield and photo modes */ void toggleMode(); - + void fn11(); /** * Toggles whether the viewpoint box is visible in the starfield */ void toggleBox(); - + void fn13(); void fn14(); @@ -163,7 +163,7 @@ public: * Called when the photograph is used on the navigation computer */ void setHasReference(); - + /** * Handles locking in a star */ diff --git a/engines/titanic/star_control/unmarked_camera_mover.cpp b/engines/titanic/star_control/unmarked_camera_mover.cpp index c879dc25e8..401f550bee 100644 --- a/engines/titanic/star_control/unmarked_camera_mover.cpp +++ b/engines/titanic/star_control/unmarked_camera_mover.cpp @@ -48,7 +48,7 @@ void CUnmarkedCameraMover::moveTo(const FVector &srcV, const FVector &destV, con void CUnmarkedCameraMover::transitionBetweenOrientations(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m) { if (isLocked()) decLockCount(); - + FVector vector1 = v1; FVector vector2 = v2; FPose matrix1 = vector2.getFrameTransform(vector1); diff --git a/engines/titanic/star_control/viewport.cpp b/engines/titanic/star_control/viewport.cpp index e368dfa317..d66ff423c6 100644 --- a/engines/titanic/star_control/viewport.cpp +++ b/engines/titanic/star_control/viewport.cpp @@ -178,7 +178,7 @@ void CViewport::randomizeOrientation() { FPose m1(X_AXIS, ranRotAngleX); FPose m2(Y_AXIS, ranRotAngleY); FPose m3(Z_AXIS, ranRotAngleZ); - + FPose s1(m1, m2); FPose s2(s1, m3); diff --git a/engines/titanic/support/avi_surface.cpp b/engines/titanic/support/avi_surface.cpp index 3b22a4fee2..ff439abe25 100644 --- a/engines/titanic/support/avi_surface.cpp +++ b/engines/titanic/support/avi_surface.cpp @@ -489,7 +489,7 @@ Graphics::ManagedSurface *AVISurface::duplicateTransparency() const { bool AVISurface::playCutscene(const Rect &r, uint startFrame, uint endFrame) { if (g_vm->shouldQuit()) return false; - + // TODO: Fixes slight "jumping back" when rotating in place in Top Of Well // balcony between two elevators. Need a more generalized fix at some point if (_movieName == "z48.avi") diff --git a/engines/titanic/titanic.cpp b/engines/titanic/titanic.cpp index 5daf399b04..0931d91806 100644 --- a/engines/titanic/titanic.cpp +++ b/engines/titanic/titanic.cpp @@ -190,7 +190,7 @@ void TitanicEngine::setRoomNames() { bool TitanicEngine::canLoadGameStateCurrently() { CGameManager *gameManager = _window->_gameManager; CScreenManager *screenMan = CScreenManager::_screenManagerPtr; - + if (!gameManager) // Allow loading from copyright screen and continue dialogs return true; diff --git a/engines/titanic/true_talk/tt_talker.h b/engines/titanic/true_talk/tt_talker.h index 4f0b59c044..68b77d8b75 100644 --- a/engines/titanic/true_talk/tt_talker.h +++ b/engines/titanic/true_talk/tt_talker.h @@ -54,7 +54,7 @@ public: * End the speech */ void endSpeech(int val); - + /** * Called when a speech is finished, to signal to the associated character * that the speech is over diff --git a/engines/titanic/true_talk/tt_vocab.cpp b/engines/titanic/true_talk/tt_vocab.cpp index e9fc098749..0269e71cee 100644 --- a/engines/titanic/true_talk/tt_vocab.cpp +++ b/engines/titanic/true_talk/tt_vocab.cpp @@ -1,585 +1,585 @@ -/* 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_vocab.h"
-#include "titanic/true_talk/script_handler.h"
-#include "titanic/true_talk/tt_action.h"
-#include "titanic/true_talk/tt_adj.h"
-#include "titanic/true_talk/tt_major_word.h"
-#include "titanic/true_talk/tt_picture.h"
-#include "titanic/true_talk/tt_pronoun.h"
-#include "titanic/titanic.h"
-#include "titanic/translation.h"
-#include "common/file.h"
-
-namespace Titanic {
-
-TTvocab::TTvocab(VocabMode vocabMode): _headP(nullptr), _tailP(nullptr),
- _word(nullptr), _vocabMode(vocabMode) {
- load("STVOCAB");
-}
-
-TTvocab::~TTvocab() {
- if (_headP) {
- _headP->deleteSiblings();
- delete _headP;
- _headP = _tailP = 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;
- WordClass wordClass = (WordClass)file->readNumber();
- TTstring space(" ");
-
- switch (wordClass) {
- case WC_UNKNOWN: {
- if (_word)
- result = _word->readSyn(file);
- skipFlag = true;
- break;
- }
-
- case WC_ACTION: {
- TTaction *word = new TTaction(space, WC_UNKNOWN, 0, 0, 0);
- result = word->load(file);
- _word = word;
- break;
- }
-
- case WC_THING: {
- TTpicture *word = new TTpicture(space, WC_UNKNOWN, 0, 0, 0, 0, 0);
- result = word->load(file);
- _word = word;
- break;
- }
-
- case WC_ABSTRACT:
- case WC_ADVERB: {
- TTmajorWord *word = new TTmajorWord(space, WC_UNKNOWN, 0, 0);
- result = word->load(file, wordClass);
- _word = word;
- break;
- }
-
- case WC_ARTICLE:
- case WC_CONJUNCTION:
- case WC_PREPOSITION: {
- TTword *word = new TTword(space, WC_UNKNOWN, 0);
- result = word->load(file, wordClass);
- _word = word;
- break;
- }
-
- case WC_ADJECTIVE: {
- TTadj *word = new TTadj(space, WC_UNKNOWN, 0, 0, 0);
- result = word->load(file);
- _word = word;
- break;
- }
-
- case WC_PRONOUN: {
- TTpronoun *word = new TTpronoun(space, WC_UNKNOWN, 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 = g_language == Common::DE_DEU ? nullptr :
- findWord(word->_text);
-
- if (existingWord) {
- if (word->_synP) {
- // Move over the synonym
- existingWord->appendNode(word->_synP);
- word->_synP = nullptr;
- }
-
- _word = nullptr;
- if (word)
- delete word;
- } else if (_tailP) {
- _tailP->_nextP = word;
- _tailP = word;
- } else {
- if (!_headP)
- _headP = word;
-
- _tailP = word;
- }
-}
-
-TTword *TTvocab::findWord(const TTstring &str) {
- TTsynonym *tempNode = new TTsynonym();
- bool flag = false;
- TTword *word = _headP;
-
- while (word && !flag) {
- if (_vocabMode != VOCAB_MODE_EN || strcmp(word->c_str(), str)) {
- if (word->findSynByName(str, tempNode, _vocabMode))
- flag = true;
- else
- word = word->_nextP;
- } else {
- flag = true;
- }
- }
-
- delete tempNode;
- return word;
-}
-
-TTword *TTvocab::getWord(TTstring &str, TTword **srcWord) const {
- TTword *word = getPrimeWord(str, srcWord);
-
- if (!word) {
- TTstring tempStr(str);
- if (tempStr.size() > 2) {
- word = getSuffixedWord(tempStr, srcWord);
-
- if (!word)
- word = getPrefixedWord(tempStr, srcWord);
- }
- }
-
- return word;
-}
-
-TTword *TTvocab::getPrimeWord(TTstring &str, TTword **srcWord) const {
- TTsynonym tempSyn;
- char c = str.charAt(0);
- TTword *newWord = nullptr;
- TTword *vocabP;
-
- if (Common::isDigit(c)) {
- // Number
- vocabP = _headP;
- newWord = new TTword(str, WC_ABSTRACT, 300);
- } else {
- // Standard word
- for (vocabP = _headP; vocabP; vocabP = vocabP->_nextP) {
- if (_vocabMode == VOCAB_MODE_EN && !strcmp(str.c_str(), vocabP->c_str())) {
- newWord = vocabP->copy();
- newWord->_nextP = nullptr;
- newWord->setSyn(nullptr);
- break;
- } else if (vocabP->findSynByName(str, &tempSyn, _vocabMode)) {
- // Create a copy of the word and the found synonym
- TTsynonym *newSyn = new TTsynonym(tempSyn);
- newSyn->_nextP = newSyn->_priorP = nullptr;
- newWord = vocabP->copy();
- newWord->_nextP = nullptr;
- newWord->setSyn(newSyn);
- break;
- }
- }
- }
-
- if (srcWord)
- // Pass out the pointer to the original word
- *srcWord = vocabP;
-
- // Return the new copy of the word
- return newWord;
-}
-
-TTword *TTvocab::getSuffixedWord(TTstring &str, TTword **srcWord) const {
- TTstring tempStr(str);
- TTword *word = nullptr;
-
- if (g_language == Common::DE_DEU) {
- static const char *const SUFFIXES[11] = {
- "est", "em", "en", "er", "es", "et", "st",
- "s", "e", "n", "t"
- };
-
- for (int idx = 0; idx < 11; ++idx) {
- if (tempStr.hasSuffix(SUFFIXES[idx])) {
- tempStr.deleteSuffix(strlen(SUFFIXES[idx]));
- word = getPrimeWord(tempStr, srcWord);
- if (word)
- break;
- tempStr = str;
- }
- }
-
- if (word)
- word->setSynStr(str);
- return word;
- }
-
- if (tempStr.hasSuffix("s")) {
- tempStr.deleteSuffix(1);
- word = getPrimeWord(tempStr);
-
- if (!word) {
- if (!tempStr.hasSuffix("e")) {
- tempStr = str;
- } else {
- tempStr.deleteLastChar();
- word = getPrimeWord(tempStr);
- }
- }
-
- } else if (tempStr.hasSuffix("ing")) {
- tempStr.deleteSuffix(3);
- word = getPrimeWord(tempStr);
-
- if (word) {
- if (word->_wordClass == 1) {
- delete word;
- word = nullptr;
- } else {
- delete word;
- word = new TTadj(str, WC_ADJECTIVE, 0, 0, 0);
- }
- } else {
- tempStr += "e";
- word = getPrimeWord(tempStr);
-
- if (word) {
- if (word->_wordClass != 1) {
- delete word;
- word = new TTadj(str, WC_ADJECTIVE, 0, 0, 0);
- }
- } else {
- tempStr.deleteSuffix(2);
- word = getPrimeWord(tempStr);
-
- if (word) {
- if (word->_wordClass != 1) {
- delete word;
- word = new TTadj(str, WC_ADJECTIVE, 0, 0, 0);
- }
- } else {
- tempStr = str;
- }
- }
- }
-
- } else if (tempStr.hasSuffix("ed")) {
- tempStr.deleteSuffix(1);
- word = getPrimeWord(tempStr);
-
- if (!word) {
- tempStr.deleteSuffix(1);
- word = getPrimeWord(tempStr);
- }
-
- if (word) {
- if (word->_wordClass == WC_ACTION) {
- TTaction *action = dynamic_cast<TTaction *>(word);
- assert(action);
- action->setVal(1);
- }
- } else {
- tempStr = str;
- }
-
- } else if (tempStr.hasSuffix("ly")) {
- tempStr.deleteSuffix(2);
- word = getPrimeWord(tempStr);
-
- if (word) {
- delete word;
- word = new TTword(str, WC_ADVERB, 0);
- } else {
- tempStr = str;
- }
-
- } else if (tempStr.hasSuffix("er")) {
- tempStr.deleteSuffix(1);
- word = getPrimeWord(tempStr);
-
- if (word) {
- if (word->_wordClass == WC_ADJECTIVE) {
- TTadj *adj = static_cast<TTadj *>(word);
- int val1 = word->proc15();
- int val2 = word->proc15();
-
- if (val2 < 5) {
- if (--val1 > 0) {
- adj->adjFn1(val1);
- }
- } else {
- if (++val1 < 11) {
- adj->adjFn1(val1);
- }
- }
- }
- } else {
- tempStr.deleteSuffix(1);
- word = getPrimeWord(tempStr);
-
- if (word) {
- if (word->_wordClass == WC_ADJECTIVE) {
- TTadj *adj = dynamic_cast<TTadj *>(word);
- int val1 = word->proc15();
- int val2 = word->proc15();
-
- if (val2 < 5) {
- if (--val1 > 0) {
- adj->adjFn1(val1);
- }
- } else {
- if (++val1 < 11) {
- adj->adjFn1(val1);
- }
- }
- }
- } else {
- tempStr.deleteSuffix(1);
- word = getPrimeWord(tempStr);
-
- if (word && word->_wordClass == WC_ADJECTIVE) {
- TTadj *adj = dynamic_cast<TTadj *>(word);
- int val1 = word->proc15();
- int val2 = word->proc15();
-
- if (val2 < 5) {
- if (--val1 > 0) {
- adj->adjFn1(val1);
- }
- } else {
- if (++val1 < 11) {
- adj->adjFn1(val1);
- }
- }
- }
- }
- }
-
- } else if (tempStr.hasSuffix("est")) {
- tempStr.deleteSuffix(2);
- word = getPrimeWord(tempStr);
-
- if (word) {
- if (word->_wordClass == WC_ADJECTIVE) {
- TTadj *adj = static_cast<TTadj *>(word);
- int val1 = word->proc15();
- int val2 = word->proc15();
-
- if (val2 < 5) {
- if (--val1 > 0) {
- adj->adjFn1(val1);
- }
- } else {
- if (++val1 < 11) {
- adj->adjFn1(val1);
- }
- }
- }
- } else {
- tempStr.deleteSuffix(1);
- word = getPrimeWord(tempStr);
-
- if (word) {
- if (word->_wordClass == WC_ADJECTIVE) {
- TTadj *adj = dynamic_cast<TTadj *>(word);
- int val1 = word->proc15();
- int val2 = word->proc15();
-
- if (val2 < 5) {
- if (--val1 > 0) {
- adj->adjFn1(val1);
- }
- } else {
- if (++val1 < 11) {
- adj->adjFn1(val1);
- }
- }
- }
- } else {
- tempStr.deleteSuffix(1);
- word = getPrimeWord(tempStr);
-
- if (word) {
- TTadj *adj = dynamic_cast<TTadj *>(word);
- int val1 = word->proc15();
- int val2 = word->proc15();
-
- if (val2 < 5) {
- if (--val1 > 0) {
- adj->adjFn1(val1);
- }
- } else {
- if (++val1 < 11) {
- adj->adjFn1(val1);
- }
- }
- }
- }
- }
-
- } else if (tempStr.hasSuffix("s*")) {
- tempStr.deleteSuffix(2);
- word = getPrimeWord(tempStr);
-
- if (word) {
- if (word->_wordClass == WC_PRONOUN || word->_wordClass == WC_ADVERB) {
- delete word;
- TTstring isStr("is");
- word = getPrimeWord(isStr);
- } else {
- switch (word->_id) {
- case 200:
- if (word->proc10() == 2) {
- delete word;
- word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 5);
- } else if (word->proc10() == 1) {
- delete word;
- word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 4);
- }
- break;
-
- case 201:
- delete word;
- word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 5);
- break;
-
- case 202:
- case 203:
- if (word->proc10() == 2) {
- delete word;
- word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 5);
- } else {
- int val = word->proc10() == 1 ? 0 : 4;
- delete word;
- word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, val);
- }
- break;
-
- case 204:
- delete word;
- word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 6);
- break;
-
- default:
- delete word;
- word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 0);
- break;
- }
- }
- }
- }
-
- if (word)
- word->setSynStr(str);
-
- return word;
-}
-
-TTword *TTvocab::getPrefixedWord(TTstring &str, TTword **srcWord) const {
- TTstring tempStr(str);
- TTword *word = nullptr;
- int prefixLen = 0;
-
- if (tempStr.hasPrefix("pre")) {
- prefixLen = 3;
- } else if (tempStr.hasPrefix("re") || tempStr.hasPrefix("co")) {
- prefixLen = 2;
- } else if (tempStr.hasPrefix("inter") || tempStr.hasPrefix("multi")) {
- prefixLen = 5;
- } else if (tempStr.hasPrefix("over") || tempStr.hasPrefix("post") || tempStr.hasPrefix("self")) {
- prefixLen = 4;
- }
-
- if (prefixLen) {
- // Known prefix found, so scan for word without prefix
- tempStr.deletePrefix(prefixLen);
- word = getPrimeWord(tempStr);
- if (word)
- tempStr = str;
-
- } else if (tempStr.hasPrefix("anti") || tempStr.hasPrefix("counter")) {
- prefixLen = tempStr[0] == 'a' ? 4 : 7;
-
- tempStr.deletePrefix(prefixLen);
- word = getPrimeWord(tempStr);
- if (!word)
- tempStr = str;
- else if (word->_wordClass == 8) {
- delete word;
- word = nullptr;
- }
-
- } else if (tempStr.hasPrefix("hyper") || tempStr.hasPrefix("super") ||
- tempStr.hasPrefix("ultra")) {
- tempStr.deletePrefix(5);
- word = getPrimeWord(tempStr);
-
- if (!word)
- tempStr = str;
- else if (word->_wordClass == WC_ADJECTIVE) {
- TTadj *adj = static_cast<TTadj *>(word);
- int val1 = word->proc15();
- int val2 = word->proc15();
-
- if (val2 < 5) {
- if (--val1 > 0)
- adj->adjFn1(val1);
- } else if (++val1 < 11) {
- adj->adjFn1(val1);
- }
- }
- }
-
- if (word) {
- // Set the original word on either the found word or synonym
- if (word->hasSynonyms())
- word->setSynStr(str);
- else
- word->_text = str;
- }
-
- return word;
-}
-
-} // End of namespace Titanic
+/* 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_vocab.h" +#include "titanic/true_talk/script_handler.h" +#include "titanic/true_talk/tt_action.h" +#include "titanic/true_talk/tt_adj.h" +#include "titanic/true_talk/tt_major_word.h" +#include "titanic/true_talk/tt_picture.h" +#include "titanic/true_talk/tt_pronoun.h" +#include "titanic/titanic.h" +#include "titanic/translation.h" +#include "common/file.h" + +namespace Titanic { + +TTvocab::TTvocab(VocabMode vocabMode): _headP(nullptr), _tailP(nullptr), + _word(nullptr), _vocabMode(vocabMode) { + load("STVOCAB"); +} + +TTvocab::~TTvocab() { + if (_headP) { + _headP->deleteSiblings(); + delete _headP; + _headP = _tailP = 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; + WordClass wordClass = (WordClass)file->readNumber(); + TTstring space(" "); + + switch (wordClass) { + case WC_UNKNOWN: { + if (_word) + result = _word->readSyn(file); + skipFlag = true; + break; + } + + case WC_ACTION: { + TTaction *word = new TTaction(space, WC_UNKNOWN, 0, 0, 0); + result = word->load(file); + _word = word; + break; + } + + case WC_THING: { + TTpicture *word = new TTpicture(space, WC_UNKNOWN, 0, 0, 0, 0, 0); + result = word->load(file); + _word = word; + break; + } + + case WC_ABSTRACT: + case WC_ADVERB: { + TTmajorWord *word = new TTmajorWord(space, WC_UNKNOWN, 0, 0); + result = word->load(file, wordClass); + _word = word; + break; + } + + case WC_ARTICLE: + case WC_CONJUNCTION: + case WC_PREPOSITION: { + TTword *word = new TTword(space, WC_UNKNOWN, 0); + result = word->load(file, wordClass); + _word = word; + break; + } + + case WC_ADJECTIVE: { + TTadj *word = new TTadj(space, WC_UNKNOWN, 0, 0, 0); + result = word->load(file); + _word = word; + break; + } + + case WC_PRONOUN: { + TTpronoun *word = new TTpronoun(space, WC_UNKNOWN, 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 = g_language == Common::DE_DEU ? nullptr : + findWord(word->_text); + + if (existingWord) { + if (word->_synP) { + // Move over the synonym + existingWord->appendNode(word->_synP); + word->_synP = nullptr; + } + + _word = nullptr; + if (word) + delete word; + } else if (_tailP) { + _tailP->_nextP = word; + _tailP = word; + } else { + if (!_headP) + _headP = word; + + _tailP = word; + } +} + +TTword *TTvocab::findWord(const TTstring &str) { + TTsynonym *tempNode = new TTsynonym(); + bool flag = false; + TTword *word = _headP; + + while (word && !flag) { + if (_vocabMode != VOCAB_MODE_EN || strcmp(word->c_str(), str)) { + if (word->findSynByName(str, tempNode, _vocabMode)) + flag = true; + else + word = word->_nextP; + } else { + flag = true; + } + } + + delete tempNode; + return word; +} + +TTword *TTvocab::getWord(TTstring &str, TTword **srcWord) const { + TTword *word = getPrimeWord(str, srcWord); + + if (!word) { + TTstring tempStr(str); + if (tempStr.size() > 2) { + word = getSuffixedWord(tempStr, srcWord); + + if (!word) + word = getPrefixedWord(tempStr, srcWord); + } + } + + return word; +} + +TTword *TTvocab::getPrimeWord(TTstring &str, TTword **srcWord) const { + TTsynonym tempSyn; + char c = str.charAt(0); + TTword *newWord = nullptr; + TTword *vocabP; + + if (Common::isDigit(c)) { + // Number + vocabP = _headP; + newWord = new TTword(str, WC_ABSTRACT, 300); + } else { + // Standard word + for (vocabP = _headP; vocabP; vocabP = vocabP->_nextP) { + if (_vocabMode == VOCAB_MODE_EN && !strcmp(str.c_str(), vocabP->c_str())) { + newWord = vocabP->copy(); + newWord->_nextP = nullptr; + newWord->setSyn(nullptr); + break; + } else if (vocabP->findSynByName(str, &tempSyn, _vocabMode)) { + // Create a copy of the word and the found synonym + TTsynonym *newSyn = new TTsynonym(tempSyn); + newSyn->_nextP = newSyn->_priorP = nullptr; + newWord = vocabP->copy(); + newWord->_nextP = nullptr; + newWord->setSyn(newSyn); + break; + } + } + } + + if (srcWord) + // Pass out the pointer to the original word + *srcWord = vocabP; + + // Return the new copy of the word + return newWord; +} + +TTword *TTvocab::getSuffixedWord(TTstring &str, TTword **srcWord) const { + TTstring tempStr(str); + TTword *word = nullptr; + + if (g_language == Common::DE_DEU) { + static const char *const SUFFIXES[11] = { + "est", "em", "en", "er", "es", "et", "st", + "s", "e", "n", "t" + }; + + for (int idx = 0; idx < 11; ++idx) { + if (tempStr.hasSuffix(SUFFIXES[idx])) { + tempStr.deleteSuffix(strlen(SUFFIXES[idx])); + word = getPrimeWord(tempStr, srcWord); + if (word) + break; + tempStr = str; + } + } + + if (word) + word->setSynStr(str); + return word; + } + + if (tempStr.hasSuffix("s")) { + tempStr.deleteSuffix(1); + word = getPrimeWord(tempStr); + + if (!word) { + if (!tempStr.hasSuffix("e")) { + tempStr = str; + } else { + tempStr.deleteLastChar(); + word = getPrimeWord(tempStr); + } + } + + } else if (tempStr.hasSuffix("ing")) { + tempStr.deleteSuffix(3); + word = getPrimeWord(tempStr); + + if (word) { + if (word->_wordClass == 1) { + delete word; + word = nullptr; + } else { + delete word; + word = new TTadj(str, WC_ADJECTIVE, 0, 0, 0); + } + } else { + tempStr += "e"; + word = getPrimeWord(tempStr); + + if (word) { + if (word->_wordClass != 1) { + delete word; + word = new TTadj(str, WC_ADJECTIVE, 0, 0, 0); + } + } else { + tempStr.deleteSuffix(2); + word = getPrimeWord(tempStr); + + if (word) { + if (word->_wordClass != 1) { + delete word; + word = new TTadj(str, WC_ADJECTIVE, 0, 0, 0); + } + } else { + tempStr = str; + } + } + } + + } else if (tempStr.hasSuffix("ed")) { + tempStr.deleteSuffix(1); + word = getPrimeWord(tempStr); + + if (!word) { + tempStr.deleteSuffix(1); + word = getPrimeWord(tempStr); + } + + if (word) { + if (word->_wordClass == WC_ACTION) { + TTaction *action = dynamic_cast<TTaction *>(word); + assert(action); + action->setVal(1); + } + } else { + tempStr = str; + } + + } else if (tempStr.hasSuffix("ly")) { + tempStr.deleteSuffix(2); + word = getPrimeWord(tempStr); + + if (word) { + delete word; + word = new TTword(str, WC_ADVERB, 0); + } else { + tempStr = str; + } + + } else if (tempStr.hasSuffix("er")) { + tempStr.deleteSuffix(1); + word = getPrimeWord(tempStr); + + if (word) { + if (word->_wordClass == WC_ADJECTIVE) { + TTadj *adj = static_cast<TTadj *>(word); + int val1 = word->proc15(); + int val2 = word->proc15(); + + if (val2 < 5) { + if (--val1 > 0) { + adj->adjFn1(val1); + } + } else { + if (++val1 < 11) { + adj->adjFn1(val1); + } + } + } + } else { + tempStr.deleteSuffix(1); + word = getPrimeWord(tempStr); + + if (word) { + if (word->_wordClass == WC_ADJECTIVE) { + TTadj *adj = dynamic_cast<TTadj *>(word); + int val1 = word->proc15(); + int val2 = word->proc15(); + + if (val2 < 5) { + if (--val1 > 0) { + adj->adjFn1(val1); + } + } else { + if (++val1 < 11) { + adj->adjFn1(val1); + } + } + } + } else { + tempStr.deleteSuffix(1); + word = getPrimeWord(tempStr); + + if (word && word->_wordClass == WC_ADJECTIVE) { + TTadj *adj = dynamic_cast<TTadj *>(word); + int val1 = word->proc15(); + int val2 = word->proc15(); + + if (val2 < 5) { + if (--val1 > 0) { + adj->adjFn1(val1); + } + } else { + if (++val1 < 11) { + adj->adjFn1(val1); + } + } + } + } + } + + } else if (tempStr.hasSuffix("est")) { + tempStr.deleteSuffix(2); + word = getPrimeWord(tempStr); + + if (word) { + if (word->_wordClass == WC_ADJECTIVE) { + TTadj *adj = static_cast<TTadj *>(word); + int val1 = word->proc15(); + int val2 = word->proc15(); + + if (val2 < 5) { + if (--val1 > 0) { + adj->adjFn1(val1); + } + } else { + if (++val1 < 11) { + adj->adjFn1(val1); + } + } + } + } else { + tempStr.deleteSuffix(1); + word = getPrimeWord(tempStr); + + if (word) { + if (word->_wordClass == WC_ADJECTIVE) { + TTadj *adj = dynamic_cast<TTadj *>(word); + int val1 = word->proc15(); + int val2 = word->proc15(); + + if (val2 < 5) { + if (--val1 > 0) { + adj->adjFn1(val1); + } + } else { + if (++val1 < 11) { + adj->adjFn1(val1); + } + } + } + } else { + tempStr.deleteSuffix(1); + word = getPrimeWord(tempStr); + + if (word) { + TTadj *adj = dynamic_cast<TTadj *>(word); + int val1 = word->proc15(); + int val2 = word->proc15(); + + if (val2 < 5) { + if (--val1 > 0) { + adj->adjFn1(val1); + } + } else { + if (++val1 < 11) { + adj->adjFn1(val1); + } + } + } + } + } + + } else if (tempStr.hasSuffix("s*")) { + tempStr.deleteSuffix(2); + word = getPrimeWord(tempStr); + + if (word) { + if (word->_wordClass == WC_PRONOUN || word->_wordClass == WC_ADVERB) { + delete word; + TTstring isStr("is"); + word = getPrimeWord(isStr); + } else { + switch (word->_id) { + case 200: + if (word->proc10() == 2) { + delete word; + word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 5); + } else if (word->proc10() == 1) { + delete word; + word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 4); + } + break; + + case 201: + delete word; + word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 5); + break; + + case 202: + case 203: + if (word->proc10() == 2) { + delete word; + word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 5); + } else { + int val = word->proc10() == 1 ? 0 : 4; + delete word; + word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, val); + } + break; + + case 204: + delete word; + word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 6); + break; + + default: + delete word; + word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 0); + break; + } + } + } + } + + if (word) + word->setSynStr(str); + + return word; +} + +TTword *TTvocab::getPrefixedWord(TTstring &str, TTword **srcWord) const { + TTstring tempStr(str); + TTword *word = nullptr; + int prefixLen = 0; + + if (tempStr.hasPrefix("pre")) { + prefixLen = 3; + } else if (tempStr.hasPrefix("re") || tempStr.hasPrefix("co")) { + prefixLen = 2; + } else if (tempStr.hasPrefix("inter") || tempStr.hasPrefix("multi")) { + prefixLen = 5; + } else if (tempStr.hasPrefix("over") || tempStr.hasPrefix("post") || tempStr.hasPrefix("self")) { + prefixLen = 4; + } + + if (prefixLen) { + // Known prefix found, so scan for word without prefix + tempStr.deletePrefix(prefixLen); + word = getPrimeWord(tempStr); + if (word) + tempStr = str; + + } else if (tempStr.hasPrefix("anti") || tempStr.hasPrefix("counter")) { + prefixLen = tempStr[0] == 'a' ? 4 : 7; + + tempStr.deletePrefix(prefixLen); + word = getPrimeWord(tempStr); + if (!word) + tempStr = str; + else if (word->_wordClass == 8) { + delete word; + word = nullptr; + } + + } else if (tempStr.hasPrefix("hyper") || tempStr.hasPrefix("super") || + tempStr.hasPrefix("ultra")) { + tempStr.deletePrefix(5); + word = getPrimeWord(tempStr); + + if (!word) + tempStr = str; + else if (word->_wordClass == WC_ADJECTIVE) { + TTadj *adj = static_cast<TTadj *>(word); + int val1 = word->proc15(); + int val2 = word->proc15(); + + if (val2 < 5) { + if (--val1 > 0) + adj->adjFn1(val1); + } else if (++val1 < 11) { + adj->adjFn1(val1); + } + } + } + + if (word) { + // Set the original word on either the found word or synonym + if (word->hasSynonyms()) + word->setSynStr(str); + else + word->_text = str; + } + + return word; +} + +} // End of namespace Titanic |