[Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.236,1.237 script_v2.cpp,2.241,2.242 script_v5.cpp,1.229,1.230 script_v6.cpp,1.317,1.318 script_v6he.cpp,2.38,2.39 script_v8.cpp,2.237,2.238 scumm.h,1.378,1.379 string.cpp,1.200,1.201 verbs.cpp,1.93,1.94

Max Horn fingolfin at users.sourceforge.net
Sun Mar 14 19:19:06 CET 2004


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26909

Modified Files:
	actor.cpp script_v2.cpp script_v5.cpp script_v6.cpp 
	script_v6he.cpp script_v8.cpp scumm.h string.cpp verbs.cpp 
Log Message:
refactor use of _messagePtr -> instead of using it as an implicit parameter for various methods, pass its value explicitly to those methods. Note: this *should* be just a code transformation, with no change to the program logic - unless I messed up once again <sigh>

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.236
retrieving revision 1.237
diff -u -d -r1.236 -r1.237
--- actor.cpp	15 Mar 2004 02:21:04 -0000	1.236
+++ actor.cpp	15 Mar 2004 03:09:47 -0000	1.237
@@ -1144,10 +1144,10 @@
 	return 0;
 }
 
-void ScummEngine::actorTalk() {
+void ScummEngine::actorTalk(const byte *msg) {
 	Actor *a;
 
-	_messagePtr = addMessageToStack(_messagePtr, _charsetBuffer, sizeof(_charsetBuffer));
+	_messagePtr = addMessageToStack(msg, _charsetBuffer, sizeof(_charsetBuffer));
 
 	// FIXME: Workaround for bugs #770039 and #770049 
 	if (_gameId == GID_LOOM || _gameId == GID_LOOM256) {

Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 2.241
retrieving revision 2.242
diff -u -d -r2.241 -r2.242
--- script_v2.cpp	13 Mar 2004 12:55:40 -0000	2.241
+++ script_v2.cpp	15 Mar 2004 03:09:48 -0000	2.242
@@ -428,8 +428,7 @@
 			_string[textSlot].color = v1_mm_actor_speech_color[_actorToPrintStrFor];
 	}
 
-	_messagePtr = buffer;
-	actorTalk();
+	actorTalk(buffer);
 }
 
 int ScummEngine_v2::readVar(uint var) {
@@ -1055,15 +1054,13 @@
 		ptr++;
 	}
 
-	_messagePtr = (byte*)sentence;
-
 	sentenceline.top = virtscr[2].topline;
 	sentenceline.bottom = virtscr[2].topline + 8;
 	sentenceline.left = 0;
 	sentenceline.right = 319;
 	restoreBG(sentenceline);
 
-	drawString(2);
+	drawString(2, (byte*)sentence);
 }
 
 void ScummEngine_v2::o2_ifClassOfIs() {

Index: script_v5.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v5.cpp,v
retrieving revision 1.229
retrieving revision 1.230
diff -u -d -r1.229 -r1.230
--- script_v5.cpp	26 Feb 2004 07:31:48 -0000	1.229
+++ script_v5.cpp	15 Mar 2004 03:09:48 -0000	1.230
@@ -2702,6 +2702,7 @@
 
 void ScummEngine_v5::decodeParseString() {
 	int textSlot;
+	const byte *msg;
 
 	switch (_actorToPrintStrFor) {
 	case 252:
@@ -2784,19 +2785,21 @@
 			}
 			break;
 		case 15:	// SO_TEXTSTRING
-			_messagePtr = _scriptPointer;
+			msg = _scriptPointer;
+			_scriptPointer += resStrLen(_scriptPointer)+ 1;
+
 			switch (textSlot) {
 			case 0:
-				actorTalk();
+				actorTalk(msg);
 				break;
 			case 1:
-				drawString(1);
+				drawString(1, msg);
 				break;
 			case 2:
-				unkMessage1();
+				unkMessage1(msg);
 				break;
 			case 3:
-				unkMessage2();
+				unkMessage2(msg);
 				break;
 			}
 
@@ -2812,8 +2815,6 @@
 				_string[textSlot].t_ypos = _string[textSlot].ypos;
  				_string[textSlot].t_color = _string[textSlot].color;
 			}
-
-			_scriptPointer = _messagePtr;
 			return;
 		default:
 			warning("ScummEngine_v5::decodeParseString: Unhandled case %d", _opcode & 0xF);

Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.317
retrieving revision 1.318
diff -u -d -r1.317 -r1.318
--- script_v6.cpp	15 Mar 2004 02:21:04 -0000	1.317
+++ script_v6.cpp	15 Mar 2004 03:09:48 -0000	1.318
@@ -2319,11 +2319,11 @@
 void ScummEngine_v6::o6_talkActor() {
 	_actorToPrintStrFor = pop();
 
-	_messagePtr = translateTextAndPlaySpeech(_scriptPointer);
+	const byte *msg = translateTextAndPlaySpeech(_scriptPointer);
 	_scriptPointer += resStrLen(_scriptPointer) + 1;
 
 	setStringVars(0);
-	actorTalk();
+	actorTalk(msg);
 }
 
 void ScummEngine_v6::o6_talkEgo() {
@@ -2507,9 +2507,8 @@
 		case 17:{
 			const byte *message;
 			byte buf_input[300], buf_output[300];
-			_messagePtr = getStringAddressVar(VAR_STRING2DRAW);
 			message = buf_input;
-			addMessageToStack(_messagePtr, buf_input, sizeof(buf_input));
+			addMessageToStack(getStringAddressVar(VAR_STRING2DRAW), buf_input, sizeof(buf_input));
 			if ((_gameId == GID_DIG) && !(_features & GF_DEMO)) {
 				byte buf_trans[300];
 				char *t_ptr = (char *)buf_input;
@@ -3115,6 +3114,7 @@
 
 void ScummEngine_v6::decodeParseString(int m, int n) {
 	byte b;
+	const byte *msg;
 
 	b = fetchScriptByte();
 
@@ -3149,29 +3149,30 @@
 		_string[m].no_talk_anim = true;
 		break;
 	case 75:		// SO_TEXTSTRING
-		_messagePtr = translateTextAndPlaySpeech(_scriptPointer);
-		_scriptPointer += resStrLen(_scriptPointer)+ 1;
+		msg = translateTextAndPlaySpeech(_scriptPointer);
+		_scriptPointer += resStrLen(_scriptPointer) + 1;
 
 		switch (m) {
 		case 0:
-			actorTalk();
+			actorTalk(msg);
 			break;
 		case 1:
-			drawString(1);
+			drawString(1, msg);
 			break;
 		case 2:
-			unkMessage1();
+			unkMessage1(msg);
 			break;
 		case 3:
-			unkMessage2();
+			unkMessage2(msg);
 			break;
 		}
-		return;
+
+		break;
 	case 0xFE:
 		setStringVars(m);
 		if (n)
 			_actorToPrintStrFor = pop();
-		return;
+		break;
 	case 0xFF:
 		_string[m].t_xpos = _string[m].xpos;
 		_string[m].t_ypos = _string[m].ypos;
@@ -3181,7 +3182,7 @@
 		_string[m].t_right = _string[m].right;
 		_string[m].t_color = _string[m].color;
 		_string[m].t_charset = _string[m].charset;
-		return;
+		break;
 	default:
 		error("decodeParseString: default case 0x%x", b);
 	}

Index: script_v6he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6he.cpp,v
retrieving revision 2.38
retrieving revision 2.39
diff -u -d -r2.38 -r2.39
--- script_v6he.cpp	15 Mar 2004 02:21:04 -0000	2.38
+++ script_v6he.cpp	15 Mar 2004 03:09:48 -0000	2.39
@@ -955,8 +955,7 @@
 	int mode, len, slot, l, r;
 	byte filename[100];
 
-	_messagePtr = _scriptPointer;
-	addMessageToStack(_messagePtr, filename, sizeof(filename));
+	addMessageToStack(_scriptPointer, filename, sizeof(filename));
 
 	len = resStrLen(_scriptPointer);
 	_scriptPointer += len + 1;
@@ -1002,8 +1001,7 @@
 	int len, r;
 	byte filename[100];
 
-	_messagePtr = _scriptPointer;
-	addMessageToStack(_messagePtr, filename, sizeof(filename));
+	addMessageToStack(_scriptPointer, filename, sizeof(filename));
 
 	len = resStrLen(_scriptPointer);
 	_scriptPointer += len + 1;
@@ -1020,8 +1018,7 @@
 	int len, r1, r2;
 	byte filename[100],filename2[100];
 
-	_messagePtr = _scriptPointer;
-	addMessageToStack(_messagePtr, filename, sizeof(filename));
+	addMessageToStack(_scriptPointer, filename, sizeof(filename));
 
 	len = resStrLen(_scriptPointer);
 	_scriptPointer += len + 1;
@@ -1031,8 +1028,7 @@
 			break;
 	}
 
-	_messagePtr = _scriptPointer;
-	addMessageToStack(_messagePtr, filename2, sizeof(filename2));
+	addMessageToStack(_scriptPointer, filename2, sizeof(filename2));
 
 	len = resStrLen(_scriptPointer);
 	_scriptPointer += len + 1;
@@ -1340,22 +1336,19 @@
 
 		switch (b) {
 		case 1:
-			_messagePtr = _scriptPointer;
-			addMessageToStack(_messagePtr, filename1, sizeof(filename1));
+			addMessageToStack(_scriptPointer, filename1, sizeof(filename1));
 
 			len = resStrLen(_scriptPointer);
 			_scriptPointer += len + 1;
-			debug(1, "o6_unknownF4(%d, %d, \"%s\")", a, b, _messagePtr);
+			debug(1, "o6_unknownF4(%d, %d, \"%s\")", a, b, filename1);
 			break;
 		case 2:
-			_messagePtr = _scriptPointer;
-			addMessageToStack(_messagePtr, filename1, sizeof(filename1));
+			addMessageToStack(_scriptPointer, filename1, sizeof(filename1));
 
 			len = resStrLen(_scriptPointer);
 			_scriptPointer += len + 1;
 
-			_messagePtr = _scriptPointer;
-			addMessageToStack(_messagePtr, filename2, sizeof(filename2));
+			addMessageToStack(_scriptPointer, filename2, sizeof(filename2));
 
 			len = resStrLen(_scriptPointer);
 			_scriptPointer += len + 1;
@@ -1371,8 +1364,7 @@
 	int len, r;
 	byte filename[100];
 
-	_messagePtr = _scriptPointer;
-	addMessageToStack(_messagePtr, filename, sizeof(filename));
+	addMessageToStack(_scriptPointer, filename, sizeof(filename));
 
 	len = resStrLen(_scriptPointer);
 	_scriptPointer += len + 1;
@@ -1413,6 +1405,7 @@
 void ScummEngine_v6he::decodeParseString(int m, int n) {
 	byte b;
 	int c;
+	const byte *msg;
 
 	b = fetchScriptByte();
 
@@ -1447,24 +1440,25 @@
 		_string[m].no_talk_anim = true;
 		break;
 	case 75:		// SO_TEXTSTRING
-		_messagePtr = translateTextAndPlaySpeech(_scriptPointer);
-		_scriptPointer += resStrLen(_scriptPointer)+ 1;
+		msg = translateTextAndPlaySpeech(_scriptPointer);
+		_scriptPointer += resStrLen(_scriptPointer) + 1;
 
 		switch (m) {
 		case 0:
-			actorTalk();
+			actorTalk(msg);
 			break;
 		case 1:
-			drawString(1);
+			drawString(1, msg);
 			break;
 		case 2:
-			unkMessage1();
+			unkMessage1(msg);
 			break;
 		case 3:
-			unkMessage2();
+			unkMessage2(msg);
 			break;
 		}
-		return;
+
+		break;
 	case 0xF9:
 		c = pop();
 		if (c == 1) {
@@ -1475,12 +1469,12 @@
 			getStackList(args, ARRAYSIZE(args));
 		}
 		warning("decodeParseString case 0xF9 stub");
-		return;
+		break;
 	case 0xFE:
 		setStringVars(m);
 		if (n)
 			_actorToPrintStrFor = pop();
-		return;
+		break;
 	case 0xFF:
 		_string[m].t_xpos = _string[m].xpos;
 		_string[m].t_ypos = _string[m].ypos;
@@ -1490,7 +1484,7 @@
 		_string[m].t_right = _string[m].right;
 		_string[m].t_color = _string[m].color;
 		_string[m].t_charset = _string[m].charset;
-		return;
+		break;
 	default:
 		error("decodeParseString: default case 0x%x", b);
 	}

Index: script_v8.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v8.cpp,v
retrieving revision 2.237
retrieving revision 2.238
diff -u -d -r2.237 -r2.238
--- script_v8.cpp	15 Mar 2004 02:21:04 -0000	2.237
+++ script_v8.cpp	15 Mar 2004 03:09:48 -0000	2.238
@@ -467,6 +467,7 @@
 
 void ScummEngine_v8::decodeParseString(int m, int n) {
 	byte b;
+	const byte *msg;
 
 	b = fetchScriptByte();
 
@@ -513,29 +514,30 @@
 		_string[m].no_talk_anim = true;
 		break;
 	case 0xD1:		// SO_PRINT_STRING
-		_messagePtr = translateTextAndPlaySpeech(_scriptPointer);
-		_scriptPointer += resStrLen(_scriptPointer)+ 1;
+		msg = translateTextAndPlaySpeech(_scriptPointer);
+		_scriptPointer += resStrLen(_scriptPointer) + 1;
 
 		switch (m) {
 		case 0:
-			actorTalk();
+			actorTalk(msg);
 			break;
 		case 1:
-			drawString(1);
+			drawString(1, msg);
 			break;
 		case 2:
-			unkMessage1();
+			unkMessage1(msg);
 			break;
 		case 3:
-			unkMessage2();
+			unkMessage2(msg);
 			break;
 		case 5:{
 			byte buffer[256];
-			addMessageToStack(_messagePtr, buffer, sizeof(buffer));
+			addMessageToStack(msg, buffer, sizeof(buffer));
 			enqueueText(buffer, _string[m].xpos, _string[m].ypos, _string[m].color, _string[m].charset, _string[m].center);
 			}
 			break;
 		}
+
 		break;
 	case 0xD2:		// SO_PRINT_WRAP Set print wordwrap
 		//warning("decodeParseString: SO_PRINT_WRAP");

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.378
retrieving revision 1.379
diff -u -d -r1.378 -r1.379
--- scumm.h	15 Mar 2004 02:21:04 -0000	1.378
+++ scumm.h	15 Mar 2004 03:09:48 -0000	1.379
@@ -775,7 +775,7 @@
 	SentenceTab _sentence[NUM_SENTENCE];
 	StringTab _string[6];
 	int16 _talkDelay;
-	void actorTalk();
+	void actorTalk(const byte *msg);
 	void stopTalk();
 	int talkingActor();		// Wrapper around VAR_TALK_ACTOR for V1 Maniac
 	void talkingActor(int variable);
@@ -1063,14 +1063,14 @@
 	void initCharset(int charset);
 
 	void CHARSET_1();
-	void drawString(int a);
+	void drawString(int a, const byte *msg);
 	const byte *addMessageToStack(const byte *msg, byte *dstBuffer, int dstBufferSize);
 	void addIntToStack(int var);
 	void addVerbToStack(int var);
 	void addNameToStack(int var);
 	void addStringToStack(int var);
-	void unkMessage1();
-	void unkMessage2();
+	void unkMessage1(const byte *msg);
+	void unkMessage2(const byte *msg);
 public:
 	void clearMsgQueue();	// Used by Actor::putActor
 protected:

Index: string.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/string.cpp,v
retrieving revision 1.200
retrieving revision 1.201
diff -u -d -r1.200 -r1.201
--- string.cpp	15 Mar 2004 02:21:04 -0000	1.200
+++ string.cpp	15 Mar 2004 03:09:48 -0000	1.201
@@ -46,9 +46,9 @@
 	st->charset = st->t_charset;
 }
 
-void ScummEngine::unkMessage1() {
+void ScummEngine::unkMessage1(const byte *msg) {
 	byte buffer[100];
-	_messagePtr = addMessageToStack(_messagePtr, buffer, sizeof(buffer));
+	_messagePtr = addMessageToStack(msg, buffer, sizeof(buffer));
 
 //	if ((_gameId == GID_CMI) && _debugMode) {	// In CMI, unkMessage1 is used for printDebug output
 	if ((buffer[0] != 0xFF) && _debugMode) {
@@ -71,13 +71,13 @@
 	}
 }
 
-void ScummEngine::unkMessage2() {
+void ScummEngine::unkMessage2(const byte *msg) {
 	// Original COMI used different code at this point.
 	// Seemed to use blastText for the messages
 	byte buf[100];
 	const byte *tmp;
 
-	tmp = _messagePtr = addMessageToStack(_messagePtr, buf, sizeof(buf));
+	tmp = _messagePtr = addMessageToStack(msg, buf, sizeof(buf));
 
 	if (_string[3].color == 0)
 		_string[3].color = 4;
@@ -339,14 +339,14 @@
 	_charset->_mask = _charset->_str;
 }
 
-void ScummEngine::drawString(int a) {
+void ScummEngine::drawString(int a, const byte *msg) {
 	byte buf[256];
 	byte *space;
 	int i, c;
 	byte fontHeight = 0;
 	uint color;
 
-	_messagePtr = addMessageToStack(_messagePtr, buf, sizeof(buf));
+	_messagePtr = addMessageToStack(msg, buf, sizeof(buf));
 
 	_charset->_top = _string[a].ypos + _screenTop;
 	_charset->_startLeft = _charset->_left = _string[a].xpos;

Index: verbs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/verbs.cpp,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- verbs.cpp	16 Jan 2004 10:20:43 -0000	1.93
+++ verbs.cpp	15 Mar 2004 03:09:48 -0000	1.94
@@ -228,18 +228,18 @@
 		_string[1].xpos = v2_mouseover_boxes[i].rect.left;
 
 		_string[1].color = v2_mouseover_boxes[i].color;
-		_messagePtr = getObjOrActorName(obj);
-		assert(_messagePtr);
+
+		const byte *tmp = getObjOrActorName(obj);
+		assert(tmp);
 
 		// Prevent inventory entries from overflowing by truncating the text
 		// after 144/8 = 18 chars
 		byte msg[18 + 1];
 		msg[18] = 0;
-		strncpy((char *)msg, (const char *)_messagePtr, 18);
-		_messagePtr = msg;
+		strncpy((char *)msg, (const char *)tmp, 18);
 		
 		// Draw it
-		drawString(1);
+		drawString(1, msg);
 	}
 
 
@@ -248,8 +248,7 @@
 		_string[1].xpos = v2_mouseover_boxes[kInventoryUpArrow].rect.left;
 		_string[1].ypos = v2_mouseover_boxes[kInventoryUpArrow].rect.top + vs->topline;
 	        _string[1].color = v2_mouseover_boxes[kInventoryUpArrow].color;
-		_messagePtr = (const byte *)" \1\2";
-		drawString(1);
+		drawString(1, (const byte *)" \1\2");
 	}
 
 	// If necessary, draw "down" arrow
@@ -257,8 +256,7 @@
 		_string[1].xpos = v2_mouseover_boxes[kInventoryDownArrow].rect.left;
 		_string[1].ypos = v2_mouseover_boxes[kInventoryDownArrow].rect.top + vs->topline;
 	        _string[1].color = v2_mouseover_boxes[kInventoryDownArrow].color;
-		_messagePtr = (const byte *)" \3\4";
-		drawString(1);
+		drawString(1, (const byte *)" \3\4");
 	}
 }
 
@@ -397,19 +395,18 @@
 		   verb += _inventoryOffset;
 		 */
 
-		_messagePtr = getResourceAddress(rtVerb, verb);
-		if (!_messagePtr)
+		const byte *msg = getResourceAddress(rtVerb, verb);
+		if (!msg)
 			return;
-		assert(_messagePtr);
 
-		if ((_version == 8) && (_messagePtr[0] == '/')) {
-			translateText(_messagePtr, _transText);
-			_messagePtr = _transText;
+		if ((_version == 8) && (msg[0] == '/')) {
+			translateText(msg, _transText);
+			msg = _transText;
 		}
 
 		tmp = _charset->_center;
 		_charset->_center = 0;
-		drawString(4);
+		drawString(4, msg);
 		_charset->_center = tmp;
 
 		vs->curRect.right = _charset->_str.right;





More information about the Scummvm-git-logs mailing list