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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Aug 26 02:27:15 CEST 2009


Revision: 43749
          http://scummvm.svn.sourceforge.net/scummvm/?rev=43749&view=rev
Author:   thebluegr
Date:     2009-08-26 00:27:14 +0000 (Wed, 26 Aug 2009)

Log Message:
-----------
Added automatic detection of the game language to the fallback detector

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

Modified: scummvm/trunk/engines/sci/detection.cpp
===================================================================
--- scummvm/trunk/engines/sci/detection.cpp	2009-08-25 23:39:21 UTC (rev 43748)
+++ scummvm/trunk/engines/sci/detection.cpp	2009-08-26 00:27:14 UTC (rev 43749)
@@ -257,15 +257,35 @@
 	return sierraId;
 }
 
+Common::Language charToScummVMLanguage(const char c) {
+	switch (c) {
+	case 'F':
+		return Common::FR_FRA;
+	case 'S':
+		return Common::ES_ESP;
+	case 'I':
+		return Common::IT_ITA;
+	case 'G':
+		return Common::DE_DEU;
+	case 'J':
+	case 'j':
+		return Common::JA_JPN;
+	case 'P':
+		return Common::PT_BRA;
+	default:
+		return Common::UNK_LANG;
+	}
+}
+
 const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fslist) const {
 	bool foundResMap = false;
 	bool foundRes000 = false;
 
 	// Set some defaults
 	s_fallbackDesc.desc.extra = "";
-	s_fallbackDesc.desc.language = Common::UNK_LANG;
+	s_fallbackDesc.desc.language = Common::EN_ANY;
 	s_fallbackDesc.desc.flags = ADGF_NO_FLAGS;
-	s_fallbackDesc.desc.platform = Common::kPlatformUnknown;
+	s_fallbackDesc.desc.platform = Common::kPlatformPC;	// default to PC platform
 	s_fallbackDesc.desc.gameid = "sci";
 
 	// First grab all filenames
@@ -318,6 +338,18 @@
 		if (filename.contains("resource.000") || filename.contains("resource.001")
 			|| filename.contains("ressci.000") || filename.contains("ressci.001"))
 			foundRes000 = true;
+
+		// Determine the game platform
+		// The existence of any of these files indicates an Amiga game
+		if (filename.contains("9.pat") || filename.contains("spal") ||
+			filename.contains("patch.005") || filename.contains("bank.001"))
+				s_fallbackDesc.desc.platform = Common::kPlatformAmiga;
+
+		// The existence of 7.pat indicates a Mac game
+		if (filename.contains("7.pat"))
+			s_fallbackDesc.desc.platform = Common::kPlatformMacintosh;
+	
+		// The data files for Atari ST versions are the same as their DOS counterparts
 	}
 
 	// If these files aren't found, it can't be SCI
@@ -350,32 +382,12 @@
 	if (gameViews == kViewEga)
 		s_fallbackDesc.desc.extra = "EGA";
 
-	SegManager *segManager = new SegManager(resourceManager);
-	Common::Platform gamePlatform = Common::kPlatformUnknown;
+	// Set the platform to Amiga if the game is using Amiga views
+	if (gameViews == kViewAmiga)
+		s_fallbackDesc.desc.platform = Common::kPlatformAmiga;
 
-	// Try to determine the platform from game resources
-	if (gameViews == kViewEga || gameViews == kViewVga ||
-		gameViews == kViewVga11) {
-		// Must be PC or Mac, set to PC for now
-		gamePlatform = Common::kPlatformPC;
-	} else if (gameViews == kViewAmiga) {
-		gamePlatform = Common::kPlatformAmiga;
-	}
-
-	// The existence of any of these files indicates an Amiga game
-	if (Common::File::exists("9.pat") || Common::File::exists("spal") ||
-		Common::File::exists("patch.005") || Common::File::exists("bank.001"))
-		gamePlatform = Common::kPlatformAmiga;
-
-	// The existence of 7.pat indicates a Mac game
-	if (Common::File::exists("7.pat"))
-		gamePlatform = Common::kPlatformMacintosh;
-	
-	// The data files for Atari ST versions are the same as their DOS counterparts
-
-	s_fallbackDesc.desc.platform = gamePlatform;
-
 	// Determine the game id
+	SegManager *segManager = new SegManager(resourceManager);
 	if (!script_instantiate(resourceManager, segManager, 0)) {
 		warning("fallbackDetect(): Could not instantiate script 0");
 		SearchMan.remove("SCI_detection");
@@ -389,6 +401,24 @@
 	gameName.toLowercase();
 	s_fallbackDesc.desc.gameid = strdup(convertSierraGameId(gameName).c_str());
 	delete segManager;
+
+	// Try to determine the game language
+	// Load up text 0 and start looking for "#" characters
+	// Non-English versions contain strings like XXXX#YZZZZ
+	// Where XXXX is the English string, #Y a separator indicating the language
+	// (e.g. #G for German) and the translated text
+	Resource *text = resourceManager->findResource(ResourceId(kResourceTypeText, 0), 0);
+	uint seeker = 0;
+	if (text) {
+		while (seeker < text->size) {
+			if (text->data[seeker] == '#') {
+				s_fallbackDesc.desc.language = charToScummVMLanguage(text->data[seeker + 1]);
+				break;
+			}
+			seeker++;
+		}
+	}
+
 	delete resourceManager;
 
 	SearchMan.remove("SCI_detection");


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