diff options
-rw-r--r-- | engines/sci/detection.cpp | 18 | ||||
-rw-r--r-- | engines/sci/engine/state.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/state.h | 6 | ||||
-rw-r--r-- | engines/sci/exereader.cpp | 57 | ||||
-rw-r--r-- | engines/sci/exereader.h | 2 | ||||
-rw-r--r-- | engines/sci/resource.cpp | 2 | ||||
-rw-r--r-- | engines/sci/resource.h | 16 | ||||
-rw-r--r-- | engines/sci/sci.cpp | 4 | ||||
-rw-r--r-- | engines/sci/sci.h | 13 |
9 files changed, 46 insertions, 74 deletions
diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp index eb01b7720e..7f9190444d 100644 --- a/engines/sci/detection.cpp +++ b/engines/sci/detection.cpp @@ -3326,9 +3326,6 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fsl } } - 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 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fsl 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 { diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index f0e9863068..fd45ef5834 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -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; diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h index a814a20df8..2fa1bd82a6 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -126,7 +126,7 @@ public: 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 @@ private: 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 @@ public: 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) */ diff --git a/engines/sci/exereader.cpp b/engines/sci/exereader.cpp index c1d279244c..304429c919 100644 --- a/engines/sci/exereader.cpp +++ b/engines/sci/exereader.cpp @@ -276,7 +276,7 @@ Common::String readSciVersionFromExe(Common::SeekableReadStream *exeStream, Comm 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 @@ Common::String readSciVersionFromExe(Common::SeekableReadStream *exeStream, Comm 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 diff --git a/engines/sci/exereader.h b/engines/sci/exereader.h index 5349ad3724..c614c4c0da 100644 --- a/engines/sci/exereader.h +++ b/engines/sci/exereader.h @@ -33,7 +33,7 @@ namespace Sci { 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 diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp index 126112d761..b42f36bd63 100644 --- a/engines/sci/resource.cpp +++ b/engines/sci/resource.cpp @@ -319,7 +319,7 @@ int sci0_get_compression_method(Common::ReadStream &stream) { return compressionMethod; } -int ResourceManager::guessSciVersion() { +SciVersion ResourceManager::guessSciVersion() { Common::File file; char filename[MAXPATHLEN]; int compression; diff --git a/engines/sci/resource.h b/engines/sci/resource.h index e6bacdab1d..3a51b3908e 100644 --- a/engines/sci/resource.h +++ b/engines/sci/resource.h @@ -45,6 +45,16 @@ namespace Sci { /** 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 @@ public: * 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 @@ protected: 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 @@ protected: void addToLRU(Resource *res); void removeFromLRU(Resource *res); - int guessSciVersion(); + SciVersion guessSciVersion(); }; } // End of namespace Sci diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 194a75a513..b4fe197962 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -128,7 +128,7 @@ Common::Error SciEngine::run() { // 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 @@ const char* SciEngine::getGameID() const { return _gameDescription->desc.gameid; } -int SciEngine::getVersion() const { +SciVersion SciEngine::getVersion() const { return _gameDescription->version; } diff --git a/engines/sci/sci.h b/engines/sci/sci.h index 8045b8ea96..43c0b9f8f8 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -66,16 +66,7 @@ enum kDebugLevels { struct SciGameDescription { ADGameDescription desc; uint32 flags; - sci_version_t 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 + SciVersion version; }; extern const char *versionNames[6]; @@ -103,7 +94,7 @@ public: const char* getGameID() const; int getResourceVersion() const; - int getVersion() const; + SciVersion getVersion() const; Common::Language getLanguage() const; Common::Platform getPlatform() const; uint32 getFlags() const; |