static int findGames(Game *games, int max) { Dir *dirs = new Dir[MAX_DIR]; int curr_game = 0, curr_dir = 0, num_dirs = 1; dirs[0].node = Common::FSNode(""); while (curr_game < max && curr_dir < num_dirs) { strncpy(dirs[curr_dir].name, dirs[curr_dir].node.getPath().c_str(), 252); dirs[curr_dir].name[251] = '\0'; 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 (num_dirs < MAX_DIR && strcasecmp(entry->getDisplayName().c_str(), "install")) { dirs[num_dirs].node = *entry; num_dirs++; } } else if (isIcon(*entry)) strcpy(dirs[curr_dir-1].deficon, entry->getDisplayName().c_str()); else files.push_back(*entry); } GameList candidates = EngineMan.detectGames(files); for (GameList::const_iterator ge = candidates.begin(); ge != candidates.end(); ++ge) if (curr_game < max) { strcpy(games[curr_game].filename_base, ge->gameid().c_str()); strcpy(games[curr_game].dir, dirs[curr_dir-1].name); games[curr_game].language = ge->language(); games[curr_game].platform = ge->platform(); if (uniqueGame(games[curr_game].filename_base, games[curr_game].dir, games[curr_game].language, games[curr_game].platform, games, curr_game)) { strcpy(games[curr_game].text, ge->description().c_str()); #if 0 printf("Registered game <%s> (l:%d p:%d) in <%s> <%s> because of <%s> <*>\n", games[curr_game].text, (int)games[curr_game].language, (int)games[curr_game].platform, games[curr_game].dir, games[curr_game].filename_base, dirs[curr_dir-1].name); #endif curr_game++; } } } for (int i=0; i<curr_game; i++) if (!loadIcon(games[i], dirs, num_dirs)) makeDefIcon(games[i].icon); delete[] dirs; return curr_game; }