[Scummvm-cvs-logs] CVS: scummvm/queen command.cpp,1.40,1.41 command.h,1.12,1.13 logic.cpp,1.133,1.134 logic.h,1.89,1.90 queen.cpp,1.54,1.55 structs.h,1.27,1.28 xref.txt,1.47,1.48

Gregory Montoir cyx at users.sourceforge.net
Sun Dec 14 02:52:03 CET 2003


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

Modified Files:
	command.cpp command.h logic.cpp logic.h queen.cpp structs.h 
	xref.txt 
Log Message:
some refactoring in Command code (removed/commented unused code, renamed some methods)

Index: command.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/command.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- command.cpp	12 Dec 2003 20:26:20 -0000	1.40
+++ command.cpp	13 Dec 2003 20:05:28 -0000	1.41
@@ -100,31 +100,14 @@
 }
 
 
-void CurrentCmdState::init() {
+void CmdState::init() {
 
 	commandLevel = 1;
 	oldVerb = verb = action = VERB_NONE;
-	oldNoun = noun = subject1 = subject2 = 0;
-}
-
[...1168 lines suppressed...]
+				}
+			}
 		}
-
-		_curCmd.oldVerb = _curCmd.verb;
-		if (_curCmd.verb == VERB_NONE) {
-			_cmdText.display(INK_CMD_NORMAL);
+		else if (isVerbAction(_state.verb)) {
+			_cmdText.displayTemp(INK_CMD_NORMAL, false, _state.verb);
 		}
-		else if (isVerbPanel(_curCmd.verb) || _curCmd.verb == VERB_WALK_TO) {
-			_cmdText.displayTemp(INK_CMD_NORMAL, false, _curCmd.verb);
+		else if (_state.verb == VERB_NONE) {
+			_cmdText.display(INK_CMD_NORMAL);
 		}
+
+		_state.oldVerb = _state.verb;
 	}
 }
 

Index: command.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/command.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- command.h	12 Dec 2003 10:33:34 -0000	1.12
+++ command.h	13 Dec 2003 20:05:28 -0000	1.13
@@ -51,31 +51,22 @@
 };
 
 
-struct CurrentCmdState {
+struct CmdState {
 
 	void init();
-	void addObject(int16 objNum);
 
-	Verb oldVerb;
-	Verb verb;
+	Verb oldVerb, verb;
 	Verb action;
-	int16 oldNoun;
-	int16 noun;
+	int16 oldNoun, noun;
 	int commandLevel;
-	int16 subject1;
-	int16 subject2;
-};
-
-
-struct SelectedCmdState {
+	int16 subject[2];
 
-	void init();
-	
 	Verb defaultVerb;
-	Verb action;
-	int16 noun;
+	Verb selAction;
+	int16 selNoun;
 };
 
+
 class Command {
 public:
 	
@@ -85,7 +76,7 @@
 	void clear(bool clearTexts);
 
 	//! execute last constructed command
-	void executeCurrentAction(bool walk);
+	void executeCurrentAction();
 
 	//! get player input and construct command from it
 	void updatePlayer();
@@ -93,8 +84,6 @@
 	//! read all command arrays from stream
 	void readCommandsFrom(byte *&ptr);
 
-	//! return true if command is ready to be executed
-	bool parse() const { return _parse; }
 
 	enum {
 		MAX_MATCHING_CMDS = 50
@@ -103,6 +92,9 @@
 
 private:
 
+	ObjectData *findObjectData(uint16 objRoomNum) const;
+	ItemData *findItemData(Verb invNum) const;
+
 	int16 executeCommand(uint16 comId, int16 condResult);
 
 	int16 makeJoeWalkTo(int16 x, int16 y, int16 objNum, Verb v, bool mustWalk);
@@ -116,16 +108,10 @@
 	bool executeIfCutaway(const char *description);
 	bool executeIfDialog(const char *description);
 	
-	bool handleDefaultCommand(bool walk);
-	void executeStandardStuff(Verb action, int16 subj1, int16 subj2);
+	bool handleWrongAction();
+	void sayInvalidAction(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(Verb def, bool itemType);
 	
 	//! OPEN_CLOSE_OTHER(OBJECT_DATA[S][4])
 	void openOrCloseAssociatedObject(Verb action, int16 obj);
@@ -145,15 +131,17 @@
 	//! update description for object and returns description number to use
 	uint16 nextObjectDescription(ObjectDescription *objDesc, uint16 firstDesc);
 
-	//! look at current object / item and speak its description
-	void look();
-	void lookCurrentItem();
-	void lookCurrentRoom();
-	void lookCurrentIcon();
+	//! speak description of selected object
+	void lookAtSelectedObject();
 
-	bool isVerbPanel(Verb v) const { return v >= VERB_PANEL_COMMAND_FIRST && v <= VERB_PANEL_COMMAND_LAST; };
+	//! get the current objects under the cursor
+	void lookForCurrentObject();
+
+	//! get the current icon panel under the cursor (inventory item or verb)
+	void lookForCurrentIcon();
+
+	bool isVerbAction(Verb v) const { return (v >= VERB_PANEL_COMMAND_FIRST && v <= VERB_PANEL_COMMAND_LAST) || (v == VERB_WALK_TO); };
 	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;
@@ -176,9 +164,8 @@
 	//! flag indicating that the current command is fully constructed
 	bool _parse;
 
-	CurrentCmdState _curCmd;
-
-	SelectedCmdState _selCmd;
+	//! state of current constructed command
+	CmdState _state;
 
 	//! last user selection
 	int _mouseKey, _selPosX, _selPosY;

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.cpp,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -d -r1.133 -r1.134
--- logic.cpp	12 Dec 2003 20:26:20 -0000	1.133
+++ logic.cpp	13 Dec 2003 20:05:28 -0000	1.134
@@ -968,7 +968,7 @@
 
 	// check the object is in the current room
 	if (pod->room != _currentRoom) {
-		debug(0, "Trying to display an object (%i=%s) that is not in room (object room=%i, current room=%i)", obj, _objName[ABS(pod->name)], pod->room, _currentRoom);
+		debug(0, "Refreshing an object (%i=%s) not in current room (object room=%i, current room=%i)", obj, _objName[ABS(pod->name)], pod->room, _currentRoom);
 		return curImage;
 	}
 
@@ -1770,6 +1770,7 @@
 
 
 Verb Logic::findVerbUnderCursor(int16 cursorx, int16 cursory) const {
+
 	static const Verb pv[] = {
 		VERB_NONE,
 		VERB_OPEN,
@@ -1802,27 +1803,21 @@
 }
 
 
-uint16 Logic::findObjectRoomNumber(uint16 zoneNum) const {
+uint16 Logic::findObjectNumber(uint16 zoneNum) const {
 
 	// l.316-327 select.c
-	uint16 noun = zoneNum;
-	uint16 objectMax = _objMax[_currentRoom];
-	debug(0, "Logic::findObjectRoomNumber(%X, %X)", zoneNum, objectMax);
+	uint16 obj = zoneNum;
+	uint16 objectMax = currentRoomObjMax();
+	debug(9, "Logic::findObjectNumber(%X, %X)", zoneNum, objectMax);
 	if (zoneNum > objectMax) {
 		// this is an area box, check for associated object
-		uint16 obj = currentRoomArea(zoneNum - objectMax)->object;
-		if (obj != 0 && objectData(obj)->name != 0) {
+		obj = currentRoomArea(zoneNum - objectMax)->object;
+		if (obj != 0) {
 			// there is an object, get its number
-			noun = obj - _roomData[_currentRoom];
+			obj -= currentRoomData();
 		}
 	}
-	return noun;
-}
-
-
-uint16 Logic::findObjectGlobalNumber(uint16 zoneNum) const {
-
-	return _roomData[_currentRoom] + findObjectRoomNumber(zoneNum);
+	return obj;
 }
 
 
@@ -2015,8 +2010,11 @@
 
 
 void Logic::checkPlayer() {
+
 	update();
-	_vm->command()->updatePlayer();
+	if (!_vm->input()->cutawayRunning()) {
+		_vm->command()->updatePlayer();
+	}
 }
 
 

Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.h,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- logic.h	12 Dec 2003 20:26:20 -0000	1.89
+++ logic.h	13 Dec 2003 20:05:28 -0000	1.90
@@ -198,8 +198,7 @@
 
 	Verb findVerbUnderCursor(int16 cursorx, int16 cursory) const;
 	uint16 findObjectUnderCursor(int16 cursorx, int16 cursory) const;
-	uint16 findObjectRoomNumber(uint16 zoneNum) const;
-	uint16 findObjectGlobalNumber(uint16 zoneNum) const;
+	uint16 findObjectNumber(uint16 zoneNum) const;
 
 	void inventorySetup();
 	uint16 findInventoryItem(int invSlot) const;

Index: queen.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/queen.cpp,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- queen.cpp	13 Dec 2003 00:20:00 -0000	1.54
+++ queen.cpp	13 Dec 2003 20:05:28 -0000	1.55
@@ -142,12 +142,12 @@
 		else {
 			if (_logic->joeWalk() == JWM_EXECUTE) {
 				_logic->joeWalk(JWM_NORMAL);
-				_command->executeCurrentAction(true);
+				_command->executeCurrentAction();
 			}
 			else {
-				if (_command->parse()) {
-					_command->clear(true);
-				}
+//				if (_command->parse()) {
+//					_command->clear(true);
+//				}
 				_logic->joeWalk(JWM_NORMAL);
 				_logic->checkPlayer();
 			}

Index: structs.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/structs.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- structs.h	12 Dec 2003 10:33:34 -0000	1.27
+++ structs.h	13 Dec 2003 20:05:28 -0000	1.28
@@ -382,32 +382,7 @@
 	bool setConditions;
 	//! graphic image order
 	int16 imageOrder;
-	//! special section to execute
-	/*!
-		refer to execute.c l.423-451
-		<table>
-			<tr>
-				<td>value</td>
-				<td>description</td>
-			</tr>
-			<tr>
-				<td>1</td>
-				<td>use journal</td>
-			</tr>
-			<tr>
-				<td>2</td>
-				<td>use dress</td>
-			</tr>
-			<tr>
-				<td>3</td>
-				<td>use normal clothes</td>
-			</tr>
-			<tr>
-				<td>4</td>
-				<td>use underwear</td>
-			</tr>
-		</table>
-	*/
+	//! special section to execute (refer to execute.c l.423-451)
 	int16 specialSection;
 
 	void readFrom(byte *&ptr) {

Index: xref.txt
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/xref.txt,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- xref.txt	11 Dec 2003 13:26:13 -0000	1.47
+++ xref.txt	13 Dec 2003 20:05:28 -0000	1.48
@@ -14,14 +14,13 @@
 
 COMMAND
 =======
-ALTER_DEFAULT()				Command::alterDefault
+ALTER_DEFAULT()				*not needed* (use State::alterDefaultVerb)
 CLEAR_COMMAND()				Command::clear
 EXECUTE_ACTION()			Command::executeCurrentAction
-FIND_DEFAULT()				Command::findDefault
-LOOK()						Command::look
-LOOK_ICON()					Command::lookCurrentIcon
-LOOK_ITEM()					Command::lookCurrentItem
-LOOK_ROOM()					Command::lookCurrentRoom
+FIND_DEFAULT()				*not needed* (use State::findDefaultVerb)
+LOOK()						Command::lookAtSelectedObject
+LOOK_ICON(),LOOK_ITEM()		Command::lookForCurrentIcon
+LOOK_ROOM()					Command::lookForCurrentObject
 OPEN_CLOSE_OTHER()			Command::openOrCloseAssociatedObject
 P1_SET_CONDITIONS()			Command::setConditions
 P2_SET_AREAS()				Command::setAreas
@@ -33,9 +32,9 @@
 SELECT_VERB()				Command::grabSelectedVerb
 WALK()						Command::makeJoeWalkTo
 -
-ACTION						Command::_curCmd.action
-ACTION2						Command::_selCmd.action
-CLEVEL						Command::_curCmd.commandLevel
+ACTION						Command::_state.action
+ACTION2						Command::_state.selAction
+CLEVEL						Command::_state.commandLevel
 COM_A						Command::_cmdArea
 COM_A_MAX					Command::_numCmdArea
 COM_O						Command::_cmdObject
@@ -47,13 +46,13 @@
 COM_LIST					Command::_cmdList
 COM_LIST_MAX				Command::_numCmdList
 COMMANDstr					Command::_command
-DEFCOMM						Command::_selCmd.defaultVerb
+DEFCOMM						Command::_state.defaultVerb
 MKEY						Command::_mouseKey
-OLDVERB,VERB				Command::_curCmd.*verb
-OLDNOUN,NOUN				Command::_curCmd.*noun
-NOUN2						Command::_selCmd.noun
+OLDVERB,VERB				Command::_state.*verb
+OLDNOUN,NOUN				Command::_state.*noun
+NOUN2						Command::_state.selNoun
 PARSE						Command::_parse
-SUBJ1,SUBJ2,SUBJECT			Command::_selCmd.subject*
+SUBJ1,SUBJ2					Command::_state.subject*
 
 
 CREDIT SCRIPTING SYSTEM
@@ -497,4 +496,4 @@
 TEMPstr
 WORDstr 
 JOE2str,PERSON2str // locals in Talk::initialTalk
-
+SUBJECT





More information about the Scummvm-git-logs mailing list