Skip to content

Commit

Permalink
Load mod subfolder rulesets
Browse files Browse the repository at this point in the history
Put .rul's in any subfolder, go nuts
  • Loading branch information
SupSuper committed Sep 14, 2018
1 parent 50c2cb7 commit 6f50bac
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/Engine/FileMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,19 @@ static void _mapFiles(const std::string &modId, const std::string &basePath,
for (std::vector<std::string>::iterator i = files.begin(); i != files.end(); ++i)
{
std::string fullpath = fullDir + "/" + *i;
if (_canonicalize(*i) == "metadata.yml" || rulesetFiles.find(*i) != rulesetFiles.end())

if (CrossPlatform::folderExists(fullpath))
{
// no need to map mod metadata files or ruleset files
Log(LOG_VERBOSE) << " ignoring non-resource file: " << fullpath;
Log(LOG_VERBOSE) << " recursing into: " << fullpath;
_mapFiles(modId, basePath, _combinePath(relPath, *i), ignoreMods);
continue;
}

if (CrossPlatform::folderExists(fullpath))
std::string canonicalFile = _canonicalize(*i);
if (canonicalFile == "metadata.yml" || rulesetFiles.find(*i) != rulesetFiles.end())
{
Log(LOG_VERBOSE) << " recursing into: " << fullpath;
// allow old mod directory format -- if the top-level subdir
// is named "Mod" and no top-level ruleset files were found,
// record ruleset files in that subdirectory, otherwise ignore them
bool ignoreModsRecurse = ignoreMods ||
!rulesetFiles.empty() || !relPath.empty() || _canonicalize(*i) != "ruleset";
_mapFiles(modId, basePath, _combinePath(relPath, *i), ignoreModsRecurse);
// no need to map mod metadata files or ruleset files
Log(LOG_VERBOSE) << " ignoring non-resource file: " << fullpath;
continue;
}

Expand All @@ -161,7 +157,6 @@ static void _mapFiles(const std::string &modId, const std::string &basePath,

// populate vdir map
std::string canonicalRelativePath = _canonicalize(relPath);
std::string canonicalFile = _canonicalize(*i);
if (_vdirs.find(canonicalRelativePath) == _vdirs.end())
{
_vdirs.insert(std::pair< std::string, std::set<std::string> >(canonicalRelativePath, std::set<std::string>()));
Expand Down

0 comments on commit 6f50bac

Please sign in to comment.