aboutsummaryrefslogtreecommitdiff
path: root/sword1
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 /sword1
parent58bf9028b16a1a6d125baa79b223de5e2a5aa0e0 (diff)
downloadscummvm-rg350-0d7ab01640a2209167272936c624c32142131993.tar.gz
scummvm-rg350-0d7ab01640a2209167272936c624c32142131993.tar.bz2
scummvm-rg350-0d7ab01640a2209167272936c624c32142131993.zip
Pass subdirectories to gamedetector functions
svn-id: r16002
Diffstat (limited to 'sword1')
-rw-r--r--sword1/sword1.cpp76
1 files changed, 47 insertions, 29 deletions
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;
}