* Loads the pool from a YAML file. * @param filename YAML file. */
| 48 | * @param filename YAML file. |
| 49 | */ |
| 50 | void SoldierNamePool::load(const std::string &filename) |
| 51 | { |
| 52 | std::string s = CrossPlatform::getDataFile("SoldierName/" + filename + ".nam"); |
| 53 | YAML::Node doc = YAML::LoadFile(s); |
| 54 | |
| 55 | for (YAML::const_iterator i = doc["maleFirst"].begin(); i != doc["maleFirst"].end(); ++i) |
| 56 | { |
| 57 | std::wstring name = Language::utf8ToWstr(i->as<std::string>()); |
| 58 | _maleFirst.push_back(name); |
| 59 | } |
| 60 | for (YAML::const_iterator i = doc["femaleFirst"].begin(); i != doc["femaleFirst"].end(); ++i) |
| 61 | { |
| 62 | std::wstring name = Language::utf8ToWstr(i->as<std::string>()); |
| 63 | _femaleFirst.push_back(name); |
| 64 | } |
| 65 | for (YAML::const_iterator i = doc["maleLast"].begin(); i != doc["maleLast"].end(); ++i) |
| 66 | { |
| 67 | std::wstring name = Language::utf8ToWstr(i->as<std::string>()); |
| 68 | _maleLast.push_back(name); |
| 69 | } |
| 70 | for (YAML::const_iterator i = doc["femaleLast"].begin(); i != doc["femaleLast"].end(); ++i) |
| 71 | { |
| 72 | std::wstring name = Language::utf8ToWstr(i->as<std::string>()); |
| 73 | _femaleLast.push_back(name); |
| 74 | } |
| 75 | if (_femaleLast.empty()) |
| 76 | { |
| 77 | _femaleLast = _maleLast; |
| 78 | } |
| 79 | _lookWeights = doc["lookWeights"].as< std::vector<int> >(_lookWeights); |
| 80 | _totalWeight = 0; |
| 81 | for (std::vector<int>::iterator i = _lookWeights.begin(); i != _lookWeights.end(); ++i) |
| 82 | { |
| 83 | _totalWeight += (*i); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Returns a new random name (first + last) from the |
nothing calls this directly
no test coverage detected