From ee16e35bb6c86323d69937992e34ac214e2005c2 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Thu, 19 Feb 2009 02:04:31 +0000 Subject: [PATCH] - Fix finding versions from exe's - Fix fallback detection - Make getVersion() return an int instead of a uint16 which makes the version lose precision and the "major" version can get lost. svn-id: r38529 --- engines/sci/detection.cpp | 46 +++++++++++++++++++++++++++++-- engines/sci/sci.h | 2 +- engines/sci/scicore/exe_lzexe.cpp | 2 +- engines/sci/scicore/exe_raw.cpp | 2 +- 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp index 861826ffc0c..8856ebe9b63 100644 --- a/engines/sci/detection.cpp +++ b/engines/sci/detection.cpp @@ -105,7 +105,7 @@ uint32 SciEngine::getFlags() const { return _gameDescription->desc.flags; } -uint16 SciEngine::getVersion() const { +int SciEngine::getVersion() const { return _gameDescription->version; } @@ -1320,6 +1320,24 @@ static const struct SciGameDescription SciGameDescriptions[] = { {AD_TABLE_END_MARKER, {}, SCI_VERSION(0, 000, 000)} }; +/** + * The fallback game descriptor used by the SCI engine's fallbackDetector. + * Contents of this struct are to be overwritten by the fallbackDetector. + */ +static SciGameDescription g_fallbackDesc = { + { + "", + "", + AD_ENTRY1(0, 0), // This should always be AD_ENTRY1(0, 0) in the fallback descriptor + Common::UNK_LANG, + Common::kPlatformPC, + ADGF_NO_FLAGS + }, + {}, + SCI_VERSION(0, 000, 000) +}; + + static const ADParams detectionParams = { // Pointer to ADGameDescription or its superset structure (const byte *)SciGameDescriptions, @@ -1358,19 +1376,41 @@ public: const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fslist) const { int exeVersion = 0; + bool foundResMap = false; + bool foundRes000 = false; // First grab all filenames for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { if (file->isDirectory()) continue; Common::String filename = file->getName(); filename.toLowercase(); + + if (filename.contains("resource.map") || filename.contains("resmap.000")) + foundResMap = true; + + if (filename.contains("resource.000") || filename.contains("resource.001") + || filename.contains("ressci.000") || filename.contains("ressci.001")) + foundRes000 = true; // FIXME: This is all quite hackish - if (filename.contains("scidhuv")) { + if (filename.contains("scidhuv") || filename.contains("sciv") || + filename.contains("sierra") || filename.contains("sciw")) { exeVersion = version_detect_from_executable((char *)file->getPath().c_str()); break; } } + + // If these files aren't found, it can't be SCI + if (!foundResMap && !foundRes000) + return 0; + + // Set some defaults + g_fallbackDesc.desc.gameid = "sci"; + g_fallbackDesc.desc.extra = ""; + g_fallbackDesc.desc.language = Common::UNK_LANG; + g_fallbackDesc.desc.platform = Common::kPlatformPC; + g_fallbackDesc.desc.flags = ADGF_NO_FLAGS; + g_fallbackDesc.version = exeVersion; 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"); @@ -1381,7 +1421,7 @@ const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fsl SCI_VERSION_MINOR(exeVersion), SCI_VERSION_PATCHLEVEL(exeVersion)); - return 0; + return (const ADGameDescription *)&g_fallbackDesc; } bool SciMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const { diff --git a/engines/sci/sci.h b/engines/sci/sci.h index 57d140f01a5..575fa5eadd9 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -64,7 +64,7 @@ public: const SciGameDescription *_gameDescription; const char* getGameID() const; - uint16 getVersion() const; + int getVersion() const; Common::Language getLanguage() const; Common::Platform getPlatform() const; uint32 getFlags() const; diff --git a/engines/sci/scicore/exe_lzexe.cpp b/engines/sci/scicore/exe_lzexe.cpp index a8876b3bc57..a7a1c31a082 100644 --- a/engines/sci/scicore/exe_lzexe.cpp +++ b/engines/sci/scicore/exe_lzexe.cpp @@ -217,7 +217,7 @@ lzexe_open(const char *filename) { guint8 size[2]; off_t fpos; - FILE *f = sci_fopen(filename, "rb"); + FILE *f = fopen(filename, "rb"); if (!f) return NULL; diff --git a/engines/sci/scicore/exe_raw.cpp b/engines/sci/scicore/exe_raw.cpp index 17d46f524f8..69daaca45fb 100644 --- a/engines/sci/scicore/exe_raw.cpp +++ b/engines/sci/scicore/exe_raw.cpp @@ -33,7 +33,7 @@ struct _exe_handle { static exe_handle_t * raw_open(const char *filename) { - FILE *f = sci_fopen(filename, "rb"); + FILE *f = fopen(filename, "rb"); exe_handle_t *handle; if (!f)