aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm
diff options
context:
space:
mode:
authorJohannes Schickel2014-07-05 14:08:24 +0200
committerJohannes Schickel2014-07-05 14:16:20 +0200
commitc44c46a4fbd778d32b522d5a004167c5847e7778 (patch)
tree0361b893a3395e63d9b4f50fb09c99ad41dbeb18 /engines/scumm
parent44ac74119bd5eb827ad15aebf087905124132e3f (diff)
downloadscummvm-rg350-c44c46a4fbd778d32b522d5a004167c5847e7778.tar.gz
scummvm-rg350-c44c46a4fbd778d32b522d5a004167c5847e7778.tar.bz2
scummvm-rg350-c44c46a4fbd778d32b522d5a004167c5847e7778.zip
SCUMM: Simplify index file handling for Steam versions.
This also makes sure that all extra needed detection data for the Steam releases is located inside detection.cpp.
Diffstat (limited to 'engines/scumm')
-rw-r--r--engines/scumm/detection.cpp34
-rw-r--r--engines/scumm/file.cpp27
-rw-r--r--engines/scumm/file.h25
-rw-r--r--engines/scumm/scumm.cpp7
4 files changed, 50 insertions, 43 deletions
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index e77047d1b7..87c1aa1505 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -211,14 +211,29 @@ Common::String ScummEngine_v70he::generateFilename(const int room) const {
return result;
}
-static const char *getSteamExeNameFromPattern(Common::String pattern, Common::Platform platform) {
+// The following table includes all the index files, which are embedded in the
+// main game executables in Steam versions.
+static const SteamIndexFile steamIndexFiles[] = {
+ { GID_INDY3, Common::kPlatformWindows, "%02d.LFL", "00.LFL", "Indiana Jones and the Last Crusade.exe", 162056, 6295 },
+ { GID_INDY3, Common::kPlatformMacintosh, "%02d.LFL", "00.LFL", "The Last Crusade", 150368, 6295 },
+ { GID_INDY4, Common::kPlatformWindows, "atlantis.%03d", "ATLANTIS.000", "Indiana Jones and the Fate of Atlantis.exe", 224336, 12035 },
+ { GID_INDY4, Common::kPlatformMacintosh, "atlantis.%03d", "ATLANTIS.000", "The Fate of Atlantis", 260224, 12035 },
+ { GID_LOOM, Common::kPlatformWindows, "%03d.LFL", "000.LFL", "Loom.exe", 187248, 8307 },
+ { GID_LOOM, Common::kPlatformMacintosh, "%03d.LFL", "000.LFL", "Loom", 170464, 8307 },
+#ifdef ENABLE_SCUMM_7_8
+ { GID_DIG, Common::kPlatformWindows, "dig.la%d", "DIG.LA0", "The Dig.exe", 340632, 16304 },
+ { GID_DIG, Common::kPlatformMacintosh, "dig.la%d", "DIG.LA0", "The Dig", 339744, 16304 },
+#endif
+ { 0, Common::kPlatformUnknown, "", "", "", 0, 0 }
+};
+
+const SteamIndexFile *lookUpSteamIndexFile(Common::String pattern, Common::Platform platform) {
for (const SteamIndexFile *indexFile = steamIndexFiles; indexFile->len; ++indexFile) {
if (platform == indexFile->platform && pattern.equalsIgnoreCase(indexFile->pattern))
- return indexFile->executableName;
+ return indexFile;
}
- error("Unable to find Steam executable from detection pattern");
- return "";
+ return nullptr;
}
static Common::String generateFilenameForDetection(const char *pattern, FilenameGenMethod genMethod, Common::Platform platform) {
@@ -231,9 +246,14 @@ static Common::String generateFilenameForDetection(const char *pattern, Filename
break;
case kGenDiskNumSteam:
- case kGenRoomNumSteam:
- result = getSteamExeNameFromPattern(pattern, platform);
- break;
+ case kGenRoomNumSteam: {
+ const SteamIndexFile *indexFile = lookUpSteamIndexFile(pattern, platform);
+ if (!indexFile) {
+ error("Unable to find Steam executable from detection pattern");
+ } else {
+ result = indexFile->executableName;
+ }
+ } break;
case kGenHEPC:
case kGenHEIOS:
diff --git a/engines/scumm/file.cpp b/engines/scumm/file.cpp
index 8f6fdbe0cf..475ffa3238 100644
--- a/engines/scumm/file.cpp
+++ b/engines/scumm/file.cpp
@@ -29,22 +29,6 @@
namespace Scumm {
-// The following table includes all the index files, which are embedded in the
-// main game executables in Steam versions.
-const SteamIndexFile steamIndexFiles[] = {
- { GID_INDY3, Common::kPlatformWindows, "%02d.LFL", "00.LFL", "Indiana Jones and the Last Crusade.exe", 162056, 6295 },
- { GID_INDY3, Common::kPlatformMacintosh, "%02d.LFL", "00.LFL", "The Last Crusade", 150368, 6295 },
- { GID_INDY4, Common::kPlatformWindows, "atlantis.%03d", "ATLANTIS.000", "Indiana Jones and the Fate of Atlantis.exe", 224336, 12035 },
- { GID_INDY4, Common::kPlatformMacintosh, "atlantis.%03d", "ATLANTIS.000", "The Fate of Atlantis", 260224, 12035 },
- { GID_LOOM, Common::kPlatformWindows, "%03d.LFL", "000.LFL", "Loom.exe", 187248, 8307 },
- { GID_LOOM, Common::kPlatformMacintosh, "%03d.LFL", "000.LFL", "Loom", 170464, 8307 },
-#ifdef ENABLE_SCUMM_7_8
- { GID_DIG, Common::kPlatformWindows, "dig.la%d", "DIG.LA0", "The Dig.exe", 340632, 16304 },
- { GID_DIG, Common::kPlatformMacintosh, "dig.la%d", "DIG.LA0", "The Dig", 339744, 16304 },
-#endif
- { 0, Common::kPlatformUnknown, "", "", "", 0, 0 }
-};
-
#pragma mark -
#pragma mark --- ScummFile ---
#pragma mark -
@@ -205,13 +189,12 @@ uint32 ScummFile::read(void *dataPtr, uint32 dataSize) {
#pragma mark -
bool ScummSteamFile::open(const Common::String &filename) {
- for (const SteamIndexFile *indexFile = steamIndexFiles; indexFile->len; ++indexFile) {
- if (indexFile->id == _steamGame.id && indexFile->platform == _steamGame.platform && filename.equalsIgnoreCase(indexFile->indexFileName))
- return openWithSubRange(indexFile->executableName, indexFile->start, indexFile->len);
+ if (filename.equalsIgnoreCase(_indexFile.indexFileName)) {
+ return openWithSubRange(_indexFile.executableName, _indexFile.start, _indexFile.len);
+ } else {
+ // Regular non-bundled file
+ return ScummFile::open(filename);
}
-
- // Regular non-bundled file
- return ScummFile::open(filename);
}
bool ScummSteamFile::openWithSubRange(const Common::String &filename, int32 subFileStart, int32 subFileLen) {
diff --git a/engines/scumm/file.h b/engines/scumm/file.h
index f3eaac5d32..e7c1eb6d71 100644
--- a/engines/scumm/file.h
+++ b/engines/scumm/file.h
@@ -76,18 +76,6 @@ public:
uint32 read(void *dataPtr, uint32 dataSize);
};
-class ScummSteamFile : public ScummFile {
-private:
- GameSettings _steamGame;
-
- bool openWithSubRange(const Common::String &filename, int32 subFileStart, int32 subFileLen);
-
-public:
- ScummSteamFile(GameSettings game) : ScummFile(), _steamGame(game) {}
-
- bool open(const Common::String &filename);
-};
-
class ScummDiskImage : public BaseScummFile {
private:
Common::SeekableReadStream *_stream;
@@ -142,7 +130,18 @@ struct SteamIndexFile {
int32 len;
};
-extern const SteamIndexFile steamIndexFiles[];
+const SteamIndexFile *lookUpSteamIndexFile(Common::String pattern, Common::Platform platform);
+
+class ScummSteamFile : public ScummFile {
+private:
+ const SteamIndexFile &_indexFile;
+
+ bool openWithSubRange(const Common::String &filename, int32 subFileStart, int32 subFileLen);
+public:
+ ScummSteamFile(const SteamIndexFile &indexFile) : ScummFile(), _indexFile(indexFile) {}
+
+ bool open(const Common::String &filename);
+};
} // End of namespace Scumm
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 8c0325934d..73776bad5a 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -1161,7 +1161,12 @@ Common::Error ScummEngine::init() {
} else {
if (_filenamePattern.genMethod == kGenDiskNumSteam || _filenamePattern.genMethod == kGenRoomNumSteam) {
// Steam game versions have the index file embedded in the main executable
- _fileHandle = new ScummSteamFile(_game);
+ const SteamIndexFile *indexFile = lookUpSteamIndexFile(_filenamePattern.pattern, _game.platform);
+ if (!indexFile || indexFile->id != _game.id) {
+ error("Couldn't find index file description for Steam version");
+ } else {
+ _fileHandle = new ScummSteamFile(*indexFile);
+ }
} else {
// Regular access, no container file involved
_fileHandle = new ScummFile();