diff --git a/JGE/src/JFileSystem.cpp b/JGE/src/JFileSystem.cpp index 1b4f0680d..57e7b44dc 100644 --- a/JGE/src/JFileSystem.cpp +++ b/JGE/src/JFileSystem.cpp @@ -385,7 +385,11 @@ std::vector& JFileSystem::scanfolder(const std::string& _folderName if (folderName[folderName.length() - 1] != '/') folderName.append("/"); - //user filesystem + //we scan zips first, then normal folders. + // This is to avoid duplicate folders coming from the real folder + // (a folder "foo" in the zip comes out as "foo/", while on the real FS it comes out as "foo") + + //user zips { //Scan the zip filesystem std::vector userZips; @@ -393,18 +397,9 @@ std::vector& JFileSystem::scanfolder(const std::string& _folderName for (size_t i = 0; i < userZips.size(); ++i) seen[userZips[i]] = true; - - //scan the real files - //TODO check for "/" - std::vector userReal; - string realFolderName = mUserFSPath; - realFolderName.append(folderName); - scanRealFolder(realFolderName, userReal); - - for (size_t i = 0; i < userReal.size(); ++i) - seen[userReal[i]] = true; } + //system zips if (mSystemFS) { //Scan the zip filesystem @@ -414,8 +409,28 @@ std::vector& JFileSystem::scanfolder(const std::string& _folderName for (size_t i = 0; i < systemZips.size(); ++i) seen[systemZips[i]] = true; + } + + //user real files + { //scan the real files - //TODO check for "/" + std::vector userReal; + string realFolderName = mUserFSPath; + realFolderName.append(folderName); + scanRealFolder(realFolderName, userReal); + + for (size_t i = 0; i < userReal.size(); ++i) + { + string asFolder = userReal[i] + "/"; + if (seen.find(asFolder) == seen.end()) + seen[userReal[i]] = true; + } + } + + //system real files + if (mSystemFS) + { + //scan the real files std::vector systemReal; string realFolderName = mSystemFSPath; realFolderName.append(folderName); @@ -423,10 +438,13 @@ std::vector& JFileSystem::scanfolder(const std::string& _folderName for (size_t i = 0; i < systemReal.size(); ++i) - seen[systemReal[i]] = true; + { + string asFolder = systemReal[i] + "/"; + if (seen.find(asFolder) == seen.end()) + seen[systemReal[i]] = true; + } } - for(map::iterator it = seen.begin(); it != seen.end(); ++it) { results.push_back(it->first); diff --git a/projects/mtg/src/GameApp.cpp b/projects/mtg/src/GameApp.cpp index abf58b204..04a2840c0 100644 --- a/projects/mtg/src/GameApp.cpp +++ b/projects/mtg/src/GameApp.cpp @@ -101,7 +101,7 @@ void GameApp::Create() // Create User Folders (for write access) if they don't exist { - const char* folders[] = { "ai", "ai/baka", "ai/baka/stats", "campaigns", "graphics", "lang", "packs", "player", "player/stats", "profiles", "rules", "sets", "settings", "sound", "sound/sfx", "themes"}; + const char* folders[] = { "ai", "ai/baka", "ai/baka/stats", "campaigns", "graphics", "lang", "packs", "player", "player/stats", "profiles", "rules", "sets", "settings", "sound", "sound/sfx", "themes", "test"}; string userRoot = JFileSystem::GetInstance()->GetUserRoot(); MAKEDIR(userRoot.c_str()); diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index 24bc364a3..3235c94b7 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -329,8 +329,8 @@ int MTGAllCards::load(const char * config_file, const char * set_name, int autol if (!std::getline(stream, s)) return total_cards; lineNumber++; if (!s.size()) continue; - if (s[s.size() - 1] == '\r') s.erase(s.size() - 1); // Handle DOS files + if (!s.size()) continue; switch (conf_read_mode) { case MTGAllCards::READ_ANYTHING: