From 6ebd324be47a90560bb6937eada37f5dabae94b3 Mon Sep 17 00:00:00 2001 From: Arnaud Boutonné Date: Sun, 10 Oct 2010 22:13:38 +0000 Subject: HUGO: Add specific takeObject and dropObject for H1 DOS svn-id: r53135 --- engines/hugo/parser.cpp | 93 +++++++++++++++++++++++++++++++------------------ engines/hugo/parser.h | 9 ++--- 2 files changed, 64 insertions(+), 38 deletions(-) diff --git a/engines/hugo/parser.cpp b/engines/hugo/parser.cpp index 300bd319d6..d116dda5f3 100644 --- a/engines/hugo/parser.cpp +++ b/engines/hugo/parser.cpp @@ -372,6 +372,38 @@ bool Parser_v1w::isNear(object_t *obj, char *verb, char *comment) { return true; } +// Do all things necessary to carry an object +void Parser_v1w::takeObject(object_t *obj) { + debugC(1, kDebugParser, "takeObject(object_t *obj)"); + + obj->carriedFl = true; + if (obj->seqNumb) { // Don't change if no image to display + obj->cycling = INVISIBLE; + } + _vm.adjustScore(obj->objValue); + + if (obj->seqNumb > 0) // If object has an image, force walk to dropped + obj->viewx = -1; // (possibly moved) object next time taken! + Utils::Box(BOX_ANY, TAKE_TEXT, _vm._arrayNouns[obj->nounIndex][TAKE_NAME]); +} + +// Do all necessary things to drop an object +void Parser_v1w::dropObject(object_t *obj) { + debugC(1, kDebugParser, "dropObject(object_t *obj)"); + + obj->carriedFl = false; + obj->screenIndex = *_vm._screen_p; + if ((obj->seqNumb > 1) || (obj->seqList[0].imageNbr > 1)) + obj->cycling = CYCLE_FORWARD; + else + obj->cycling = NOT_CYCLING; + obj->x = _vm._hero->x - 1; + obj->y = _vm._hero->y + _vm._hero->currImagePtr->y2 - 1; + obj->y = (obj->y + obj->currImagePtr->y2 < YPIX) ? obj->y : YPIX - obj->currImagePtr->y2 - 10; + _vm.adjustScore(-obj->objValue); + Utils::Box(BOX_ANY, "%s", _vm._textParser[kTBOk]); +} + // Search for matching verbs in background command list. // Noun is not required. Return TRUE if match found // Note that if the background command list has match set TRUE then do not @@ -615,40 +647,6 @@ void Parser::showTakeables() { } } -// Do all things necessary to carry an object -void Parser::takeObject(object_t *obj) { - debugC(1, kDebugParser, "takeObject(object_t *obj)"); - - obj->carriedFl = true; - if (obj->seqNumb) { // Don't change if no image to display - obj->cycling = INVISIBLE; - if (_vm.getPlatform() != Common::kPlatformWindows) - warning("takeObject : DOS version should use ALMOST_INVISIBLE"); - } - _vm.adjustScore(obj->objValue); - - if (obj->seqNumb > 0) // If object has an image, force walk to dropped - obj->viewx = -1; // (possibly moved) object next time taken! - Utils::Box(BOX_ANY, TAKE_TEXT, _vm._arrayNouns[obj->nounIndex][TAKE_NAME]); -} - -// Do all necessary things to drop an object -void Parser::dropObject(object_t *obj) { - debugC(1, kDebugParser, "dropObject(object_t *obj)"); - - obj->carriedFl = false; - obj->screenIndex = *_vm._screen_p; - if ((obj->seqNumb > 1) || (obj->seqList[0].imageNbr > 1)) - obj->cycling = CYCLE_FORWARD; - else - obj->cycling = NOT_CYCLING; - obj->x = _vm._hero->x - 1; - obj->y = _vm._hero->y + _vm._hero->currImagePtr->y2 - 1; - obj->y = (obj->y + obj->currImagePtr->y2 < YPIX) ? obj->y : YPIX - obj->currImagePtr->y2 - 10; - _vm.adjustScore(-obj->objValue); - Utils::Box(BOX_ANY, "%s", _vm._textParser[kTBOk]); -} - // Return TRUE if object being carried by hero bool Parser::isCarrying(uint16 wordIndex) { debugC(1, kDebugParser, "isCarrying(%d)", wordIndex); @@ -892,6 +890,33 @@ bool Parser_v1d::isBackgroundWord(char *noun, char *verb, objectList_t obj) { return false; } +// Do all things necessary to carry an object +void Parser_v1d::takeObject(object_t *obj) { + debugC(1, kDebugParser, "takeObject(object_t *obj)"); + + obj->carriedFl = true; + if (obj->seqNumb) // Don't change if no image to display + obj->cycling = ALMOST_INVISIBLE; + + _vm.adjustScore(obj->objValue); + + Utils::Box(BOX_ANY, TAKE_TEXT, _vm._arrayNouns[obj->nounIndex][TAKE_NAME]); +} + +// Do all necessary things to drop an object +void Parser_v1d::dropObject(object_t *obj) { + debugC(1, kDebugParser, "dropObject(object_t *obj)"); + + obj->carriedFl = false; + obj->screenIndex = *_vm._screen_p; + if (obj->seqNumb) // Don't change if no image to display + obj->cycling = NOT_CYCLING; + obj->x = _vm._hero->x - 1; + obj->y = _vm._hero->y + _vm._hero->currImagePtr->y2 - 1; + _vm.adjustScore(-obj->objValue); + Utils::Box(BOX_ANY, "%s", _vm._textParser[kTBOk]); +} + // Print text for possible background object. Return TRUE if match found // If test_noun TRUE, must have a noun given bool Parser_v1d::isCatchallVerb(bool testNounFl, char *noun, char *verb, objectList_t obj) { diff --git a/engines/hugo/parser.h b/engines/hugo/parser.h index 3176b2bb35..245dded5f2 100644 --- a/engines/hugo/parser.h +++ b/engines/hugo/parser.h @@ -63,8 +63,6 @@ protected: char *findNoun(); char *findVerb(); - void dropObject(object_t *obj); - void takeObject(object_t *obj); void showTakeables(); private: @@ -89,6 +87,8 @@ private: bool isGenericVerb(object_t *obj, char *comment); bool isNear(object_t *obj, char *verb, char *comment); bool isObjectVerb(object_t *obj, char *comment); + void dropObject(object_t *obj); + void takeObject(object_t *obj); }; class Parser_v1d : public Parser { @@ -99,13 +99,14 @@ public: void lineHandler(); protected: - char *findNextNoun(char *noun); bool isNear(char *verb, char *noun, object_t *obj, char *comment); bool isGenericVerb(char *word, object_t *obj); bool isObjectVerb(char *word, object_t *obj); bool isBackgroundWord(char *noun, char *verb, objectList_t obj); bool isCatchallVerb(bool testNounFl, char *noun, char *verb, objectList_t obj); - + char *findNextNoun(char *noun); + void dropObject(object_t *obj); + void takeObject(object_t *obj); }; class Parser_v2d : public Parser_v1d { -- cgit v1.2.3