[Scummvm-cvs-logs] CVS: scummvm/scumm resource.cpp,1.288,1.289 script_v72he.cpp,2.197,2.198 scumm.cpp,1.302,1.303 scumm.h,1.529,1.530 sound.cpp,1.413,1.414

Eugene Sandulenko sev at users.sourceforge.net
Sat Jan 29 09:58:16 CET 2005


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

Modified Files:
	resource.cpp script_v72he.cpp scumm.cpp scumm.h sound.cpp 
Log Message:
Add support for Humongous Mac titles in native format. Please test :)


Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/resource.cpp,v
retrieving revision 1.288
retrieving revision 1.289
diff -u -d -r1.288 -r1.289
--- resource.cpp	1 Jan 2005 16:09:15 -0000	1.288
+++ resource.cpp	29 Jan 2005 17:57:57 -0000	1.289
@@ -123,6 +123,16 @@
 			encByte = (_features & GF_USE_KEY) ? 0xFF : 0;
 		}
 
+		// If we have substitute
+		if (_heMacFileNameIndex > 0) {
+			char tmpBuf[128];
+
+			generateMacFileName(buf, tmpBuf, 128, 0, _heMacFileNameIndex);
+			strcpy(buf, tmpBuf);
+			generateMacFileName(buf2, tmpBuf, 128, 0, _heMacFileNameIndex);
+			strcpy(buf2, tmpBuf);
+		}
+
 		result = openResourceFile(buf, encByte);
 		if ((result == false) && (buf2[0])) {
 			result = openResourceFile(buf2, encByte);

Index: script_v72he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v72he.cpp,v
retrieving revision 2.197
retrieving revision 2.198
diff -u -d -r2.197 -r2.198
--- script_v72he.cpp	10 Jan 2005 22:05:46 -0000	2.197
+++ script_v72he.cpp	29 Jan 2005 17:57:57 -0000	2.198
@@ -1547,6 +1547,13 @@
 		sprintf((char *)filename, "%s.he9", _gameName.c_str());
 	}
 
+	if (_heMacFileNameIndex > 0) {
+		char buf1[128];
+
+		generateMacFileName((char *)filename, buf1, 128, 0, _heMacFileNameIndex);
+		strcpy((char *)filename, buf1);
+	}
+
 	for (r = strlen((char*)filename); r != 0; r--) {
 		if (filename[r - 1] == '\\')
 			break;

Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.302
retrieving revision 1.303
diff -u -d -r1.302 -r1.303
--- scumm.cpp	29 Jan 2005 15:49:56 -0000	1.302
+++ scumm.cpp	29 Jan 2005 17:57:57 -0000	1.303
@@ -69,7 +69,7 @@
 extern bool isSmartphone(void);
 #endif
 
-static int generateMacFileName(const char *filename, char *buf, int bufsize, int cont = 0);
+static int generateMacFileName_(const char *filename, char *buf, int bufsize, int cont = 0, int index = 0);
 
 namespace Scumm {
 
@@ -678,6 +678,7 @@
 	_expire_counter = 0;
 	_lastLoadedRoom = 0;
 	_roomResource = 0;
+	_heMacFileNameIndex = 0;
 	OF_OWNER_ROOM = 0;
 	_verbMouseOver = 0;
 	_inventoryOffset = 0;
@@ -2597,6 +2598,11 @@
 	}
 }
 
+int ScummEngine::generateMacFileName(const char *filename, char *buf, int bufsize, int cont, int index) {
+	return generateMacFileName_(filename, buf, bufsize, cont, index);
+}
+
+
 } // End of namespace Scumm
 
 using namespace Scumm;
@@ -2674,7 +2680,7 @@
 			}
 
 			if (g->features & GF_HUMONGOUS) {
-				if ((heLastName = generateMacFileName(tempName, detectName, 128, 
+				if ((heLastName = generateMacFileName_(tempName, detectName, 128, 
 													  heLastName)) == -1)
 					heOver = true;
 			} else {
@@ -2736,7 +2742,7 @@
 	return detectedGames;
 }
 
-static int generateMacFileName(const char *filename, char *buf, int bufsize, int cont) {
+static int generateMacFileName_(const char *filename, char *buf, int bufsize, int cont, int index) {
 	if (cont == -1)
 		return -1;
 
@@ -2744,9 +2750,17 @@
 		cont++;
 
 	char num = filename[strlen(filename) - 1];
+	
+	// In some cases we have .(a) and .(b) extensions
+	if (num == ')')
+		num = filename[strlen(filename) - 2];
+
 	char *n = strrchr(filename, '.');
 	int len = n - filename;
 
+	if (index > 0)
+		cont = index;
+
 	for (int i = cont; i < ARRAYSIZE(heMacFileNameTable); i++) {
 		if (!scumm_strnicmp(filename, heMacFileNameTable[i].winName, len)) {
 			if (heMacFileNameTable[i].hasParens)
@@ -2777,8 +2791,9 @@
 
 	// Calculate MD5 of the games detection file, for savegames etc.
 	const char *name = g->name;
-	char detectName[256], gameMD5[32+1];
+	char detectName[256], tempName[256], gameMD5[32+1];
 	uint8 md5sum[16];
+	int heLastName = 0;
 
 	if (g->detectFilename) {
 		strcpy(detectName, game.detectFilename);
@@ -2792,6 +2807,24 @@
 	} else if (g->features & GF_HUMONGOUS) {
 		strcpy(detectName, name);
 		strcat(detectName, ".he0");
+		strcpy(tempName, name);
+		strcat(tempName, ".he0");
+		
+		bool heOver = false;
+		File f;
+
+		while (!heOver) {
+			if (f.exists(detectName, ConfMan.get("path").c_str()))
+				break;
+
+			if ((heLastName = generateMacFileName_(tempName, detectName, 256, 
+													  heLastName)) == -1)
+					heOver = true;
+		}
+
+		// Force game to have Mac platform
+		if (heLastName > 0)
+			game.features |= GF_MACINTOSH;
 	} else {
 		strcpy(detectName, name);
 		strcat(detectName, ".000");
@@ -2922,6 +2955,10 @@
 		error("Engine_SCUMM_create(): Unknown version of game engine");
 	}
 
+	// FIXME: dirty HACK. Should we introduce another parameter to constructor
+	// instead?
+	((ScummEngine *)engine)->_heMacFileNameIndex = heLastName;
+
 	return engine;
 }
 

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.529
retrieving revision 1.530
diff -u -d -r1.529 -r1.530
--- scumm.h	29 Jan 2005 15:49:57 -0000	1.529
+++ scumm.h	29 Jan 2005 17:57:58 -0000	1.530
@@ -489,6 +489,9 @@
 	int _roomResource;  // FIXME - should be protected but Sound::pauseSounds uses it
 	bool _egoPositioned;	// Used by Actor::putActor, hence public
 
+	int generateMacFileName(const char *filename, char *buf, int bufsize, int cont = 0, int index = 0);
+	int _heMacFileNameIndex;
+
 protected:
 	int _keyPressed;
 	uint16 _lastKeyHit;

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.413
retrieving revision 1.414
diff -u -d -r1.413 -r1.414
--- sound.cpp	28 Jan 2005 22:05:44 -0000	1.413
+++ sound.cpp	29 Jan 2005 17:57:58 -0000	1.414
@@ -171,10 +171,15 @@
 
 		int music_offs, total_size;
 		uint tracks, skip = 0;
-		char buf[32];
+		char buf[32], buf1[128];
 		File musicFile;
 
 		sprintf(buf, "%s.he4", _vm->getGameName());
+
+		if (_vm->_heMacFileNameIndex > 0) {
+			_vm->generateMacFileName(buf, buf1, 128, 0, _vm->_heMacFileNameIndex);
+			strcpy(buf, buf1);
+		}
 		if (musicFile.open(buf) == false) {
 			warning("playSound: Music file is not open");
 			return;
@@ -1072,10 +1077,18 @@
 	}
 
 	if (!file->isOpen()) {
-		if (_vm->_heversion >= 70)
+		if (_vm->_heversion >= 70) {
 			sprintf(buf, "%s.he2", _vm->getGameName());
-		else
+
+			if (_vm->_heMacFileNameIndex > 0) {
+				char buf1[128];
+
+				_vm->generateMacFileName(buf, buf1, 128, 0, _vm->_heMacFileNameIndex);
+				strcpy(buf, buf1);
+			}
+		} else {
 			sprintf(buf, "%s.tlk", _vm->getGameName());
+		}
 		if (file->open(buf) && _vm->_heversion <= 72) 
 			file->setEnc(0x69);
 		_soundMode = kVOCMode;





More information about the Scummvm-git-logs mailing list