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

waltervn at users.sourceforge.net waltervn at users.sourceforge.net
Sat Aug 15 14:09:47 CEST 2009


Revision: 43407
          http://scummvm.svn.sourceforge.net/scummvm/?rev=43407&view=rev
Author:   waltervn
Date:     2009-08-15 12:09:47 +0000 (Sat, 15 Aug 2009)

Log Message:
-----------
SCI: Rename sci_version_t to SciVersion

Modified Paths:
--------------
    scummvm/trunk/engines/sci/detection.cpp
    scummvm/trunk/engines/sci/engine/state.cpp
    scummvm/trunk/engines/sci/engine/state.h
    scummvm/trunk/engines/sci/exereader.cpp
    scummvm/trunk/engines/sci/exereader.h
    scummvm/trunk/engines/sci/resource.cpp
    scummvm/trunk/engines/sci/resource.h
    scummvm/trunk/engines/sci/sci.cpp
    scummvm/trunk/engines/sci/sci.h

Modified: scummvm/trunk/engines/sci/detection.cpp
===================================================================
--- scummvm/trunk/engines/sci/detection.cpp	2009-08-15 11:50:59 UTC (rev 43406)
+++ scummvm/trunk/engines/sci/detection.cpp	2009-08-15 12:09:47 UTC (rev 43407)
@@ -3326,9 +3326,6 @@
 		}
 	}
 
-	if (exePlatform == Common::kPlatformUnknown)
-		return 0;
-
 	// If these files aren't found, it can't be SCI
 	if (!foundResMap && !foundRes000)
 		return 0;
@@ -3339,23 +3336,14 @@
 	s_fallbackDesc.desc.language = Common::UNK_LANG;
 	s_fallbackDesc.desc.platform = exePlatform;
 	s_fallbackDesc.desc.flags = ADGF_NO_FLAGS;
-	s_fallbackDesc.version = SCI_VERSION_0;
+	getSciVersionFromString(exeVersionString, &s_fallbackDesc.version, s_fallbackDesc.desc.platform);
 
 	printf("If this is *NOT* a fan-modified version (in particular, not a fan-made\n");
 	printf("translation), please, report the data above, including the following\n");
 	printf("version number, from the game's executable:\n");
+	printf("Version: %s\n\n", exeVersionString.empty() ? "not found" : exeVersionString.c_str());
 
-	// Try to parse the executable version
-	if (getSciVersionFromString(exeVersionString, &s_fallbackDesc.version, s_fallbackDesc.desc.platform)) {
-		printf("Detected version: %s, parsed SCI version: %s\n",
-					exeVersionString.c_str(), versionNames[s_fallbackDesc.version]);
-
-		return (const ADGameDescription *)&s_fallbackDesc;
-	} else {
-		printf("Couldn't parse the interpreter version: %s (by executable scan)\n",
-			exeVersionString.c_str());
-		return NULL;
-	}
+	return (const ADGameDescription *)&s_fallbackDesc;
 }
 
 bool SciMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const {

Modified: scummvm/trunk/engines/sci/engine/state.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/state.cpp	2009-08-15 11:50:59 UTC (rev 43406)
+++ scummvm/trunk/engines/sci/engine/state.cpp	2009-08-15 12:09:47 UTC (rev 43407)
@@ -27,7 +27,7 @@
 
 namespace Sci {
 
-EngineState::EngineState(ResourceManager *res, sci_version_t version, uint32 flags)
+EngineState::EngineState(ResourceManager *res, SciVersion version, uint32 flags)
 : resmgr(res), _version(version), _flags(flags), _dirseeker(this) {
 	widget_serial_counter = 0;
 

Modified: scummvm/trunk/engines/sci/engine/state.h
===================================================================
--- scummvm/trunk/engines/sci/engine/state.h	2009-08-15 11:50:59 UTC (rev 43406)
+++ scummvm/trunk/engines/sci/engine/state.h	2009-08-15 12:09:47 UTC (rev 43407)
@@ -126,7 +126,7 @@
 		kSegmentLength = 20 /**< Time segment length in ms */
 	};
 
-	SpeedThrottler(sci_version_t version) {
+	SpeedThrottler(SciVersion version) {
 		if (version >= SCI_VERSION_1_1)
 			_maxInstructions = 3300;
 		else if (version >= SCI_VERSION_1)
@@ -161,7 +161,7 @@
 
 struct EngineState : public Common::Serializable {
 public:
-	EngineState(ResourceManager *res, sci_version_t version, uint32 flags);
+	EngineState(ResourceManager *res, SciVersion version, uint32 flags);
 	virtual ~EngineState();
 	virtual void saveLoadWithSerializer(Common::Serializer &ser);
 
@@ -171,7 +171,7 @@
 
 	ResourceManager *resmgr; /**< The resource manager */
 
-	const sci_version_t _version; /**< The approximated patchlevel of the version to emulate */
+	const SciVersion _version; /**< The approximated patchlevel of the version to emulate */
 	const uint32 _flags;			/**< Specific game flags */
 
 	Common::String _gameName; /**< Designation of the primary object (which inherits from Game) */

Modified: scummvm/trunk/engines/sci/exereader.cpp
===================================================================
--- scummvm/trunk/engines/sci/exereader.cpp	2009-08-15 11:50:59 UTC (rev 43406)
+++ scummvm/trunk/engines/sci/exereader.cpp	2009-08-15 12:09:47 UTC (rev 43407)
@@ -276,7 +276,7 @@
 			currentString[9] = 0;
 
 			// Return the current string if it's parseable
-			int version;
+			SciVersion version;
 			if (getSciVersionFromString(currentString, &version, platform)) {
 				delete[] buffer;
 				return currentString;
@@ -296,61 +296,44 @@
 	return resultString;
 }
 
-bool getSciVersionFromString(Common::String versionString, int *version, Common::Platform platform) {
-	// Map non-numeric versions to their numeric counterparts
-	Common::String mappedVersion = versionString;
+bool getSciVersionFromString(Common::String versionString, SciVersion *version, Common::Platform platform) {
+	*version = SCI_VERSION_AUTODETECT;
+
 	if (platform == Common::kPlatformAmiga) {
 		if (versionString.hasPrefix("1.002.")) {
-			mappedVersion = "0.000.685";
+			*version = SCI_VERSION_0;
 		} else if (versionString.hasPrefix("1.003.")) {
-			mappedVersion = "0.001.010";
+			*version = SCI_VERSION_01;
 		} else if (versionString.hasPrefix("1.004.")) {
-			mappedVersion = "1.000.784";
+			*version = SCI_VERSION_01;
 		} else if (versionString.hasPrefix("1.005.")) {
-			mappedVersion = "1.000.510";
+			*version = SCI_VERSION_1;
 		} else if (versionString == "x.yyy.zzz") {
 			// How to map it?
+		} else {
+			return false;
 		}
 	} else if (versionString.hasPrefix("S.old.")) {
-		// SCI 01
-		mappedVersion = "0.001.";
-		mappedVersion += versionString.c_str() + 6;
+		*version = SCI_VERSION_01;
 	} else if (versionString.hasPrefix("1.ECO.")
 		|| versionString.hasPrefix("1.SQ1.")
 		|| versionString.hasPrefix("1.SQ4.")
 		|| versionString.hasPrefix("1.LS5.")
 		|| versionString.hasPrefix("1.pq3.")
-		|| versionString.hasPrefix("FAIRY.")) {
-		// SCI 1.0
-		mappedVersion = "1.000.";
-		mappedVersion += versionString.c_str() + 6;
-	} else if (versionString.hasPrefix("T.A00.")) {
-		mappedVersion = "1.000.510";
+		|| versionString.hasPrefix("FAIRY.")
+		|| versionString.hasPrefix("T.A00.")) {
+		*version = SCI_VERSION_1;
 	} else if (versionString.hasPrefix("L.rry.")
 		|| versionString.hasPrefix("l.cfs.")) {
-		// SCI 1.1
-		mappedVersion = "1.001.";
-		mappedVersion += versionString.c_str() + 6;
-	} else if (versionString == "x.yyy.yyy") {
+		*version = SCI_VERSION_1_1;
+	} else if (versionString == "x.yyy.zzz") {
 		// How to map it?
+	} else {
+		// Unknown or not a version number
+		return false;
 	}
 
-	// Parse to a version number
-	char *endptr[3];
-	const char *ver = mappedVersion.c_str();
-	int major = strtol(ver, &endptr[0], 10);
-	//int minor = strtol(ver + 2, &endptr[1], 10);
-	//int patchlevel = strtol(ver + 6, &endptr[2], 10);
-
-	if (endptr[0] != ver + 1 || endptr[1] != ver + 5 || *endptr[2] != '\0') {
-		warning("Failed to parse version string '%s'", ver);
-		return true;
-	}
-
-	//printf("Detected version: %s, parsed version: %s\n", versionString, ver);
-	*version = major;
-
-	return false;
+	return true;
 }
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/exereader.h
===================================================================
--- scummvm/trunk/engines/sci/exereader.h	2009-08-15 11:50:59 UTC (rev 43406)
+++ scummvm/trunk/engines/sci/exereader.h	2009-08-15 12:09:47 UTC (rev 43407)
@@ -33,7 +33,7 @@
 
 Common::Platform getGameExePlatform(Common::SeekableReadStream *exeStream);
 Common::String readSciVersionFromExe(Common::SeekableReadStream *exeStream, Common::Platform platform);
-bool getSciVersionFromString(Common::String versionString, int *version, Common::Platform platform);
+bool getSciVersionFromString(Common::String versionString, SciVersion *version, Common::Platform platform);
 
 } // End of namespace Sci
 

Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp	2009-08-15 11:50:59 UTC (rev 43406)
+++ scummvm/trunk/engines/sci/resource.cpp	2009-08-15 12:09:47 UTC (rev 43407)
@@ -319,7 +319,7 @@
 	return compressionMethod;
 }
 
-int ResourceManager::guessSciVersion() {
+SciVersion ResourceManager::guessSciVersion() {
 	Common::File file;
 	char filename[MAXPATHLEN];
 	int compression;

Modified: scummvm/trunk/engines/sci/resource.h
===================================================================
--- scummvm/trunk/engines/sci/resource.h	2009-08-15 11:50:59 UTC (rev 43406)
+++ scummvm/trunk/engines/sci/resource.h	2009-08-15 12:09:47 UTC (rev 43407)
@@ -45,6 +45,16 @@
 /** The maximum allowed size for a compressed or decompressed resource */
 #define SCI_MAX_RESOURCE_SIZE 0x0400000
 
+/** SCI versions */
+enum SciVersion {
+	SCI_VERSION_AUTODETECT = 0,
+	SCI_VERSION_0 = 1,
+	SCI_VERSION_01 = 2,
+	SCI_VERSION_1 = 3,
+	SCI_VERSION_1_1 = 4,
+	SCI_VERSION_32 = 5
+};
+
 /** Resource status types */
 enum ResourceStatus {
 	kResStatusNoMalloc = 0,
@@ -221,7 +231,7 @@
 	 * Returns the SCI version as detected by the resource manager
 	 * @return SCI version
 	 */
-	sci_version_t sciVersion() const { return _sciVersion; }
+	SciVersion sciVersion() const { return _sciVersion; }
 
 	/**
 	 * Creates a new SCI resource manager.
@@ -285,7 +295,7 @@
 	ResourceSource *_audioMapSCI1; //!< Currently loaded audio map for SCI1
 	ResVersion _volVersion; //!< RESOURCE.0xx version
 	ResVersion _mapVersion; //!< RESOURCE.MAP version
-	sci_version_t _sciVersion; //!< Detected SCI version */
+	SciVersion _sciVersion; //!< Detected SCI version */
 
 	/**
 	 * Add a path to the resource manager's list of sources.
@@ -393,7 +403,7 @@
 	void addToLRU(Resource *res);
 	void removeFromLRU(Resource *res);
 
-	int guessSciVersion();
+	SciVersion guessSciVersion();
 };
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2009-08-15 11:50:59 UTC (rev 43406)
+++ scummvm/trunk/engines/sci/sci.cpp	2009-08-15 12:09:47 UTC (rev 43407)
@@ -128,7 +128,7 @@
 
 	// FIXME/TODO: Move some of the stuff below to init()
 
-	sci_version_t version = getVersion();
+	SciVersion version = getVersion();
 	const uint32 flags = getFlags();
 
 	_resmgr = new ResourceManager(256 * 1024);
@@ -264,7 +264,7 @@
 	return _gameDescription->desc.gameid;
 }
 
-int SciEngine::getVersion() const {
+SciVersion SciEngine::getVersion() const {
 	return _gameDescription->version;
 }
 

Modified: scummvm/trunk/engines/sci/sci.h
===================================================================
--- scummvm/trunk/engines/sci/sci.h	2009-08-15 11:50:59 UTC (rev 43406)
+++ scummvm/trunk/engines/sci/sci.h	2009-08-15 12:09:47 UTC (rev 43407)
@@ -66,18 +66,9 @@
 struct SciGameDescription {
 	ADGameDescription desc;
 	uint32 flags;
-	sci_version_t version;
+	SciVersion version;
 };
 
-enum SciGameVersions {
-	SCI_VERSION_AUTODETECT = 0,
-	SCI_VERSION_0 = 1,
-	SCI_VERSION_01 = 2,
-	SCI_VERSION_1 = 3,
-	SCI_VERSION_1_1 = 4,
-	SCI_VERSION_32 = 5
-};
-
 extern const char *versionNames[6];
 
 enum SciGameFlags {
@@ -103,7 +94,7 @@
 
 	const char* getGameID() const;
 	int getResourceVersion() const;
-	int getVersion() const;
+	SciVersion getVersion() const;
 	Common::Language getLanguage() const;
 	Common::Platform getPlatform() const;
 	uint32 getFlags() const;


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