[Scummvm-cvs-logs] CVS: scummvm/queen command.h,1.3,1.4 command.cpp,1.3,1.4 logic.h,1.53,1.54 logic.cpp,1.72,1.73 xref.txt,1.29,1.30

Gregory Montoir cyx at users.sourceforge.net
Mon Nov 3 11:53:32 CET 2003


Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1:/tmp/cvs-serv16438

Modified Files:
	command.h command.cpp logic.h logic.cpp xref.txt 
Log Message:
cleanup

Index: command.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/command.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- command.h	3 Nov 2003 14:47:22 -0000	1.3
+++ command.h	3 Nov 2003 19:52:12 -0000	1.4
@@ -56,26 +56,61 @@
 };
 
 
+struct CurrentCmdState {
+
+	void init();
+	void addObject(int16 objNum);
+
+	Verb oldVerb;
+	Verb verb;
+	Verb action;
+	int16 oldNoun;
+	int16 noun;
+	//! current level of the command (max=2 for GIVE and USE verbs)
+	int commandLevel;
+	int16 subject1;
+	int16 subject2;
+};
+
+
+struct SelectedCmdState {
+
+	void init();
+	
+	//! locked verb (using 2nd mouse button)
+	Verb defaultVerb;
+	Verb action;
+	int16 noun;
+};
+
+
 class Command {
 public:
 	
 	Command(Logic*, Graphics*, Input*, Walk*);
 	
+	//! initialise command construction
 	void clear(bool clearTexts);
 
+	//! execute last constructed command
 	void executeCurrentAction(bool walk);
 
+	//! get player input and construct command from it
 	void updatePlayer();
 
+	//! read all command arrays from stream
 	void readCommandsFrom(byte *&ptr);
 
-	Verb selectedAction() const { return _selCmd.action; }
-	int16 selectedNoun() const { return _selCmd.noun; }
+	//! return true if command is ready to be executed
 	bool parse() const { return _parse; }
 
+
 private:
 
+	int16 makeJoeWalkTo(int16 x, int16 y, int16 objNum, const Verb &v, bool mustWalk);
+
 	void grabCurrentSelection();
+	void grabSelectedObject(int16 objNum, uint16 objState, uint16 objName);
 	void grabSelectedItem();
 	void grabSelectedNoun();
 	void grabSelectedVerb();
@@ -89,27 +124,31 @@
 	void changeObjectState(const 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);
 	
-	//! Opens/closes the object associated with object - OPEN_CLOSE_OTHER(OBJECT_DATA[S][4])
+	//! OPEN_CLOSE_OTHER(OBJECT_DATA[S][4])
 	void openOrCloseAssociatedObject(const Verb& action, int16 obj);
 	
-	//! Update gamestates - P1_SET_CONDITIONS
+	//! update gamestates - P1_SET_CONDITIONS
 	int16 setConditions(uint16 command, bool lastCmd);
 
-	//! Turn on/off areas - P2_SET_AREAS
+	//! turn on/off areas - P2_SET_AREAS
 	void setAreas(uint16 command);
 
-	//! Hide/show objects, redisplay if in the same room as Joe - P3_SET_OBJECTS
+	//! hide/show objects, redisplay if in the same room as Joe - P3_SET_OBJECTS
 	void setObjects(uint16 command);
 	
-	//! Inserts/deletes items (inventory) - P4_SET_ITEMS
+	//! inserts/deletes items (inventory) - P4_SET_ITEMS
 	void setItems(uint16 command);
 
+	//! update description for object and returns description number to use
 	uint16 nextObjectDescription(ObjectDescription *objDesc, uint16 firstDesc);
 
-	//! Look at Objects/Items and speak their description
+	//! look at current object / item and speak its description
 	void look();
 	void lookCurrentItem();
 	void lookCurrentRoom();
@@ -131,33 +170,18 @@
 	CmdGameState *_cmdGameState;
 	uint16 _numCmdGameState;
 
-	//! Textual form of the command (displayed between room and panel areas)
+	//! textual form of the command (displayed between room and panel areas)
 	CmdText _cmdText;
 	
-	//! If true, command string is executed
+	//! flag indicating that the current command is fully constructed
 	bool _parse;
 
-	struct {
-		Verb oldVerb, verb;
-		Verb action;
-		int16 oldNoun, noun;
-		//! Current level of the command (max=2 for GIVE and USE verbs)
-		int commandLevel;
-	} _curCmd;
-
-	struct {
-		//! Locked verb (using 2nd mouse button)
-		Verb defaultVerb;
-		Verb action;
-		int16 noun;
-		int16 subject1, subject2;
-	} _selCmd;
+	CurrentCmdState _curCmd;
 
-	//! MKEY
-	int _mouseKey;
+	SelectedCmdState _selCmd;
 
-	//! Position of last selection
-	int _selPosX, _selPosY;
+	//! last user selection
+	int _mouseKey, _selPosX, _selPosY;
 
 	Logic *_logic;
 	Graphics *_graphics;

Index: command.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/command.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- command.cpp	3 Nov 2003 14:47:22 -0000	1.3
+++ command.cpp	3 Nov 2003 19:52:13 -0000	1.4
@@ -96,6 +96,33 @@
 }
 
 
+void CurrentCmdState::init() {
+
+	commandLevel = 1;
+	oldVerb = verb = action = Verb(VERB_NONE);
+	oldNoun = noun = subject1 = subject2 = 0;
+}
+
+
+void CurrentCmdState::addObject(int16 objNum) {
+	
+	switch (commandLevel) {
+	case 1:
+		subject1 = objNum;
+		break;
+	case 2:
+		subject2 = objNum;
+		break;
+	}
+}
+
+
+void SelectedCmdState::init() {
+	
+	action = defaultVerb = Verb(VERB_NONE);
+	noun = 0;
+}
+
 
 Command::Command(Logic *l, Graphics *g, Input *i, Walk *w)
 	: _logic(l), _graphics(g), _input(i), _walk(w) {
@@ -111,13 +138,8 @@
 		_graphics->textClear(151, 151);
 	}
 	_parse = false;
-
-	_curCmd.commandLevel = 1;
-	_curCmd.oldVerb = _curCmd.verb = _curCmd.action = Verb(VERB_NONE);
-	_curCmd.oldNoun = _curCmd.noun = 0;
-
-	_selCmd.action = _selCmd.defaultVerb = Verb(VERB_NONE);
-	_selCmd.noun = _selCmd.subject1 = _selCmd.subject2 = 0;
+	_curCmd.init();
+	_selCmd.init();
 }
 
 
@@ -137,11 +159,11 @@
 	uint16 objMax = _logic->currentRoomObjMax();
 	uint16 roomData = _logic->currentRoomData();
 
-	if (_mouseKey == Input::MOUSE_RBUTTON && _selCmd.subject1 != 0) {
+	if (_mouseKey == Input::MOUSE_RBUTTON && _curCmd.subject1 != 0) {
 		// check to see if selecting default command for object/item
-		if (_selCmd.subject1 > 0) {
+		if (_curCmd.subject1 > 0) {
 			// an object
-			int16 i = _selCmd.subject1;
+			int16 i = _curCmd.subject1;
 			if (_curCmd.noun > objMax) {
 				int16 aObj = _logic->currentRoomArea(_curCmd.noun - objMax)->object;
 				int16 aObjName = _logic->objectData(aObj)->name;
@@ -173,7 +195,7 @@
 		}
 		else {
 			// an item
-			int16 name = _logic->itemData(ABS(_selCmd.subject1))->name;
+			int16 name = _logic->itemData(ABS(_curCmd.subject1))->name;
 			obj1Name = _logic->objectName(name);
 		}
 	}
@@ -187,8 +209,8 @@
 	// XXX SUBJECT[2]=0;
 
 	// get objects names
-	obj1Name = _logic->objectOrItemName(_selCmd.subject1);
-	obj2Name = _logic->objectOrItemName(_selCmd.subject2);
+	obj1Name = _logic->objectOrItemName(_curCmd.subject1);
+	obj2Name = _logic->objectOrItemName(_curCmd.subject2);
 
 	if (handleBadCommand(walk)) {
 		cleanupCurrentAction();
@@ -196,12 +218,12 @@
 	}
 
 	// get the number of commands associated with Object/Item
-	uint16 comMax = countAssociatedCommands(_selCmd.action, _selCmd.subject1, _selCmd.subject2);
+	uint16 comMax = countAssociatedCommands(_selCmd.action, _curCmd.subject1, _curCmd.subject2);
 	if (comMax == 0) {
 		// no command match was found, so exit
-		// pass ACTION2 as paramater, as a new Command (and a new ACTION2) 
+		// pass ACTION2 as parameter, as a new Command (and a new ACTION2) 
 		// can be constructed while Joe speaks 
-		executeStandardStuff(_selCmd.action, _selCmd.subject1, _selCmd.subject2);
+		executeStandardStuff(_selCmd.action, _curCmd.subject1, _curCmd.subject2);
 		cleanupCurrentAction();
 		return;
 	}
@@ -209,7 +231,7 @@
     // process each associated command for the Object, until all done
     // or one of the Gamestate tests fails...
 	int16 cond = 0;
-	CmdListData *com = &_cmdList[0];
+	CmdListData *com = &_cmdList[1];
 	uint16 comId = 0;
 	uint16 curCommand;
 	for (curCommand = 1; curCommand <= comMax; ++curCommand) {
@@ -217,7 +239,7 @@
 		++comId;
 		// try to find a match for the command in COM_LIST
 		for (; comId <= _numCmdList; ++comId, ++com) {
-			if (com->match(_selCmd.action, _selCmd.subject1, _selCmd.subject2)) {
+			if (com->match(_selCmd.action, _curCmd.subject1, _curCmd.subject2)) {
 				break;
 			}
 		}
@@ -258,11 +280,11 @@
 
 	// Don't grab if action is TALK or WALK
 	if (_selCmd.action.value() != VERB_TALK_TO && _selCmd.action.value() != VERB_WALK_TO) {
-		if (_selCmd.subject1 > 0) {
-			_logic->joeGrab(_logic->objectData(_selCmd.subject1)->state, 0);
+		if (_curCmd.subject1 > 0) {
+			_logic->joeGrab(_logic->objectData(_curCmd.subject1)->state, 0);
 		}
-		if (_selCmd.subject2 > 0) {
-			_logic->joeGrab(_logic->objectData(_selCmd.subject2)->state, 0);
+		if (_curCmd.subject2 > 0) {
+			_logic->joeGrab(_logic->objectData(_curCmd.subject2)->state, 0);
 		}
 	}
 
@@ -295,9 +317,9 @@
 	}
 
 	int16 oldImage = 0;
-	if (_selCmd.subject1 > 0) {
+	if (_curCmd.subject1 > 0) {
 		// an object (not an item)
-		oldImage = _logic->objectData(_selCmd.subject1)->image;
+		oldImage = _logic->objectData(_curCmd.subject1)->image;
 	}
 
 	if (com->setObjects) {
@@ -308,7 +330,7 @@
 	}
 
 	if (com->imageOrder != 0) {
-		ObjectData* od = _logic->objectData(_selCmd.subject1);
+		ObjectData* od = _logic->objectData(_curCmd.subject1);
 		// we must update the graphic image of the object
 		if (com->imageOrder < 0) {
 			// instead of setting to -1 or -2, flag as negative
@@ -320,15 +342,15 @@
 		else {
 			od->image = com->imageOrder;
 		}
-		_logic->roomRefreshObject(_selCmd.subject1);
+		_logic->roomRefreshObject(_curCmd.subject1);
 	}
 	else {
 		// this object is not being updated by command list, see if
 		// it has another image copied to it
-		if (_selCmd.subject1 > 0) {
+		if (_curCmd.subject1 > 0) {
 			// an object (not an item)
-			if (_logic->objectData(_selCmd.subject1)->image != oldImage) {
-				_logic->roomRefreshObject(_selCmd.subject1);
+			if (_logic->objectData(_curCmd.subject1)->image != oldImage) {
+				_logic->roomRefreshObject(_curCmd.subject1);
 			}
 		}
 	}
@@ -361,7 +383,7 @@
 		break;
 	}
 
-	changeObjectState(_selCmd.action, _selCmd.subject1, com->song, cutDone);
+	changeObjectState(_selCmd.action, _curCmd.subject1, com->song, cutDone);
 
 	if (_selCmd.action.value() == VERB_TALK_TO && cond > 0) {
 		if (executeIfDialog(_logic->objectTextualDescription(cond))) {
@@ -417,7 +439,7 @@
 
 		if (_input->keyVerb().isJournal()) {
 			// XXX queen.c l.348-365
-			warning("Command::updatePlayer() - Journal not implemented");
+			warning("Command::updatePlayer() - Journal not yet implemented");
 		}
 		else if (!_input->keyVerb().isSkipText()) {
 			_curCmd.verb = _input->keyVerb();
@@ -496,6 +518,56 @@
 }
 
 
+int16 Command::makeJoeWalkTo(int16 x, int16 y, int16 objNum, const Verb &v, bool mustWalk) {
+
+	// Check to see if object is actually an exit to another
+	// room. If so, then set up new room
+
+
+	ObjectData *objData = _logic->objectData(objNum);
+	if (objData->x != 0 || objData->y != 0) {
+		x = objData->x;
+		y = objData->y;
+	}
+
+	if (v.value() == VERB_WALK_TO) {
+		_logic->entryObj(objData->entryObj);
+		if (_logic->entryObj() != 0) {
+			_logic->newRoom(_logic->objectData(_logic->entryObj())->room);
+			// because this is an exit object, see if there is
+			// a walk off point and set (x,y) accordingly
+			WalkOffData *wod = _logic->walkOffPointForObject(objNum);
+			if (wod != NULL) {
+				x = wod->x;
+				y = wod->y;
+			}
+		}
+	}
+	else {
+		_logic->entryObj(0);
+		_logic->newRoom(0);
+	}
+
+
+	int16 p = 0;
+	if (mustWalk) {
+		// determine which way for Joe to face Object
+		uint16 facing = State::findDirection(objData->state);
+
+		BobSlot *bobJoe  = _graphics->bob(0);
+		if (x == bobJoe->x && y == bobJoe->y) {
+			_logic->joeFacing(facing);
+			_logic->joeFace();
+		}
+		else {
+			p = _walk->joeMove(facing, x, y, false); // XXX inCutaway parameter
+			// XXX if(P != 0) P = FIND_VERB
+		}
+	}
+	return p;
+}
+
+
 void Command::grabCurrentSelection() {
 	
 	_selPosX = _input->mousePosX();
@@ -525,6 +597,51 @@
 }
 
 
+void Command::grabSelectedObject(int16 objNum, uint16 objState, uint16 objName) {
+
+	if (!_curCmd.action.isNone()) {
+		_cmdText.addObject(_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 (State::findUse(objState) == STATE_USE_ON) {
+			// object supports 2 levels
+			_curCmd.commandLevel = 2;
+			_cmdText.addLinkWord(Verb(VERB_PREP_WITH));
+			 // command not fully constructed
+			_cmdText.display(INK_CMD_NORMAL);
+			_parse = false;
+		}
+		else {
+			_cmdText.display(INK_CMD_SELECT);
+			_parse = true;
+		}
+	}
+	else if (_curCmd.action.value() == VERB_GIVE && _curCmd.commandLevel == 1) {
+		_curCmd.commandLevel = 2;
+		_cmdText.addLinkWord(Verb(VERB_PREP_TO));
+		 // command not fully constructed
+		_cmdText.display(INK_CMD_NORMAL);
+		_parse = false;
+	}
+	else {
+		_cmdText.display(INK_CMD_SELECT);
+		_parse = true;
+	}
+
+	if (_parse) {
+		_curCmd.verb = Verb(VERB_NONE);
+		_logic->joeWalk(2); // set JOEWALK flag to perform EXECUTE_ACTION procedure
+		_selCmd.action = _curCmd.action;
+		_curCmd.action = Verb(VERB_NONE);
+	}
+
+}
+
+
 void Command::grabSelectedItem() {
 
 	// if the NOUN has been selected from screen then it is positive
@@ -601,47 +718,7 @@
 		}
 	}
 
-	if (_curCmd.action.isTwoLevelsCommand() && _curCmd.commandLevel == 1) {
-		_parse = false;
-	}
-	if (!_curCmd.action.isNone()) {
-		_cmdText.addObject(_logic->objectName(_logic->itemData(item)->name));
-	}
-	
-	switch (_curCmd.commandLevel) {
-	case 1:
-		_selCmd.subject1 = -item;
-		break;
-	case 2:
-		_selCmd.subject2 = -item;
-		break;
-	}
-
-	if (_curCmd.action.value() == VERB_USE && _curCmd.commandLevel == 1) {
-		if (State::findUse(_logic->itemData(item)->state) == STATE_USE_ON) {
-			_cmdText.addLinkWord(Verb(VERB_PREP_WITH));
-			_curCmd.commandLevel = 2;
-		}
-		else {
-			_parse = true;
-		}
-		_cmdText.display(INK_CMD_NORMAL);
-	}
-	else if (_curCmd.action.value() == VERB_GIVE && _curCmd.commandLevel == 1) {
-		_cmdText.addLinkWord(Verb(VERB_PREP_TO));
-		_curCmd.commandLevel = 2;
-		_cmdText.display(INK_CMD_NORMAL);
-	}
-	else {
-		_cmdText.display(INK_CMD_SELECT);
-	}
-
-	if (_parse) {
-		_curCmd.verb = Verb(VERB_NONE);
-		_logic->joeWalk(2); // set JOEWALK flag to perform EXECUTE_ACTION procedure
-		_selCmd.action = _curCmd.action;
-		_curCmd.action = Verb(VERB_NONE);
-	}
+	grabSelectedObject(-item, _logic->itemData(item)->state, _logic->itemData(item)->name);
 }
 
 
@@ -720,55 +797,7 @@
 	}
 
 	_selCmd.noun = 0;
-
-	if (_curCmd.action.isTwoLevelsCommand() && _curCmd.commandLevel == 1) {
-		// command not fully constructed
-		_parse = false;
-	}
-	else {
-		_parse = true;
-	}
-
-	if (!_curCmd.action.isNone()) {
-		_cmdText.addObject(_logic->objectName(objName));
-	}
-	
-	switch (_curCmd.commandLevel) {
-	case 1:
-		_selCmd.subject1 = objNum;
-		break;
-	case 2:
-		_selCmd.subject2 = objNum;
-		break;
-	}
-
-    // 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 (State::findUse(_logic->objectData(objNum)->state) == STATE_USE_ON) {
-			_cmdText.addLinkWord(Verb(VERB_PREP_WITH));
-			_curCmd.commandLevel = 2;
-		}
-		else {
-			// object does not support 2nd level
-			_parse = true;
-		}
-		_cmdText.display(INK_CMD_NORMAL);
-	}
-	else if (_curCmd.action.value() == VERB_GIVE && _curCmd.commandLevel == 1) {
-		_cmdText.addLinkWord(Verb(VERB_PREP_TO));
-		_cmdText.display(INK_CMD_NORMAL);
-	}
-	else {
-		_cmdText.display(INK_CMD_SELECT);
-	}
-
-	if (_parse) {
-		_curCmd.verb = Verb(VERB_NONE);
-		_logic->joeWalk(2); // set JOEWALK flag to perform EXECUTE_ACTION procedure
-		_selCmd.action = _curCmd.action;
-		_curCmd.action = Verb(VERB_NONE);
-	}
+	grabSelectedObject(objNum, _logic->objectData(objNum)->state, objName);
 }
 	
 
@@ -781,8 +810,8 @@
 	}
 	else if (_curCmd.verb.isPanelCommand() || _curCmd.verb.value() == VERB_WALK_TO) {
 		_curCmd.action = _curCmd.verb;
-		_selCmd.subject1 = 0;
-		_selCmd.subject2 = 0;
+		_curCmd.subject1 = 0;
+		_curCmd.subject2 = 0;
 
 		// if right mouse key selected, then store command VERB
 		if (_mouseKey == Input::MOUSE_RBUTTON) {
@@ -858,7 +887,7 @@
 
 	// l.96-141 execute.c
 	uint16 objMax = _logic->currentRoomObjMax();
-	uint16 roomData = _logic->roomData(_logic->currentRoom());
+	uint16 roomData = _logic->currentRoomData();
 
 	// select without a command or WALK TO ; do a WALK
 	if ((_selCmd.action.value() == VERB_WALK_TO || _selCmd.action.isNone()) && 
@@ -870,19 +899,21 @@
 		return true;
 	}
 	// check to see if one of the objects is hidden
-	if (_selCmd.subject1 > 0 && _logic->objectData(_selCmd.subject1)->name <= 0) {
+	if (_curCmd.subject1 > 0 && _logic->objectData(_curCmd.subject1)->name <= 0) {
 		return true;
 	}
-	if (_selCmd.action.value() == VERB_GIVE && _selCmd.subject2 > 0 && _logic->objectData(_selCmd.subject2)->name <= 0) {
+	if (_selCmd.action.value() == VERB_GIVE && 
+		_curCmd.subject2 > 0 && _logic->objectData(_curCmd.subject2)->name <= 0) {
 		return true;
 	}
     // check for USE command on exists
-	if (_selCmd.action.value() == VERB_USE && _selCmd.subject1 > 0 && _logic->objectData(_selCmd.subject1)->entryObj > 0) {
+	if (_selCmd.action.value() == VERB_USE && 
+		_curCmd.subject1 > 0 && _logic->objectData(_curCmd.subject1)->entryObj > 0) {
 		_selCmd.action = Verb(VERB_WALK_TO);
 	}
 	if (_selCmd.noun > 0 && _selCmd.noun <= objMax) {
-		int16 p = _logic->joeWalkTo(_selPosX, _selPosY, walk);
-		if (p != 0) {
+		uint16 objNum = _logic->currentRoomData() + _selCmd.noun;
+		if (makeJoeWalkTo(_selPosX, _selPosY, objNum, _selCmd.action, walk) != 0) {
 			return true;
 		}
 		if (_selCmd.action.value() == VERB_WALK_TO && _logic->objectData(roomData + _selCmd.noun)->entryObj < 0) {
@@ -911,7 +942,7 @@
 
 	case VERB_USE:
 		if (subj1 < 0) {
-			k = _logic->itemData(ABS(subj1))->sfxDescription;
+			k = _logic->itemData(-subj1)->sfxDescription;
 			if (k > 0) {
 				_logic->joeSpeak(k, true);
 			}
@@ -933,6 +964,7 @@
 		break;
 
 	case 4: // weird, isn't it ? l.193 execute.c
+		warning("Command::executeStandardStuff() - Use of verb 4");
 	case VERB_MOVE:
 		// 'I can't move it'
 		if (subj1 > 0) {
@@ -1128,10 +1160,10 @@
 		if (cmdList->match(action, otherObj, 0)) {
 			if (cmdList->setConditions) {
 				CmdGameState *cmdGs = _cmdGameState;
-				// FIXME: weird loop...
 				uint16 j;
 				for (j = 1; j <= _numCmdGameState; ++j) {
 					if (cmdGs[j].id == i && cmdGs[i].gameStateSlot > 0) {
+						// FIXME: weird, why using 'i' instead of 'j' ?
 						if (_logic->gameState(cmdGs[i].gameStateSlot) == cmdGs[i].gameStateValue) {
 							com = i;
 							break;
@@ -1278,7 +1310,7 @@
 					// turning off graphic image
 					objData->name = 0;
 					if (objData->room == _logic->currentRoom()) {
-						if (dstObj != _selCmd.subject1) {
+						if (dstObj != _curCmd.subject1) {
 							// if the new object we have updated is on screen and is not the 
 							// current object, then we can update. This is because we turn
 							// current object off ourselves by COM_LIST(com, 8)
@@ -1307,7 +1339,7 @@
 					}
 				}
 
-				if (dstObj != _selCmd.subject1) {
+				if (dstObj != _curCmd.subject1) {
 					// if the new object we have updated is on screen and
 					// is not current object then update it
 					_logic->roomRefreshObject(dstObj);
@@ -1416,9 +1448,9 @@
 void Command::look() {
 
 	if (_selCmd.noun > 0 && _selCmd.noun <= _logic->currentRoomObjMax()) {
-		uint16 k = _logic->currentRoomData();
-		if (_logic->objectData(k + _selCmd.noun)->entryObj == 0) {
-			if (_logic->joeWalkTo(_selPosX, _selPosY, true) == -2) {
+		uint16 objNum = _logic->currentRoomData() + _selCmd.noun;
+		if (_logic->objectData(objNum)->entryObj == 0) {
+			if (makeJoeWalkTo(_selPosX, _selPosY, objNum, _selCmd.action, true) == -2) { // XXX inCutaway parameter
 				// 'I can't get close enough to have a look.'
 				_logic->joeSpeak(13);
 			}
@@ -1426,25 +1458,25 @@
 	}
 
 	// if object type and disabled, don't look
-	if (_selCmd.subject1 > 0 && _logic->objectData(_selCmd.subject1)->name <= 0) {
+	if (_curCmd.subject1 > 0 && _logic->objectData(_curCmd.subject1)->name <= 0) {
 		return;
 	}
 
 	uint16 desc;
-	if (_selCmd.subject1 < 0) {
-		desc = _logic->itemData(ABS(_selCmd.subject1))->description;
+	if (_curCmd.subject1 < 0) {
+		desc = _logic->itemData(-_curCmd.subject1)->description;
 	}
 	else {
-		desc = _logic->objectData(_selCmd.subject1)->description;
+		desc = _logic->objectData(_curCmd.subject1)->description;
 	}
 
-	debug(0, "Command::look() - desc = %X, _selCmd.subject1 = %X", desc, _selCmd.subject1);
+	debug(0, "Command::look() - desc = %X, _curCmd.subject1 = %X", desc, _curCmd.subject1);
 
 	// check to see if the object/item has a series of description
 	ObjectDescription *objDesc = _logic->objectDescription(1);
 	uint16 i;
 	for (i = 1; i <= _logic->objectDescriptionCount(); ++i, ++objDesc) {
-		if (objDesc->object == _selCmd.subject1) {
+		if (objDesc->object == _curCmd.subject1) {
 			desc = nextObjectDescription(objDesc, desc);
 			break;
 		}
@@ -1477,7 +1509,6 @@
 		}
 	}
 }
-
 
 
 void Command::lookCurrentRoom() {

Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.h,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- logic.h	2 Nov 2003 16:47:31 -0000	1.53
+++ logic.h	3 Nov 2003 19:52:13 -0000	1.54
@@ -138,8 +138,8 @@
 
 	uint16 findBob(uint16 obj);
 	uint16 findFrame(uint16 obj);
-	uint16 objectForPerson(uint16 bobnum); // OBJ_PERSON
-	WalkOffData *walkOffPointForObject(uint16 obj);
+	uint16 objectForPerson(uint16 bobnum) const; // OBJ_PERSON
+	WalkOffData *walkOffPointForObject(uint16 obj) const;
 
 	Area *area(int room, int num);
 	Area *currentRoomArea(int num);
@@ -217,9 +217,6 @@
 	//! FACE_JOE()
 	uint16 joeFace();
 
-	//! WALK()
-	int16 joeWalkTo(int16 x, int16 y, bool mustWalk);
-
 	//! GRAB_JOE()
 	void joeGrab(uint16 state, uint16 speed);
 
@@ -234,7 +231,7 @@
 
 	void playCutaway(const char *cutFile, char *next = NULL);
 
-	const char* objectOrItemName(int16 obj) const;
+	const char *objectOrItemName(int16 obj) const;
 
 	Verb findVerbUnderCursor(int16 cursorx, int16 cursory) const;
 	uint16 findObjectUnderCursor(int16 cursorx, int16 cursory) const;

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- logic.cpp	3 Nov 2003 14:47:05 -0000	1.72
+++ logic.cpp	3 Nov 2003 19:52:13 -0000	1.73
@@ -170,57 +170,6 @@
 	*objState = (*objState & ~0xF0) | (val << 4);
 }
 
-/*
-void Command_::readAllCommandsFrom(byte *&ptr) {
-
-	uint16 i;
-
-	// Command List Data
-	_numCmdList = READ_BE_UINT16(ptr); ptr += 2;
-
-	_cmdList = new CmdListData[_numCmdList + 1];
-	memset(&_cmdList[0], 0, sizeof(CmdListData));
-	for (i = 1; i <= _numCmdList; i++) {
-		_cmdList[i].readFrom(ptr);
-	}
-	
-	// Command AREA
-	_numCmdArea = READ_BE_UINT16(ptr); ptr += 2;
-
-	_cmdArea = new CmdArea[_numCmdArea + 1];
-	memset(&_cmdArea[0], 0, sizeof(CmdArea));
-	for (i = 1; i <= _numCmdArea; i++) {
-		_cmdArea[i].readFrom(ptr);
-	}
-	
-	// Command OBJECT
-	_numCmdObject = READ_BE_UINT16(ptr); ptr += 2;
-
-	_cmdObject = new CmdObject[_numCmdObject + 1];
-	memset(&_cmdObject[0], 0, sizeof(CmdObject));
-	for (i = 1; i <= _numCmdObject; i++) {
-		_cmdObject[i].readFrom(ptr);
-	}
-
-	// Command INVENTORY
-	_numCmdInventory = READ_BE_UINT16(ptr);	ptr += 2;
-
-	_cmdInventory = new CmdInventory[_numCmdInventory + 1];
-	memset(&_cmdInventory[0], 0, sizeof(CmdInventory));
-	for (i = 1; i <= _numCmdInventory; i++) {
-		_cmdInventory[i].readFrom(ptr);
-	}
-	
-	// Command GAMESTATE
-	_numCmdGameState = READ_BE_UINT16(ptr);	ptr += 2;
-	_cmdGameState = new CmdGameState[_numCmdGameState + 1];
-	memset(&_cmdGameState[0], 0, sizeof(CmdGameState));
-	for (i = 1; i <= _numCmdGameState; i++) {
-		_cmdGameState[i].readFrom(ptr);
-	}
-}
-*/
-
 
 Common::RandomSource Logic::randomizer;
 
@@ -659,7 +608,7 @@
 }
 
 
-uint16 Logic::objectForPerson(uint16 bobNum) {
+uint16 Logic::objectForPerson(uint16 bobNum) const {
 
 	uint16 bobcur = 0;
 	// first object number in the room
@@ -681,7 +630,7 @@
 }
 
 
-WalkOffData *Logic::walkOffPointForObject(uint16 obj) {
+WalkOffData *Logic::walkOffPointForObject(uint16 obj) const {
 	
 	uint16 i;
 	for (i = 1; i <= _numWalkOffs; ++i) {
@@ -1726,59 +1675,6 @@
 }
 
 
-int16 Logic::joeWalkTo(int16 x, int16 y, bool mustWalk) {
-
-	// Check to see if object is actually an exit to another
-	// room. If so, then set up new room
-
-	uint16 k = _roomData[_currentRoom];
-
-	ObjectData *objData = &_objectData[k + _cmd->selectedNoun()];
-	if (objData->x != 0 || objData->y != 0) {
-		x = objData->x;
-		y = objData->y;
-	}
-
-	if (_cmd->selectedAction().value() == VERB_WALK_TO) {
-		_entryObj = objData->entryObj;
-	}
-	else {
-		_entryObj = 0;
-	}
-
-	_newRoom = 0;
-
-	if (_entryObj != 0 && _cmd->selectedAction().value() != VERB_CLOSE) {
-		_newRoom = _objectData[_entryObj].room;
-		// because this is an exit object, see if there is
-		// a walk off point and set (x,y) accordingly
-		WalkOffData *wod = walkOffPointForObject(k + _cmd->selectedNoun());
-		if (wod != NULL) {
-			x = wod->x;
-			y = wod->y;
-		}
-	}
-
-	// determine which way for Joe to face Object
-	uint16 facing = State::findDirection(objData->state);
-
-	int16 p = 0;
-	if (mustWalk) {
-		BobSlot *bobJoe  = _graphics->bob(0);
-		if (x == bobJoe->x && y == bobJoe->y) {
-			joeFacing(facing);
-			joeFace();
-		}
-		else {
-			// XXX inCutaway parameter
-			p = _walk->joeMove(facing, x, y, false);
-			// if(P != 0) P = FIND_VERB
-		}
-	}
-	return p;
-}
-
-
 void Logic::joeGrab(uint16 state, uint16 speed) {
 
 	StateGrab sg = State::findGrab(state);
@@ -2203,7 +2099,7 @@
 	case 14:
 		playCutaway("c14b.CUT", nextCut);
 		break;
-    case 16:
+	case 16:
 		if (areaNum == 3) {
 			playCutaway("c16a.CUT", nextCut);
 		}
@@ -2216,41 +2112,41 @@
 			playCutaway("c17b.CUT", nextCut);
 		}
 		break;
-    case 22:
+	case 22:
 		playCutaway("c22a.CUT", nextCut);
 		break;
-    case 26:
+	case 26:
 		playCutaway("c26b.CUT", nextCut);
 		break;
-    case 30:
+	case 30:
 		playCutaway("c30a.CUT", nextCut);
 		break;
-    case 32:
+	case 32:
 		playCutaway("c32c.CUT", nextCut);
 		break;
-    case 50:
+	case 50:
 		if (areaNum == 6) {
 			if (_gameState[21] == 0) {
 				playCutaway("c50d.CUT", nextCut);
 				while (nextCut[0] != '\0') {
 					playCutaway(nextCut, nextCut);
 				}
-			    _gameState[21] = 1;
+				_gameState[21] = 1;
 			} else {
 				playCutaway("c50h.CUT", nextCut);
 			}
 		}
 		break;
-    case 53:
+	case 53:
 		playCutaway("c53b.CUT", nextCut);
 		break;
-    case 55:
+	case 55:
 		joeSpeak(19);
 		break;
-    case 71:
+	case 71:
 		joeSpeak(21);
 		break;
-    case 73:
+	case 73:
 		// don't play next Cutaway
 		if (_gameState[VAR_ROOM73_CUTAWAY] == 0) {
 			playCutaway("c73a.CUT"); 
@@ -2266,7 +2162,7 @@
 			playCutaway("c73c.CUT");
 		}
 		break;
-    case 100:
+	case 100:
 		if (areaNum == 7) {
 			joeSpeak(17);
 		}
@@ -2276,7 +2172,7 @@
 			playCutaway("c101b.CUT", nextCut);
 		}
 		break;
-    case 103:
+	case 103:
 		if (areaNum == 3) {
 			if (_gameState[35] == 1) {
 				playCutaway("c103e.CUT", nextCut);

Index: xref.txt
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/xref.txt,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- xref.txt	2 Nov 2003 16:46:37 -0000	1.29
+++ xref.txt	3 Nov 2003 19:52:14 -0000	1.30
@@ -31,10 +31,11 @@
 SELECT_ITEM()				Command::grabSelectedItem
 SELECT_NOUN()				Command::grabSelectedNoun
 SELECT_VERB()				Command::grabSelectedVerb
+WALK()						Command::makeJoeWalkTo
 -
-ACTION						Command::_currentAction
-ACTION2						Command::_selectedAction
-CLEVEL						Command::_commandLevel
+ACTION						Command::_curCmd.action
+ACTION2						Command::_selCmd.action
+CLEVEL						Command::_curCmd.commandLevel
 COM_A						Command::_cmdArea
 COM_A_MAX					Command::_numCmdArea
 COM_O						Command::_cmdObject
@@ -46,13 +47,13 @@
 COM_LIST					Command::_cmdList
 COM_LIST_MAX				Command::_numCmdList
 COMMANDstr					Command::_command
-DEFCOMM						Command::_defaultVerb
+DEFCOMM						Command::_selCmd.defaultVerb
 MKEY						Command::_mouseKey
-OLDVERB,VERB				Command::_*verb*
-OLDNOUN,NOUN				Command::_*noun*
-NOUN2						Command::_selectedNoun
+OLDVERB,VERB				Command::_curCmd.*verb
+OLDNOUN,NOUN				Command::_curCmd.*noun
+NOUN2						Command::_selCmd.noun
 PARSE						Command::_parse
-SUBJ1,SUBJ2,SUBJECT			Command::_subject*
+SUBJ1,SUBJ2,SUBJECT			Command::_selCmd.subject*
 
 
 CREDIT SCRIPTING SYSTEM
@@ -187,7 +188,6 @@
 USE_UNDERWEAR()				Logic::joeUseUnderwear
 USE_CLOTHES()				Logic::joeUseClothes
 USE_DRESS()					Logic::joeUseDress
-WALK()						Logic::joeWalkTo
 -
 JOE_RESPstr 				Logic::_joeResponse
 JOEF,JX,JY,JDIR				Logic::_joe.*





More information about the Scummvm-git-logs mailing list