Skip to content

Commit 006cc8b

Browse files
committed
interpret directories in soldierNames list
make soldierNames rul file common
1 parent 935207c commit 006cc8b

4 files changed

Lines changed: 26 additions & 38 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# pull in all *.nam files in the SoldierName virtual directory by default
2+
# mods can override with specific files if desired
3+
soldierNames:
4+
- SoldierName/

‎bin/standard/xcom1/soldierNames.rul‎

Lines changed: 0 additions & 34 deletions
This file was deleted.

‎src/Engine/Options.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ void mapResources()
727727
_loadMod(modInfo, circDepCheck);
728728
}
729729
// pick up stuff in common
730-
FileMap::load("", CrossPlatform::searchDataFolder("common"), true);
730+
FileMap::load("common", CrossPlatform::searchDataFolder("common"), false);
731731
}
732732

733733
/**

‎src/Ruleset/Ruleset.cpp‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,13 @@ struct compareRule<ArticleDefinition> : public std::binary_function<const std::s
14951495
};
14961496
std::map<std::string, int> compareRule<ArticleDefinition>::_sections;
14971497

1498+
static void addSoldierNamePool(std::vector<SoldierNamePool*> &names, const std::string &namFile)
1499+
{
1500+
SoldierNamePool *pool = new SoldierNamePool();
1501+
pool->load(FileMap::getFilePath(namFile));
1502+
names.push_back(pool);
1503+
}
1504+
14981505
/**
14991506
* Sorts all our lists according to their weight.
15001507
*/
@@ -1513,9 +1520,20 @@ void Ruleset::sortLists()
15131520

15141521
for (std::vector<std::string>::iterator i = _soldierNames.begin(); i != _soldierNames.end(); ++i)
15151522
{
1516-
SoldierNamePool *pool = new SoldierNamePool();
1517-
pool->load(FileMap::getFilePath(*i));
1518-
_names.push_back(pool);
1523+
if (i->substr(i->length() - 1, 1) == "/")
1524+
{
1525+
// load all *.nam files in given directory
1526+
std::set<std::string> names = FileMap::filterFiles(FileMap::getVFolderContents(*i), "nam");
1527+
for (std::set<std::string>::iterator j = names.begin(); j != names.end(); ++j)
1528+
{
1529+
addSoldierNamePool(_names, *i + *j);
1530+
}
1531+
}
1532+
else
1533+
{
1534+
// load given file
1535+
addSoldierNamePool(_names, *i);
1536+
}
15191537
}
15201538
}
15211539

0 commit comments

Comments
 (0)