From 5b2e90504c210dbffcdfc8eafbdc84635de79134 Mon Sep 17 00:00:00 2001 From: Marcus Comstedt Date: Sun, 17 Jul 2011 20:59:07 +0200 Subject: DC: Directory handling fixes * Include directory nodes in FSList sent to detectGames - This is required for correct detection of toon. * Don't add / at the end of directories found in getChildren - It looks like that behaviour was removed from posix-fs a long time ago, and now there's apparently code depending on directories _not_ having a / at the end of their name... * Treat games detected in subdirs as duplicates - This is a workaround for a detection bug in toon; it will incorrectly detect the game in the MISC subdirectory as well. * Don't avoid directories called "install" in the game selector - I don't know if the original reason for ignoring "install" is still valid, but the code for doing do so was broken anyway. --- backends/platform/dc/dc-fs.cpp | 2 +- backends/platform/dc/selector.cpp | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) (limited to 'backends/platform') diff --git a/backends/platform/dc/dc-fs.cpp b/backends/platform/dc/dc-fs.cpp index ac709f62b9..c46f9df093 100644 --- a/backends/platform/dc/dc-fs.cpp +++ b/backends/platform/dc/dc-fs.cpp @@ -124,7 +124,7 @@ bool RoninCDDirectoryNode::getChildren(AbstractFSList &myList, ListMode mode, bo if (mode == Common::FSNode::kListFilesOnly) continue; - myList.push_back(new RoninCDDirectoryNode(newPath+"/")); + myList.push_back(new RoninCDDirectoryNode(newPath)); } else { // Honor the chosen mode if (mode == Common::FSNode::kListDirectoriesOnly) diff --git a/backends/platform/dc/selector.cpp b/backends/platform/dc/selector.cpp index 859f2a40ed..339e5df62d 100644 --- a/backends/platform/dc/selector.cpp +++ b/backends/platform/dc/selector.cpp @@ -185,12 +185,24 @@ static void makeDefIcon(Icon &icon) icon.load(scummvm_icon, sizeof(scummvm_icon)); } +static bool sameOrSubdir(const char *dir1, const char *dir2) +{ + int l1 = strlen(dir1), l2 = strlen(dir2); + if (l1<=l2) + return !strcmp(dir1, dir2); + else + return !memcmp(dir1, dir2, l2); +} + static bool uniqueGame(const char *base, const char *dir, Common::Language lang, Common::Platform plf, Game *games, int cnt) { while (cnt--) - if (!strcmp(dir, games->dir) && + if (/*Don't detect the same game in a subdir, + this is a workaround for the detector bug in toon... */ + sameOrSubdir(dir, games->dir) && + /*!strcmp(dir, games->dir) &&*/ !stricmp(base, games->filename_base) && lang == games->language && plf == games->platform) @@ -237,19 +249,24 @@ static int findGames(Game *games, int max, bool use_ini) } while ((curr_game < max || use_ini) && curr_dir < num_dirs) { - strncpy(dirs[curr_dir].name, dirs[curr_dir].node.getPath().c_str(), 252); - dirs[curr_dir].name[251] = '\0'; + strncpy(dirs[curr_dir].name, dirs[curr_dir].node.getPath().c_str(), 251); + dirs[curr_dir].name[250] = '\0'; + if (!dirs[curr_dir].name[0] || + dirs[curr_dir].name[strlen(dirs[curr_dir].name)-1] != '/') + strcat(dirs[curr_dir].name, "/"); dirs[curr_dir].deficon[0] = '\0'; Common::FSList files, fslist; dirs[curr_dir++].node.getChildren(fslist, Common::FSNode::kListAll); for (Common::FSList::const_iterator entry = fslist.begin(); entry != fslist.end(); ++entry) { if (entry->isDirectory()) { - if (!use_ini && num_dirs < MAX_DIR && - strcasecmp(entry->getDisplayName().c_str(), "install")) { + if (!use_ini && num_dirs < MAX_DIR) { dirs[num_dirs].node = *entry; num_dirs++; } + /* Toonstruck detector needs directories to be present too */ + if(!use_ini) + files.push_back(*entry); } else if (isIcon(*entry)) strcpy(dirs[curr_dir-1].deficon, entry->getDisplayName().c_str()); -- cgit v1.2.3