aboutsummaryrefslogtreecommitdiff
path: root/engines/hugo/parser_v3d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/hugo/parser_v3d.cpp')
-rw-r--r--engines/hugo/parser_v3d.cpp81
1 files changed, 41 insertions, 40 deletions
diff --git a/engines/hugo/parser_v3d.cpp b/engines/hugo/parser_v3d.cpp
index 2ab13eaed3..63508a2742 100644
--- a/engines/hugo/parser_v3d.cpp
+++ b/engines/hugo/parser_v3d.cpp
@@ -41,6 +41,7 @@
#include "hugo/util.h"
#include "hugo/sound.h"
#include "hugo/object.h"
+#include "hugo/text.h"
namespace Hugo {
@@ -76,7 +77,7 @@ void Parser_v3d::lineHandler() {
// Special code to allow me to go straight to any screen
if (strstr(_vm->_line, "goto")) {
for (int i = 0; i < _vm->_numScreens; i++) {
- if (!scumm_stricmp(&_vm->_line[strlen("goto") + 1], _vm->_screenNames[i])) {
+ if (!scumm_stricmp(&_vm->_line[strlen("goto") + 1], _vm->_text->getScreenNames(i))) {
_vm->_scheduler->newScreen(i);
return;
}
@@ -94,7 +95,7 @@ void Parser_v3d::lineHandler() {
if (strstr(_vm->_line, "fetch")) {
for (int i = 0; i < _vm->_object->_numObj; i++) {
- if (!scumm_stricmp(&_vm->_line[strlen("fetch") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
+ if (!scumm_stricmp(&_vm->_line[strlen("fetch") + 1], _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 0))) {
takeObject(&_vm->_object->_objects[i]);
return;
}
@@ -104,7 +105,7 @@ void Parser_v3d::lineHandler() {
// Special code to allow me to goto objects
if (strstr(_vm->_line, "find")) {
for (int i = 0; i < _vm->_object->_numObj; i++) {
- if (!scumm_stricmp(&_vm->_line[strlen("find") + 1], _vm->_arrayNouns[_vm->_object->_objects[i].nounIndex][0])) {
+ if (!scumm_stricmp(&_vm->_line[strlen("find") + 1], _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 0))) {
_vm->_scheduler->newScreen(_vm->_object->_objects[i].screenIndex);
return;
}
@@ -115,7 +116,7 @@ void Parser_v3d::lineHandler() {
// Special meta commands
// EXIT/QUIT
if (!strcmp("exit", _vm->_line) || strstr(_vm->_line, "quit")) {
- if (Utils::Box(kBoxYesNo, "%s", _vm->_textParser[kTBExit_1d]) != 0)
+ if (Utils::Box(kBoxYesNo, "%s", _vm->_text->getTextParser(kTBExit_1d)) != 0)
_vm->endGame();
else
return;
@@ -156,7 +157,7 @@ void Parser_v3d::lineHandler() {
// Test for nearby objects referenced explicitly
for (int i = 0; i < _vm->_object->_numObj; i++) {
object_t *obj = &_vm->_object->_objects[i];
- if (isWordPresent(_vm->_arrayNouns[obj->nounIndex])) {
+ if (isWordPresent(_vm->_text->getNounArray(obj->nounIndex))) {
if (isObjectVerb(obj, farComment) || isGenericVerb(obj, farComment))
return;
}
@@ -194,13 +195,13 @@ void Parser_v3d::lineHandler() {
char *noun = findNoun();
if (verb && noun) { // A combination I didn't think of
- Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBNoPoint]);
+ Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBNoPoint));
} else if (noun) {
- Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBNoun]);
+ Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBNoun));
} else if (verb) {
- Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBVerb]);
+ Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBVerb));
} else {
- Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBEh]);
+ Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBEh));
}
}
@@ -219,7 +220,7 @@ bool Parser_v3d::isObjectVerb(object_t *obj, char *comment) {
int i;
for (i = 0; _vm->_cmdList[cmdIndex][i].verbIndex != 0; i++) { // For each cmd
- if (isWordPresent(_vm->_arrayVerbs[_vm->_cmdList[cmdIndex][i].verbIndex])) // Was this verb used?
+ if (isWordPresent(_vm->_text->getVerbArray(_vm->_cmdList[cmdIndex][i].verbIndex))) // Was this verb used?
break;
}
@@ -227,7 +228,7 @@ bool Parser_v3d::isObjectVerb(object_t *obj, char *comment) {
return false;
// Verb match found. Check if object is Near
- char *verb = *_vm->_arrayVerbs[_vm->_cmdList[cmdIndex][i].verbIndex];
+ char *verb = *_vm->_text->getVerbArray(_vm->_cmdList[cmdIndex][i].verbIndex);
if (!isNear(obj, verb, comment))
return false;
@@ -237,7 +238,7 @@ bool Parser_v3d::isObjectVerb(object_t *obj, char *comment) {
uint16 *reqs = _vm->_arrayReqs[cmnd->reqIndex]; // ptr to list of required objects
for (i = 0; reqs[i]; i++) { // for each obj
if (!_vm->_object->isCarrying(reqs[i])) {
- Utils::Box(kBoxAny, "%s", _vm->_textData[cmnd->textDataNoCarryIndex]);
+ Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(cmnd->textDataNoCarryIndex));
return true;
}
}
@@ -245,18 +246,18 @@ bool Parser_v3d::isObjectVerb(object_t *obj, char *comment) {
// Required objects are present, now check state is correct
if ((obj->state != cmnd->reqState) && (cmnd->reqState != kStateDontCare)) {
- Utils::Box(kBoxAny, "%s", _vm->_textData[cmnd->textDataWrongIndex]);
+ Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(cmnd->textDataWrongIndex));
return true;
}
// Everything checked. Change the state and carry out any actions
if (cmnd->reqState != kStateDontCare) // Don't change new state if required state didn't care
obj->state = cmnd->newState;
- Utils::Box(kBoxAny, "%s", _vm->_textData[cmnd->textDataDoneIndex]);
+ Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(cmnd->textDataDoneIndex));
_vm->_scheduler->insertActionList(cmnd->actIndex);
// See if any additional generic actions
- if ((verb == _vm->_arrayVerbs[_vm->_look][0]) || (verb == _vm->_arrayVerbs[_vm->_take][0]) || (verb == _vm->_arrayVerbs[_vm->_drop][0]))
+ if ((verb == _vm->_text->getVerb(_vm->_look, 0)) || (verb == _vm->_text->getVerb(_vm->_take, 0)) || (verb == _vm->_text->getVerb(_vm->_drop, 0)))
isGenericVerb(obj, comment);
return true;
}
@@ -271,38 +272,38 @@ bool Parser_v3d::isGenericVerb(object_t *obj, char *comment) {
return false;
// Following is equivalent to switch, but couldn't do one
- if (isWordPresent(_vm->_arrayVerbs[_vm->_look]) && isNear(obj, _vm->_arrayVerbs[_vm->_look][0], comment)) {
+ if (isWordPresent(_vm->_text->getVerbArray(_vm->_look)) && isNear(obj, _vm->_text->getVerb(_vm->_look, 0), comment)) {
// Test state-dependent look before general look
if ((obj->genericCmd & LOOK_S) == LOOK_S) {
- Utils::Box(kBoxAny, "%s", _vm->_textData[obj->stateDataIndex[obj->state]]);
+ Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(obj->stateDataIndex[obj->state]));
} else {
if ((LOOK & obj->genericCmd) == LOOK) {
if (obj->dataIndex != 0)
- Utils::Box(kBoxAny, "%s", _vm->_textData[obj->dataIndex]);
+ Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(obj->dataIndex));
else
return false;
} else {
- Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBUnusual]);
+ Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBUnusual));
}
}
- } else if (isWordPresent(_vm->_arrayVerbs[_vm->_take]) && isNear(obj, _vm->_arrayVerbs[_vm->_take][0], comment)) {
+ } else if (isWordPresent(_vm->_text->getVerbArray(_vm->_take)) && isNear(obj, _vm->_text->getVerb(_vm->_take, 0), comment)) {
if (obj->carriedFl)
- Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBHave]);
+ Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBHave));
else if ((TAKE & obj->genericCmd) == TAKE)
takeObject(obj);
else if (obj->cmdIndex) // No comment if possible commands
return false;
else if (!obj->verbOnlyFl && (TAKE & obj->genericCmd) == TAKE) // Make sure not taking object in context!
- Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBNoUse]);
+ Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBNoUse));
else
return false;
- } else if (isWordPresent(_vm->_arrayVerbs[_vm->_drop])) {
+ } else if (isWordPresent(_vm->_text->getVerbArray(_vm->_drop))) {
if (!obj->carriedFl && ((DROP & obj->genericCmd) == DROP))
- Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBDontHave]);
+ Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBDontHave));
else if (obj->carriedFl && ((DROP & obj->genericCmd) == DROP))
dropObject(obj);
else if (obj->cmdIndex == 0)
- Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBNeed]);
+ Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBNeed));
else
return false;
} else { // It was not a generic cmd
@@ -327,16 +328,16 @@ bool Parser_v3d::isNear(object_t *obj, char *verb, char *comment) {
if (obj->screenIndex != *_vm->_screen_p) {
// Not in same screen
if (obj->objValue)
- strcpy(comment, _vm->_textParser[kCmtAny1]);
+ strcpy(comment, _vm->_text->getTextParser(kCmtAny1));
else
- strcpy(comment, _vm->_textParser[kCmtAny2]);
+ strcpy(comment, _vm->_text->getTextParser(kCmtAny2));
return false;
}
if (obj->cycling == kCycleInvisible) {
if (obj->seqNumb) {
// There is an image
- strcpy(comment, _vm->_textParser[kCmtAny3]);
+ strcpy(comment, _vm->_text->getTextParser(kCmtAny3));
return false;
} else {
// No image, assume visible
@@ -346,10 +347,10 @@ bool Parser_v3d::isNear(object_t *obj, char *verb, char *comment) {
return true;
} else {
// User is not close enough
- if (obj->objValue && (verb != _vm->_arrayVerbs[_vm->_take][0]))
- strcpy(comment, _vm->_textParser[kCmtAny1]);
+ if (obj->objValue && (verb != _vm->_text->getVerb(_vm->_take, 0)))
+ strcpy(comment, _vm->_text->getTextParser(kCmtAny1));
else
- strcpy(comment, _vm->_textParser[kCmtClose]);
+ strcpy(comment, _vm->_text->getTextParser(kCmtClose));
return false;
}
}
@@ -361,10 +362,10 @@ bool Parser_v3d::isNear(object_t *obj, char *verb, char *comment) {
return true;
} else {
// User is not close enough
- if (obj->objValue && (verb != _vm->_arrayVerbs[_vm->_take][0]))
- strcpy(comment, _vm->_textParser[kCmtAny1]);
+ if (obj->objValue && (verb != _vm->_text->getVerb(_vm->_take, 0)))
+ strcpy(comment, _vm->_text->getTextParser(kCmtAny1));
else
- strcpy(comment, _vm->_textParser[kCmtClose]);
+ strcpy(comment, _vm->_text->getTextParser(kCmtClose));
return false;
}
return true;
@@ -384,7 +385,7 @@ void Parser_v3d::takeObject(object_t *obj) {
if (obj->seqNumb > 0) // If object has an image, force walk to dropped
obj->viewx = -1; // (possibly moved) object next time taken!
- Utils::Box(kBoxAny, TAKE_TEXT, _vm->_arrayNouns[obj->nounIndex][TAKE_NAME]);
+ Utils::Box(kBoxAny, TAKE_TEXT, _vm->_text->getNoun(obj->nounIndex, TAKE_NAME));
}
/**
@@ -403,7 +404,7 @@ void Parser_v3d::dropObject(object_t *obj) {
obj->y = _vm->_hero->y + _vm->_hero->currImagePtr->y2 - 1;
obj->y = (obj->y + obj->currImagePtr->y2 < kYPix) ? obj->y : kYPix - obj->currImagePtr->y2 - 10;
_vm->adjustScore(-obj->objValue);
- Utils::Box(kBoxAny, "%s", _vm->_textParser[kTBOk]);
+ Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBOk));
}
/**
@@ -416,7 +417,7 @@ bool Parser_v3d::isCatchallVerb(objectList_t obj) {
debugC(1, kDebugParser, "isCatchallVerb(object_list_t obj)");
for (int i = 0; obj[i].verbIndex != 0; i++) {
- if (isWordPresent(_vm->_arrayVerbs[obj[i].verbIndex]) && obj[i].nounIndex == 0 &&
+ if (isWordPresent(_vm->_text->getVerbArray(obj[i].verbIndex)) && obj[i].nounIndex == 0 &&
(!obj[i].matchFl || !findNoun()) &&
((obj[i].roomState == kStateDontCare) ||
(obj[i].roomState == _vm->_screenStates[*_vm->_screen_p]))) {
@@ -424,7 +425,7 @@ bool Parser_v3d::isCatchallVerb(objectList_t obj) {
_vm->_scheduler->processBonus(obj[i].bonusIndex);
// If this is LOOK (without a noun), show any takeable objects
- if (*(_vm->_arrayVerbs[obj[i].verbIndex]) == _vm->_arrayVerbs[_vm->_look][0])
+ if (*(_vm->_text->getVerbArray(obj[i].verbIndex)) == _vm->_text->getVerb(_vm->_look, 0))
_vm->_object->showTakeables();
return true;
@@ -441,8 +442,8 @@ bool Parser_v3d::isBackgroundWord(objectList_t obj) {
debugC(1, kDebugParser, "isBackgroundWord(object_list_t obj)");
for (int i = 0; obj[i].verbIndex != 0; i++) {
- if (isWordPresent(_vm->_arrayVerbs[obj[i].verbIndex]) &&
- isWordPresent(_vm->_arrayNouns[obj[i].nounIndex]) &&
+ if (isWordPresent(_vm->_text->getVerbArray(obj[i].verbIndex)) &&
+ isWordPresent(_vm->_text->getNounArray(obj[i].nounIndex)) &&
((obj[i].roomState == kStateDontCare) ||
(obj[i].roomState == _vm->_screenStates[*_vm->_screen_p]))) {
Utils::Box(kBoxAny, "%s", _vm->_file->fetchString(obj[i].commentIndex));