diff options
author | Gregory Montoir | 2003-12-12 10:33:34 +0000 |
---|---|---|
committer | Gregory Montoir | 2003-12-12 10:33:34 +0000 |
commit | fef457ed0e63e0cf8df9fa7d724f4ea624d7cc5d (patch) | |
tree | 4f0da60737e7db3506b763f57fc83ba85c5bce34 /queen | |
parent | d7411615b89972917bd0da6a08c9ebcbe6c66c53 (diff) | |
download | scummvm-rg350-fef457ed0e63e0cf8df9fa7d724f4ea624d7cc5d.tar.gz scummvm-rg350-fef457ed0e63e0cf8df9fa7d724f4ea624d7cc5d.tar.bz2 scummvm-rg350-fef457ed0e63e0cf8df9fa7d724f4ea624d7cc5d.zip |
get rid of Verb class
svn-id: r11594
Diffstat (limited to 'queen')
-rw-r--r-- | queen/command.cpp | 235 | ||||
-rw-r--r-- | queen/command.h | 23 | ||||
-rw-r--r-- | queen/cutaway.cpp | 2 | ||||
-rw-r--r-- | queen/defs.h | 41 | ||||
-rw-r--r-- | queen/input.h | 3 | ||||
-rw-r--r-- | queen/logic.cpp | 11 | ||||
-rw-r--r-- | queen/logic.h | 6 | ||||
-rw-r--r-- | queen/state.cpp | 61 | ||||
-rw-r--r-- | queen/state.h | 1 | ||||
-rw-r--r-- | queen/structs.h | 4 | ||||
-rw-r--r-- | queen/talk.cpp | 12 | ||||
-rw-r--r-- | queen/verb.h | 167 |
12 files changed, 214 insertions, 352 deletions
diff --git a/queen/command.cpp b/queen/command.cpp index d08fd310fe..c1826e57ec 100644 --- a/queen/command.cpp +++ b/queen/command.cpp @@ -48,14 +48,14 @@ void CmdText::display(uint8 color) { } -void CmdText::displayTemp(uint8 color, bool locked, const Verb& v, const char *name) { +void CmdText::displayTemp(uint8 color, bool locked, Verb v, const char *name) { char temp[MAX_COMMAND_LEN]; if (locked) { - sprintf(temp, "%s%s", _vm->logic()->joeResponse(39), v.name()); + sprintf(temp, "%s%s", _vm->logic()->joeResponse(39), _vm->logic()->verbName(v)); } else { - strcpy(temp, v.name()); + strcpy(temp, _vm->logic()->verbName(v)); } if (name != NULL) { strcat(temp, " "); @@ -75,16 +75,16 @@ void CmdText::displayTemp(uint8 color, const char *name) { } -void CmdText::setVerb(const Verb& v) { +void CmdText::setVerb(Verb v) { - strcpy(_command, v.name()); + strcpy(_command, _vm->logic()->verbName(v)); } -void CmdText::addLinkWord(const Verb& v) { +void CmdText::addLinkWord(Verb v) { strcat(_command, " "); - strcat(_command, v.name()); + strcat(_command, _vm->logic()->verbName(v)); } @@ -103,7 +103,7 @@ bool CmdText::isEmpty() const { void CurrentCmdState::init() { commandLevel = 1; - oldVerb = verb = action = Verb(VERB_NONE); + oldVerb = verb = action = VERB_NONE; oldNoun = noun = subject1 = subject2 = 0; } @@ -123,7 +123,7 @@ void CurrentCmdState::addObject(int16 objNum) { void SelectedCmdState::init() { - action = defaultVerb = Verb(VERB_NONE); + action = defaultVerb = VERB_NONE; noun = 0; } @@ -173,10 +173,10 @@ void Command::executeCurrentAction(bool walk) { uint16 obj = _vm->logic()->currentRoomData() + _curCmd.noun; _curCmd.verb = findDefault(obj, false); - if (_curCmd.verb.isNone()) { + if (_curCmd.verb == VERB_NONE) { // no match made, so command not yet completed, redefine as WALK_TO - _cmdText.setVerb(Verb(VERB_WALK_TO)); - _selCmd.action = Verb(VERB_WALK_TO); + _cmdText.setVerb(VERB_WALK_TO); + _selCmd.action = VERB_WALK_TO; } else { _cmdText.setVerb(_curCmd.verb); @@ -254,7 +254,7 @@ void Command::executeCurrentAction(bool walk) { } } - if (cond <= 0 && _selCmd.action.value() == VERB_LOOK_AT) { + if (cond <= 0 && _selCmd.action == VERB_LOOK_AT) { look(); } else { @@ -275,22 +275,22 @@ void Command::updatePlayer() { lookCurrentRoom(); lookCurrentIcon(); - if (!_vm->input()->keyVerb().isNone()) { + if (_vm->input()->keyVerb() != VERB_NONE) { - if (_vm->input()->keyVerb().isJournal()) { + if (_vm->input()->keyVerb() == VERB_USE_JOURNAL) { _vm->input()->clearKeyVerb(); _vm->logic()->useJournal(); } - else if (!_vm->input()->keyVerb().isSkipText()) { + else if (_vm->input()->keyVerb() != VERB_SKIP_TEXT) { _curCmd.verb = _vm->input()->keyVerb(); - if (_curCmd.verb.isInventory()) { + if (isVerbInv(_curCmd.verb)) { _curCmd.noun = _selCmd.noun = 0; // Clear old noun and old verb in case we're pointing at an // object (noun) or item (verb) and we want to use an item // on it. This was the command will be redisplayed with the // object/item that the cursor is currently on. _curCmd.oldNoun = 0; - _curCmd.oldVerb = Verb(VERB_NONE); + _curCmd.oldVerb = VERB_NONE; grabSelectedItem(); } else { @@ -361,7 +361,7 @@ int16 Command::executeCommand(uint16 comId, int16 condResult) { } // Don't grab if action is TALK or WALK - if (_selCmd.action.value() != VERB_TALK_TO && _selCmd.action.value() != VERB_WALK_TO) { + if (_selCmd.action != VERB_TALK_TO && _selCmd.action != VERB_WALK_TO) { if (_curCmd.subject1 > 0) { _vm->logic()->joeGrab(State::findGrab(_vm->logic()->objectData(_curCmd.subject1)->state)); } @@ -427,7 +427,7 @@ int16 Command::executeCommand(uint16 comId, int16 condResult) { } // don't play music on an OPEN/CLOSE command - in case the command fails - if (_selCmd.action.value() != VERB_OPEN && _selCmd.action.value() != VERB_CLOSE) { + if (_selCmd.action != VERB_OPEN && _selCmd.action != VERB_CLOSE) { // only play song if it's a PLAY BEFORE type if (com->song > 0) { _vm->sound()->playSong(com->song); @@ -455,7 +455,7 @@ int16 Command::executeCommand(uint16 comId, int16 condResult) { // execute.c l.533-548 // FIXME: useless test, as .dog has already been played - // if (_selCmd.action.value() == VERB_TALK_TO && cond > 0) { + // if (_selCmd.action == VERB_TALK_TO && cond > 0) { // if (executeIfDialog(_vm->logic()->objectTextualDescription(cond))) { // cleanupCurrentAction(); // return; @@ -472,7 +472,7 @@ int16 Command::executeCommand(uint16 comId, int16 condResult) { } -int16 Command::makeJoeWalkTo(int16 x, int16 y, int16 objNum, const Verb &v, bool mustWalk) { +int16 Command::makeJoeWalkTo(int16 x, int16 y, int16 objNum, Verb v, bool mustWalk) { // Check to see if object is actually an exit to another // room. If so, then set up new room @@ -482,7 +482,7 @@ int16 Command::makeJoeWalkTo(int16 x, int16 y, int16 objNum, const Verb &v, bool y = objData->y; } - if (v.value() == VERB_WALK_TO) { + if (v == VERB_WALK_TO) { _vm->logic()->entryObj(objData->entryObj); if (_vm->logic()->entryObj() != 0) { _vm->logic()->newRoom(_vm->logic()->objectData(_vm->logic()->entryObj())->room); @@ -535,16 +535,16 @@ void Command::grabCurrentSelection() { _selPosX += _vm->display()->horizontalScroll(); - if (_curCmd.verb.isAction()) { + if (isVerbPanel(_curCmd.verb) || _curCmd.verb == VERB_WALK_TO || isVerbScrollInv(_curCmd.verb)) { grabSelectedVerb(); } - else if (_curCmd.verb.isInventory()) { + else if (isVerbInv(_curCmd.verb)) { grabSelectedItem(); } else if (_curCmd.noun > 0 && _curCmd.noun <= _vm->logic()->currentRoomObjMax()) { grabSelectedNoun(); } - else if (_selPosY < ROOM_ZONE_HEIGHT && _curCmd.verb.isNone()) { + else if (_selPosY < ROOM_ZONE_HEIGHT && _curCmd.verb == VERB_NONE) { // select without a command, do a WALK clear(true); _vm->logic()->joeWalk(JWM_EXECUTE); @@ -554,18 +554,18 @@ void Command::grabCurrentSelection() { void Command::grabSelectedObject(int16 objNum, uint16 objState, uint16 objName) { - if (!_curCmd.action.isNone()) { + if (_curCmd.action != VERB_NONE) { _cmdText.addObject(_vm->logic()->objectName(objName)); } _curCmd.addObject(objNum); // if first noun and it's a 2 level command then set up action word - if (_curCmd.action.value() == VERB_USE && _curCmd.commandLevel == 1) { + if (_curCmd.action == VERB_USE && _curCmd.commandLevel == 1) { if (State::findUse(objState) == STATE_USE_ON) { // object supports 2 levels _curCmd.commandLevel = 2; - _cmdText.addLinkWord(Verb(VERB_PREP_WITH)); + _cmdText.addLinkWord(VERB_PREP_WITH); // command not fully constructed _cmdText.display(INK_CMD_NORMAL); _parse = false; @@ -575,9 +575,9 @@ void Command::grabSelectedObject(int16 objNum, uint16 objState, uint16 objName) _parse = true; } } - else if (_curCmd.action.value() == VERB_GIVE && _curCmd.commandLevel == 1) { + else if (_curCmd.action == VERB_GIVE && _curCmd.commandLevel == 1) { _curCmd.commandLevel = 2; - _cmdText.addLinkWord(Verb(VERB_PREP_TO)); + _cmdText.addLinkWord(VERB_PREP_TO); // command not fully constructed _cmdText.display(INK_CMD_NORMAL); _parse = false; @@ -588,11 +588,11 @@ void Command::grabSelectedObject(int16 objNum, uint16 objState, uint16 objName) } if (_parse) { - _curCmd.verb = Verb(VERB_NONE); + _curCmd.verb = VERB_NONE; //_vm->logic()->newRoom(0); _vm->logic()->joeWalk(JWM_EXECUTE); _selCmd.action = _curCmd.action; - _curCmd.action = Verb(VERB_NONE); + _curCmd.action = VERB_NONE; } } @@ -604,7 +604,7 @@ void Command::grabSelectedItem() { // Set PARSE to TRUE, default FALSE if command half complete _parse = true; - uint16 item = _vm->logic()->findInventoryItem(_curCmd.verb.inventoryItem()); + uint16 item = _vm->logic()->findInventoryItem(_curCmd.verb - VERB_INV_FIRST); if (item == 0 || _vm->logic()->itemData(item)->name == 0) { return; } @@ -613,49 +613,49 @@ void Command::grabSelectedItem() { // the ITEMs default, otherwise keep constructing! if (_mouseKey == Input::MOUSE_LBUTTON || - (!_vm->input()->keyVerb().isNone() && !_curCmd.verb.isNone())) { - if (_curCmd.action.isNone()) { - if (!_vm->input()->keyVerb().isNone()) { + (_vm->input()->keyVerb() != VERB_NONE && _curCmd.verb != VERB_NONE)) { + if (_curCmd.action == VERB_NONE) { + if (_vm->input()->keyVerb() != VERB_NONE) { /* 2 - We've selected via the keyboard, no command is being */ /* constructed, so we shall find the item's default */ _curCmd.verb = findDefault(item, true); - if (_curCmd.verb.isNone()) { + if (_curCmd.verb == VERB_NONE) { // set to Look At - _curCmd.verb = Verb(VERB_LOOK_AT); - _cmdText.setVerb(Verb(VERB_LOOK_AT)); + _curCmd.verb = VERB_LOOK_AT; + _cmdText.setVerb(VERB_LOOK_AT); } _curCmd.action = _curCmd.verb; } else { // Action>0 ONLY if command has been constructed // Left Mouse Button pressed just do Look At - _curCmd.verb = Verb(VERB_LOOK_AT); - _curCmd.action = Verb(VERB_LOOK_AT); - _cmdText.setVerb(Verb(VERB_LOOK_AT)); + _curCmd.verb = VERB_LOOK_AT; + _curCmd.action = VERB_LOOK_AT; + _cmdText.setVerb(VERB_LOOK_AT); } } - _curCmd.verb = Verb(VERB_NONE); + _curCmd.verb = VERB_NONE; } else { if (_vm->logic()->joeWalk() == JWM_MOVE) { _cmdText.clear(); _curCmd.commandLevel = 1; _vm->logic()->joeWalk(JWM_NORMAL); - _curCmd.action = Verb(VERB_NONE); + _curCmd.action = VERB_NONE; lookCurrentIcon(); } - if (!_selCmd.defaultVerb.isNone()) { + if (_selCmd.defaultVerb != VERB_NONE) { alterDefault(_selCmd.defaultVerb, true); - _selCmd.defaultVerb = Verb(VERB_NONE); + _selCmd.defaultVerb = VERB_NONE; clear(true); return; } if (_cmdText.isEmpty()) { - _curCmd.verb = Verb(VERB_LOOK_AT); - _curCmd.action = Verb(VERB_LOOK_AT); - _cmdText.setVerb(Verb(VERB_LOOK_AT)); + _curCmd.verb = VERB_LOOK_AT; + _curCmd.action = VERB_LOOK_AT; + _cmdText.setVerb(VERB_LOOK_AT); } else { if (_curCmd.commandLevel == 2 && _parse) { @@ -664,15 +664,15 @@ void Command::grabSelectedItem() { else { _curCmd.verb = findDefault(item, true); } - if (_curCmd.verb.isNone()) { + if (_curCmd.verb == VERB_NONE) { // No match made, so command not yet completed. Redefine as LOOK AT - _curCmd.action = Verb(VERB_LOOK_AT); - _cmdText.setVerb(Verb(VERB_LOOK_AT)); + _curCmd.action = VERB_LOOK_AT; + _cmdText.setVerb(VERB_LOOK_AT); } else { _curCmd.action = _curCmd.verb; } - _curCmd.verb = Verb(VERB_NONE); + _curCmd.verb = VERB_NONE; } } @@ -699,24 +699,24 @@ void Command::grabSelectedNoun() { return; } - if (_curCmd.verb.isNone()) { + if (_curCmd.verb == VERB_NONE) { if (_mouseKey == Input::MOUSE_LBUTTON) { - if ((_curCmd.commandLevel != 2 && _curCmd.action.isNone()) || + if ((_curCmd.commandLevel != 2 && _curCmd.action == VERB_NONE) || (_curCmd.commandLevel == 2 && _parse)) { // action2 > 0 only if command has been constructed // lmb pressed, just walk - _curCmd.verb = Verb(VERB_WALK_TO); - _curCmd.action = Verb(VERB_WALK_TO); - _cmdText.setVerb(Verb(VERB_WALK_TO)); + _curCmd.verb = VERB_WALK_TO; + _curCmd.action = VERB_WALK_TO; + _cmdText.setVerb(VERB_WALK_TO); } } else if (_mouseKey == Input::MOUSE_RBUTTON) { // rmb pressed, do default if one exists - if (!_selCmd.defaultVerb.isNone()) { + if (_selCmd.defaultVerb != VERB_NONE) { // change default of command alterDefault(_selCmd.defaultVerb, false); - _selCmd.defaultVerb = Verb(VERB_NONE); + _selCmd.defaultVerb = VERB_NONE; clear(true); return; } @@ -724,9 +724,9 @@ void Command::grabSelectedNoun() { if (_cmdText.isEmpty()) { // Ensures that Right Mkey will select correct default _curCmd.verb = findDefault(objNum, false); - if (!_curCmd.verb.isNone()) { + if (_curCmd.verb != VERB_NONE) { // no match made, redefine as Walk To - _selCmd.action = Verb(VERB_WALK_TO); + _selCmd.action = VERB_WALK_TO; } else { _selCmd.action = _curCmd.verb; @@ -735,21 +735,21 @@ void Command::grabSelectedNoun() { _cmdText.addObject(_vm->logic()->objectName(_vm->logic()->objectData(objNum)->name)); } else { - _curCmd.verb = Verb(VERB_NONE); - if ((_curCmd.commandLevel == 2 && !_parse) || !_curCmd.action.isNone()) { + _curCmd.verb = VERB_NONE; + if ((_curCmd.commandLevel == 2 && !_parse) || _curCmd.action != VERB_NONE) { _curCmd.verb = _curCmd.action; } else { _curCmd.verb = findDefault(objNum, false); } - if (_curCmd.verb.isNone()) { - _curCmd.action = Verb(VERB_WALK_TO); - _cmdText.setVerb(Verb(VERB_WALK_TO)); + if (_curCmd.verb != VERB_NONE) { + _curCmd.action = VERB_WALK_TO; + _cmdText.setVerb(VERB_WALK_TO); } else { _curCmd.action = _curCmd.verb; } - _curCmd.verb = Verb(VERB_NONE); + _curCmd.verb = VERB_NONE; } } } @@ -763,12 +763,12 @@ void Command::grabSelectedNoun() { void Command::grabSelectedVerb() { - if (_curCmd.verb.isScrollInventory()) { + if (isVerbScrollInv(_curCmd.verb)) { // move through inventory (by four if right mouse button) uint16 scroll = _mouseKey == Input::MOUSE_RBUTTON ? 4 : 1; - _vm->logic()->inventoryScroll(scroll, _curCmd.verb.value() == VERB_SCROLL_UP); + _vm->logic()->inventoryScroll(scroll, _curCmd.verb == VERB_SCROLL_UP); } - else if (_curCmd.verb.isPanelCommand() || _curCmd.verb.value() == VERB_WALK_TO) { + else if (isVerbPanel(_curCmd.verb) || _curCmd.verb == VERB_WALK_TO) { _curCmd.action = _curCmd.verb; _curCmd.subject1 = 0; _curCmd.subject2 = 0; @@ -779,12 +779,12 @@ void Command::grabSelectedVerb() { _cmdText.displayTemp(11, true, _curCmd.verb); } else { - _selCmd.defaultVerb = Verb(VERB_NONE); - if (_vm->logic()->joeWalk() == JWM_MOVE && !_curCmd.verb.isNone()) { + _selCmd.defaultVerb = VERB_NONE; + if (_vm->logic()->joeWalk() == JWM_MOVE && _curCmd.verb != VERB_NONE) { _vm->logic()->joeWalk(JWM_NORMAL); } _curCmd.commandLevel = 1; - _curCmd.oldVerb = Verb(VERB_NONE); + _curCmd.oldVerb = VERB_NONE; _curCmd.oldNoun = 0; _cmdText.setVerb(_curCmd.verb); _cmdText.display(INK_CMD_NORMAL); @@ -842,9 +842,9 @@ bool Command::handleDefaultCommand(bool walk) { uint16 roomData = _vm->logic()->currentRoomData(); // select without a command or WALK TO ; do a WALK - if ((_selCmd.action.value() == VERB_WALK_TO || _selCmd.action.isNone()) && + if ((_selCmd.action == VERB_WALK_TO || _selCmd.action == VERB_NONE) && (_selCmd.noun > objMax || _selCmd.noun == 0)) { - if (_selCmd.action.isNone()) { + if (_selCmd.action == VERB_NONE) { _vm->graphics()->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); } _vm->walk()->moveJoe(0, _selPosX, _selPosY, false); // XXX inCutaway parameter @@ -854,21 +854,21 @@ bool Command::handleDefaultCommand(bool walk) { if (_curCmd.subject1 > 0 && _vm->logic()->objectData(_curCmd.subject1)->name <= 0) { return true; } - if (// _selCmd.action.value() == VERB_GIVE && // can be TALK_TO ! + if (// _selCmd.action == VERB_GIVE && // can be TALK_TO ! _curCmd.subject2 > 0 && _vm->logic()->objectData(_curCmd.subject2)->name <= 0) { return true; } // check for USE command on exists - if (_selCmd.action.value() == VERB_USE && + if (_selCmd.action == VERB_USE && _curCmd.subject1 > 0 && _vm->logic()->objectData(_curCmd.subject1)->entryObj > 0) { - _selCmd.action = Verb(VERB_WALK_TO); + _selCmd.action = VERB_WALK_TO; } if (_selCmd.noun > 0 && _selCmd.noun <= objMax) { uint16 objNum = _vm->logic()->currentRoomData() + _selCmd.noun; if (makeJoeWalkTo(_selPosX, _selPosY, objNum, _selCmd.action, walk) != 0) { return true; } - if (_selCmd.action.value() == VERB_WALK_TO && _vm->logic()->objectData(roomData + _selCmd.noun)->entryObj < 0) { + if (_selCmd.action == VERB_WALK_TO && _vm->logic()->objectData(roomData + _selCmd.noun)->entryObj < 0) { return true; } } @@ -876,12 +876,12 @@ bool Command::handleDefaultCommand(bool walk) { } -void Command::executeStandardStuff(const Verb& action, int16 subj1, int16 subj2) { +void Command::executeStandardStuff(Verb action, int16 subj1, int16 subj2) { // l.158-272 execute.c uint16 k; - switch (action.value()) { + switch (action) { case VERB_LOOK_AT: look(); @@ -976,15 +976,15 @@ void Command::executeStandardStuff(const Verb& action, int16 subj1, int16 subj2) } -void Command::changeObjectState(const Verb& action, int16 obj, int16 song, bool cutDone) { +void Command::changeObjectState(Verb action, int16 obj, int16 song, bool cutDone) { // l.456-533 execute.c ObjectData *objData = _vm->logic()->objectData(obj); - if (action.value() == VERB_OPEN && !cutDone) { + if (action == VERB_OPEN && !cutDone) { if (State::findOn(objData->state) == STATE_ON_ON) { State::alterOn(&objData->state, STATE_ON_OFF); - State::alterDefaultVerb(&objData->state, Verb(VERB_NONE)); + State::alterDefaultVerb(&objData->state, VERB_NONE); // play music if it exists... (or SFX for open/close door) if (song != 0) { @@ -1002,11 +1002,11 @@ void Command::changeObjectState(const Verb& action, int16 obj, int16 song, bool _vm->logic()->joeSpeak(9); } } - else if (action.value() == VERB_CLOSE && !cutDone) { + else if (action == VERB_CLOSE && !cutDone) { if (State::findOn(objData->state) == STATE_ON_OFF) { State::alterOn(&objData->state, STATE_ON_ON); - State::alterDefaultVerb(&objData->state, Verb(VERB_OPEN)); + State::alterDefaultVerb(&objData->state, VERB_OPEN); // play music if it exists... (or SFX for open/close door) if (song != 0) { @@ -1024,7 +1024,7 @@ void Command::changeObjectState(const Verb& action, int16 obj, int16 song, bool _vm->logic()->joeSpeak(10); } } - else if (action.value() == VERB_MOVE) { + else if (action == VERB_MOVE) { State::alterOn(&objData->state, STATE_ON_OFF); } } @@ -1034,7 +1034,7 @@ void Command::cleanupCurrentAction() { // l.595-597 execute.c _vm->logic()->joeFace(); _curCmd.oldNoun = 0; - _curCmd.oldVerb = Verb(VERB_NONE); + _curCmd.oldVerb = VERB_NONE; } @@ -1045,7 +1045,7 @@ Verb Command::findDefault(uint16 obj, bool itemType) { } -void Command::alterDefault(const Verb& def, bool itemType) { +void Command::alterDefault(Verb def, bool itemType) { uint16 *newDefaultState = 0; const char *name = NULL; @@ -1064,7 +1064,7 @@ void Command::alterDefault(const Verb& def, bool itemType) { name = _vm->logic()->objectTextualDescription(od->name); } else { - uint16 item = _vm->logic()->findInventoryItem(_curCmd.verb.inventoryItem()); + uint16 item = _vm->logic()->findInventoryItem(_curCmd.verb - VERB_INV_FIRST); if (item == 0 || _vm->logic()->itemData(item)->name == 0) { return; } @@ -1078,14 +1078,14 @@ void Command::alterDefault(const Verb& def, bool itemType) { _cmdText.clear(); } else { - _cmdText.setVerb(def.isNone() ? Verb(VERB_WALK_TO) : def); + _cmdText.setVerb(def == VERB_NONE ? VERB_WALK_TO : def); } _cmdText.displayTemp(INK_CMD_NORMAL, name); _curCmd.oldNoun = _curCmd.noun; } -void Command::openOrCloseAssociatedObject(const Verb& action, int16 otherObj) { +void Command::openOrCloseAssociatedObject(Verb action, int16 otherObj) { CmdListData *cmdList = &_cmdList[1]; uint16 com = 0; @@ -1125,17 +1125,17 @@ void Command::openOrCloseAssociatedObject(const Verb& action, int16 otherObj) { objData->image = cmdList->imageOrder; } - if (action.value() == VERB_OPEN) { + if (action == VERB_OPEN) { if (State::findOn(objData->state) == STATE_ON_ON) { State::alterOn(&objData->state, STATE_ON_OFF); - State::alterDefaultVerb(&objData->state, Verb(VERB_NONE)); + State::alterDefaultVerb(&objData->state, VERB_NONE); objData->entryObj = ABS(objData->entryObj); } } - else if (action.value() == VERB_CLOSE) { + else if (action == VERB_CLOSE) { if (State::findOn(objData->state) == STATE_ON_OFF) { State::alterOn(&objData->state, STATE_ON_ON); - State::alterDefaultVerb(&objData->state, Verb(VERB_OPEN)); + State::alterDefaultVerb(&objData->state, VERB_OPEN); objData->entryObj = -ABS(objData->entryObj); } } @@ -1430,17 +1430,17 @@ void Command::look() { void Command::lookCurrentItem() { - if (_curCmd.verb.isInventory()) { - uint16 item = _vm->logic()->findInventoryItem(_curCmd.verb.inventoryItem()); + if (isVerbInv(_curCmd.verb)) { + uint16 item = _vm->logic()->findInventoryItem(_curCmd.verb - VERB_INV_FIRST); if (item != 0) { ItemData *itemData = _vm->logic()->itemData(item); const char *name = _vm->logic()->objectName(itemData->name); - if (_curCmd.action.isNone()) { + if (_curCmd.action == VERB_NONE) { Verb v = State::findDefaultVerb(itemData->state); - _cmdText.setVerb(v.isNone() ? Verb(VERB_LOOK_AT) : v); + _cmdText.setVerb(v == VERB_NONE ? VERB_LOOK_AT : v); } - if (!_selCmd.defaultVerb.isNone()) { + if (_selCmd.defaultVerb != VERB_NONE) { _cmdText.displayTemp(INK_CMD_LOCK, true, _selCmd.defaultVerb, name); } else { @@ -1487,10 +1487,10 @@ void Command::lookCurrentRoom() { if (_curCmd.noun > _vm->logic()->currentRoomObjMax() && aObjName <= 0) { if (_curCmd.oldNoun != 0) { - if (!_selCmd.defaultVerb.isNone()) { + if (_selCmd.defaultVerb != VERB_NONE) { _cmdText.displayTemp(INK_CMD_LOCK, true, _selCmd.defaultVerb); } - else if (!_curCmd.action.isNone()) { + else if (_curCmd.action != VERB_NONE) { _cmdText.display(INK_CMD_NORMAL); } _curCmd.oldNoun = 0; @@ -1501,19 +1501,19 @@ void Command::lookCurrentRoom() { if (i <= 0) { _curCmd.oldNoun = _curCmd.noun; _vm->graphics()->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); - if (!_selCmd.defaultVerb.isNone()) { + if (_selCmd.defaultVerb != VERB_NONE) { _cmdText.displayTemp(INK_CMD_LOCK, true, _selCmd.defaultVerb); } - else if (!_curCmd.action.isNone()) { + else if (_curCmd.action != VERB_NONE) { _cmdText.display(INK_CMD_NORMAL); } return; } // if no command yet selected, then use DEFAULT command, if any - if (_curCmd.action.isNone()) { + if (_curCmd.action == VERB_NONE) { Verb v = State::findDefaultVerb(_vm->logic()->objectData(k + _curCmd.noun)->state); - _cmdText.setVerb(v.isNone() ? Verb(VERB_WALK_TO) : v); + _cmdText.setVerb(v == VERB_NONE ? VERB_WALK_TO : v); if (_curCmd.noun == 0) { _cmdText.clear(); } @@ -1522,7 +1522,7 @@ void Command::lookCurrentRoom() { if (_curCmd.noun > 0) { objName = _vm->logic()->objectName(i); } - if (!_selCmd.defaultVerb.isNone()) { + if (_selCmd.defaultVerb != VERB_NONE) { _cmdText.displayTemp(INK_CMD_LOCK, true, _selCmd.defaultVerb, objName); } else { @@ -1537,7 +1537,7 @@ void Command::lookCurrentIcon() { _curCmd.verb = _vm->logic()->findVerbUnderCursor(_vm->input()->mousePosX(), _vm->input()->mousePosY()); if (_curCmd.verb != _curCmd.oldVerb && _vm->logic()->joeWalk() != JWM_MOVE) { - if (_curCmd.action.isNone()) { + if (_curCmd.action == VERB_NONE) { _cmdText.clear(); } _vm->graphics()->textClear(CmdText::COMMAND_Y_POS, CmdText::COMMAND_Y_POS); @@ -1549,15 +1549,14 @@ void Command::lookCurrentIcon() { } _curCmd.oldVerb = _curCmd.verb; - if (_curCmd.verb.isPanelCommand() || _curCmd.verb.value() == VERB_WALK_TO) { - if (_curCmd.verb.isNone()) { - _cmdText.display(INK_CMD_NORMAL); - } - else { - _cmdText.displayTemp(INK_CMD_NORMAL, false, _curCmd.verb); - } + if (_curCmd.verb == VERB_NONE) { + _cmdText.display(INK_CMD_NORMAL); + } + else if (isVerbPanel(_curCmd.verb) || _curCmd.verb == VERB_WALK_TO) { + _cmdText.displayTemp(INK_CMD_NORMAL, false, _curCmd.verb); } } } + } // End of namespace Queen diff --git a/queen/command.h b/queen/command.h index 3c04451840..27ba554b37 100644 --- a/queen/command.h +++ b/queen/command.h @@ -23,8 +23,8 @@ #define QUEENCOMMAND_H #include "common/util.h" +#include "queen/defs.h" #include "queen/structs.h" -#include "queen/verb.h" namespace Queen { @@ -34,10 +34,10 @@ struct CmdText { void clear(); void display(uint8 color); - void displayTemp(uint8 color, bool locked, const Verb& v, const char *name = NULL); + void displayTemp(uint8 color, bool locked, Verb v, const char *name = NULL); void displayTemp(uint8 color, const char *name); - void setVerb(const Verb& v); - void addLinkWord(const Verb& v); + void setVerb(Verb v); + void addLinkWord(Verb v); void addObject(const char *objName); bool isEmpty() const; @@ -105,7 +105,7 @@ private: int16 executeCommand(uint16 comId, int16 condResult); - int16 makeJoeWalkTo(int16 x, int16 y, int16 objNum, const Verb &v, bool mustWalk); + int16 makeJoeWalkTo(int16 x, int16 y, int16 objNum, Verb v, bool mustWalk); void grabCurrentSelection(); void grabSelectedObject(int16 objNum, uint16 objState, uint16 objName); @@ -117,18 +117,18 @@ private: bool executeIfDialog(const char *description); bool handleDefaultCommand(bool walk); - void executeStandardStuff(const Verb& action, int16 subj1, int16 subj2); - void changeObjectState(const Verb& action, int16 obj, int16 song, bool cutDone); + void executeStandardStuff(Verb action, int16 subj1, int16 subj2); + void changeObjectState(Verb action, int16 obj, int16 song, bool cutDone); void cleanupCurrentAction(); //! find default verb action for specified object Verb findDefault(uint16 obj, bool itemType); //! alter default verb action for specified object and update command display - void alterDefault(const Verb& def, bool itemType); + void alterDefault(Verb def, bool itemType); //! OPEN_CLOSE_OTHER(OBJECT_DATA[S][4]) - void openOrCloseAssociatedObject(const Verb& action, int16 obj); + void openOrCloseAssociatedObject(Verb action, int16 obj); //! update gamestates - P1_SET_CONDITIONS int16 setConditions(uint16 command, bool lastCmd); @@ -151,7 +151,10 @@ private: void lookCurrentRoom(); void lookCurrentIcon(); - + bool isVerbPanel(Verb v) const { return v >= VERB_PANEL_COMMAND_FIRST && v <= VERB_PANEL_COMMAND_LAST; }; + bool isVerbInv(Verb v) const { return v >= VERB_INV_FIRST && v <= VERB_INV_LAST; } + bool isVerbScrollInv(Verb v) const { return v == VERB_SCROLL_UP || v == VERB_SCROLL_DOWN; } + CmdListData *_cmdList; uint16 _numCmdList; diff --git a/queen/cutaway.cpp b/queen/cutaway.cpp index 6b9467c6bd..2f968eff87 100644 --- a/queen/cutaway.cpp +++ b/queen/cutaway.cpp @@ -1380,7 +1380,7 @@ void Cutaway::handleText( if (_vm->input()->cutawayQuit()) return; - if (_vm->input()->keyVerb().isSkipText()) { + if (_vm->input()->keyVerb() == VERB_SKIP_TEXT) { _vm->input()->clearKeyVerb(); break; } diff --git a/queen/defs.h b/queen/defs.h index 20a22955c9..21c0bb3771 100644 --- a/queen/defs.h +++ b/queen/defs.h @@ -275,6 +275,47 @@ enum Language { }; +enum Verb { + VERB_NONE = 0, + + VERB_PANEL_COMMAND_FIRST = 1, + VERB_OPEN = 1, + VERB_CLOSE = 2, + VERB_MOVE = 3, + // no verb 4 + VERB_GIVE = 5, + VERB_USE = 6, + VERB_PICK_UP = 7, + VERB_LOOK_AT = 9, + VERB_TALK_TO = 8, + VERB_PANEL_COMMAND_LAST = 9, + + VERB_WALK_TO = 10, + VERB_SCROLL_UP = 11, + VERB_SCROLL_DOWN = 12, + + VERB_DIGIT_FIRST = 13, + VERB_DIGIT_1 = 13, + VERB_DIGIT_2 = 14, + VERB_DIGIT_3 = 15, + VERB_DIGIT_4 = 16, + VERB_DIGIT_LAST = 16, + + VERB_INV_FIRST = VERB_DIGIT_FIRST, + VERB_INV_1 = VERB_DIGIT_1, + VERB_INV_2 = VERB_DIGIT_2, + VERB_INV_3 = VERB_DIGIT_3, + VERB_INV_4 = VERB_DIGIT_4, + VERB_INV_LAST = VERB_DIGIT_LAST, + + VERB_USE_JOURNAL = 20, + VERB_SKIP_TEXT = 101, + + VERB_PREP_WITH = 11, + VERB_PREP_TO = 12 +}; + + } // End of namespace Queen #endif diff --git a/queen/input.h b/queen/input.h index a6acd75f5b..439ca10a37 100644 --- a/queen/input.h +++ b/queen/input.h @@ -24,7 +24,6 @@ #include "common/util.h" #include "queen/defs.h" -#include "queen/verb.h" namespace Queen { @@ -57,7 +56,7 @@ class Input { int checkKeys(); //! use instead of KEYVERB=0 - void clearKeyVerb() { _keyVerb = Verb(VERB_NONE); } + void clearKeyVerb() { _keyVerb = VERB_NONE; } void canQuit(bool cq) { _canQuit = cq; } diff --git a/queen/logic.cpp b/queen/logic.cpp index 498bff11cc..6c87191c1c 100644 --- a/queen/logic.cpp +++ b/queen/logic.cpp @@ -41,7 +41,7 @@ namespace Queen { -const VerbEnum Logic::PANEL_VERBS[] = { +const Verb Logic::PANEL_VERBS[] = { VERB_NONE, VERB_OPEN, VERB_CLOSE, @@ -60,9 +60,6 @@ const VerbEnum Logic::PANEL_VERBS[] = { }; -char* Verb::_verbName[13]; - - Logic::Logic(QueenEngine *vm) : _vm(vm) { _joe.x = _joe.y = 0; @@ -246,9 +243,9 @@ void Logic::initialise() { for (i = 1; i <= _numRooms; i++) _roomName[i] = _vm->resource()->getJAS2Line(); - Verb::initName(0, NULL); + _verbName[0] = 0; for (i = 1; i <= 12; i++) - Verb::initName(i, _vm->resource()->getJAS2Line()); + _verbName[i] = _vm->resource()->getJAS2Line(); _joeResponse[0] = 0; for (i = 1; i <= JOE_RESPONSE_MAX; i++) @@ -2195,7 +2192,7 @@ void Logic::handlePinnacleRoom() { if (objData->name > 0) { _entryObj = objData->entryObj; char textCmd[CmdText::MAX_COMMAND_LEN]; - sprintf(textCmd, "%s %s", Verb(VERB_WALK_TO).name(), _objName[objData->name]); + sprintf(textCmd, "%s %s", verbName(VERB_WALK_TO), _objName[objData->name]); _vm->graphics()->textCurrentColor(INK_PINNACLE_ROOM); _vm->graphics()->textSetCentered(5, textCmd); } diff --git a/queen/logic.h b/queen/logic.h index f0167d9c77..e9ce7851cc 100644 --- a/queen/logic.h +++ b/queen/logic.h @@ -25,7 +25,6 @@ #include "common/util.h" #include "queen/defs.h" #include "queen/structs.h" -#include "queen/verb.h" namespace Queen { @@ -126,6 +125,7 @@ public: void joePrevFacing(uint16 dir); const char *joeResponse(int i) const { return _joeResponse[i]; } + const char *verbName(Verb v) const { return _verbName[v]; } int16 gameState(int index); void gameState(int index, int16 newValue); @@ -370,6 +370,8 @@ protected: //! Room name, prefix for data files (PCX, LUM...) char **_roomName; //ROOM_NAMEstr + char *_verbName[13]; + char *_joeResponse[JOE_RESPONSE_MAX + 1]; //JOE_RESPstr //! Actor animation string @@ -427,7 +429,7 @@ protected: QueenEngine *_vm; //! Verbs (in order) available in panel - static const VerbEnum PANEL_VERBS[]; + static const Verb PANEL_VERBS[]; }; diff --git a/queen/state.cpp b/queen/state.cpp index 65fc915076..8bb4c978cf 100644 --- a/queen/state.cpp +++ b/queen/state.cpp @@ -26,7 +26,6 @@ namespace Queen { Direction State::findDirection(uint16 state) { - // queen.c l.4014-4021 static const Direction sd[] = { DIR_BACK, DIR_RIGHT, @@ -43,14 +42,13 @@ StateTalk State::findTalk(uint16 state) { StateGrab State::findGrab(uint16 state) { - // queen.c l.4022-4029 - static const StateGrab gd[] = { + static const StateGrab sg[] = { STATE_GRAB_NONE, STATE_GRAB_DOWN, STATE_GRAB_UP, STATE_GRAB_MID }; - return gd[state & 3]; + return sg[state & 3]; } @@ -60,37 +58,28 @@ StateOn State::findOn(uint16 state) { Verb State::findDefaultVerb(uint16 state) { - Verb v; - switch((state >> 4) & 0xF) { - case 1: - v = Verb(VERB_OPEN); - break; - case 3: - v = Verb(VERB_CLOSE); - break; - case 7: - v = Verb(VERB_MOVE); - break; - case 8: - v = Verb(VERB_GIVE); - break; - case 12: - v = Verb(VERB_USE); - break; - case 14: - v = Verb(VERB_PICK_UP); - break; - case 9: - v = Verb(VERB_TALK_TO); - break; - case 6: - v = Verb(VERB_LOOK_AT); - break; - default: - v = Verb(VERB_NONE); - break; - } - return v; + static const Verb sdv[] = { + VERB_NONE, + VERB_OPEN, + VERB_NONE, + VERB_CLOSE, + + VERB_NONE, + VERB_NONE, + VERB_LOOK_AT, + VERB_MOVE, + + VERB_GIVE, + VERB_TALK_TO, + VERB_NONE, + VERB_NONE, + + VERB_USE, + VERB_NONE, + VERB_PICK_UP, + VERB_NONE + }; + return sdv[(state >> 4) & 0xF]; } @@ -113,7 +102,7 @@ void State::alterOn(uint16 *objState, StateOn state) { void State::alterDefaultVerb(uint16 *objState, Verb v) { uint16 val; - switch (v.value()) { + switch (v) { case VERB_OPEN: val = 1; break; diff --git a/queen/state.h b/queen/state.h index 86f72368bd..2ba9790d40 100644 --- a/queen/state.h +++ b/queen/state.h @@ -24,7 +24,6 @@ #include "common/util.h" #include "queen/defs.h" -#include "queen/verb.h" namespace Queen { diff --git a/queen/structs.h b/queen/structs.h index 74332c7ed7..712f01ab85 100644 --- a/queen/structs.h +++ b/queen/structs.h @@ -22,7 +22,7 @@ #ifndef QUEENSTRUCTS_H #define QUEENSTRUCTS_H -#include "queen/verb.h" +#include "queen/defs.h" namespace Queen { @@ -411,7 +411,7 @@ struct CmdListData { int16 specialSection; void readFrom(byte *&ptr) { - verb = Verb((VerbEnum)READ_BE_UINT16(ptr)); ptr += 2; + verb = (Verb)READ_BE_UINT16(ptr); ptr += 2; nounObj1 = (int16)READ_BE_UINT16(ptr); ptr += 2; nounObj2 = (int16)READ_BE_UINT16(ptr); ptr += 2; song = (int16)READ_BE_UINT16(ptr); ptr += 2; diff --git a/queen/talk.cpp b/queen/talk.cpp index 78cb514adc..e7fdf023f6 100644 --- a/queen/talk.cpp +++ b/queen/talk.cpp @@ -871,7 +871,7 @@ void Talk::defaultAnimation( } // Skip through text more quickly - if (_vm->input()->keyVerb().isSkipText()) { + if (_vm->input()->keyVerb() == VERB_SKIP_TEXT) { _vm->input()->clearKeyVerb(); break; } @@ -1332,11 +1332,11 @@ int16 Talk::selectSentence() { int mouseButton = _vm->input()->mouseButton(); _vm->input()->clearMouseButton(); - if (_vm->input()->keyVerb().isDigit()) { - for (i = 1; i <= 4; i++) - { - if (talkZone[i] == _vm->input()->keyVerb().digit()) - { + Verb v = _vm->input()->keyVerb(); + if (v >= VERB_DIGIT_FIRST && v <= VERB_DIGIT_LAST) { + int n = v - VERB_DIGIT_FIRST + 1; + for (i = 1; i <= 4; i++) { + if (talkZone[i] == n) { selectedSentence = i; break; } diff --git a/queen/verb.h b/queen/verb.h deleted file mode 100644 index 3c2437f3b7..0000000000 --- a/queen/verb.h +++ /dev/null @@ -1,167 +0,0 @@ - -/* ScummVM - Scumm Interpreter - * Copyright (C) 2003 The ScummVM project - * - * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Header$ - * - */ - -#ifndef QUEENVERB_H -#define QUEENVERB_H - -namespace Queen { - -enum VerbEnum { - VERB_NONE = 0, - - VERB_PANEL_COMMAND_FIRST = 1, - VERB_OPEN = 1, - VERB_CLOSE = 2, - VERB_MOVE = 3, - // no verb 4 - VERB_GIVE = 5, - VERB_USE = 6, - VERB_PICK_UP = 7, - VERB_LOOK_AT = 9, - VERB_TALK_TO = 8, - VERB_PANEL_COMMAND_LAST = 9, - - VERB_WALK_TO = 10, - VERB_SCROLL_UP = 11, - VERB_SCROLL_DOWN = 12, - - VERB_DIGIT_FIRST = 13, - VERB_DIGIT_1 = 13, - VERB_DIGIT_2 = 14, - VERB_DIGIT_3 = 15, - VERB_DIGIT_4 = 16, - VERB_DIGIT_LAST = 16, - - VERB_INV_FIRST = VERB_DIGIT_FIRST, - VERB_INV_1 = VERB_DIGIT_1, - VERB_INV_2 = VERB_DIGIT_2, - VERB_INV_3 = VERB_DIGIT_3, - VERB_INV_4 = VERB_DIGIT_4, - VERB_INV_LAST = VERB_DIGIT_LAST, - - VERB_USE_JOURNAL = 20, - VERB_SKIP_TEXT = 101, - - VERB_PREP_WITH = 11, - VERB_PREP_TO = 12 -}; - - -class Verb { -public: - - Verb() { - _verb = VERB_NONE; - } - - Verb(VerbEnum v) { - _verb = v; - } - - //! _verb is open/close/move/give/look at/pick up/talk to - bool isPanelCommand() const { - return - _verb >= VERB_PANEL_COMMAND_FIRST && - _verb <= VERB_PANEL_COMMAND_LAST; - } - - bool isScrollInventory() const { - return - _verb == VERB_SCROLL_UP || - _verb == VERB_SCROLL_DOWN; - } - - bool isInventory() const { - return - _verb >= VERB_INV_FIRST && - _verb <= VERB_INV_LAST; - } - - bool isJournal() const { - return _verb == VERB_USE_JOURNAL; - } - - bool isDigit() const { - return - _verb >= VERB_DIGIT_FIRST && - _verb <= VERB_DIGIT_LAST; - } - - int digit() const { - return (int)_verb - VERB_DIGIT_1 + 1; - } - - bool isSkipText() const { - return _verb == VERB_SKIP_TEXT; - } - - bool isAction() const { - return - isPanelCommand() || - _verb == VERB_WALK_TO || - isScrollInventory(); - } - - bool isNone() const { - return _verb == VERB_NONE; - } - - int inventoryItem() const { - if (isInventory()) { - return _verb - VERB_INV_FIRST; - } - return -1; - } - - VerbEnum value() const { - return _verb; - } - - const char* name() const { - if (_verb > 0 && _verb < 13) { - return _verbName[_verb]; - } - return NULL; - } - - bool operator==(const Verb& other) const { - return _verb == other._verb; - } - - bool operator!=(const Verb& other) const { - return _verb != other._verb; - } - - static void initName(int i, char* name) { - _verbName[i] = name; - } - -private: - - VerbEnum _verb; - - static char* _verbName[13]; -}; - -} // End of namespace Queen - -#endif |