[Scummvm-cvs-logs] CVS: scummvm/scumm saveload.cpp,1.134,1.135 scumm.h,1.350,1.351 scummvm.cpp,2.535,2.536 string.cpp,1.182,1.183

Max Horn fingolfin at users.sourceforge.net
Thu Jan 8 09:32:00 CET 2004


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv18204

Modified Files:
	saveload.cpp scumm.h scummvm.cpp string.cpp 
Log Message:
cleanup

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -d -r1.134 -r1.135
--- saveload.cpp	8 Jan 2004 00:48:37 -0000	1.134
+++ saveload.cpp	8 Jan 2004 17:30:36 -0000	1.135
@@ -410,7 +410,7 @@
 
 		MKLINE(ScummEngine, _talkDelay, sleInt16, VER(8)),
 		MKLINE(ScummEngine, _defaultTalkDelay, sleInt16, VER(8)),
-		MKLINE(ScummEngine, _numInMsgStack, sleInt16, VER(8)),
+		MK_OBSOLETE(ScummEngine, _numInMsgStack, sleInt16, VER(8), VER(27)),
 		MKLINE(ScummEngine, _sentenceNum, sleByte, VER(8)),
 
 		MKLINE(ScummEngine, vm.cutSceneStackPointer, sleByte, VER(8)),

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.350
retrieving revision 1.351
diff -u -d -r1.350 -r1.351
--- scumm.h	8 Jan 2004 03:24:41 -0000	1.350
+++ scumm.h	8 Jan 2004 17:30:36 -0000	1.351
@@ -1034,8 +1034,6 @@
 public:
 	void clearMsgQueue();	// Used by Actor::putActor
 protected:
-
-	int _numInMsgStack;
 	byte *_msgPtrToAdd;
 	const byte *_messagePtr;
 	bool _keepText;

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.535
retrieving revision 2.536
diff -u -d -r2.535 -r2.536
--- scummvm.cpp	6 Jan 2004 17:28:28 -0000	2.535
+++ scummvm.cpp	8 Jan 2004 17:30:36 -0000	2.536
@@ -477,7 +477,6 @@
 	_copyProtection = false;
 	_demoMode = false;
 	_confirmExit = false;
-	_numInMsgStack = 0;
 	_msgPtrToAdd = NULL;
 	_messagePtr = NULL;
 	_talkDelay = 0;
@@ -1140,10 +1139,6 @@
 	for (i = 0; i < 512; i++)
 		_keyDownMap[i] = false;
 
-	_numInMsgStack = 0;
-
-	createResource(rtTemp, 6, 500);
-
 	initScummVars();
 
 	_lastSaveTime = _system->get_msecs();
@@ -2515,7 +2510,6 @@
 	// Reinit things
 	allocateArrays();                   // Reallocate arrays
 	readIndexFile();                    // Reread index (reset objectstate etc)
-	createResource(rtTemp, 6, 500);     // Create temp buffer
 	initScummVars();                    // Reinit scumm variables
 	if (_imuse) {
 		_imuse->setBase(res.address[rtSound]);

Index: string.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/string.cpp,v
retrieving revision 1.182
retrieving revision 1.183
diff -u -d -r1.182 -r1.183
--- string.cpp	8 Jan 2004 08:47:09 -0000	1.182
+++ string.cpp	8 Jan 2004 17:30:36 -0000	1.183
@@ -488,112 +488,87 @@
 }
 
 const byte *ScummEngine::addMessageToStack(const byte *msg) {
-	int num, numorg;
-	unsigned char *ptr, chr;
-
-	numorg = num = _numInMsgStack;
-	ptr = getResourceAddress(rtTemp, 6);
-
-	if (ptr == NULL)
-		error("Message stack not allocated");
+	uint num = 0;
+	uint32 val;
+	byte chr;
+	byte buf[512];
 
 	if (msg == NULL) {
 		warning("Bad message in addMessageToStack, ignoring");
 		return NULL;
 	}
 
-	while ((ptr[num++] = chr = *msg++) != 0) {
-		if (num >= 500)
+	while ((buf[num++] = chr = *msg++) != 0) {
+		if (num >= sizeof(buf))
 			error("Message stack overflow");
 
 		if (chr == 0xff) {	// 0xff is an escape character
-			ptr[num++] = chr = *msg++;	// followed by a "command" code
+			buf[num++] = chr = *msg++;	// followed by a "command" code
 			if (chr != 1 && chr != 2 && chr != 3 && chr != 8) {
-				ptr[num++] = *msg++;	// and some commands are followed by parameters to the functions below
-				ptr[num++] = *msg++;	// these are numbers of names, strings, verbs, variables, etc
+				buf[num++] = *msg++;	// and some commands are followed by parameters to the functions below
+				buf[num++] = *msg++;	// these are numbers of names, strings, verbs, variables, etc
 				if (_version == 8) {
-					ptr[num++] = *msg++;
-					ptr[num++] = *msg++;
+					buf[num++] = *msg++;
+					buf[num++] = *msg++;
 				}
 			}
 		}
 	}
 
-	_numInMsgStack = num;
-	num = numorg;
+	num = 0;
 
 	while (1) {
-		ptr = getResourceAddress(rtTemp, 6);
-		chr = ptr[num++];
+		chr = buf[num++];
 		if (chr == 0)
 			break;
 		if (chr == 0xFF) {
-			chr = ptr[num++];
-			switch (chr) {
-			case 4:
-				if (_version == 8) {
-					addIntToStack(READ_LE_UINT32(ptr + num));
-					num += 4;
-				} else {
-					addIntToStack(READ_LE_UINT16(ptr + num));
-					num += 2;
-				}
-				break;
-			case 5:
-				if (_version == 8) {
-					addVerbToStack(READ_LE_UINT32(ptr + num));
-					num += 4;
-				} else {
-					addVerbToStack(READ_LE_UINT16(ptr + num));
-					num += 2;
-				}
-				break;
-			case 6:
-				if (_version == 8) {
-					addNameToStack(READ_LE_UINT32(ptr + num));
-					num += 4;
-				} else {
-					addNameToStack(READ_LE_UINT16(ptr + num));
-					num += 2;
-				}
-				break;
-			case 7:
-				if (_version == 8) {
-					addStringToStack(READ_LE_UINT32(ptr + num));
-					num += 4;
-				} else if (_version <= 2) {
-					int var = READ_LE_UINT16(ptr + num);
-					num += 2;
-					char c;
-					while ((c = (char) _scummVars[var++])) {
-						if (c != '@')
-							*_msgPtrToAdd++ = c;
-					}
-				} else {
-					addStringToStack(READ_LE_UINT16(ptr + num));
-					num += 2;
-				}
-				break;
-			case 3:
-			case 9:
-			case 10:
-			case 12:
-			case 13:
-			case 14:
+			chr = buf[num++];
+			if (chr == 1 || chr == 2 || chr == 3 || chr == 8) {
+				// Simply copy these special codes
 				*_msgPtrToAdd++ = 0xFF;
 				*_msgPtrToAdd++ = chr;
-				*_msgPtrToAdd++ = ptr[num++];
-				*_msgPtrToAdd++ = ptr[num++];
-				if (_version == 8) {
-					*_msgPtrToAdd++ = ptr[num++];
-					*_msgPtrToAdd++ = ptr[num++];
+			} else {
+				val = (_version == 8) ? READ_LE_UINT32(buf + num) : READ_LE_UINT16(buf + num);
+				switch (chr) {
+				case 4:
+					addIntToStack(val);
+					break;
+				case 5:
+					addVerbToStack(val);
+					break;
+				case 6:
+					addNameToStack(val);
+					break;
+				case 7:
+					if (_version <= 2) {
+						while ((chr = (byte) _scummVars[val++])) {
+							if (chr != '@')
+								*_msgPtrToAdd++ = chr;
+						}
+					} else {
+						addStringToStack(val);
+					}
+					break;
+				case 9:
+				case 10:
+				case 12:
+				case 13:
+				case 14:
+					// Simply copy these special codes
+					*_msgPtrToAdd++ = 0xFF;
+					*_msgPtrToAdd++ = chr;
+					*_msgPtrToAdd++ = buf[num+0];
+					*_msgPtrToAdd++ = buf[num+1];
+					if (_version == 8) {
+						*_msgPtrToAdd++ = buf[num+2];
+						*_msgPtrToAdd++ = buf[num+3];
+					}
+					break;
+				default:
+					warning("addMessageToStack(): string escape sequence %d unknown", chr);
+					break;
 				}
-				break;
-			default:
-				debug(2, "addMessageToStack(): string escape sequence %d unknown", chr);
-				*_msgPtrToAdd++ = 0xFF;
-				*_msgPtrToAdd++ = chr;
-				break;
+				num += (_version == 8) ? 4 : 2;
 			}
 		} else {
 			if (chr != '@') {
@@ -602,7 +577,6 @@
 		}
 	}
 	*_msgPtrToAdd = 0;
-	_numInMsgStack = numorg;
 
 	return msg;
 }
@@ -627,8 +601,6 @@
 				break;
 			}
 		}
-	} else {
-		addMessageToStack((const byte *)"");
 	}
 }
 
@@ -646,8 +618,6 @@
 		} else {
 			addMessageToStack(ptr);
 		}
-	} else {
-		addMessageToStack((const byte *)"");
 	}
 }
 
@@ -667,8 +637,7 @@
 				addMessageToStack(ptr);
 			}
 		}
-	} else
-		addMessageToStack((const byte *)"");
+	}
 }
 
 void ScummEngine::initCharset(int charsetno) {





More information about the Scummvm-git-logs mailing list