[Scummvm-cvs-logs] CVS: scummvm/scumm saveload.cpp,1.149,1.150 script_v2.cpp,2.244,2.245 script_v5.cpp,1.233,1.234 script_v6.cpp,1.326,1.327 script_v6he.cpp,2.41,2.42 script_v8.cpp,2.244,2.245 scumm.cpp,1.15,1.16 scumm.h,1.391,1.392 string.cpp,1.210,1.211

Max Horn fingolfin at users.sourceforge.net
Sat Apr 3 11:54:05 CEST 2004


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

Modified Files:
	saveload.cpp script_v2.cpp script_v5.cpp script_v6.cpp 
	script_v6he.cpp script_v8.cpp scumm.cpp scumm.h string.cpp 
Log Message:
cleanup StringTab stuff

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.149
retrieving revision 1.150
diff -u -d -r1.149 -r1.150
--- saveload.cpp	28 Mar 2004 16:30:49 -0000	1.149
+++ saveload.cpp	3 Apr 2004 19:41:30 -0000	1.150
@@ -573,27 +573,23 @@
 	};
 
 	const SaveLoadEntry stringTabEntries[] = {
-		// TODO - It makes no sense to have all these t_* fields in StringTab
-		// Rather let's dump them all when the save game format changes, and 
-		// keep two StringTab objects where we have one now: a "normal" one,
-		// and a temporar y"t_" one.
 		// Then backup/restore of a StringTab entry becomes a one liner.
 		MKLINE(StringTab, xpos, sleInt16, VER(8)),
-		MKLINE(StringTab, t_xpos, sleInt16, VER(8)),
+		MKLINE(StringTab, backup.xpos, sleInt16, VER(8)),
 		MKLINE(StringTab, ypos, sleInt16, VER(8)),
-		MKLINE(StringTab, t_ypos, sleInt16, VER(8)),
+		MKLINE(StringTab, backup.ypos, sleInt16, VER(8)),
 		MKLINE(StringTab, right, sleInt16, VER(8)),
-		MKLINE(StringTab, t_right, sleInt16, VER(8)),
+		MKLINE(StringTab, backup.right, sleInt16, VER(8)),
 		MKLINE(StringTab, color, sleInt8, VER(8)),
-		MKLINE(StringTab, t_color, sleInt8, VER(8)),
+		MKLINE(StringTab, backup.color, sleInt8, VER(8)),
 		MKLINE(StringTab, charset, sleInt8, VER(8)),
-		MKLINE(StringTab, t_charset, sleInt8, VER(8)),
+		MKLINE(StringTab, backup.charset, sleInt8, VER(8)),
 		MKLINE(StringTab, center, sleByte, VER(8)),
-		MKLINE(StringTab, t_center, sleByte, VER(8)),
+		MKLINE(StringTab, backup.center, sleByte, VER(8)),
 		MKLINE(StringTab, overhead, sleByte, VER(8)),
-		MKLINE(StringTab, t_overhead, sleByte, VER(8)),
+		MKLINE(StringTab, backup.overhead, sleByte, VER(8)),
 		MKLINE(StringTab, no_talk_anim, sleByte, VER(8)),
-		MKLINE(StringTab, t_no_talk_anim, sleByte, VER(8)),
+		MKLINE(StringTab, backup.no_talk_anim, sleByte, VER(8)),
 		MKEND()
 	};
 

Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 2.244
retrieving revision 2.245
diff -u -d -r2.244 -r2.245
--- script_v2.cpp	17 Mar 2004 01:50:14 -0000	2.244
+++ script_v2.cpp	3 Apr 2004 19:41:30 -0000	2.245
@@ -847,7 +847,7 @@
 			vs->dimcolor = 8;
 		}
 		vs->type = kTextVerbType;
-		vs->charset_nr = _string[0].t_charset;
+		vs->charset_nr = _string[0].backup.charset;
 		vs->curmode = 1;
 		vs->saveid = 0;
 		vs->key = 0;

Index: script_v5.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v5.cpp,v
retrieving revision 1.233
retrieving revision 1.234
diff -u -d -r1.233 -r1.234
--- script_v5.cpp	17 Mar 2004 01:50:14 -0000	1.233
+++ script_v5.cpp	3 Apr 2004 19:41:30 -0000	1.234
@@ -707,7 +707,7 @@
 		} else {
 			getWordVararg(table);
 			for (i = 0; i < 16; i++)
-				_charsetColorMap[i] = _charsetData[_string[1].t_charset][i] = (unsigned char)table[i];
+				_charsetColorMap[i] = _charsetData[_string[1].backup.charset][i] = (unsigned char)table[i];
 		}
 		break;
 	}
@@ -2405,7 +2405,7 @@
 			vs->hicolor = (_version == 3) ? 14 : 0;
 			vs->dimcolor = 8;
 			vs->type = kTextVerbType;
-			vs->charset_nr = _string[0].t_charset;
+			vs->charset_nr = _string[0].backup.charset;
 			vs->curmode = 0;
 			vs->saveid = 0;
 			vs->key = 0;
@@ -2616,7 +2616,7 @@
 		textSlot = 0;
 	}
 
-	setStringVars(textSlot);
+	_string[textSlot].restoreString();
 
 	while ((_opcode = fetchScriptByte()) != 0xFF) {
 		switch (_opcode & 0xF) {
@@ -2709,9 +2709,9 @@
  			// speaks during the intro are put at position 0,0.
  			// In addition, Loom needs to remember the text colour.
 			if (_gameId == GID_LOOM || _gameId == GID_INDY3) {
-				_string[textSlot].t_xpos = _string[textSlot].xpos;
-				_string[textSlot].t_ypos = _string[textSlot].ypos;
- 				_string[textSlot].t_color = _string[textSlot].color;
+				_string[textSlot].backup.xpos = _string[textSlot].xpos;
+				_string[textSlot].backup.ypos = _string[textSlot].ypos;
+ 				_string[textSlot].backup.color = _string[textSlot].color;
 			}
 			return;
 		default:
@@ -2720,13 +2720,7 @@
 		}
 	}
 
-	_string[textSlot].t_xpos = _string[textSlot].xpos;
-	_string[textSlot].t_ypos = _string[textSlot].ypos;
-	_string[textSlot].t_center = _string[textSlot].center;
-	_string[textSlot].t_overhead = _string[textSlot].overhead;
-	_string[textSlot].t_right = _string[textSlot].right;
-	_string[textSlot].t_color = _string[textSlot].color;
-	_string[textSlot].t_charset = _string[textSlot].charset;
+	_string[textSlot].backupString();
 }
 
 void ScummEngine_v5::o5_oldRoomEffect() {

Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.326
retrieving revision 1.327
diff -u -d -r1.326 -r1.327
--- script_v6.cpp	2 Apr 2004 21:42:34 -0000	1.326
+++ script_v6.cpp	3 Apr 2004 19:41:30 -0000	1.327
@@ -949,7 +949,7 @@
 	case 0x9D:		// SO_CHARSET_COLOR
 		getStackList(args, ARRAYSIZE(args));
 		for (i = 0; i < 16; i++)
-			_charsetColorMap[i] = _charsetData[_string[1].t_charset][i] = (unsigned char)args[i];
+			_charsetColorMap[i] = _charsetData[_string[1].backup.charset][i] = (unsigned char)args[i];
 		break;
 	case 0xD6:		// SO_CURSOR_TRANSPARENT Set cursor transparent color
 		makeCursorColorTransparent(pop());
@@ -1925,7 +1925,7 @@
 		vs->hicolor = 0;
 		vs->dimcolor = 8;
 		vs->type = kTextVerbType;
-		vs->charset_nr = _string[0].t_charset;
+		vs->charset_nr = _string[0].backup.charset;
 		vs->curmode = 0;
 		vs->saveid = 0;
 		vs->key = 0;
@@ -2294,7 +2294,7 @@
 void ScummEngine_v6::o6_talkActor() {
 	_actorToPrintStrFor = pop();
 
-	setStringVars(0);
+	_string[0].restoreString();
 	actorTalk(_scriptPointer);
 
 	_scriptPointer += resStrLen(_scriptPointer) + 1;
@@ -3119,19 +3119,12 @@
 
 		break;
 	case 0xFE:
-		setStringVars(m);
+		_string[m].restoreString();
 		if (n)
 			_actorToPrintStrFor = pop();
 		break;
 	case 0xFF:
-		_string[m].t_xpos = _string[m].xpos;
-		_string[m].t_ypos = _string[m].ypos;
-		_string[m].t_center = _string[m].center;
-		_string[m].t_overhead = _string[m].overhead;
-		_string[m].t_no_talk_anim = _string[m].no_talk_anim;
-		_string[m].t_right = _string[m].right;
-		_string[m].t_color = _string[m].color;
-		_string[m].t_charset = _string[m].charset;
+		_string[m].backupString();
 		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.41
retrieving revision 2.42
diff -u -d -r2.41 -r2.42
--- script_v6he.cpp	2 Apr 2004 21:42:35 -0000	2.41
+++ script_v6he.cpp	3 Apr 2004 19:41:30 -0000	2.42
@@ -756,7 +756,7 @@
 		vs->hicolor = 0;
 		vs->dimcolor = 8;
 		vs->type = kTextVerbType;
-		vs->charset_nr = _string[0].t_charset;
+		vs->charset_nr = _string[0].backup.charset;
 		vs->curmode = 0;
 		vs->saveid = 0;
 		vs->key = 0;
@@ -1468,19 +1468,12 @@
 		warning("decodeParseString case 0xF9 stub");
 		break;
 	case 0xFE:
-		setStringVars(m);
+		_string[m].restoreString();
 		if (n)
 			_actorToPrintStrFor = pop();
 		break;
 	case 0xFF:
-		_string[m].t_xpos = _string[m].xpos;
-		_string[m].t_ypos = _string[m].ypos;
-		_string[m].t_center = _string[m].center;
-		_string[m].t_overhead = _string[m].overhead;
-		_string[m].t_no_talk_anim = _string[m].no_talk_anim;
-		_string[m].t_right = _string[m].right;
-		_string[m].t_color = _string[m].color;
-		_string[m].t_charset = _string[m].charset;
+		_string[m].backupString();
 		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.244
retrieving revision 2.245
diff -u -d -r2.244 -r2.245
--- script_v8.cpp	2 Apr 2004 21:56:27 -0000	2.244
+++ script_v8.cpp	3 Apr 2004 19:41:30 -0000	2.245
@@ -472,19 +472,12 @@
 
 	switch (b) {
 	case 0xC8:		// SO_PRINT_BASEOP
-		setStringVars(m);
+		_string[m].restoreString();
 		if (n)
 			_actorToPrintStrFor = pop();
 		break;
 	case 0xC9:		// SO_PRINT_END
-		_string[m].t_xpos = _string[m].xpos;
-		_string[m].t_ypos = _string[m].ypos;
-		_string[m].t_center = _string[m].center;
-		_string[m].t_overhead = _string[m].overhead;
-		_string[m].t_no_talk_anim = _string[m].no_talk_anim;
-		_string[m].t_right = _string[m].right;
-		_string[m].t_color = _string[m].color;
-		_string[m].t_charset = _string[m].charset;
+		_string[m].backupString();
 		break;
 	case 0xCA:		// SO_PRINT_AT
 		_string[m].ypos = pop();
@@ -769,7 +762,7 @@
 	case 0xE8:		// SO_CHARSET_COLOR
 		getStackList(args, ARRAYSIZE(args));
 		for (i = 0; i < 16; i++)
-			_charsetColorMap[i] = _charsetData[_string[1].t_charset][i] = (unsigned char)args[i];
+			_charsetColorMap[i] = _charsetData[_string[1].backup.charset][i] = (unsigned char)args[i];
 		break;
 	case 0xE9: 		// SO_CURSOR_PUT
 		{
@@ -1151,7 +1144,7 @@
 		vs->hicolor = 0;
 		vs->dimcolor = 8;
 		vs->type = kTextVerbType;
-		vs->charset_nr = _string[0].t_charset;
+		vs->charset_nr = _string[0].backup.charset;
 		vs->curmode = 0;
 		vs->saveid = 0;
 		vs->key = 0;

Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- scumm.cpp	3 Apr 2004 00:56:53 -0000	1.15
+++ scumm.cpp	3 Apr 2004 19:41:30 -0000	1.16
@@ -1128,16 +1128,16 @@
 
 	for (i = 0; i < 6; i++) {
 		if (_version == 3) { // FIXME - what is this?
-			_string[i].t_xpos = 0;
-			_string[i].t_ypos = 0;
+			_string[i].backup.xpos = 0;
+			_string[i].backup.ypos = 0;
 		} else {
-			_string[i].t_xpos = 2;
-			_string[i].t_ypos = 5;
+			_string[i].backup.xpos = 2;
+			_string[i].backup.ypos = 5;
 		}
-		_string[i].t_right = _screenWidth - 1;
-		_string[i].t_color = 0xF;
-		_string[i].t_center = 0;
-		_string[i].t_charset = 0;
+		_string[i].backup.right = _screenWidth - 1;
+		_string[i].backup.color = 0xF;
+		_string[i].backup.center = 0;
+		_string[i].backup.charset = 0;
 	}
 
 	// all keys are released

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.391
retrieving revision 1.392
diff -u -d -r1.391 -r1.392
--- scumm.h	2 Apr 2004 21:56:27 -0000	1.391
+++ scumm.h	3 Apr 2004 19:41:31 -0000	1.392
@@ -252,21 +252,33 @@
 	uint8 freezeCount;
 };
 
-// TODO / FIXME: next time save game format changes, Fingolfin would like to
-// revise StringTab. In particular, all t_* fields can be removed, making some
-// code a bit cleaner & easier to understand.
-struct StringTab {
-	int16 t_xpos, t_ypos;
-	int16 t_right;
-	int16 xpos, ypos;
+struct StringSlot {
+	int16 xpos;
+	int16 ypos;
 	int16 right;
-	byte color, t_color;
-	byte charset, t_charset;
-	bool center, t_center;
-	bool overhead, t_overhead;
-	bool no_talk_anim, t_no_talk_anim;
+	byte color;
+	byte charset;
+	bool center;
+	bool overhead;
+	bool no_talk_anim;
+};
+
+struct StringTab : StringSlot {
+	StringSlot backup;
+
+	void backupString() {
+		StringSlot &s = *this;
+		backup = s;
+	}
+
+	void restoreString() {
+		StringSlot &s = *this;
+		s = backup;
+	}
 };
 
+
+
 enum WhereIsObject {
 	WIO_NOT_FOUND = -1,
 	WIO_INVENTORY = 0,
@@ -582,7 +594,6 @@
 	void copyScriptString(byte *dst);
 	int resStrLen(const byte *src) const;
 	void doSentence(int c, int b, int a);
-	void setStringVars(int i);
 
 	/* Should be in Resource class */
 	File _fileHandle;

Index: string.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/string.cpp,v
retrieving revision 1.210
retrieving revision 1.211
diff -u -d -r1.210 -r1.211
--- string.cpp	3 Apr 2004 13:16:02 -0000	1.210
+++ string.cpp	3 Apr 2004 19:41:31 -0000	1.211
@@ -34,18 +34,6 @@
 
 namespace Scumm {
 
-void ScummEngine::setStringVars(int slot) {
-	StringTab *st = &_string[slot];
-	st->xpos = st->t_xpos;
-	st->ypos = st->t_ypos;
-	st->center = st->t_center;
-	st->overhead = st->t_overhead;
-	st->no_talk_anim = st->t_no_talk_anim;
-	st->right = st->t_right;
-	st->color = st->t_color;
-	st->charset = st->t_charset;
-}
-
 void ScummEngine::unkMessage1(const byte *msg) {
 	byte buffer[100];
 	addMessageToStack(msg, buffer, sizeof(buffer));
@@ -616,8 +604,8 @@
 	if (!getResourceAddress(rtCharset, charsetno))
 		loadCharset(charsetno);
 
-	_string[0].t_charset = charsetno;
-	_string[1].t_charset = charsetno;
+	_string[0].backup.charset = charsetno;
+	_string[1].backup.charset = charsetno;
 
 	for (i = 0; i < 16; i++)
 		_charsetColorMap[i] = _charsetData[charsetno][i];





More information about the Scummvm-git-logs mailing list