[Scummvm-cvs-logs] SF.net SVN: scummvm: [26939] scummvm/trunk/engines/agi/detection.cpp

sev at users.sourceforge.net sev at users.sourceforge.net
Sat May 26 17:16:22 CEST 2007


Revision: 26939
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26939&view=rev
Author:   sev
Date:     2007-05-26 08:16:21 -0700 (Sat, 26 May 2007)

Log Message:
-----------
Add fallback detector to AGI engine.

Modified Paths:
--------------
    scummvm/trunk/engines/agi/detection.cpp

Modified: scummvm/trunk/engines/agi/detection.cpp
===================================================================
--- scummvm/trunk/engines/agi/detection.cpp	2007-05-26 15:14:25 UTC (rev 26938)
+++ scummvm/trunk/engines/agi/detection.cpp	2007-05-26 15:16:21 UTC (rev 26939)
@@ -1822,8 +1822,115 @@
 	{ AD_TABLE_END_MARKER, 0, 0, 0, 0 }
 };
 
+static const AGIGameDescription fallbackDescs[] = {
+	{
+		{
+			"agi-fanmade",
+			"Unknown v2 Game",
+			AD_ENTRY1(0, 0),
+			Common::UNK_LANG,
+			Common::kPlatformPC,
+			Common::ADGF_NO_FLAGS
+		},
+		GID_FANMADE,
+		GType_V2,
+		GF_FANMADE,
+		0x2917,
+	},
+	{
+		{
+			"agi-fanmade",
+			"Unknown v2 AGIPAL Game",
+			AD_ENTRY1(0, 0),
+			Common::UNK_LANG,
+			Common::kPlatformPC,
+			Common::ADGF_NO_FLAGS
+		},
+		GID_FANMADE,
+		GType_V2,
+		GF_FANMADE | GF_AGIPAL,
+		0x2917,
+	},
+	{
+		{
+			"agi-fanmade",
+			"Unknown v3 Game",
+			AD_ENTRY1(0, 0),
+			Common::UNK_LANG,
+			Common::kPlatformPC,
+			Common::ADGF_NO_FLAGS
+		},
+		GID_FANMADE,
+		GType_V3,
+		GF_FANMADE,
+		0x3149,
+	},
+};
+
+Common::ADGameDescList fallbackDetector(const FSList *fslist) {
+	Common::String tstr;
+	typedef Common::HashMap<Common::String, int32, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> IntMap;
+	IntMap allFiles;
+	Common::ADGameDescList matched;
+	int matchedNum = -1;
+
+	// TODO:
+	// WinAGI produces *.wag file with interpretator version, game name
+	// and other parameters. Add support for this once specs are known
+
+
+	// First grab all filenames
+	for (FSList::const_iterator file = fslist->begin(); file != fslist->end(); ++file) {
+		if (file->isDirectory()) continue;
+		tstr = file->name();
+		tstr.toLowercase();
+
+		allFiles[tstr] = true;
+	}
+
+	// Now check for v2
+	if (allFiles.contains("logdir") && allFiles.contains("object") &&
+		allFiles.contains("picdir") && allFiles.contains("snddir") &&
+		allFiles.contains("viewdir") && allFiles.contains("vol.0") &&
+		allFiles.contains("words.tok")) {
+		matchedNum = 0;
+
+		// Check if it is AGIPAL
+		if (allFiles.contains("pal.101"))
+			matchedNum = 1;
+	} else { // Try v3
+		char name[8];
+
+		for (IntMap::const_iterator f = allFiles.begin(); f != allFiles.end(); ++f) {
+			debug(" --> %s", f->_key.c_str());
+			if (f->_key.hasSuffix("vol.0")) {
+				memset(name, 0, 8);
+				strncpy(name, f->_key.c_str(), f->_key.size() > 5 ? f->_key.size() - 5 : f->_key.size());
+				debug("YEAH! (%s)", name);
+
+				if (allFiles.contains("object") && allFiles.contains("words.tok") &&
+					allFiles.contains(Common::String(name) + "dir")) {
+					matchedNum = 2;
+					break;
+				}
+			}
+		}
+	}
+	
+	if (matchedNum != -1) {
+		matched.push_back(&fallbackDescs[matchedNum].desc);
+
+		printf("Your game version has been detected using fallback matching as a\n");
+		printf("variant of %s (%s).\n", fallbackDescs[matchedNum].desc.gameid, fallbackDescs[matchedNum].desc.extra);
+		printf("If this is an original and unmodified version or new made Fanmade game,\n");
+		printf("please report any, information previously printed by ScummVM to the team.\n");
+	}
+
+	return matched;
 }
 
+}
+
 static const Common::ADParams detectionParams = {
 	// Pointer to ADGameDescription or its superset structure
 	(const byte *)Agi::gameDescriptions,
@@ -1840,7 +1947,7 @@
 	// List of files for file-based fallback detection (optional)
 	0,
 	// Fallback callback
-	0,
+	Agi::fallbackDetector,
 	// Flags
 	Common::kADFlagAugmentPreferredTarget
 };


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