@@ -136,14 +136,6 @@ void Ruleset::resetGlobalStatics()
136136Ruleset::Ruleset () : _costSoldier(0 ), _costEngineer(0 ), _costScientist(0 ), _timePersonnel(0 ), _initialFunding(0 ), _turnAIUseGrenade(3 ), _turnAIUseBlaster(3 ), _startingTime(6 , 1 , 1 , 1999 , 12 , 0 , 0 ), _facilityListOrder(0 ), _craftListOrder(0 ), _itemListOrder(0 ), _researchListOrder(0 ), _manufactureListOrder(0 ), _ufopaediaListOrder(0 ), _invListOrder(0 )
137137{
138138 _globe = new RuleGlobe ();
139-
140- std::set<std::string> names = FileMap::filterFiles (FileMap::getVFolderContents (" SoldierName" ), " nam" );
141- for (std::set<std::string>::iterator i = names.begin (); i != names.end (); ++i)
142- {
143- SoldierNamePool *pool = new SoldierNamePool ();
144- pool->load (FileMap::getFilePath (" SoldierName/" + *i));
145- _names.push_back (pool);
146- }
147139}
148140
149141/* *
@@ -378,6 +370,7 @@ void Ruleset::loadFile(const std::string &filename, size_t spriteOffset)
378370 rule->load (*i);
379371 }
380372 }
373+ _soldierNames = doc[" soldierNames" ].as <std::vector<std::string> >(_soldierNames);
381374 for (YAML ::const_iterator i = doc[" soldiers" ].begin (); i != doc[" soldiers" ].end (); ++i)
382375 {
383376 RuleSoldier *rule = loadRule (*i, &_soldiers);
@@ -1502,6 +1495,13 @@ struct compareRule<ArticleDefinition> : public std::binary_function<const std::s
15021495};
15031496std::map<std::string, int > compareRule<ArticleDefinition>::_sections;
15041497
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+
15051505/* *
15061506 * Sorts all our lists according to their weight.
15071507 */
@@ -1517,6 +1517,24 @@ void Ruleset::sortLists()
15171517 std::sort (_craftWeaponsIndex.begin (), _craftWeaponsIndex.end (), compareRule<RuleCraftWeapon>(this ));
15181518 std::sort (_armorsIndex.begin (), _armorsIndex.end (), compareRule<Armor>(this ));
15191519 std::sort (_ufopaediaIndex.begin (), _ufopaediaIndex.end (), compareRule<ArticleDefinition>(this ));
1520+
1521+ for (std::vector<std::string>::iterator i = _soldierNames.begin (); i != _soldierNames.end (); ++i)
1522+ {
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+ }
1537+ }
15201538}
15211539
15221540/* *
0 commit comments