[Scummvm-cvs-logs] SF.net SVN: scummvm: [21771] scummvm/trunk/engines/scumm/plugin.cpp

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Apr 10 15:46:01 CEST 2006


Revision: 21771
Author:   fingolfin
Date:     2006-04-10 15:45:05 -0700 (Mon, 10 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21771&view=rev

Log Message:
-----------
More commented out stuff: added generateFilenameForDetection method, for use by the detector; and applied various fixes to generateFilename (which is still completely untested, so it certainly contains more 'bugs' :)

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/plugin.cpp
Modified: scummvm/trunk/engines/scumm/plugin.cpp
===================================================================
--- scummvm/trunk/engines/scumm/plugin.cpp	2006-04-10 22:25:42 UTC (rev 21770)
+++ scummvm/trunk/engines/scumm/plugin.cpp	2006-04-10 22:45:05 UTC (rev 21771)
@@ -606,40 +606,71 @@
 	kGenUnchanged
 };
 
-struct GameFilenames {
+struct GameFilenamePattern {
 	const char *gameid;
-	const char *expandedName;
+	const char *pattern;
 	FilenameGenMethod genMethod;
 	Common::Language language;
 	Common::Platform platform;
 	const char *variant;
 };
 
+Common::String generateFilenameForDetection(const GameFilenamePattern &gfp) {
+	char buf[128];
+
+	switch (gfp.genMethod) {
+	case kGenDiskNum:
+	case kGenRoomNum:
+		snprintf(buf, sizeof(buf), gfp.pattern, 0);
+		break;
+
+	case kGenHEPC:
+		snprintf(buf, sizeof(buf), "%s.he0", gfp.pattern);
+		break;
+
+	case kGenHEMac:
+		// FIXME: Is this correct?
+		snprintf(buf, sizeof(buf), "%s (0)", gfp.pattern);
+		break;
+
+	case kGenHEMacNoParens:
+		// FIXME: Is this correct?
+		snprintf(buf, sizeof(buf), "%s 0", gfp.pattern);
+		break;
+
+	default:
+		error("FOO");
+	}
+
+	return buf;
+}
+
 #if 0
 Common::String ScummEngine::generateFilename(int room, int diskNumber) {
 	char buf[128];
 
 	if (_game.version == 4) {
 		if (room == 0 || room >= 900) {
-			sprintf(buf, "%.3d.lfl", room);
+			snprintf(buf, sizeof(buf), "%.3d.lfl", room);
 		} else {
-			sprintf(buf, "disk%.2d.lec", diskNumber);
+			snprintf(buf, sizeof(buf), "disk%.2d.lec", diskNumber);
 		}
 	} else {
 		char id = 0;
 
-		switch (_substEntry.method) {
+		switch (_substEntry.genMethod) {
 		case kGenDiskNum:
-			sprintf(buf, _substEntry.formatStr, diskNumber);
+			snprintf(buf, sizeof(buf), _substEntry.pattern, diskNumber);
 			break;
 	
 		case kGenRoomNum:
-			sprintf(buf, _substEntry.formatStr, room);
+			snprintf(buf, sizeof(buf), _substEntry.pattern, room);
 			break;
 
 		case kGenHEMac:
 		case kGenHEMacNoParens:
 		case kGenHEPC:
+			// FIXME: Not sure if the following HE section is quite correct...
 			if (_game.heversion >= 98) {
 				int disk = 0;
 				if (_heV7DiskOffsets)
@@ -648,12 +679,15 @@
 				switch(disk) {
 				case 2:
 					id = 'b';
+					snprintf(buf, sizeof(buf), "%s.(b)", pattern);
 					break;
 				case 1:
 					id = 'a';
+					snprintf(buf, sizeof(buf), "%s.(a)", pattern);
 					break;
 				default:
 					id = '0';
+					snprintf(buf, sizeof(buf), "%s.he0", pattern);
 				}
 			} else if (_game.heversion >= 70) {
 				id = (room == 0) ? '0' : '1';
@@ -661,20 +695,19 @@
 				id = diskNumber + '0';
 			}
 			
-			if (_substEntry.method == kGenHEPC) {
-				if (_game.heversion >= 98)
-					sprintf(buf, _substEntry.formatStr, id);
-				else
-					sprintf(buf, "%s.he%c", _baseName.c_str(), id);
+			if (_substEntry.genMethod == kGenHEPC) {
+				// For HE >= 98, we already called snprintf above.
+				if (_game.heversion < 98)
+					snprintf(buf, sizeof(buf), "%s.he%c", pattern, id);
 			} else {
 				if (id == '3') { // special case for cursors
 					// For mac they're stored in game binary
-					strncpy(buf, _substEntry.formatStr, bufsize);
+					strncpy(buf, _substEntry.pattern, bufsize);
 				} else {
 					if (subst.genMethod == kGenMac)
-						snprintf(buf, bufsize, "%s (%c)", _substEntry.formatStr, id);
+						snprintf(buf, sizeof(buf), "%s (%c)", _substEntry.pattern, id);
 					else
-						snprintf(buf, bufsize, "%s %c", _substEntry.formatStr, id);
+						snprintf(buf, sizeof(buf), "%s %c", _substEntry.pattern, id);
 				}
 			}
 
@@ -697,14 +730,14 @@
 // The following table maps gameids to possible filename variants for that game.
 // This information is used by the detector to determin possible "detect files".
 // It is also later used by the engine creation code to verify the game to be
-// launched is present. Finally, the correct GameFilenames entry is passed on
+// launched is present. Finally, the correct GameFilenamePattern entry is passed on
 // to the engine which uses it to locate the files for the game.
 //
 // The table is augmented by platform/language/variant information where applicable.
 //
 // Note: Setting variant to 0 means "don't care", while setting it to ""
 // (i.e. an empty string) means "use the default variant".
-static const GameFilenames gameFilenamesTable[] = {
+static const GameFilenamePattern gameFilenamesTable[] = {
 	{ "maniac", "%.2d.LFL", kGenRoomNum, UNK_LANG, UNK, 0 },
 	{ "maniac", "%.2d.MAN", kGenRoomNum, UNK_LANG, UNK, 0 },
 	{ "maniac", "maniac1.d64", kGenUnchanged, UNK_LANG, Common::kPlatformC64, 0 },   // ... and maniac2.d64


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list