aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Göffringmann2004-12-09 15:06:49 +0000
committerRobert Göffringmann2004-12-09 15:06:49 +0000
commit0d7ab01640a2209167272936c624c32142131993 (patch)
treed9ec454332093ae1a6c4ca7f9b2954c5d4852e78
parent58bf9028b16a1a6d125baa79b223de5e2a5aa0e0 (diff)
downloadscummvm-rg350-0d7ab01640a2209167272936c624c32142131993.tar.gz
scummvm-rg350-0d7ab01640a2209167272936c624c32142131993.tar.bz2
scummvm-rg350-0d7ab01640a2209167272936c624c32142131993.zip
Pass subdirectories to gamedetector functions
svn-id: r16002
-rw-r--r--gui/launcher.cpp2
-rw-r--r--kyra/kyra.cpp10
-rw-r--r--queen/queen.cpp12
-rw-r--r--saga/game.cpp14
-rw-r--r--scumm/scumm.cpp16
-rw-r--r--simon/simon.cpp14
-rw-r--r--sky/sky.cpp12
-rw-r--r--sword1/sword1.cpp76
-rw-r--r--sword2/sword2.cpp12
9 files changed, 100 insertions, 68 deletions
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 130e008f7c..0e5b6c2703 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -506,7 +506,7 @@ void LauncherDialog::addGame() {
if (_browser->runModal() > 0) {
// User made his choice...
FilesystemNode dir(_browser->getResult());
- FSList files = dir.listDir(FilesystemNode::kListFilesOnly);
+ FSList files = dir.listDir(FilesystemNode::kListAll);
// ...so let's determine a list of candidates, games that
// could be contained in the specified directory.
diff --git a/kyra/kyra.cpp b/kyra/kyra.cpp
index fb42bbe4c4..3ed497581d 100644
--- a/kyra/kyra.cpp
+++ b/kyra/kyra.cpp
@@ -77,10 +77,12 @@ DetectedGameList Engine_KYRA_detectGames(const FSList &fslist) {
continue;
for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
- const char *name = file->displayName().c_str();
- if ((!scumm_stricmp(game->detectName, name))) {
- detectedGames.push_back(game->toGameSettings());
- break;
+ if (!file->isDirectory()) {
+ const char *name = file->displayName().c_str();
+ if ((!scumm_stricmp(game->detectName, name))) {
+ detectedGames.push_back(game->toGameSettings());
+ break;
+ }
}
}
}
diff --git a/queen/queen.cpp b/queen/queen.cpp
index f386300696..1ed5501291 100644
--- a/queen/queen.cpp
+++ b/queen/queen.cpp
@@ -64,12 +64,14 @@ DetectedGameList Engine_QUEEN_detectGames(const FSList &fslist) {
// Iterate over all files in the given directory
for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
- const char *gameName = file->displayName().c_str();
+ if (!file->isDirectory()) {
+ const char *gameName = file->displayName().c_str();
- if (0 == scumm_stricmp("queen.1", gameName) || 0 == scumm_stricmp("queen.1c", gameName)) {
- // Match found, add to list of candidates, then abort loop.
- detectedGames.push_back(queen_setting);
- break;
+ if (0 == scumm_stricmp("queen.1", gameName) || 0 == scumm_stricmp("queen.1c", gameName)) {
+ // Match found, add to list of candidates, then abort loop.
+ detectedGames.push_back(queen_setting);
+ break;
+ }
}
}
return detectedGames;
diff --git a/saga/game.cpp b/saga/game.cpp
index 1466daa4d9..d04ac2412f 100644
--- a/saga/game.cpp
+++ b/saga/game.cpp
@@ -385,12 +385,14 @@ DetectedGameList GAME_ProbeGame(const FSList &fslist) {
file_missing = 1;
// Iterate over all files in the given directory
for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
- const char *gameName = file->displayName().c_str();
-
- if (0 == scumm_stricmp(GameDescs[game_n].gd_filedescs[file_n].gf_fname,
- gameName)) {
- file_missing = 0;
- break;
+ if (!file->isDirectory()) {
+ const char *gameName = file->displayName().c_str();
+
+ if (0 == scumm_stricmp(GameDescs[game_n].gd_filedescs[file_n].gf_fname,
+ gameName)) {
+ file_missing = 0;
+ break;
+ }
}
}
diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp
index 365e3d4e56..18f746f73c 100644
--- a/scumm/scumm.cpp
+++ b/scumm/scumm.cpp
@@ -2678,13 +2678,15 @@ DetectedGameList Engine_SCUMM_detectGames(const FSList &fslist) {
// Iterate over all files in the given directory
for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
- const char *name = file->displayName().c_str();
-
- if (0 == scumm_stricmp(detectName, name)) {
- // Match found, add to list of candidates, then abort inner loop.
- detectedGames.push_back(g->toGameSettings());
- fileSet.addKey(file->path());
- break;
+ if (!file->isDirectory()) {
+ const char *name = file->displayName().c_str();
+
+ if (0 == scumm_stricmp(detectName, name)) {
+ // Match found, add to list of candidates, then abort inner loop.
+ detectedGames.push_back(g->toGameSettings());
+ fileSet.addKey(file->path());
+ break;
+ }
}
}
}
diff --git a/simon/simon.cpp b/simon/simon.cpp
index 579f40da05..96c3f96a7c 100644
--- a/simon/simon.cpp
+++ b/simon/simon.cpp
@@ -113,13 +113,15 @@ DetectedGameList Engine_SIMON_detectGames(const FSList &fslist) {
// Iterate over all files in the given directory
for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
- const char *name = file->displayName().c_str();
+ if (!file->isDirectory()) {
+ const char *name = file->displayName().c_str();
- if ((!scumm_stricmp(detectName, name)) || (!scumm_stricmp(detectName2, name))) {
- // Match found, add to list of candidates, then abort inner loop.
- detectedGames.push_back(g->toGameSettings());
- fileSet.addKey(file->path());
- break;
+ if ((!scumm_stricmp(detectName, name)) || (!scumm_stricmp(detectName2, name))) {
+ // Match found, add to list of candidates, then abort inner loop.
+ detectedGames.push_back(g->toGameSettings());
+ fileSet.addKey(file->path());
+ break;
+ }
}
}
}
diff --git a/sky/sky.cpp b/sky/sky.cpp
index 048044d43f..bf6b742e1f 100644
--- a/sky/sky.cpp
+++ b/sky/sky.cpp
@@ -90,12 +90,14 @@ DetectedGameList Engine_SKY_detectGames(const FSList &fslist) {
DetectedGameList detectedGames;
// Iterate over all files in the given directory
for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
- const char *fileName = file->displayName().c_str();
+ if (!file->isDirectory()) {
+ const char *fileName = file->displayName().c_str();
- if (0 == scumm_stricmp("sky.dsk", fileName)) {
- // Match found, add to list of candidates, then abort inner loop.
- detectedGames.push_back(skySetting);
- break;
+ if (0 == scumm_stricmp("sky.dsk", fileName)) {
+ // Match found, add to list of candidates, then abort inner loop.
+ detectedGames.push_back(skySetting);
+ break;
+ }
}
}
return detectedGames;
diff --git a/sword1/sword1.cpp b/sword1/sword1.cpp
index 005467e706..1adeeb66ef 100644
--- a/sword1/sword1.cpp
+++ b/sword1/sword1.cpp
@@ -46,44 +46,62 @@
using namespace Sword1;
/* Broken Sword 1 */
-static const GameSettings sword1_settings[] = {
- {"sword1", "Broken Sword I", GF_DEFAULT_TO_1X_SCALER},
- {"sword1demo", "Broken Sword I (Demo)", GF_DEFAULT_TO_1X_SCALER | Sword1::GF_DEMO },
- { NULL, NULL, 0 }
+static const GameSettings sword1FullSettings =
+ {"sword1", "Broken Sword I", GF_DEFAULT_TO_1X_SCALER};
+static const GameSettings sword1DemoSettings =
+ {"sword1demo", "Broken Sword I (Demo)", GF_DEFAULT_TO_1X_SCALER | Sword1::GF_DEMO };
+
+// check these subdirectories (if present)
+static const char *g_dirNames[] = { "clusters", "speech" };
+
+#define NUM_FILES_TO_CHECK 5
+static const char *g_filesToCheck[NUM_FILES_TO_CHECK] = { // these files have to be found
+ "swordres.rif",
+ "general.clu",
+ "compacts.clu",
+ "scripts.clu",
+ "cows.mad", // this one should only exist in the demo version
+ // the engine needs several more files to work, but checking these should be sufficient
};
GameList Engine_SWORD1_gameList() {
- const GameSettings *g = sword1_settings;
GameList games;
- while (g->name) {
- games.push_back(*g);
- g++;
- }
+ games.push_back(sword1FullSettings);
+ games.push_back(sword1DemoSettings);
return games;
}
-DetectedGameList Engine_SWORD1_detectGames(const FSList &fslist) {
- DetectedGameList detectedGames;
- const GameSettings *g = sword1_settings;
-
- // TODO: It would be nice if we had code here which distinguishes
- // between the 'sword1' and 'sword1demo' targets.
-
- while (g->name) {
- // Iterate over all files in the given directory
- for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
- const char *gameName = file->displayName().c_str();
-
- if ((0 == scumm_stricmp("swordres.rif", gameName)) ||
- (0 == scumm_stricmp("cd1.id", gameName)) ||
- (0 == scumm_stricmp("cd2.id", gameName))) {
- // Match found, add to list of candidates, then abort inner loop.
- detectedGames.push_back(*g);
- break;
- }
+void Sword1CheckDirectory(const FSList &fslist, bool *filesFound) {
+ for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
+ if (!file->isDirectory()) {
+ const char *fileName = file->displayName().c_str();
+ for (int cnt = 0; cnt < NUM_FILES_TO_CHECK; cnt++)
+ if (scumm_stricmp(fileName, g_filesToCheck[cnt]) == 0)
+ filesFound[cnt] = true;
+ } else {
+ for (int cnt = 0; cnt < ARRAYSIZE(g_dirNames); cnt++)
+ if (scumm_stricmp(file->displayName().c_str(), g_dirNames[cnt]) == 0)
+ Sword1CheckDirectory(file->listDir(AbstractFilesystemNode::kListFilesOnly), filesFound);
}
- g++;
}
+}
+
+DetectedGameList Engine_SWORD1_detectGames(const FSList &fslist) {
+ DetectedGameList detectedGames;
+ bool filesFound[NUM_FILES_TO_CHECK];
+ for (int i = 0; i < NUM_FILES_TO_CHECK; i++)
+ filesFound[i] = false;
+
+ Sword1CheckDirectory(fslist, filesFound);
+ bool mainFilesFound = true;
+ for (int i = 0; i < NUM_FILES_TO_CHECK -1; i++)
+ if (!filesFound[i])
+ mainFilesFound = false;
+
+ if (mainFilesFound && filesFound[NUM_FILES_TO_CHECK - 1])
+ detectedGames.push_back(sword1DemoSettings);
+ else if (mainFilesFound)
+ detectedGames.push_back(sword1FullSettings);
return detectedGames;
}
diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp
index 27ce3e0ae3..82d7d0c0b7 100644
--- a/sword2/sword2.cpp
+++ b/sword2/sword2.cpp
@@ -80,12 +80,14 @@ DetectedGameList Engine_SWORD2_detectGames(const FSList &fslist) {
for (g = sword2_settings; g->name; ++g) {
// Iterate over all files in the given directory
for (FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
- const char *gameName = file->displayName().c_str();
+ if (!file->isDirectory()) {
+ const char *gameName = file->displayName().c_str();
- if (0 == scumm_stricmp(g->detectname, gameName)) {
- // Match found, add to list of candidates, then abort inner loop.
- detectedGames.push_back(g->toGameSettings());
- break;
+ if (0 == scumm_stricmp(g->detectname, gameName)) {
+ // Match found, add to list of candidates, then abort inner loop.
+ detectedGames.push_back(g->toGameSettings());
+ break;
+ }
}
}
}