[Scummvm-cvs-logs] CVS: scummvm/queen input.cpp,1.12,1.13 input.h,1.8,1.9 logic.cpp,1.98,1.99 structs.h,1.22,1.23 talk.cpp,1.44,1.45 talk.h,1.20,1.21

David Eriksson twogood at users.sourceforge.net
Sat Nov 15 13:17:12 CET 2003


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

Modified Files:
	input.cpp input.h logic.cpp structs.h talk.cpp talk.h 
Log Message:
- Talk clean-up
- Make it possible to quit a dialogue


Index: input.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/input.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- input.cpp	9 Nov 2003 21:31:18 -0000	1.12
+++ input.cpp	15 Nov 2003 21:16:00 -0000	1.13
@@ -168,8 +168,8 @@
 					_cutawayQuit = true;
 				}
 
-				// XXX if (_joeWalk == 3)	// Dialogue
-				// XXX 	_talkQuit = true;
+				if (_dialogueRunning)
+					_talkQuit = true;
 			}
 			break;
 

Index: input.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/input.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- input.h	9 Nov 2003 21:31:18 -0000	1.8
+++ input.h	15 Nov 2003 21:16:01 -0000	1.9
@@ -69,6 +69,8 @@
 		bool cutawayQuit() const  { return _cutawayQuit; }
 		void cutawayQuitReset()   { _cutawayQuit = false; }
 
+		void dialogueRunning(bool running) { _dialogueRunning = running; }
+
 		bool talkQuit() const { return _talkQuit; }
 		void talkQuitReset()  { _talkQuit = false; }
 
@@ -134,6 +136,9 @@
 
 		//! moved Cutaway::_quit here
 		bool _cutawayQuit;          // cutawayQuit
+
+		//! set if a dialogue is running
+		bool _dialogueRunning;
 
 		//! moved Talk::_quit here 
 		bool _talkQuit;         // TALKQUIT

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.cpp,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -d -r1.98 -r1.99
--- logic.cpp	15 Nov 2003 15:44:50 -0000	1.98
+++ logic.cpp	15 Nov 2003 21:16:01 -0000	1.99
@@ -665,6 +665,9 @@
 
 void Logic::joeWalk(JoeWalkMode walking) {
 	_joe.walk = walking;
+
+	// Do this so that Input doesn't need to know the walk value
+	_input->dialogueRunning(JWM_SPEAK == walking);
 }
 
 void Logic::joeScale(uint16 scale) {

Index: structs.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/structs.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- structs.h	9 Nov 2003 21:31:18 -0000	1.22
+++ structs.h	15 Nov 2003 21:16:01 -0000	1.23
@@ -550,18 +550,18 @@
 
 
 struct TalkSelected {
-	int16 hasTalkedTo;
+	bool hasTalkedTo;
 	int16 values[4];
 
 	void readFrom(byte *&ptr) {
-		hasTalkedTo = (int16)READ_BE_UINT16(ptr); ptr += 2;
+		hasTalkedTo = (bool)READ_BE_UINT16(ptr); ptr += 2;
 		for (int i = 0; i < 4; i++) {
 			values[i] = (int16)READ_BE_UINT16(ptr); ptr += 2;
 		}	
 	}
 
 	void writeTo(byte *&ptr) {
-		WRITE_BE_UINT16(ptr, hasTalkedTo); ptr += 2;
+		WRITE_BE_UINT16(ptr, (uint16)hasTalkedTo); ptr += 2;
 		for (int i = 0; i < 4; i++) {
 			WRITE_BE_UINT16(ptr, values[i]); ptr += 2;
 		}

Index: talk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.cpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- talk.cpp	15 Nov 2003 20:04:59 -0000	1.44
+++ talk.cpp	15 Nov 2003 21:16:01 -0000	1.45
@@ -132,11 +132,11 @@
 
 	// Lines 828-846 in talk.c
 	for (i = 1; i <= 4; i++) {
-		if (talkSelected()->values[i-1] > 0) {
+		if (selectedValue(i) > 0) {
 			// This option has been redefined so display new dialogue option
-			_dialogueTree[1][i].head = talkSelected()->values[i-1];
+			_dialogueTree[1][i].head = selectedValue(i);
 		}
-		else if (talkSelected()->values[i-1] == -1) {
+		else if (selectedValue(i) == -1) {
 
 			// Already selected so don't redisplay
 			if (_dialogueTree[1][i].gameStateIndex >= 0) {
@@ -164,12 +164,12 @@
 
 		_talkString[0][0] = '\0';
 
-		if(talkSelected()->hasTalkedTo == 1 && head == 1)
+		if (hasTalkedTo() && head == 1)
 			strcpy(_talkString[0], _person2String);
 		else
 			findDialogueString(_person1Ptr, head, _talkString[0]);
 
-		if(talkSelected()->hasTalkedTo == 1 && head == 1)
+		if (hasTalkedTo() && head == 1)
 			sprintf(otherVoiceFilePrefix, "%2dXXXXP", _talkKey);
 		else
 			sprintf(otherVoiceFilePrefix, "%2d%4xP", _talkKey, head);
@@ -261,8 +261,8 @@
 			if (_dialogueTree[level][0].dialogueNodeValue1 > 0) {
 				if (1 == oldLevel) {
 						_oldSelectedSentenceIndex = selectedSentence;
-						_oldSelectedSentenceValue = talkSelected()->values[selectedSentence-1];
-						talkSelected()->values[selectedSentence-1] = _dialogueTree[level][0].dialogueNodeValue1;
+						_oldSelectedSentenceValue = selectedValue(selectedSentence);
+						selectedValue(selectedSentence, _dialogueTree[level][0].dialogueNodeValue1);
 				}
 
 				_dialogueTree[oldLevel][selectedSentence].head = _dialogueTree[level][0].dialogueNodeValue1;
@@ -333,16 +333,18 @@
 	}
 
 	if (_input->talkQuit()) {
-		// TODO: missing some code here!
+		if (_oldSelectedSentenceIndex > 0)
+			selectedValue(_oldSelectedSentenceIndex, _oldSelectedSentenceValue);
+		_input->talkQuitReset();
+		_graphics->textClear(0, 198);
+		speak(_talkString[15], NULL, "JOE0015");
 	}
 	else {
-		talkSelected()->hasTalkedTo = 1;
+		setHasTalkedTo();
 	}
 
 	_logic->joeFace();
 
-	// TODO: missing some code here!
-
 	if (cutawayFilename[0] == '\0') {
 		BobSlot *pbs = _graphics->bob(person.actor->bobNum);
 
@@ -365,8 +367,8 @@
 		if (_dialogueTree[oldLevel][selectedSentence].dialogueNodeValue1 != -1) {
 			// Make sure choice is not exit option
 			_oldSelectedSentenceIndex = selectedSentence;
-			_oldSelectedSentenceValue = talkSelected()->values[selectedSentence-1];
-			talkSelected()->values[selectedSentence-1] = -1;
+			_oldSelectedSentenceValue = selectedValue(selectedSentence);
+			selectedValue(selectedSentence, -1);
 		}
 	}
 
@@ -486,7 +488,7 @@
 	ptr = getString(ptr, joe2String, MAX_STRING_LENGTH);
 	//debug(0, "joe2String = '%s'", joe2String);
 
-	if (talkSelected()->hasTalkedTo == 0) {
+	if (!hasTalkedTo()) {
 		
 		// Not yet talked to this person
 		

Index: talk.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- talk.h	9 Nov 2003 14:16:46 -0000	1.20
+++ talk.h	15 Nov 2003 21:16:01 -0000	1.21
@@ -180,6 +180,22 @@
 	//! Get TalkSelected struct for this talk
 	TalkSelected *talkSelected();
 
+	//! Interface to the TalkSelected struct
+	bool hasTalkedTo() { return talkSelected()->hasTalkedTo; }
+
+	//! Interface to the TalkSelected struct
+	void setHasTalkedTo() { talkSelected()->hasTalkedTo = true; }
+
+	//! Get a selected value
+	int16 selectedValue(int index) { 
+		return talkSelected()->values[index-1];
+	}
+
+	//! Set a selected value
+	void selectedValue(int index, int16 value) { 
+		talkSelected()->values[index-1] = value;
+	}
+
 	//! The sentence will not be displayed again
 	void disableSentence(int oldLevel, int selectedSentence);
 





More information about the Scummvm-git-logs mailing list